[PATCH] D40275: [CUDA] Report "unsupported VLA" errors only on device side.

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 21 10:37:38 PST 2017


tra added a comment.

In https://reviews.llvm.org/D40275#931947, @hfinkel wrote:

> > When Sema sees this code during compilation, it can not tell whether there is an error. Calling foo from the host code is perfectly valid. Calling it from device code is not. CUDADiagIfDeviceCode creates 'postponed' diagnostics which only gets emitted if we ever need to generate code for the function on device.
>
> Interesting. I suspect that we'll end up dealing with this problem for OpenMP as well (in the future - for OpenMP v5). In this next version (for which the draft is available here: http://www.openmp.org/wp-content/uploads/openmp-TR6.pdf), we'll have "implicit declare target" functions (whereby we generate target code based on the locally-defined subset of the transitive closure of the call graph starting from target regions).


We've been contemplating treating all functions as `__host__ __device__` by default. After all, most of the source code is target-agnostic. Currently a lot of templated code must be `__host__ __device__` in order to be usable and it's a major obstacle to making standard library and other template libraries (somewhat) usable on device. Alas, making `__host__ __device__` the default would be a major departure from CUDA semantics.


https://reviews.llvm.org/D40275





More information about the cfe-commits mailing list