@@ -71,31 +71,71 @@ option(DPNP_TARGET_CUDA
7171 "Build DPNP to target CUDA devices"
7272 OFF
7373)
74+ option (DPNP_TARGET_HIP
75+ "Build DPNP to target HIP devices"
76+ OFF
77+ )
7478option (DPNP_USE_ONEMKL_INTERFACES
7579 "Build DPNP with oneMKL Interfaces"
7680 OFF
7781)
82+ set (HIP_TARGETS "" CACHE STRING "HIP architecture for target" )
83+
84+ #Add rocm root dir to CMAKE_PREFIX_PATH, usually "/opt/rocm"
85+ if (DPNP_TARGET_HIP)
86+ if (DEFINED ENV{ROCM_PATH})
87+ set (ROCM_PATH $ENV{ROCM_PATH} )
88+ else ()
89+ set (ROCM_PATH "/opt/rocm" )
90+ endif ()
91+ list (APPEND CMAKE_PREFIX_PATH ${ROCM_PATH} )
92+ endif ()
93+
7894set (_dpnp_sycl_targets)
95+ set (_dpnp_amd_targets)
96+ set (_use_onemkl_interfaces OFF )
7997set (_use_onemkl_interfaces_cuda OFF )
98+ set (_use_onemkl_interfaces_hip OFF )
99+
100+ set (_dpnp_sycl_target_compile_options)
101+ set (_dpnp_sycl_target_link_options)
102+
80103if ("x${DPNP_SYCL_TARGETS} " STREQUAL "x" )
81- if (DPNP_TARGET_CUDA)
82- set (_dpnp_sycl_targets "nvptx64-nvidia-cuda,spir64-unknown-unknown" )
83- set (_use_onemkl_interfaces_cuda ON )
84- else ()
85- if (DEFINED ENV{DPNP_TARGET_CUDA})
86- set (_dpnp_sycl_targets "nvptx64-nvidia-cuda,spir64-unknown-unknown" )
87- set (_use_onemkl_interfaces_cuda ON )
88- endif ()
89- endif ()
104+ if (DPNP_TARGET_CUDA)
105+ set (_dpnp_sycl_targets "nvptx64-nvidia-cuda,spir64-unknown-unknown" )
106+ set (_use_onemkl_interfaces_cuda ON )
107+ endif ()
108+ if (DPNP_TARGET_HIP)
109+ if (NOT "x${HIP_TARGETS} " STREQUAL "x" )
110+ set (_dpnp_amd_targets ${HIP_TARGETS} )
111+ set (_use_onemkl_interfaces_hip ON )
112+ if (_dpnp_sycl_targets)
113+ set (_dpnp_sycl_targets "amdgcn-amd-amdhsa,${_dpnp_sycl_targets} " )
114+ else ()
115+ set (_dpnp_sycl_targets "amdgcn-amd-amdhsa,spir64-unknown-unknown" )
116+ endif ()
117+ else ()
118+ message (FATAL_ERROR "HIP_TARGETS must be specified when using HIP backend" )
119+ endif ()
120+ endif ()
90121else ()
91- set (_dpnp_sycl_targets ${DPNP_SYCL_TARGETS} )
122+ set (_dpnp_sycl_targets ${DPNP_SYCL_TARGETS} )
123+ if (NOT "x${HIP_TARGETS} " STREQUAL "x" )
124+ set (_dpnp_amd_targets ${HIP_TARGETS} )
125+ set (_use_onemkl_interfaces_hip ON )
126+ endif ()
92127endif ()
93128
94- if (_dpnp_sycl_targets)
129+ if (_dpnp_sycl_targets)
95130 message (STATUS "Compiling for -fsycl-targets=${_dpnp_sycl_targets} " )
131+ list (APPEND _dpnp_sycl_target_compile_options -fsycl-targets=${_dpnp_sycl_targets} )
132+ list (APPEND _dpnp_sycl_target_link_options -fsycl-targets=${_dpnp_sycl_targets} )
133+ if (_dpnp_amd_targets)
134+ list (APPEND _dpnp_sycl_target_compile_options -Xsycl-target -backend=amdgcn-amd-amdhsa --offload-arch=${_dpnp_amd_targets} )
135+ list (APPEND _dpnp_sycl_target_link_options -Xsycl-target -backend=amdgcn-amd-amdhsa --offload-arch=${_dpnp_amd_targets} )
136+ endif ()
96137endif ()
97138
98- set (_use_onemkl_interfaces OFF )
99139if (DPNP_USE_ONEMKL_INTERFACES)
100140 set (_use_onemkl_interfaces ON )
101141else ()
@@ -107,13 +147,20 @@ endif()
107147if (_use_onemkl_interfaces)
108148 set (BUILD_FUNCTIONAL_TESTS False )
109149 set (BUILD_EXAMPLES False )
150+ set (ENABLE_MKLGPU_BACKEND True )
151+ set (ENABLE_MKLCPU_BACKEND True )
152+
110153 if (_use_onemkl_interfaces_cuda)
111154 set (ENABLE_CUBLAS_BACKEND True )
112155 set (ENABLE_CUSOLVER_BACKEND True )
113156 set (ENABLE_CUFFT_BACKEND True )
114157 # set(ENABLE_CURAND_BACKEND True)
115- set (ENABLE_MKLGPU_BACKEND True )
116- set (ENABLE_MKLCPU_BACKEND True )
158+ endif ()
159+ if (_use_onemkl_interfaces_hip)
160+ set (ENABLE_ROCBLAS_BACKEND True )
161+ set (ENABLE_ROCSOLVER_BACKEND True )
162+ set (ENABLE_ROCFFT_BACKEND True )
163+ # set(ENABLE_ROCRAND_BACKEND True)
117164 endif ()
118165
119166 if (DPNP_ONEMKL_INTERFACES_DIR)
0 commit comments