Previously when using the clang-offload-packager we did not pass the
active offloading kinds. Then in Clang when we attempted to detect when
there was host-offloading action that needed to be embedded in the host
we did not find it. This patch adds the active offloading kinds so we
know when there is input to be embedded.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Driver/Driver.cpp | ||
---|---|---|
4394 | getActiveOffloadKinds returns a mask of offload kinds, yet we cast it to OffloadKind in DeviceDependences::add above. This mixing of OffloadKind and sets of them looks questionable to me. If we are relying on passing sets of OffloadKindnow, then we should make it clear in the code that it is the intent, including a more detailed description that DeviceOffloadKinds is a list of OffloadKind sets, so whoever iterates over elements does not attempt to compare its elements with OffloadKind values. I think it would be helpful to change DeviceOffloadKinds element type to a new class with a helper method hasOffloadKind(OffloadKind) to avoid accidental comparison of a mask with enum value. |
Mixing the concept of the mask passing via an unsigned and a single enum value was incorrect. Add a new interface that accepts a mask and adds all active values instead.
clang/lib/Driver/Driver.cpp | ||
---|---|---|
4394 | Yeah I think I shouldn't mix the logic here. I updated it. |
LGTM with a few nits.
clang/include/clang/Driver/Action.h | ||
---|---|---|
304 | Nit: Add a*n* action | |
307 | Nit: OffloadKindMask? | |
clang/lib/Driver/Action.cpp | ||
320 | It would be good to clear processed bits in Mask and then assert that it's zero after we're done. Otherwise it would be easy to miss handling a new offload kind if/when it gets added. |
clang/lib/Driver/Action.cpp | ||
---|---|---|
320 | I was also considering just putting something like this next to the declarations since we already do this for the new driver as well. constexpr OffloadKind[] DeviceOffloadingKinds = {OFK_OpenMP, OFK_Cuda, OFK_HIP}; |
Nit: Add a*n* action