Files
rocm-systems/tests/src/CMakeLists.txt
T

138 lines
4.4 KiB
CMake
Raw Normal View History

2016-01-26 20:14:33 -06:00
cmake_minimum_required (VERSION 2.6)
project (HIP_Unit_Tests)
include(CTest)
include_directories( ${PROJECT_SOURCE_DIR}/include )
# The version number.
set (HIP_Unit_Test_VERSION_MAJOR 1)
set (HIP_Unit_Test_VERSION_MINOR 0)
set (HIP_PATH $ENV{HIP_PATH})
if (NOT DEFINED HIP_PATH)
set (HIP_PATH ../..)
endif()
2016-02-05 07:15:46 -06:00
execute_process(COMMAND ${HIP_PATH}/bin/hipconfig --platform OUTPUT_VARIABLE HIP_PLATFORM)
2016-01-26 20:14:33 -06:00
2016-02-05 07:15:46 -06:00
MESSAGE ("HIP_PATH=" ${HIP_PATH})
2016-01-26 20:14:33 -06:00
if (${HIP_PLATFORM} STREQUAL "hcc")
2016-02-05 07:15:46 -06:00
MESSAGE ("HIP_PLATFORM=hcc")
2016-01-26 20:14:33 -06:00
set (HC_PATH ${HIP_PATH}/hc)
set (HSA_PATH /opt/hsa)
#---
# Add HSA library:
add_library(hsa-runtime64 SHARED IMPORTED)
set_property(TARGET hsa-runtime64 PROPERTY IMPORTED_LOCATION "${HSA_PATH}/lib/libhsa-runtime64.so")
#These includes are used for all files.
#Include HIP and HC since the tests need both of these:
#Note below HSA path is surgically included only where necessary.
include_directories(${HIP_PATH}/include ${HC_PATH}/include)
# hip_hcc.o:
add_library(hip_hcc OBJECT ${HIP_PATH}/src/hip_hcc.cpp)
target_include_directories(hip_hcc PRIVATE ${HSA_PATH}/include)
elseif (${HIP_PLATFORM} STREQUAL "nvcc")
2016-02-05 07:15:46 -06:00
MESSAGE ("HIP_PLATFORM=nvcc")
2016-01-26 20:14:33 -06:00
# NVCC does not not support -rdynamic option
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS )
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS )
2016-02-05 07:15:46 -06:00
2016-01-26 20:14:33 -06:00
else()
2016-02-05 07:15:46 -06:00
MESSAGE (FATAL_ERROR "UNKNOWN HIP_PLATFORM=" ${HIP_PLATFORM})
2016-01-26 20:14:33 -06:00
endif()
set (HIPCC ${HIP_PATH}/bin/hipcc)
set (CMAKE_CXX_COMPILER ${HIPCC})
add_library(test_common OBJECT test_common.cpp )
# usage : make_hip_executable (exe_name CPP_FILES)
macro (make_hip_executable exe cpp)
if (${HIP_PLATFORM} STREQUAL "hcc")
add_executable (${exe} ${cpp} ${ARGN} $<TARGET_OBJECTS:test_common> $<TARGET_OBJECTS:hip_hcc> )
else()
add_executable (${exe} ${cpp} ${ARGN} $<TARGET_OBJECTS:test_common> )
endif()
endmacro()
2016-01-26 20:14:33 -06:00
macro (make_test exe )
string (REPLACE " " "" smush_args ${ARGN})
set (testname ${exe}${smush_args}.tst)
add_test (NAME ${testname}
COMMAND ${PROJECT_BINARY_DIR}/${exe} ${ARGN}
)
set_tests_properties (${testname}
PROPERTIES PASS_REGULAR_EXPRESSION "PASSED"
)
endmacro()
macro (make_hipify_test sourceFile )
#string (REPLACE " " "" smush_args ${ARGN})
set (testname ${sourceFile}${smush_args}.tst)
add_test (NAME ${testname}
COMMAND ${HIP_PATH}/bin/hipify ${PROJECT_SOURCE_DIR}/${sourceFile} ${ARGN}
)
endmacro()
2016-01-26 20:14:33 -06:00
macro (make_test_matches exe match_string)
string (REPLACE " " "" smush_args ${ARGN})
set (testname ${exe}${smush_args}.tst)
add_test (NAME ${testname}
COMMAND ${PROJECT_BINARY_DIR}/${exe} ${ARGN}
)
set_tests_properties (${testname}
PROPERTIES PASS_REGULAR_EXPRESSION ${match_string}
)
endmacro()
make_hip_executable (hip_ballot hip_ballot.cpp)
2016-01-26 20:14:33 -06:00
make_hip_executable (hip_anyall hip_anyall.cpp)
make_hip_executable (hip_popc hip_popc.cpp)
make_hip_executable (hip_clz hip_clz.cpp)
make_hip_executable (hip_brev hip_brev.cpp)
make_hip_executable (hip_ffs hip_ffs.cpp)
2016-02-04 17:39:07 +03:00
make_hip_executable (hipInfo hipInfo.cpp)
2016-02-05 07:15:46 -06:00
make_hip_executable (hipSetValidDevices hipSetValidDevices.cpp)
2016-01-26 20:14:33 -06:00
make_hip_executable (hipMemcpy hipMemcpy.cpp)
make_hip_executable (hipEventRecord hipEventRecord.cpp)
make_hip_executable (hipLanguageExtensions hipLanguageExtensions.cpp)
make_hip_executable (hipGridLaunch hipGridLaunch.cpp)
make_hip_executable (hipHcc hipHcc.cpp)
make_hip_executable (hipSimpleAtomicsTest hipSimpleAtomicsTest.cpp)
make_hip_executable (hipMathFunctionsHost hipMathFunctions.cpp hipSinglePrecisionMathHost.cpp hipDoublePrecisionMathHost.cpp)
make_hip_executable (hipMathFunctionsDevice hipMathFunctions.cpp hipSinglePrecisionMathDevice.cpp hipDoublePrecisionMathDevice.cpp)
2016-02-01 16:00:45 +05:30
make_hip_executable (hipIntrinsics hipMathFunctions.cpp hipSinglePrecisionIntrinsics.cpp hipDoublePrecisionIntrinsics.cpp hipIntegerIntrinsics.cpp)
target_link_libraries(hipMathFunctionsHost m)
2016-01-26 20:14:33 -06:00
make_test(hip_ballot " " )
2016-01-26 20:14:33 -06:00
make_test(hip_anyall " " )
make_test(hip_popc " " )
make_test(hip_brev " " )
make_test(hip_clz " " )
make_test(hip_ffs " " )
make_test(hipEventRecord --iterations 10)
make_test(hipMemset " " )
make_test(hipMemset --N 10 --memsetval 0x42 ) # small copy, just 10 bytes.
make_test(hipMemset --N 10013 --memsetval 0x5a ) # oddball size.
make_test(hipMemset --N 500M --memsetval 0xa6 ) # big copy
make_test(hipGridLaunch " " )
2016-02-05 07:15:46 -06:00
make_test(hipSetValidDevices " " )
2016-01-26 20:14:33 -06:00
make_test(hipMemcpy " " )
make_test(hipHcc " " )
make_hipify_test(specialFunc.cu )