Support performance tests
Support performance tests while direct tests commands keep unchanged.
To build performance tests, run "make build_perf".
To run all performance testis, run "make perf".
To run specific tests, for example, run
/usr/bin/ctest -C performance -R performance_tests/perfDispatch --verbose
To run individual test, for example, run
performance_tests/memory/hipPerfMemMallocCpyFree
Change-Id: I168c1b9ef1ec21b392d48648d0c71e8fbd37d57b
[ROCm/hip commit: 6e972dd3bb]
Este cometimento está contido em:
cometido por
Tao Sang
ascendente
84b36e38c3
cometimento
afbd11eb66
@@ -648,15 +648,27 @@ if(${RUN_HIT} EQUAL 0)
|
||||
|
||||
# Add tests
|
||||
include_directories(${HIP_SRC_PATH}/tests/src)
|
||||
hit_add_directory_recursive(${HIP_SRC_PATH}/tests/src "directed_tests")
|
||||
hit_add_directory_recursive(${HIP_CTEST_CONFIG_DEFAULT} ${HIP_SRC_PATH}/tests/src "directed_tests")
|
||||
|
||||
# Add unit tests
|
||||
include_directories(${HIP_SRC_PATH}/tests/unit)
|
||||
hit_add_directory_recursive(${HIP_SRC_PATH}/tests/unit "unit_tests")
|
||||
hit_add_directory_recursive(${HIP_CTEST_CONFIG_DEFAULT} ${HIP_SRC_PATH}/tests/unit "unit_tests")
|
||||
|
||||
# Add performance tests
|
||||
include_directories(${HIP_SRC_PATH}/tests/performance)
|
||||
hit_add_directory_recursive(${HIP_CTEST_CONFIG_PERFORMANCE} ${HIP_SRC_PATH}/tests/performance "performance_tests")
|
||||
|
||||
# Add top-level tests to build_tests
|
||||
add_custom_target(build_tests DEPENDS directed_tests unit_tests)
|
||||
|
||||
# Add top-level tests to build performance_tests.
|
||||
# To build performance tests, just run "make build_perf"
|
||||
add_custom_target(build_perf DEPENDS performance_tests)
|
||||
|
||||
# Add custom target: perf.
|
||||
# To run performance tests, just run "make perf"
|
||||
add_custom_target(perf COMMAND "${CMAKE_CTEST_COMMAND}" -C "${HIP_CTEST_CONFIG_PERFORMANCE}" -R "performance_tests/" --verbose)
|
||||
|
||||
# Add custom target: check
|
||||
add_custom_target(check COMMAND "${CMAKE_COMMAND}" --build . --target test DEPENDS build_tests)
|
||||
else()
|
||||
|
||||
@@ -121,6 +121,28 @@ ctest -R Memcpy
|
||||
ctest -R memory
|
||||
```
|
||||
|
||||
### Performance tests:
|
||||
```
|
||||
Above tests are direct tests which are majorly used for function verification.
|
||||
We also provide performance tests under tests/performance folder.
|
||||
|
||||
# Build all performance tests after running "make install" under build folder:
|
||||
make build_perf
|
||||
|
||||
Then all performance test applications will be built into ./performance_tests folder.
|
||||
|
||||
# Run all performance tests:
|
||||
make perf
|
||||
|
||||
# Run individual performance test:
|
||||
For example,
|
||||
performance_tests/memory/hipPerfMemMallocCpyFree
|
||||
|
||||
# Run a specific test set:
|
||||
For example,
|
||||
/usr/bin/ctest -C performance -R performance_tests/perfDispatch --verbose
|
||||
Here "-C performance" indicate the "performance" configuration of ctest.
|
||||
```
|
||||
|
||||
### If a test fails - how to debug a test
|
||||
|
||||
|
||||
@@ -10,4 +10,4 @@ include(${HIP_SRC_PATH}/tests/hit/HIT.cmake)
|
||||
|
||||
# Add tests
|
||||
include_directories(${HIP_SRC_PATH}/tests/src)
|
||||
hit_add_directory_recursive(${HIP_SRC_PATH}/tests/src "directed_tests")
|
||||
hit_add_directory_recursive(${HIP_CTEST_CONFIG_DEFAULT} ${HIP_SRC_PATH}/tests/src "directed_tests")
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
include(CTest)
|
||||
find_package(HIP REQUIRED)
|
||||
|
||||
set(HIP_CTEST_CONFIG_DEFAULT "default")
|
||||
set(HIP_CTEST_CONFIG_PERFORMANCE "performance")
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Helper macro to parse BUILD instructions
|
||||
macro(PARSE_BUILD_COMMAND _target _sources _hipcc_options _hcc_options _clang_options _nvcc_options _link_options _exclude_platforms _exclude_runtime _exclude_compiler _depends _dir)
|
||||
@@ -291,22 +294,30 @@ macro(READ_FROM_MAP _map _key _value)
|
||||
endmacro()
|
||||
|
||||
# Helper macro to create a test
|
||||
macro(MAKE_TEST exe)
|
||||
macro(MAKE_TEST _config exe)
|
||||
string(REPLACE " " "" smush_args ${ARGN})
|
||||
set(testname ${exe}${smush_args}.tst)
|
||||
add_test(NAME ${testname} COMMAND ${PROJECT_BINARY_DIR}/${exe} ${ARGN})
|
||||
if(${_config} STREQUAL ${HIP_CTEST_CONFIG_DEFAULT})
|
||||
add_test(NAME ${testname} COMMAND ${PROJECT_BINARY_DIR}/${exe} ${ARGN})
|
||||
else()
|
||||
add_test(NAME ${testname} CONFIGURATIONS ${_config} COMMAND ${PROJECT_BINARY_DIR}/${exe} ${ARGN})
|
||||
endif()
|
||||
set_tests_properties(${testname} PROPERTIES PASS_REGULAR_EXPRESSION "PASSED" ENVIRONMENT HIP_PATH=${HIP_ROOT_DIR})
|
||||
endmacro()
|
||||
|
||||
macro(MAKE_NAMED_TEST exe testname)
|
||||
add_test(NAME ${testname} COMMAND ${PROJECT_BINARY_DIR}/${exe} ${ARGN})
|
||||
macro(MAKE_NAMED_TEST _config exe testname)
|
||||
if(${_config} STREQUAL ${HIP_CTEST_CONFIG_DEFAULT})
|
||||
add_test(NAME ${testname} COMMAND ${PROJECT_BINARY_DIR}/${exe} ${ARGN})
|
||||
else()
|
||||
add_test(NAME ${testname} CONFIGURATIONS ${_config} COMMAND ${PROJECT_BINARY_DIR}/${exe} ${ARGN})
|
||||
endif()
|
||||
set_tests_properties(${testname} PROPERTIES PASS_REGULAR_EXPRESSION "PASSED" ENVIRONMENT HIP_PATH=${HIP_ROOT_DIR})
|
||||
endmacro()
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Macro: HIT_ADD_FILES used to scan+add multiple files for testing.
|
||||
file(GLOB HIP_LIB_FILES ${HIP_PATH}/lib/*)
|
||||
macro(HIT_ADD_FILES _dir _label _parent)
|
||||
macro(HIT_ADD_FILES _config _dir _label _parent)
|
||||
foreach (file ${ARGN})
|
||||
# Build tests
|
||||
execute_process(COMMAND ${HIP_SRC_PATH}/tests/hit/parser --buildCMDs ${file}
|
||||
@@ -398,7 +409,7 @@ macro(HIT_ADD_FILES _dir _label _parent)
|
||||
elseif(${HIP_RUNTIME} IN_LIST _exclude_runtime AND ${HIP_COMPILER} IN_LIST _exclude_compiler)
|
||||
elseif(_exclude_test_from_build STREQUAL TRUE)
|
||||
else()
|
||||
make_test(${_label}/${_target} ${_arguments})
|
||||
make_test(${_config} ${_label}/${_target} ${_arguments})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@@ -420,7 +431,7 @@ macro(HIT_ADD_FILES _dir _label _parent)
|
||||
elseif(${HIP_RUNTIME} IN_LIST _exclude_runtime AND ${HIP_COMPILER} IN_LIST _exclude_compiler)
|
||||
elseif(_exclude_test_from_build STREQUAL TRUE)
|
||||
else()
|
||||
make_named_test(${_label}/${_target} ${_label}/${_testname}.tst ${_arguments})
|
||||
make_named_test(${_config} ${_label}/${_target} ${_label}/${_testname}.tst ${_arguments})
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
@@ -432,16 +443,16 @@ macro(HIT_ADD_DIRECTORY _dir _label)
|
||||
string(REGEX REPLACE "/" "." _parent ${_label})
|
||||
add_custom_target(${_parent})
|
||||
file(GLOB files "${_dir}/*.c*")
|
||||
hit_add_files(${_dir} ${_label} ${parent} ${files})
|
||||
hit_add_files(${HIP_CTEST_CONFIG_DEFAULT} ${_dir} ${_label} ${parent} ${files})
|
||||
endmacro()
|
||||
|
||||
# Macro: HIT_ADD_DIRECTORY_RECURSIVE to scan+add all files in a directory+subdirectories for testing
|
||||
macro(HIT_ADD_DIRECTORY_RECURSIVE _dir _label)
|
||||
macro(HIT_ADD_DIRECTORY_RECURSIVE _config _dir _label)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_label} WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
string(REGEX REPLACE "/" "." _parent ${_label})
|
||||
add_custom_target(${_parent})
|
||||
if(${ARGC} EQUAL 3)
|
||||
add_dependencies(${ARGV2} ${_parent})
|
||||
if(${ARGC} EQUAL 4)
|
||||
add_dependencies(${ARGV3} ${_parent})
|
||||
endif()
|
||||
file(GLOB children RELATIVE ${_dir} ${_dir}/*)
|
||||
set(dirlist "")
|
||||
@@ -449,12 +460,12 @@ macro(HIT_ADD_DIRECTORY_RECURSIVE _dir _label)
|
||||
if(IS_DIRECTORY ${_dir}/${child})
|
||||
list(APPEND dirlist ${child})
|
||||
else()
|
||||
hit_add_files(${_dir} ${_label} ${_parent} ${child})
|
||||
hit_add_files(${_config} ${_dir} ${_label} ${_parent} ${child})
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(child ${dirlist})
|
||||
string(REGEX REPLACE "/" "." _parent ${_label})
|
||||
hit_add_directory_recursive(${_dir}/${child} ${_label}/${child} ${_parent})
|
||||
hit_add_directory_recursive(${_config} ${_dir}/${child} ${_label}/${child} ${_parent})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ THE SOFTWARE.
|
||||
#include <time.h>
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* BUILD: %t %s ../../src/test_common.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
#include "test_common.h"
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp timer.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* BUILD: %t %s ../../src/test_common.cpp timer.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
#include "test_common.h"
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp timer.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* BUILD: %t %s ../../src/test_common.cpp timer.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
#include "test_common.h"
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp timer.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* BUILD: %t %s ../../src/test_common.cpp timer.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
Criar uma nova questão referindo esta
Bloquear um utilizador