diff --git a/clang/test/dpct/cmake_migration/case_012/case_012_cuda_add_cufft_to_target.cpp b/clang/test/dpct/cmake_migration/case_012/case_012_cuda_add_cufft_to_target.cpp new file mode 100644 index 000000000000..98924a79f2f9 --- /dev/null +++ b/clang/test/dpct/cmake_migration/case_012/case_012_cuda_add_cufft_to_target.cpp @@ -0,0 +1,10 @@ +// RUN: rm -rf %T && mkdir -p %T +// RUN: cd %T +// RUN: cp %S/input.cmake ./input.cmake +// RUN: dpct -in-root ./ -out-root out ./input.cmake --migrate-cmake-script-only +// RUN: echo "begin" > %T/diff.txt +// RUN: diff --strip-trailing-cr %S/expected.txt %T/out/input.cmake >> %T/diff.txt +// RUN: echo "end" >> %T/diff.txt + +// CHECK: begin +// CHECK-NEXT: end diff --git a/clang/test/dpct/cmake_migration/case_012/expected.txt b/clang/test/dpct/cmake_migration/case_012/expected.txt new file mode 100644 index 000000000000..02727138c561 --- /dev/null +++ b/clang/test/dpct/cmake_migration/case_012/expected.txt @@ -0,0 +1,4 @@ +dpct_helper_add_mkl_to_target(culib) +dpct_helper_add_mkl_to_target( + culib +) diff --git a/clang/test/dpct/cmake_migration/case_012/input.cmake b/clang/test/dpct/cmake_migration/case_012/input.cmake new file mode 100644 index 000000000000..1176f1be179a --- /dev/null +++ b/clang/test/dpct/cmake_migration/case_012/input.cmake @@ -0,0 +1,4 @@ +CUDA_ADD_CUFFT_TO_TARGET(culib) +cuda_add_cufft_to_target( + culib +) diff --git a/clang/tools/dpct/DpctOptRules/cmake_script_migration_rule.yaml b/clang/tools/dpct/DpctOptRules/cmake_script_migration_rule.yaml index 1f58c4a39093..4d94f454a667 100644 --- a/clang/tools/dpct/DpctOptRules/cmake_script_migration_rule.yaml +++ b/clang/tools/dpct/DpctOptRules/cmake_script_migration_rule.yaml @@ -539,3 +539,10 @@ In: cuda_include_directories(${value}) Out: include_directories(${value}) +- Rule: rule_cuda_add_cufft_to_target + Kind: CMakeRule + Priority: Fallback + CmakeSyntax: cuda_add_cufft_to_target + In: cuda_add_cufft_to_target(${target}) + Out: dpct_helper_add_mkl_to_target(${target}) + diff --git a/clang/tools/dpct/cmake/dpct.cmake b/clang/tools/dpct/cmake/dpct.cmake index 9e614210a288..4a2fcf353de6 100644 --- a/clang/tools/dpct/cmake/dpct.cmake +++ b/clang/tools/dpct/cmake/dpct.cmake @@ -96,3 +96,16 @@ if(WIN32) else() set(DNN_LIB "dnnl") endif() + +# Link MKL library to target +macro(DPCT_HELPER_ADD_MKL_TO_TARGET target) + if(WIN32) + target_compile_options(${target} PUBLIC -fsycl /DMKL_ILP64 /Qmkl:parallel /Qtbb /MD) + target_link_libraries(${target} PUBLIC -fsycl OpenCL.lib) + elseif(UNIX AND NOT APPLE) + target_compile_options(${target} PUBLIC -fsycl -DMKL_ILP64 -qmkl=parallel -qtbb) + target_link_libraries(${target} PUBLIC -qmkl=parallel -qtbb -fsycl) + else() + message(FATAL_ERROR "Unsupported platform") + endif() +endmacro()