llvm icon indicating copy to clipboard operation
llvm copied to clipboard

[SYCL] [Driver] Add offload-arch support for SYCL offloading

Open srividya-sundaram opened this issue 1 year ago • 2 comments

Implement --offload-arch option to enable SYCL offloading to Intel CPUs, Intel GPUs, NVidia and AMD GPUs.

--offload-arch implementation is currently supported in the new driver model ( i.e. with --offload-new-driver option)

Example usage:

clang++   --offload-new-driver  -fsycl  --offload-arch=bdw         // Offload SYCL code to Intel GPU
clang++   --offload-new-driver  -fsycl  --offload-arch=broadwell   // Offload SYCL code to Intel CPU
clang++   --offload-new-driver  -fsycl  --offload-arch=sm_80       // Offload SYCL code to NVidia GPU
clang++   --offload-new-driver  -fsycl  --offload-arch=gfx700      // Offload SYCL code to AMD GPU

srividya-sundaram avatar Oct 07 '24 21:10 srividya-sundaram

Overall, despite not being a pinged reviewer, I wanted to say I like the direction of these changes. I am aware this is still a Draft but is there a plan to address the --offload-arch with no -fsycl-targets case in

https://github.com/intel/llvm/blob/35b926a88318efc9599441c3084e4d9c722dc1d7/clang/lib/Driver/Driver.cpp#L6397

either as part of this PR or a follow-up? I am asking this because the effect of these changes will also require extra handling in OffloadingActionBuilder::SYCLActionBuilder::initialize(). Thanks.

Hello, AFAIK, OffloadingActionBuilder::SYCLActionBuilder::initialize() is the path taken when we do not pass --offload-new-driver option. Currently, --offloard-arch option is supported only in the new driver model ( i.e with --offload-new-driver option passed) Hence the --offload-arch implementation is not handled in OffloadingActionBuilder::SYCLActionBuilder::initialize()

srividya-sundaram avatar Oct 11 '24 22:10 srividya-sundaram

Hello, AFAIK, OffloadingActionBuilder::SYCLActionBuilder::initialize() is the path taken when we do not pass --offload-new-driver option. Currently, --offloard-arch option is supported only in the new driver model ( i.e with --offload-new-driver option passed) Hence the --offload-arch implementation is not handled in OffloadingActionBuilder::SYCLActionBuilder::initialize()

I see, I must've missed the chain of changes wrt the new offload driver for SYCL. I only pointed the above, likely due to confusion, because for me clang++ -fsycl --offload-new-driver --offload-arch=sm_75 test.cpp still hits OffloadingActionBuilder::SYCLActionBuilder::initialize() but does nothing really as it returns early as no SYCL Toolchain has been found as of yet. Since the implementation for --offload-arch with the new offload driver logic is handled elsewhere, I guess that's okay then. Thanks for explaining :)!

GeorgeWeb avatar Oct 14 '24 12:10 GeorgeWeb

Ping @intel/dpcpp-cfe-reviewers

srividya-sundaram avatar Oct 23 '24 17:10 srividya-sundaram

@intel/llvm-gatekeepers Hello, this PR is ready to be merged. Thanks!

srividya-sundaram avatar Oct 23 '24 22:10 srividya-sundaram