-
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
Open
vlad-perevezentsev
wants to merge
19
commits into
master
Choose a base branch
from
enable_amd_build
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
72bc4d4
Enable CMake options to build dpnp on AMD
vlad-perevezentsev 5f11917
Add build_locally args for AMD build
vlad-perevezentsev c07e0a7
Remove unused lines
vlad-perevezentsev 323bbb4
Remove ROCM_PATH logic
vlad-perevezentsev e111ce1
Support amd build for indexing extension
vlad-perevezentsev ccc7b72
Merge master into enable_amd_build
vlad-perevezentsev efbab02
Merge master into enable_amd_build
vlad-perevezentsev 310cd82
Support amd build for window extension
vlad-perevezentsev c3adf4e
Set HIP specific flags for MKL
vlad-perevezentsev 574ea90
pdate logic to use --target-hip
vlad-perevezentsev d6c5925
Merge master into enable_amd_build
vlad-perevezentsev 5bca529
Add docs for dpnp build on AMD
vlad-perevezentsev b858ae2
Remove unnecessary HIP_TARGETS validation in CMake
vlad-perevezentsev 273113e
A small docs update
vlad-perevezentsev c4da3ef
Improve validation of --target and --target-hip
vlad-perevezentsev e6c280e
Clarify --target-hip usage in doc
vlad-perevezentsev b27a8a1
Update SYCL target selection logic in CMakeLists
vlad-perevezentsev 2238372
Merge master into enable_amd_build
vlad-perevezentsev 5e2cc3d
Avoid false HIP error when building for default target
vlad-perevezentsev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||||||
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 to expand the variable using
Suggested change
|
||||||
set(_use_onemkl_interfaces_cuda ON) | ||||||
endif() | ||||||
|
||||||
if (DPNP_SYCL_TARGETS MATCHES "amdgcn-amd-amdhsa") | ||||||
set(_use_onemkl_interfaces_hip ON) | ||||||
antonwolfy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
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) | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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 am using
HIP_TARGETS
instead ofHIP_TARGET
because oneMath requiresHIP_TARGETS
to be definedhttps://github.com/uxlfoundation/oneMath/blob/4ad4dfb5db834117248ad5f8fbded5cfc1097005/CMakeLists.txt#L73
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.
Is it only declaration of cmake variable which doesn't impact oneMath, isn't that?