-
Notifications
You must be signed in to change notification settings - Fork 21
Enable dpnp build on AMD GPU #2302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
72bc4d4
5f11917
c07e0a7
323bbb4
e111ce1
ccc7b72
efbab02
310cd82
c3adf4e
574ea90
d6c5925
5bca529
b858ae2
273113e
c4da3ef
e6c280e
b27a8a1
2238372
5e2cc3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,27 +75,73 @@ option(DPNP_USE_ONEMKL_INTERFACES | |
"Build DPNP with oneMKL Interfaces" | ||
OFF | ||
) | ||
set(HIP_TARGETS "" CACHE STRING "HIP architecture for target") | ||
|
||
set(_dpnp_sycl_targets) | ||
set(_dpnp_amd_targets) | ||
set(_use_onemkl_interfaces OFF) | ||
set(_use_onemkl_interfaces_cuda OFF) | ||
set(_use_onemkl_interfaces_hip OFF) | ||
|
||
set(_dpnp_sycl_target_compile_options) | ||
set(_dpnp_sycl_target_link_options) | ||
set(_dpnp_sycl_mkl_target_compile_options) | ||
set(_dpnp_sycl_mkl_target_link_options) | ||
|
||
if ("x${DPNP_SYCL_TARGETS}" STREQUAL "x") | ||
if(DPNP_TARGET_CUDA) | ||
set(_dpnp_sycl_targets "nvptx64-nvidia-cuda,spir64-unknown-unknown") | ||
set(_use_onemkl_interfaces_cuda ON) | ||
else() | ||
if(DEFINED ENV{DPNP_TARGET_CUDA}) | ||
set(_dpnp_sycl_targets "nvptx64-nvidia-cuda,spir64-unknown-unknown") | ||
set(_use_onemkl_interfaces_cuda ON) | ||
endif() | ||
endif() | ||
if(DPNP_TARGET_CUDA) | ||
set(_dpnp_sycl_targets "nvptx64-nvidia-cuda,spir64-unknown-unknown") | ||
set(_use_onemkl_interfaces_cuda ON) | ||
endif() | ||
|
||
if (NOT "x${HIP_TARGETS}" STREQUAL "x") | ||
set(_dpnp_amd_targets ${HIP_TARGETS}) | ||
set(_use_onemkl_interfaces_hip ON) | ||
|
||
if ("x${_dpnp_sycl_targets}" STREQUAL "x") | ||
set(_dpnp_sycl_targets "amdgcn-amd-amdhsa,${_dpnp_sycl_targets}") | ||
else() | ||
set(_dpnp_sycl_targets "amdgcn-amd-amdhsa,spir64-unknown-unknown") | ||
endif() | ||
endif() | ||
else() | ||
set(_dpnp_sycl_targets ${DPNP_SYCL_TARGETS}) | ||
set(_dpnp_sycl_targets ${DPNP_SYCL_TARGETS}) | ||
|
||
if (DPNP_SYCL_TARGETS MATCHES "nvptx64-nvidia-cuda") | ||
set(_use_onemkl_interfaces_cuda ON) | ||
endif() | ||
|
||
if (DPNP_SYCL_TARGETS MATCHES "amdgcn-amd-amdhsa") | ||
set(_use_onemkl_interfaces_hip ON) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need here something similar to above? set(_dpnp_sycl_targets "amdgcn-amd-amdhsa,${_dpnp_sycl_targets}") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if we set DPNP_SYCL_TARGETS via |
||
|
||
if (NOT "x${HIP_TARGETS}" STREQUAL "x") | ||
set(_dpnp_amd_targets ${HIP_TARGETS}) | ||
else() | ||
message(FATAL_ERROR "HIP_TARGETS must be specified when using HIP backend") | ||
endif() | ||
endif() | ||
endif() | ||
|
||
if(_dpnp_sycl_targets) | ||
if (_dpnp_sycl_targets) | ||
message(STATUS "Compiling for -fsycl-targets=${_dpnp_sycl_targets}") | ||
list(APPEND _dpnp_sycl_target_compile_options -fsycl-targets=${_dpnp_sycl_targets}) | ||
list(APPEND _dpnp_sycl_target_link_options -fsycl-targets=${_dpnp_sycl_targets}) | ||
list(APPEND _dpnp_sycl_mkl_target_compile_options -fsycl-targets=${_dpnp_sycl_targets}) | ||
list(APPEND _dpnp_sycl_mkl_target_link_options -fsycl-targets=${_dpnp_sycl_targets}) | ||
if(_dpnp_amd_targets) | ||
set(_dpnp_hip_compile_options -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=${_dpnp_amd_targets}) | ||
set(_dpnp_hip_mkl_compile_options -Xsycl-target-backend --offload-arch=${_dpnp_amd_targets}) | ||
|
||
# Append HIP-specific flags for general SYCL modules | ||
list(APPEND _dpnp_sycl_target_compile_options ${_dpnp_hip_compile_options}) | ||
list(APPEND _dpnp_sycl_target_link_options ${_dpnp_hip_compile_options}) | ||
|
||
# Append HIP-specific flags for MKL modules | ||
list(APPEND _dpnp_sycl_mkl_target_compile_options -fsycl-unnamed-lambda ${_dpnp_hip_mkl_compile_options}) | ||
list(APPEND _dpnp_sycl_mkl_target_link_options ${_dpnp_hip_mkl_compile_options}) | ||
endif() | ||
endif() | ||
|
||
set(_use_onemkl_interfaces OFF) | ||
if(DPNP_USE_ONEMKL_INTERFACES) | ||
set(_use_onemkl_interfaces ON) | ||
else() | ||
|
@@ -107,13 +153,20 @@ endif() | |
if(_use_onemkl_interfaces) | ||
set(BUILD_FUNCTIONAL_TESTS False) | ||
set(BUILD_EXAMPLES False) | ||
set(ENABLE_MKLGPU_BACKEND True) | ||
set(ENABLE_MKLCPU_BACKEND True) | ||
|
||
if(_use_onemkl_interfaces_cuda) | ||
set(ENABLE_CUBLAS_BACKEND True) | ||
set(ENABLE_CUSOLVER_BACKEND True) | ||
set(ENABLE_CUFFT_BACKEND True) | ||
# set(ENABLE_CURAND_BACKEND True) | ||
set(ENABLE_MKLGPU_BACKEND True) | ||
set(ENABLE_MKLCPU_BACKEND True) | ||
endif() | ||
if(_use_onemkl_interfaces_hip) | ||
set(ENABLE_ROCBLAS_BACKEND True) | ||
set(ENABLE_ROCSOLVER_BACKEND True) | ||
set(ENABLE_ROCFFT_BACKEND True) | ||
# set(ENABLE_ROCRAND_BACKEND True) | ||
endif() | ||
|
||
if(DPNP_ONEMKL_INTERFACES_DIR) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume there is no support for multiple values:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point, it was clear in docs that only one architecture was supported at a time, but now it isn't as clear and should be tested
Also, there is new information in the extension guide
It shows that the command
is equivalent to
so maybe both dpctl and dpnp can simplify by removing the need for
-Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=[X]
completelylist of aliases:
https://intel.github.io/llvm/UsersManual.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aliases list seems to claim only one alias is supported at a time. So probably only one architecture at once is possible? That would be my guess