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)
|
|
|
|
|
|
2016-04-11 12:52:18 -05:00
|
|
|
if(NOT DEFINED HIP_MULTI_GPU)
|
|
|
|
|
set(HIP_MULTI_GPU 0 CACHE BOOL "Run tests requiring more than one GPU")
|
|
|
|
|
endif()
|
|
|
|
|
|
2016-04-04 13:53:24 +05:30
|
|
|
if(NOT DEFINED HIP_BUILD_LOCAL)
|
|
|
|
|
if(NOT DEFINED ENV{HIP_BUILD_LOCAL})
|
2016-04-09 22:05:45 +05:30
|
|
|
set(HIP_BUILD_LOCAL 1 CACHE BOOL "Build HIP in local folder")
|
2016-04-04 13:53:24 +05:30
|
|
|
else()
|
|
|
|
|
set(HIP_BUILD_LOCAL $ENV{HIP_BUILD_LOCAL} CACHE BOOL "Build HIP in local folder")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
2016-03-29 17:29:31 -05:00
|
|
|
|
2016-03-24 11:17:57 -05:00
|
|
|
set(HIP_PATH $ENV{HIP_PATH})
|
2016-01-26 20:14:33 -06:00
|
|
|
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-03-23 01:17:53 -05:00
|
|
|
|
2016-02-17 21:22:07 -06:00
|
|
|
set (HSA_PATH $ENV{HSA_PATH})
|
|
|
|
|
if (NOT DEFINED HSA_PATH)
|
2016-04-15 12:56:31 +05:30
|
|
|
set (HSA_PATH /opt/rocm/hsa)
|
2016-02-17 21:22:07 -06:00
|
|
|
endif()
|
2016-01-26 20:14:33 -06:00
|
|
|
|
2016-03-23 01:17:53 -05:00
|
|
|
set (CODEXL_PATH $ENV{CODEXL_PATH})
|
|
|
|
|
if (NOT DEFINED CODEXL_PATH)
|
|
|
|
|
set (CODEXL_PATH /opt/AMD/CodeXL)
|
|
|
|
|
endif()
|
|
|
|
|
set (CODEXL_SDK_ATAL_PATH ${CODEXL_PATH}/SDK/AMDTActivityLogger)
|
|
|
|
|
|
2016-01-26 20:14:33 -06:00
|
|
|
#---
|
|
|
|
|
# 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:
|
2016-02-15 05:40:30 -06:00
|
|
|
include_directories(${HIP_PATH}/include)
|
2016-01-26 20:14:33 -06:00
|
|
|
|
2016-03-24 13:20:25 -05:00
|
|
|
# This will create a subdir "hip_hcc" in the test build directory
|
|
|
|
|
# Any changes to hip_hcc source will be detected and force the library and then the tests to be rebuilt.
|
2016-03-29 17:29:31 -05:00
|
|
|
if (${HIP_BUILD_LOCAL})
|
|
|
|
|
add_subdirectory(${HIP_PATH} build.hip_hcc)
|
|
|
|
|
#link_directories(${CMAKE_CURRENT_BINARY_DIR}/build.hip_hcc) # search the local hip_hcc for libhip_hcc.a
|
|
|
|
|
set (CMAKE_CXX_FLAGS --hipcc_explicit_lib)
|
|
|
|
|
endif()
|
2016-03-26 10:46:20 -05:00
|
|
|
|
2016-03-24 11:17:57 -05:00
|
|
|
|
2016-01-26 20:14:33 -06:00
|
|
|
elseif (${HIP_PLATFORM} STREQUAL "nvcc")
|
2016-02-05 07:15:46 -06:00
|
|
|
MESSAGE ("HIP_PLATFORM=nvcc")
|
2016-02-22 15:09:23 -06:00
|
|
|
|
|
|
|
|
#Need C++11 for threads in some of the tests.
|
|
|
|
|
add_definitions(-std=c++11)
|
|
|
|
|
|
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)
|
2016-03-24 11:53:28 -05:00
|
|
|
set (CMAKE_CXX_COMPILER ${HIPCC})
|
2016-01-26 20:14:33 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
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")
|
2016-04-04 13:53:24 +05:30
|
|
|
#add_executable (${exe} ${cpp} ${ARGN} $<TARGET_OBJECTS:test_common> )
|
2016-03-29 17:29:31 -05:00
|
|
|
if (${HIP_BUILD_LOCAL})
|
2016-04-04 13:53:24 +05:30
|
|
|
#target_link_libraries(${exe} hip_hcc)
|
|
|
|
|
add_executable (${exe} ${cpp} ${ARGN} $<TARGET_OBJECTS:test_common> $<TARGET_OBJECTS:hip_hcc> )
|
|
|
|
|
else()
|
|
|
|
|
add_executable (${exe} ${cpp} ${ARGN} $<TARGET_OBJECTS:test_common> )
|
2016-03-29 17:29:31 -05:00
|
|
|
endif()
|
2016-01-26 20:14:33 -06:00
|
|
|
else()
|
|
|
|
|
add_executable (${exe} ${cpp} ${ARGN} $<TARGET_OBJECTS:test_common> )
|
|
|
|
|
endif()
|
|
|
|
|
endmacro()
|
|
|
|
|
|
2016-03-07 17:15:48 -06:00
|
|
|
macro (make_named_test exe testname )
|
2016-01-26 20:14:33 -06:00
|
|
|
add_test (NAME ${testname}
|
|
|
|
|
COMMAND ${PROJECT_BINARY_DIR}/${exe} ${ARGN}
|
|
|
|
|
)
|
|
|
|
|
set_tests_properties (${testname}
|
|
|
|
|
PROPERTIES PASS_REGULAR_EXPRESSION "PASSED"
|
|
|
|
|
)
|
|
|
|
|
endmacro()
|
|
|
|
|
|
2016-03-07 17:15:48 -06:00
|
|
|
macro (make_test exe )
|
|
|
|
|
string (REPLACE " " "" smush_args ${ARGN})
|
|
|
|
|
set (testname ${exe}${smush_args}.tst)
|
|
|
|
|
|
|
|
|
|
make_named_test(${exe} ${testname} ${ARGN})
|
|
|
|
|
endmacro()
|
|
|
|
|
|
2016-01-26 20:14:33 -06:00
|
|
|
|
2016-02-02 10:02:48 -06:00
|
|
|
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()
|
|
|
|
|
|
2016-03-23 10:29:44 -05:00
|
|
|
|
|
|
|
|
|
2016-03-21 14:42:23 -05:00
|
|
|
#make_hip_executable (hipAPIStreamEnable hipAPIStreamEnable.cpp)
|
|
|
|
|
#make_hip_executable (hipAPIStreamDisable hipAPIStreamDisable.cpp)
|
2016-04-01 16:07:07 +05:30
|
|
|
make_hip_executable (hip_ballot hip_ballot.cpp)
|
|
|
|
|
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-09 13:19:32 +08:00
|
|
|
make_hip_executable (hipGetDeviceAttribute hipGetDeviceAttribute.cpp)
|
2016-02-27 14:48:00 -06:00
|
|
|
make_hip_executable (hipEnvVar hipEnvVar.cpp)
|
|
|
|
|
make_hip_executable (hipEnvVarDriver hipEnvVarDriver.cpp)
|
2016-03-07 17:15:48 -06:00
|
|
|
make_hip_executable (hipMemcpy_simple hipMemcpy_simple.cpp)
|
2016-01-26 20:14:33 -06:00
|
|
|
make_hip_executable (hipMemcpy hipMemcpy.cpp)
|
2016-02-17 00:59:12 -06:00
|
|
|
make_hip_executable (hipMemcpyAsync hipMemcpyAsync.cpp)
|
2016-02-08 22:55:23 -06:00
|
|
|
make_hip_executable (hipMemset hipMemset.cpp)
|
2016-01-26 20:14:33 -06:00
|
|
|
make_hip_executable (hipEventRecord hipEventRecord.cpp)
|
|
|
|
|
make_hip_executable (hipLanguageExtensions hipLanguageExtensions.cpp)
|
|
|
|
|
make_hip_executable (hipGridLaunch hipGridLaunch.cpp)
|
|
|
|
|
make_hip_executable (hipHcc hipHcc.cpp)
|
2016-04-01 16:07:07 +05:30
|
|
|
make_hip_executable (hipSimpleAtomicsTest hipSimpleAtomicsTest.cpp)
|
2016-02-01 14:36:50 +05:30
|
|
|
make_hip_executable (hipMathFunctionsHost hipMathFunctions.cpp hipSinglePrecisionMathHost.cpp hipDoublePrecisionMathHost.cpp)
|
2016-04-01 16:07:07 +05:30
|
|
|
make_hip_executable (hipMathFunctionsDevice hipMathFunctions.cpp hipSinglePrecisionMathDevice.cpp hipDoublePrecisionMathDevice.cpp)
|
|
|
|
|
make_hip_executable (hipIntrinsics hipMathFunctions.cpp hipSinglePrecisionIntrinsics.cpp hipDoublePrecisionIntrinsics.cpp hipIntegerIntrinsics.cpp)
|
2016-03-29 17:29:31 -05:00
|
|
|
make_hip_executable (hipPointerAttrib hipPointerAttrib.cpp)
|
2016-03-01 19:33:47 -06:00
|
|
|
make_hip_executable (hipMultiThreadStreams1 hipMultiThreadStreams1.cpp)
|
|
|
|
|
make_hip_executable (hipMultiThreadStreams2 hipMultiThreadStreams2.cpp)
|
2016-03-05 13:58:56 -06:00
|
|
|
make_hip_executable (hipHostAlloc hipHostAlloc.cpp)
|
2016-02-27 05:55:56 -06:00
|
|
|
make_hip_executable (hipStreamL5 hipStreamL5.cpp)
|
2016-03-06 12:17:30 -06:00
|
|
|
make_hip_executable (hipHostGetFlags hipHostGetFlags.cpp)
|
2016-04-11 09:09:36 -05:00
|
|
|
#TODO - re-enable. This requires working hipHostRegister call, waiting on HCC feature.
|
2016-04-15 10:42:31 -05:00
|
|
|
make_hip_executable (hipHostRegister hipHostRegister.cpp)
|
2016-03-08 03:40:56 -06:00
|
|
|
make_hip_executable (hipRandomMemcpyAsync hipRandomMemcpyAsync.cpp)
|
2016-03-21 10:40:42 -05:00
|
|
|
make_hip_executable (hipMemoryAllocate hipMemoryAllocate.cpp)
|
2016-03-24 07:04:01 -05:00
|
|
|
make_hip_executable (hipFuncSetDeviceFlags hipFuncSetDeviceFlags.cpp)
|
2016-03-25 05:49:33 -05:00
|
|
|
make_hip_executable (hipFuncGetDevice hipFuncGetDevice.cpp)
|
|
|
|
|
make_hip_executable (hipFuncSetDevice hipFuncSetDevice.cpp)
|
2016-03-25 06:41:49 -05:00
|
|
|
make_hip_executable (hipFuncDeviceSynchronize hipFuncDeviceSynchronize.cpp)
|
2016-04-07 15:51:08 -05:00
|
|
|
make_hip_executable (hipPeerToPeer_simple hipPeerToPeer_simple.cpp)
|
2016-03-21 10:40:42 -05:00
|
|
|
|
2016-03-29 17:33:29 -05:00
|
|
|
make_hip_executable (hipMultiThreadDevice hipMultiThreadDevice.cpp)
|
2016-03-26 10:46:20 -05:00
|
|
|
|
2016-02-02 14:50:55 +05:30
|
|
|
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.
|
2016-02-10 20:01:16 +08:00
|
|
|
make_test(hipMemset --N 256M --memsetval 0xa6 ) # big copy
|
2016-01-26 20:14:33 -06:00
|
|
|
make_test(hipGridLaunch " " )
|
2016-02-27 14:48:00 -06:00
|
|
|
make_test(hipEnvVarDriver " " )
|
2016-03-23 01:17:53 -05:00
|
|
|
#TODO -reenable
|
|
|
|
|
#make_test(hipPointerAttrib " " )
|
2016-03-29 17:29:31 -05:00
|
|
|
#make_test(hipMultiThreadStreams1 " " ) Fails if 0x3 specified, passes otherwise.
|
|
|
|
|
|
|
|
|
|
make_test(hipMultiThreadStreams2 " " )
|
2016-03-07 17:15:48 -06:00
|
|
|
make_test(hipMemcpy_simple " " )
|
|
|
|
|
make_named_test(hipMemcpy "hipMemcpy-modes" --tests 0x1 )
|
|
|
|
|
make_named_test(hipMemcpy "hipMemcpy-size" --tests 0x6 )
|
|
|
|
|
make_named_test(hipMemcpy "hipMemcpy-multithreaded" --tests 0x8 )
|
2016-03-20 08:08:33 -05:00
|
|
|
|
2016-03-23 01:17:53 -05:00
|
|
|
# Debug synchronization, then enable.
|
|
|
|
|
#make_named_test(hipMemcpy_simple "hipMemcpyAsync-simple" --async)
|
|
|
|
|
|
2016-03-05 13:58:56 -06:00
|
|
|
make_test(hipHostAlloc " ")
|
2016-03-31 04:45:00 -05:00
|
|
|
#make_test(hipMemcpyAsync " " )
|
2016-03-23 10:29:44 -05:00
|
|
|
# BS- comment out since test appears broken - asks for device pointer but pointer was never allocated.
|
|
|
|
|
#make_test(hipHostGetFlags " ")
|
2016-01-26 20:14:33 -06:00
|
|
|
make_test(hipHcc " " )
|
2016-03-07 03:42:50 -06:00
|
|
|
make_test(hipHostRegister " ")
|
2016-02-27 05:55:56 -06:00
|
|
|
make_test(hipStreamL5 " ")
|
2016-03-08 03:40:56 -06:00
|
|
|
make_test(hipRandomMemcpyAsync " ")
|
2016-03-21 14:42:23 -05:00
|
|
|
#make_test(hipAPIStreamEnable " ")
|
|
|
|
|
#make_test(hipAPIStreamDisable " ")
|
2016-03-21 10:40:42 -05:00
|
|
|
make_test(hipMemoryAllocate " ")
|
2016-03-24 07:04:01 -05:00
|
|
|
make_test(hipFuncSetDeviceFlags " ")
|
2016-03-25 05:49:33 -05:00
|
|
|
make_test(hipFuncGetDevice " ")
|
|
|
|
|
make_test(hipFuncSetDevice " ")
|
2016-03-25 06:41:49 -05:00
|
|
|
make_test(hipFuncDeviceSynchronize " ")
|
2016-03-29 17:33:29 -05:00
|
|
|
make_named_test (hipMultiThreadDevice "hipMultiThreadDevice-serial" --tests 0x1)
|
|
|
|
|
make_named_test (hipMultiThreadDevice "hipMultiThreadDevice-pyramid" --tests 0x4)
|
|
|
|
|
make_named_test (hipMultiThreadDevice "hipMultiThreadDevice-nearzero" --tests 0x10)
|
2016-04-11 12:52:18 -05:00
|
|
|
|
|
|
|
|
if (${HIP_MULTI_GPU})
|
2016-04-11 13:46:53 -05:00
|
|
|
make_test(hipPeerToPeer_simple " ") # use current device for copy, this fails.
|
2016-04-11 12:52:18 -05:00
|
|
|
make_test(hipPeerToPeer_simple --memcpyWithPeer)
|
|
|
|
|
make_test(hipPeerToPeer_simple --mirrorPeers) # mirror mapping: test to ensure mirror doesn't destroy orig mapping.
|
|
|
|
|
|
|
|
|
|
endif()
|
2016-03-25 05:49:33 -05:00
|
|
|
|
2016-02-02 10:02:48 -06:00
|
|
|
make_hipify_test(specialFunc.cu )
|