This patch uses existing deferred diagnostics framework to emit error for unsupported type __bf16 in device code. Error is not emitted in host code.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM.
I expect this to be a common issue for all single-source offloading programming models (i.e. CUDA and HIP in addition to SYCL and OpenMP offload). Probably we can generalize the code patterns used in this patch for all of them.
In addition to that, there are other built-in data types not supported either by host or device, which are handled similar way. Right?
Looks like CUDA added support for the type - https://reviews.llvm.org/D136311, https://reviews.llvm.org/rG678d8946ba2ba790c4c52e96e2134ee136e30057.
In addition to that, there are other built-in data types not supported either by host or device, which are handled similar way. Right?
Yes. Code added here is similar to code added for other unsupported types like __float128
clang/lib/Sema/Sema.cpp | ||
---|---|---|
1978–1979 | @eandrews Do you recall what was the reason for *not* issuing the diagnostic on the GPU side? It appears to do the opposite to what the patch description says. We're supposed to emit error for unsupported type __bf16 in device code, but instead we specifically ignore it during GPU-side compilation. What am I missing? |
clang/lib/Sema/Sema.cpp | ||
---|---|---|
1978–1979 | I don't recall the specifics but I think CUDA had code handling __bf16 differently and this change broke a test with CUDA diagnostics and so I excluded it from the patch. I could try removing this check and seeing what breaks if you'd like. |
clang/lib/Sema/Sema.cpp | ||
---|---|---|
1978–1979 | It may have been around the time when x86 started exposing bf16 type in the host headers, but NVPTX didn't have any support for the type yet. This change may have just papered over the problem. Oh, well. That would be just one of the places where we currently don't handle the 'unusual' types across the host/GPU boundary. I'm attempting to clean it up, and will take care of this instance there. |
@eandrews Do you recall what was the reason for *not* issuing the diagnostic on the GPU side?
It appears to do the opposite to what the patch description says. We're supposed to emit error for unsupported type __bf16 in device code, but instead we specifically ignore it during GPU-side compilation. What am I missing?