@@ -7,6 +7,54 @@ message(STATUS "TEST_SUITE_HIP_ROOT: ${TEST_SUITE_HIP_ROOT}")
77get_filename_component (HIP_CLANG_PATH ${CMAKE_CXX_COMPILER} DIRECTORY )
88message (STATUS "HIP_CLANG_PATH: ${HIP_CLANG_PATH} " )
99
10+ # Inspired from create_one_local_test. Runs hipify on the TestSource and then compiles it.
11+ # Search for the reference files next to TestSource.
12+ macro (create_one_hipify_cuda_test TestName TestSource VairantOffload VariantSuffix VariantCPPFlags VariantLibs)
13+ set (_cuda_src "${TestSource} " )
14+ set (_hip_src "${TestName} .hip" )
15+ set (_hipify_target "${TestName} -hipify" )
16+
17+ set_source_files_properties (${_hip_src} PROPERTIES LANGUAGE CXX)
18+ add_custom_command (OUTPUT ${_hip_src}
19+ COMMAND ${HIPIFY_EXE} "${_cuda_src} " -o "${_hip_src} "
20+ DEPENDS "${_cuda_src} " )
21+ add_custom_target (${_hipify_target} DEPENDS ${_hip_src} )
22+
23+ set (_executable ${TestName} -${VariantSuffix} )
24+ set (_executable_path ${CMAKE_CURRENT_BINARY_DIR} /${_executable} )
25+ llvm_test_run()
26+
27+ get_filename_component (_test_source_dir "${TestSource} " DIRECTORY )
28+ get_filename_component (_test_source_name "${TestSource} " NAME_WE )
29+ set (REFERENCE_OUTPUT "${_test_source_dir} /${test_source_name} .reference_output" )
30+ if (EXISTS "${REFERENCE_OUTPUT} " )
31+ llvm_test_verify(WORKDIR %S
32+ %b/${FPCMP} %o ${REFERENCE_OUTPUT} -${VariantSuffix}
33+ )
34+ llvm_test_executable(${_executable} ${_hip_src} )
35+ llvm_test_data(${_executable}
36+ DEST_SUFFIX "-${VariantSuffix} "
37+ ${REFERENCE_OUTPUT} )
38+ else ()
39+ llvm_test_executable(${_executable} ${_hip_src} )
40+ endif ()
41+
42+ target_compile_options (${_executable} PUBLIC ${VariantCPPFLAGS} )
43+
44+ # In External/CUDA, tests define a STDLIB_VERSION that matches the C++
45+ # standard supported by the standard library.
46+ # For the HIP case, we set a huge number and assume that the latest C++
47+ # standard version is supported by the library.
48+ target_compile_definitions (${_executable} PRIVATE STDLIB_VERSION=9999)
49+ add_dependencies (${_executable} ${_hipify_target} )
50+ if (VariantLibs)
51+ target_link_libraries (${_executable} ${VariantLibs} )
52+ endif ()
53+
54+ add_dependencies (hip-tests-simple-${VariantSuffix} ${_executable} )
55+ list (APPEND VARIANT_SIMPLE_TEST_TARGETS ${_executable} .test )
56+ endmacro ()
57+
1058# Create targets for HIP tests that are part of the test suite.
1159macro (create_local_hip_tests VariantSuffix)
1260 set (VariantOffload "hip" )
@@ -49,6 +97,27 @@ macro(create_local_hip_tests VariantSuffix)
4997 "${VariantCPPFLAGS} " "${VariantLibs} " )
5098 endforeach ()
5199
100+ list (APPEND CUDA_LOCAL_TESTS algorithm)
101+ list (APPEND CUDA_LOCAL_TESTS cmath)
102+ list (APPEND CUDA_LOCAL_TESTS complex)
103+ list (APPEND CUDA_LOCAL_TESTS math_h)
104+ list (APPEND CUDA_LOCAL_TESTS new)
105+
106+ find_program (HIPIFY_EXE
107+ NAME hipify-perl
108+ PATHS ${_RocmPath} /bin)
109+
110+ if (HIPIFY_EXE)
111+ foreach (_cuda_test IN LISTS CUDA_LOCAL_TESTS)
112+ set (_cuda_src "${CMAKE_CURRENT_SOURCE_DIR} /../CUDA/${_cuda_test} .cu" )
113+ create_one_hipify_cuda_test(${_cuda_test} ${_cuda_src}
114+ ${VariantOffload} ${VariantSuffix}
115+ "${VariantCPPFLAGS} " "${VariantLibs} " )
116+ endforeach ()
117+ else ()
118+ message (WARNING "hipify-perl not found for ROCm installation in ${_RocmPath} ." )
119+ endif ()
120+
52121 # Add test for Blender.
53122 configure_file (workload/blender/test_blender.sh.in ${CMAKE_CURRENT_BINARY_DIR} /test_blender.sh @ONLY)
54123 configure_file (workload/blender/verify_blender.sh.in ${CMAKE_CURRENT_BINARY_DIR} /verify_blender.sh @ONLY)
0 commit comments