Skip to content

Commit b3827d2

Browse files
Lit test for cuda_add_cufft_to_target CMake macro
1 parent ba2e8ac commit b3827d2

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: rm -rf %T && mkdir -p %T
2+
// RUN: cd %T
3+
// RUN: cp %S/input.cmake ./input.cmake
4+
// RUN: dpct -in-root ./ -out-root out ./input.cmake --migrate-cmake-script-only
5+
// RUN: echo "begin" > %T/diff.txt
6+
// RUN: diff --strip-trailing-cr %S/expected.txt %T/out/input.cmake >> %T/diff.txt
7+
// RUN: echo "end" >> %T/diff.txt
8+
9+
// CHECK: begin
10+
// CHECK-NEXT: end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
add_library(culib)
2+
add_executable(cuexe)
3+
dpct_add_mkl_to_target(culib)
4+
dpct_add_mkl_to_target(
5+
culib
6+
)
7+
8+
dpct_add_mkl_to_target(cuexe)
9+
dpct_add_mkl_to_target(
10+
cuexe
11+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
add_library(culib)
2+
add_executable(cuexe)
3+
CUDA_ADD_CUFFT_TO_TARGET(culib)
4+
cuda_add_cufft_to_target(
5+
culib
6+
)
7+
8+
CUDA_ADD_CUFFT_TO_TARGET(cuexe)
9+
cuda_add_cufft_to_target(
10+
cuexe
11+
)

clang/tools/dpct/DpctOptRules/cmake_script_migration_rule.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,11 @@
174174
MatchMode: Full
175175
In: CUDA_HAS_FP16
176176
Out: SYCL_HAS_FP16
177+
178+
- Rule: rule_cuda_add_cufft_to_target
179+
Kind: CMakeRule
180+
Priority: Fallback
181+
CmakeSyntax: cuda_add_cufft_to_target
182+
In: cuda_add_cufft_to_target(${target})
183+
Out: dpct_add_mkl_to_target(${target})
184+

clang/tools/dpct/cmake/dpct.cmake

+11
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,14 @@ endmacro()
7878
# Always set SYCL_HAS_FP16 to true to assume SYCL device to support float16
7979
message("dpct.cmake: SYCL_HAS_FP16 is set true by default.")
8080
set(SYCL_HAS_FP16 TRUE)
81+
82+
# Link MKL library to target
83+
macro(DPCT_ADD_MKL_TO_TARGET target)
84+
if(WIN32)
85+
target_link_libraries(${target} mkl_sycl_dll.lib mkl_intel_ilp64_dll.lib mkl_tbb_thread_dll.lib mkl_core_dll.lib OpenCL.lib)
86+
elseif(UNIX AND NOT APPLE)
87+
target_link_libraries(${target} -L${MKLROOT}/lib/intel64 -lmkl_intel_ilp64 -lmkl_tbb_thread -lmkl_core -lOpenCL -lmkl_sycl -lpthread -ldl)
88+
else()
89+
message(FATAL_ERROR "Unsupported platform")
90+
endif()
91+
endmacro()

0 commit comments

Comments
 (0)