Refactor directed test infrastructue.

- Add hierarchy.  Tests now live in directories, each with its own
  CMakeFiles.txt.  Reduces merge conflicts.
- Change make_hip_executable -> build_hip_executable.
- Refresh docs.
- Enable some tests that were previously built but not run.

Change-Id: I8c5de3c954400bf233904282b8b42861a2b7c536


[ROCm/clr commit: 3feb13c8f6]
This commit is contained in:
Ben Sander
2016-06-17 14:56:53 -05:00
rodzic d2d921f7be
commit b31b23ff1d
46 zmienionych plików z 186 dodań i 95 usunięć
+14 -2
Wyświetl plik
@@ -14,16 +14,28 @@ $ make test
### How to add a new test
The tests/src/hipMemtest.cpp file contains a simple unit test and is a good starting point for other tests.
The tests/src/runtimeApi/memory/hipMemtest.cpp file contains a simple unit test and is a good starting point for other tests.
Copy this to a new test name and modify tests/src/CMakefiles.txt to add the test to the build environment.
Recent versions of the test infrastructure use a hierarchy of folders. Each folder contains src and CMakefiles.txt file.
See the CMakefiles.txt files for description of the intended purpose for each sub-directory.
#### Edit CMakefiles.txt:
// Example:
```
make_hip_executable (hipMemset hipMemset.cpp)
# Build the test executable:
build_hip_executable (hipMemset hipMemset.cpp)
# This runs the tests with the specified command-line testing.
# Multiple make_test may be specified.
make_test(hipMemset " ")
```
It is recommended to place the build and run steps adjacent in the CMakefiles.txt.
### Running tests:
```
ctest
@@ -8,6 +8,8 @@ endif()
set (HIPCC ${HIP_PATH}/bin/hipcc)
set (CMAKE_CXX_COMPILER ${HIPCC})
message (CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER} )
project (HIP_Unit_Tests)
include(CTest)
@@ -87,8 +89,8 @@ endif()
add_library(test_common OBJECT test_common.cpp )
# usage : make_hip_executable (exe_name CPP_FILES)
macro (make_hip_executable exe cpp)
# usage : build_hip_executable (exe_name CPP_FILES)
macro (build_hip_executable exe cpp)
if (${HIP_PLATFORM} STREQUAL "hcc")
if (${HIP_BUILD_LOCAL})
#target_link_libraries(${exe} hip_hcc)
@@ -103,8 +105,8 @@ endmacro()
# Make a hip executable, using libc++
macro (make_hip_executable_libcpp exe cpp)
make_hip_executable( ${exe} ${cpp} ${ARGN} )
macro (build_hip_executable_libcpp exe cpp)
build_hip_executable( ${exe} ${cpp} ${ARGN} )
if (${HIP_PLATFORM} STREQUAL "hcc")
set_source_files_properties (${cpp} i${ARGN} PROPERTIES COMPILE_FLAGS --stdlib=libc++ )
endif()
@@ -121,7 +123,7 @@ endfunction()
macro (make_test exe )
string (REPLACE " " "" smush_args ${ARGN})
set (testname ${exe}${smush_args}.tst)
set (testname ${PROJECT_NAME}/${exe}${smush_args}.tst)
make_named_test(${exe} ${testname} ${ARGN})
endmacro()
@@ -148,111 +150,52 @@ macro (make_test_matches exe match_string)
)
endmacro()
macro (make_hip_executable_ldg exe cpp)
if (${HIP_PLATFORM} STREQUAL "hcc")
make_hip_executable( ${exe} ${cpp} ${ARGN} )
else ()
make_hip_executable( ${exe} ${cpp} ${ARGN} )
macro (build_hip_executable_sm35 exe cpp)
build_hip_executable( ${exe} ${cpp} ${ARGN} )
if (${HIP_PLATFORM} STREQUAL "nvcc")
set_source_files_properties (${cpp} i${ARGN} PROPERTIES COMPILE_FLAGS --gpu-architecture=sm_35 )
endif()
endif()
endmacro()
#make_hip_executable (hipAPIStreamEnable hipAPIStreamEnable.cpp)
#make_hip_executable (hipAPIStreamDisable hipAPIStreamDisable.cpp)
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)
make_hip_executable_ldg (hip_test_ldg hip_test_ldg.cpp)
make_hip_executable (hipGetDeviceAttribute hipGetDeviceAttribute.cpp)
make_hip_executable (hipEnvVar hipEnvVar.cpp)
make_hip_executable (hipEnvVarDriver hipEnvVarDriver.cpp)
make_hip_executable (hipMemcpy_simple hipMemcpy_simple.cpp)
make_hip_executable (hipMemcpy hipMemcpy.cpp)
make_hip_executable (hipMemcpyAsync hipMemcpyAsync.cpp)
make_hip_executable (hipMemset hipMemset.cpp)
make_hip_executable (hipEventRecord hipEventRecord.cpp)
make_hip_executable_libcpp (hipLanguageExtensions hipLanguageExtensions.cpp)
make_hip_executable (hipGridLaunch hipGridLaunch.cpp)
build_hip_executable (hipGetDeviceAttribute hipGetDeviceAttribute.cpp)
build_hip_executable (hipEnvVar hipEnvVar.cpp)
build_hip_executable (hipEnvVarDriver hipEnvVarDriver.cpp)
build_hip_executable (hipEventRecord hipEventRecord.cpp)
make_hip_executable_libcpp (hipHcc hipHcc.cpp)
build_hip_executable_libcpp (hipHcc hipHcc.cpp)
#set_source_files_properties (hipHcc.cpp PROPERTIES COMPILE_FLAGS --stdlib=libc++ )
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)
make_hip_executable (hipIntrinsics hipMathFunctions.cpp hipSinglePrecisionIntrinsics.cpp hipDoublePrecisionIntrinsics.cpp hipIntegerIntrinsics.cpp)
make_hip_executable_libcpp (hipPointerAttrib hipPointerAttrib.cpp)
make_hip_executable (hipMultiThreadStreams1 hipMultiThreadStreams1.cpp)
make_hip_executable (hipMultiThreadStreams2 hipMultiThreadStreams2.cpp)
make_hip_executable (hipHostAlloc hipHostAlloc.cpp)
make_hip_executable (hipStreamL5 hipStreamL5.cpp)
make_hip_executable (hipHostGetFlags hipHostGetFlags.cpp)
make_hip_executable (hipHostRegister hipHostRegister.cpp)
make_hip_executable (hipRandomMemcpyAsync hipRandomMemcpyAsync.cpp)
make_hip_executable (hipMemoryAllocate hipMemoryAllocate.cpp)
make_hip_executable (hipFuncSetDeviceFlags hipFuncSetDeviceFlags.cpp)
make_hip_executable (hipFuncGetDevice hipFuncGetDevice.cpp)
make_hip_executable (hipFuncSetDevice hipFuncSetDevice.cpp)
make_hip_executable (hipFuncDeviceSynchronize hipFuncDeviceSynchronize.cpp)
make_hip_executable (hipPeerToPeer_simple hipPeerToPeer_simple.cpp)
make_hip_executable (hipMemcpyAll hipMemcpyAll.cpp)
make_hip_executable (hipMultiThreadDevice hipMultiThreadDevice.cpp)
make_hip_executable (hipTestMemcpyPin hipTestMemcpyPin.cpp)
#make_hip_executable (hipDynamicShared hipDynamicShared.cpp)
make_hip_executable (hipTestDevice hipTestDevice.cpp)
make_hip_executable (hipTestDeviceDouble hipTestDeviceDouble.cpp)
build_hip_executable_libcpp (hipPointerAttrib hipPointerAttrib.cpp)
build_hip_executable (hipHostAlloc hipHostAlloc.cpp)
build_hip_executable (hipHostGetFlags hipHostGetFlags.cpp)
build_hip_executable (hipHostRegister hipHostRegister.cpp)
build_hip_executable (hipRandomMemcpyAsync hipRandomMemcpyAsync.cpp)
build_hip_executable (hipFuncSetDeviceFlags hipFuncSetDeviceFlags.cpp)
build_hip_executable (hipFuncGetDevice hipFuncGetDevice.cpp)
build_hip_executable (hipFuncSetDevice hipFuncSetDevice.cpp)
build_hip_executable (hipFuncDeviceSynchronize hipFuncDeviceSynchronize.cpp)
build_hip_executable (hipPeerToPeer_simple hipPeerToPeer_simple.cpp)
build_hip_executable (hipTestMemcpyPin hipTestMemcpyPin.cpp)
#build_hip_executable (hipDynamicShared hipDynamicShared.cpp)
make_test(hip_ballot " " )
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 256M --memsetval 0xa6 ) # big copy
make_test(hipGridLaunch " " )
make_test(hipEnvVarDriver " " )
make_test(hipMemcpyAll " ")
#TODO -reenable
#make_test(hipPointerAttrib " " )
#make_test(hipMultiThreadStreams1 " " ) Fails if 0x3 specified, passes otherwise.
make_test(hipMultiThreadStreams2 " " )
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 )
make_test(hip_test_ldg " " )
# Debug synchronization, then enable.
#make_named_test(hipMemcpy_simple "hipMemcpyAsync-simple" --async)
make_test(hipHostAlloc " ")
#make_test(hipMemcpyAsync " " )
# BS- comment out since test appears broken - asks for device pointer but pointer was never allocated.
#make_test(hipHostGetFlags " ")
make_test(hipHcc " " )
make_test(hipHostRegister " ")
make_test(hipStreamL5 " ")
make_test(hipRandomMemcpyAsync " ")
#make_test(hipAPIStreamEnable " ")
#make_test(hipAPIStreamDisable " ")
make_test(hipFuncSetDeviceFlags " ")
make_test(hipFuncGetDevice " ")
make_test(hipFuncDeviceSynchronize " ")
make_test(hipTestMemcpyPin " ")
make_test(hipTestDevice " ")
make_named_test (hipMultiThreadDevice "hipMultiThreadDevice-serial" --tests 0x1)
make_named_test (hipMultiThreadDevice "hipMultiThreadDevice-pyramid" --tests 0x4)
make_named_test (hipMultiThreadDevice "hipMultiThreadDevice-nearzero" --tests 0x10)
make_test(hipMemoryAllocate " ")
if (${HIP_MULTI_GPU})
make_test(hipPeerToPeer_simple " ") # use current device for copy, this fails.
@@ -270,4 +213,6 @@ make_hipify_test(specialFunc.cu )
make_test(hipDynamicShared " ")
# Add subdirs here:
add_subdirectory(launch_bounds)
add_subdirectory(deviceLib)
add_subdirectory(runtimeApi)
add_subdirectory(kernel)
@@ -1,3 +0,0 @@
Unit tests for HIP API.
To add a new test:
@@ -0,0 +1,46 @@
cmake_minimum_required (VERSION 2.6)
project (deviceLib)
include_directories( ${HIPTEST_SOURCE_DIR} )
build_hip_executable (hip_ballot hip_ballot.cpp)
make_test(hip_ballot " " )
build_hip_executable (hip_anyall hip_anyall.cpp)
make_test(hip_anyall " " )
build_hip_executable (hip_popc hip_popc.cpp)
make_test(hip_popc " " )
build_hip_executable (hip_clz hip_clz.cpp)
make_test(hip_clz " " )
build_hip_executable (hip_brev hip_brev.cpp)
make_test(hip_brev " " )
build_hip_executable (hip_ffs hip_ffs.cpp)
make_test(hip_ffs " " )
build_hip_executable_sm35 (hip_test_ldg hip_test_ldg.cpp)
make_test(hip_test_ldg " " )
build_hip_executable (hipSimpleAtomicsTest hipSimpleAtomicsTest.cpp)
make_test(hipSimpleAtomicsTest " ")
build_hip_executable (hipMathFunctionsHost hipMathFunctions.cpp hipSinglePrecisionMathHost.cpp hipDoublePrecisionMathHost.cpp)
make_test(hipMathFunctionsHost " ")
build_hip_executable (hipMathFunctionsDevice hipMathFunctions.cpp hipSinglePrecisionMathDevice.cpp hipDoublePrecisionMathDevice.cpp)
make_test(hipMathFunctionsDevice " ")
build_hip_executable (hipIntrinsics hipMathFunctions.cpp hipSinglePrecisionIntrinsics.cpp hipDoublePrecisionIntrinsics.cpp hipIntegerIntrinsics.cpp)
make_test(hipIntrinsics " ")
build_hip_executable (hipTestDevice hipTestDevice.cpp)
make_test(hipTestDevice " ")
build_hip_executable (hipTestDeviceDouble hipTestDeviceDouble.cpp)
make_test(hipTestDeviceDouble " ")
@@ -26,6 +26,7 @@ THE SOFTWARE.
// Includes HIP Runtime
#include <hip_runtime.h>
#include <test_common.h>
#define EXIT_WAIVED 2
@@ -315,4 +316,6 @@ void runTest(int argc, char **argv)
// Cleanup memory
free(hOData);
hipFree(dOData);
passed();
}
@@ -213,7 +213,6 @@ bool dataTypesRun2(){
HIP_ASSERT(hipMalloc((void**)&deviceB, NUM * sizeof(T)));
HIP_ASSERT(hipMemcpy(deviceB, hostB, NUM*sizeof(T), hipMemcpyHostToDevice));
hipLaunchKernel(vectoradd_float,
dim3(WIDTH/THREADS_PER_BLOCK_X, HEIGHT/THREADS_PER_BLOCK_Y),
dim3(THREADS_PER_BLOCK_X, THREADS_PER_BLOCK_Y),
@@ -227,7 +226,7 @@ bool dataTypesRun2(){
// verify the results
errors = 0;
for (i = 0; i < NUM; i++) {
if (hostA[i].x != (hostB[i].x) && hostA[i].y != (hostB[i].y)) {
if (hostA[i].x != (hostB[i].x) && hostA[i].y != (hostB[i].y)) {
errors++;
}
}
@@ -235,7 +234,7 @@ if (hostA[i].x != (hostB[i].x) && hostA[i].y != (hostB[i].y)) {
std::cout << "FAILED\n"<<std::endl;
ret = false;
} else {
ret = true;
ret = true;
}
HIP_ASSERT(hipFree(deviceA));
@@ -315,6 +314,7 @@ int main() {
cout << " System minor " << devProp.minor << endl;
cout << " System major " << devProp.major << endl;
cout << " agent prop name " << devProp.name << endl;
int errors;
errors = dataTypesRun<char,char>() &
@@ -339,6 +339,7 @@ int main() {
return -1;
}
#if 1
errors = dataTypesRun2<int2,int>() &
dataTypesRun2<short2,short>() &
dataTypesRun2<ushort2,unsigned short>() &
@@ -355,8 +356,10 @@ int main() {
std::cout<<"Failed two element vector data types"<<std::endl;
return -1;
}
#endif
#if 1
errors = dataTypesRun4<int4,int>() &
dataTypesRun4<char4,signed char>() &
@@ -372,6 +375,7 @@ int main() {
std::cout<<"Failed four element vector data types"<<std::endl;
return -1;
}
#endif
std::cout<<"ldg test PASSED \n"<<std::endl;
@@ -0,0 +1,16 @@
cmake_minimum_required (VERSION 2.6)
# Functions for kernel attributes (grid_launch, __launch_bounds__, etc)
project (kernel)
include_directories( ${HIPTEST_SOURCE_DIR} )
build_hip_executable_libcpp (hipLanguageExtensions hipLanguageExtensions.cpp)
make_test(hipLanguageExtensions " " )
build_hip_executable (hipGridLaunch hipGridLaunch.cpp)
make_test(hipGridLaunch " " )
build_hip_executable (launch_bounds launch_bounds.cpp)
make_test(launch_bounds " ")
@@ -22,6 +22,7 @@ THE SOFTWARE.
// Collection of code to make sure that various features in the hip kernel language compile.
#include <hip_runtime.h>
#include <test_common.h>
#ifdef __HCC__
#include <amp.h>
@@ -125,4 +126,5 @@ vectorADD(const hipLaunchParm lp,
int main() {
printf ("Hello world\n");
passed();
}
@@ -4,5 +4,5 @@ project (launch_bounds)
include_directories( ${HIPTEST_SOURCE_DIR} )
make_hip_executable (hip_launch_bounds hip_launch_bounds.cpp)
build_hip_executable (hip_launch_bounds hip_launch_bounds.cpp)
make_test(hip_launch_bounds " ")
@@ -0,0 +1,7 @@
cmake_minimum_required (VERSION 2.6)
project (runtimeApi)
add_subdirectory(memory)
add_subdirectory(multiThread)
add_subdirectory(stream)
@@ -0,0 +1,31 @@
cmake_minimum_required (VERSION 2.6)
project (runtime_api)
include_directories( ${HIPTEST_SOURCE_DIR} )
build_hip_executable (hipMemset hipMemset.cpp)
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 256M --memsetval 0xa6 ) # big copy
build_hip_executable (hipMemcpy_simple hipMemcpy_simple.cpp)
make_test(hipMemcpy_simple " " )
build_hip_executable (hipMemcpy hipMemcpy.cpp)
make_named_test(hipMemcpy "hipMemcpy-modes" --tests 0x1 )
make_named_test(hipMemcpy "hipMemcpy-size" --tests 0x6 )
make_named_test(hipMemcpy "hipMemcpy-multithreaded" --tests 0x8 )
build_hip_executable (hipMemcpyAsync hipMemcpyAsync.cpp)
make_named_test(hipMemcpy_simple "hipMemcpyAsync-simple" --async)
#make_test(hipMemcpyAsync " " )
build_hip_executable (hipMemoryAllocate hipMemoryAllocate.cpp)
build_hip_executable (hipMemcpyAll hipMemcpyAll.cpp)
make_test(hipMemcpyAll " ")
# Debug synchronization, then enable.
make_test(hipMemoryAllocate " ")
@@ -0,0 +1,15 @@
cmake_minimum_required (VERSION 2.6)
project (runtime_api)
include_directories( ${HIPTEST_SOURCE_DIR} )
build_hip_executable (hipMultiThreadStreams1 hipMultiThreadStreams1.cpp)
build_hip_executable (hipMultiThreadStreams2 hipMultiThreadStreams2.cpp)
build_hip_executable (hipMultiThreadDevice hipMultiThreadDevice.cpp)
#make_test(hipMultiThreadStreams1 " " ) Fails if 0x3 specified, passes otherwise.
make_test(hipMultiThreadStreams2 " " )
make_named_test (hipMultiThreadDevice "hipMultiThreadDevice-serial" --tests 0x1)
make_named_test (hipMultiThreadDevice "hipMultiThreadDevice-pyramid" --tests 0x4)
make_named_test (hipMultiThreadDevice "hipMultiThreadDevice-nearzero" --tests 0x10)
@@ -0,0 +1,13 @@
cmake_minimum_required (VERSION 2.6)
project (runtime_api)
include_directories( ${HIPTEST_SOURCE_DIR} )
build_hip_executable (hipAPIStreamEnable hipAPIStreamEnable.cpp)
build_hip_executable (hipAPIStreamDisable hipAPIStreamDisable.cpp)
build_hip_executable (hipStreamL5 hipStreamL5.cpp)
# TODO - seg fault
#make_test(hipAPIStreamEnable " ")
#make_test(hipAPIStreamDisable " ")
make_test(hipStreamL5 " ")