From bcd067f462fbc216e583459051b8d25fc07afcad Mon Sep 17 00:00:00 2001 From: Tao Sang Date: Mon, 12 Oct 2020 10:27:33 -0400 Subject: [PATCH] Make directed_test support static libs 1.Make directed_test apps linked against static libs of hip, rocclr, rocr, roct and amd_comgr. 2.Remove custom_target amdhip64_static_combiner. 3.Support EXCLUDE_HIP_LIB_TYPE . 4.Simplify argument list parsing. 5.Install rocclr when rocm is installed. 6.Fix some original small bugs. Revert "Revert "Make directed_test support static libs"" This reverts commit 5b7533e49f0428d3fc6de2270553c8f964128fcd. Change-Id: I918eeae94487e5e2ff5bfde083667ac65fb6e702 --- cmake/FindHIP.cmake | 20 +- hip-config.cmake.in | 1 + packaging/hip-rocclr.postinst | 13 +- packaging/hip-rocclr.prerm | 15 +- packaging/hip-rocclr.txt | 18 + rocclr/CMakeLists.txt | 37 +- samples/0_Intro/bit_extract/CMakeLists.txt | 8 + samples/0_Intro/bit_extract/bit_extract.cpp | 14 + samples/0_Intro/square/CMakeLists.txt | 3 + .../CMakeLists.txt | 8 + .../12_cmake_hip_add_executable/Readme.md | 6 + samples/README.md | 18 +- tests/README.md | 16 +- tests/hit/HIT.cmake | 400 ++++++++---------- .../complex_loading_behavior.cpp | 4 +- .../src/dynamicLoading/hipApiDynamicLoad.cpp | 2 +- tests/src/g++/hipMalloc.cpp | 4 +- .../hipMemset2DAsyncMultiThreadAndKernel.cpp | 2 +- .../memory/hipMemsetAsyncAndKernel.cpp | 2 +- .../memory/hipMemsetAsyncMultiThread.cpp | 2 +- 20 files changed, 322 insertions(+), 271 deletions(-) diff --git a/cmake/FindHIP.cmake b/cmake/FindHIP.cmake index b5afd46913..6b698374a1 100644 --- a/cmake/FindHIP.cmake +++ b/cmake/FindHIP.cmake @@ -11,6 +11,7 @@ set(HIP_HCC_FLAGS "" CACHE STRING "Semicolon delimited flags for HCC") set(HIP_CLANG_FLAGS "" CACHE STRING "Semicolon delimited flags for CLANG") set(HIP_NVCC_FLAGS "" CACHE STRING "Semicolon delimted flags for NVCC") mark_as_advanced(HIP_HIPCC_FLAGS HIP_HCC_FLAGS HIP_CLANG_FLAGS HIP_NVCC_FLAGS) + set(_hip_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo) list(REMOVE_DUPLICATES _hip_configuration_types) foreach(config ${_hip_configuration_types}) @@ -226,7 +227,7 @@ elseif("${HIP_COMPILER}" STREQUAL "clang") endif() if(HIP_CLANG_NUM_PARALLEL_JOBS GREATER 1) if(${HIP_CLANG_SUPPORTS_PARALLEL_JOBS}) - set(HIP_CLANG_PARALLEL_BUILD_COMPILE_OPTIONS "-parallel-jobs=${HIP_CLANG_NUM_PARALLEL_JOBS} -Wno-format-nonliteral") + set(HIP_CLANG_PARALLEL_BUILD_COMPILE_OPTIONS "-Wno-format-nonliteral -parallel-jobs=${HIP_CLANG_NUM_PARALLEL_JOBS}") set(HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS "-parallel-jobs=${HIP_CLANG_NUM_PARALLEL_JOBS}") else() message("clang compiler doesn't support parallel jobs") @@ -237,6 +238,13 @@ elseif("${HIP_COMPILER}" STREQUAL "clang") set(CMAKE_HIP_CREATE_SHARED_LIBRARY "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HIP_CLANG_PATH} ${HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS} -o ") set(CMAKE_HIP_CREATE_SHARED_MODULE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HIP_CLANG_PATH} ${HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS} -o -shared" ) set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HIP_CLANG_PATH} ${HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS} -o ") + + if("${HIP_RUNTIME}" STREQUAL "rocclr") + if(TARGET host) + message(STATUS "host interface - found") + set(HIP_HOST_INTERFACE host) + endif() + endif() endif() ############################################################################### @@ -651,6 +659,11 @@ macro(HIP_ADD_EXECUTABLE hip_target) add_executable(${hip_target} ${_cmake_options} ${_generated_files} ${_sources}) endif() set_target_properties(${hip_target} PROPERTIES LINKER_LANGUAGE HIP) + # Link with host + if (HIP_HOST_INTERFACE) + # hip rt should be rocclr, compiler should be clang + target_link_libraries(${hip_target} ${HIP_HOST_INTERFACE}) + endif() endmacro() ############################################################################### @@ -669,6 +682,11 @@ macro(HIP_ADD_LIBRARY hip_target) add_library(${hip_target} ${_cmake_options} ${_generated_files} ${_sources}) endif() set_target_properties(${hip_target} PROPERTIES LINKER_LANGUAGE ${HIP_C_OR_CXX}) + # Link with host + if (HIP_HOST_INTERFACE) + # hip rt should be rocclr, compiler should be clang + target_link_libraries(${hip_target} ${HIP_HOST_INTERFACE}) + endif() endmacro() # vim: ts=4:sw=4:expandtab:smartindent diff --git a/hip-config.cmake.in b/hip-config.cmake.in index 4273c39e0f..a7d7d81571 100644 --- a/hip-config.cmake.in +++ b/hip-config.cmake.in @@ -101,6 +101,7 @@ include( "${CMAKE_CURRENT_LIST_DIR}/hip-targets.cmake" ) # without worrying other transitive dependencies find_dependency(hsa-runtime64) find_dependency(Threads) +find_dependency(ROCclr) #get_filename_component cannot resolve the symlinks if called from /opt/rocm/lib/hip #and do three level up again diff --git a/packaging/hip-rocclr.postinst b/packaging/hip-rocclr.postinst index 080c846f40..4403016fc7 100755 --- a/packaging/hip-rocclr.postinst +++ b/packaging/hip-rocclr.postinst @@ -7,23 +7,34 @@ popd () { command popd "$@" > /dev/null } - ROCMDIR=@ROCM_PATH@ ROCMLIBDIR=$ROCMDIR/lib +ROCCLRDIR=$ROCMDIR/rocclr +ROCCLRLIBDIR=$ROCMDIR/rocclr/lib HIPDIR=$ROCMDIR/hip HIPLIBDIR=$ROCMDIR/hip/lib # Soft-link to library files +ROCCLRLIBFILES=$(ls -A $ROCCLRLIBDIR | grep -v "cmake\|[-/$]") HIPLIBFILES=$(ls -A $HIPLIBDIR | grep -v "cmake\|[-/$]") + mkdir -p $ROCMLIBDIR mkdir -p $ROCMLIBDIR/cmake pushd $ROCMLIBDIR + +for f in $ROCCLRLIBFILES +do + ln -s -r -f $ROCCLRLIBDIR/$f $(basename $f) +done + for f in $HIPLIBFILES do ln -s -r -f $HIPLIBDIR/$f $(basename $f) done + # Make the hip cmake directory link. pushd cmake +ln -s -r -f $ROCCLRLIBDIR/cmake/rocclr rocclr ln -s -r -f $HIPLIBDIR/cmake/hip hip popd popd diff --git a/packaging/hip-rocclr.prerm b/packaging/hip-rocclr.prerm index bf2be36523..d92ec3690b 100755 --- a/packaging/hip-rocclr.prerm +++ b/packaging/hip-rocclr.prerm @@ -10,19 +10,30 @@ popd () { ROCMDIR=@ROCM_PATH@ ROCMLIBDIR=$ROCMDIR/lib +ROCCLRDIR=$ROCMDIR/rocclr +ROCCLRLIBDIR=$ROCMDIR/rocclr/lib HIPDIR=$ROCMDIR/hip HIPLIBDIR=$ROCMDIR/hip/lib -([ ! -d $ROCMDIR ] || [ ! -d $HIPDIR ]) && exit 0 -([ ! -d $ROCMLIBDIR ] || [ ! -d $HIPLIBDIR ]) && exit 0 +([ ! -d $ROCMDIR ] || [ ! -d $ROCCLRDIR ] || [ ! -d $HIPDIR ]) && exit 0 +([ ! -d $ROCMLIBDIR ] || [ ! -d $ROCCLRLIBDIR ] || [ ! -d $HIPLIBDIR ]) && exit 0 # Remove soft-links to libraries +ROCCLRLIBFILES=$(ls -A $ROCCLRLIBDIR | grep -v [-/$]) HIPLIBFILES=$(ls -A $HIPLIBDIR | grep -v [-/$]) + pushd $ROCMLIBDIR +for f in $ROCCLRLIBFILES; do + [ -e $f ] || continue + rm $(basename $f) +done + for f in $HIPLIBFILES; do [ -e $f ] || continue rm $(basename $f) done + pushd cmake +unlink rocclr unlink hip popd rmdir --ignore-fail-on-non-empty cmake diff --git a/packaging/hip-rocclr.txt b/packaging/hip-rocclr.txt index 0a3dcd32b9..2273e77033 100644 --- a/packaging/hip-rocclr.txt +++ b/packaging/hip-rocclr.txt @@ -12,6 +12,24 @@ endif() install(FILES @PROJECT_BINARY_DIR@/.hipInfo DESTINATION lib) install(FILES @PROJECT_BINARY_DIR@/hip-config.cmake @PROJECT_BINARY_DIR@/hip-config-version.cmake DESTINATION lib/cmake/hip) +############################# +# Rocclr install +############################# + +set(ROCclr_BUILD_DIR "@ROCclr_DIR@/../../..") +set(ROCclr_LIB_DIR "@ROCM_PATH@/rocclr/lib") +set(ROCclr_CMAKE_DDIR "@ROCM_PATH@/rocclr/lib/cmake/rocclr") +set(ROCclr_CMAKE_SDIR "${ROCclr_BUILD_DIR}/CMakeFiles/Export/lib/cmake/rocclr") + +install(FILES ${ROCclr_BUILD_DIR}/libamdrocclr_static.a DESTINATION ${ROCclr_LIB_DIR}) +install(FILES @ROCclr_DIR@/ROCclrConfig.cmake DESTINATION ${ROCclr_CMAKE_DDIR}) +install(FILES @ROCclr_DIR@/rocclr-config-version.cmake DESTINATION ${ROCclr_CMAKE_DDIR}) +file(GLOB _rocclr_target_files ${ROCclr_CMAKE_SDIR}/rocclr-targets*.cmake) +foreach(_rocclr_target_file ${_rocclr_target_files}) + message(STATUS "_rocclr_target_file: ${_rocclr_target_file}") +endforeach() +install(FILES ${_rocclr_target_files} DESTINATION ${ROCclr_CMAKE_DDIR}) + ############################# # Packaging steps ############################# diff --git a/rocclr/CMakeLists.txt b/rocclr/CMakeLists.txt index 630feba93f..77f0b1a020 100755 --- a/rocclr/CMakeLists.txt +++ b/rocclr/CMakeLists.txt @@ -36,10 +36,7 @@ endif() set(USE_PROF_API "1") -find_package(ROCclr REQUIRED CONFIG - PATHS - /opt/rocm - /opt/rocm/rocclr) +find_package(ROCclr REQUIRED CONFIG) ############################# # Profiling API support @@ -146,6 +143,7 @@ target_compile_definitions(hip64 $) if(ROCclr_FOUND) + message(STATUS "ROCclr found at ${ROCclr_DIR}") target_include_directories(hip64 PRIVATE $) @@ -217,7 +215,7 @@ endif() set_target_properties(amdhip64 PROPERTIES LINK_FLAGS_RELEASE -s) set_target_properties(amdhip64 PROPERTIES PUBLIC_HEADER ${PROF_API_STR}) add_library(host INTERFACE) -target_link_libraries(host INTERFACE hip::amdhip64) +target_link_libraries(host INTERFACE amdhip64) add_library(device INTERFACE) target_link_libraries(device INTERFACE host) @@ -232,31 +230,14 @@ endif() # FIXME: Linux convention is to create static library with same base # filename. -if(${BUILD_SHARED_LIBS}) - target_link_libraries(amdhip64 PRIVATE amdrocclr_static Threads::Threads dl hsa-runtime64::hsa-runtime64) +target_link_libraries(amdhip64 PRIVATE amdrocclr_static Threads::Threads dl hsa-runtime64::hsa-runtime64) - add_custom_command(TARGET amdhip64 POST_BUILD COMMAND - ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/.hipInfo ${PROJECT_BINARY_DIR}/lib/.hipInfo) - add_custom_command(TARGET amdhip64 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory - ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) - - INSTALL(PROGRAMS $ DESTINATION lib COMPONENT MAIN) -else() - target_link_libraries(amdhip64 PRIVATE Threads::Threads dl hsa-runtime64::hsa-runtime64 amd_comgr) - # combine objects of vid and hip into amdhip64_static - add_custom_target( - amdhip64_static_combiner - ALL - COMMAND rm -rf static_lib_temp && mkdir static_lib_temp && cd static_lib_temp # Create temp folder to contain *.o - COMMAND ${CMAKE_AR} -x $ # Extract *.o from amdrocclr_static - COMMAND ${CMAKE_AR} -rcs $ *.o # Append *.o to amdhip64_static - COMMAND cd .. && rm -rf static_lib_temp # Remove temp folder - DEPENDS amdhip64 amdrocclr_static # To make sure this is the last step - COMMENT "Combining static libs into amdhip64_static" - ) - INSTALL(PROGRAMS $ DESTINATION lib COMPONENT MAIN) -endif() +add_custom_command(TARGET amdhip64 POST_BUILD COMMAND + ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/.hipInfo ${PROJECT_BINARY_DIR}/lib/.hipInfo) +add_custom_command(TARGET amdhip64 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory + ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) +INSTALL(PROGRAMS $ DESTINATION lib COMPONENT MAIN) INSTALL(TARGETS amdhip64 host device EXPORT hip-targets DESTINATION ${LIB_INSTALL_DIR}) INSTALL(EXPORT hip-targets DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR} NAMESPACE hip::) diff --git a/samples/0_Intro/bit_extract/CMakeLists.txt b/samples/0_Intro/bit_extract/CMakeLists.txt index c9b13be812..ec3930f691 100644 --- a/samples/0_Intro/bit_extract/CMakeLists.txt +++ b/samples/0_Intro/bit_extract/CMakeLists.txt @@ -2,6 +2,14 @@ project(bit_extract) cmake_minimum_required(VERSION 3.10) +if(NOT DEFINED __HIP_ENABLE_PCH) + set(__HIP_ENABLE_PCH ON CACHE BOOL "enable/disable pre-compiled hip headers") +endif() + +if(${__HIP_ENABLE_PCH}) + add_definitions(-D__HIP_ENABLE_PCH) +endif() + # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) diff --git a/samples/0_Intro/bit_extract/bit_extract.cpp b/samples/0_Intro/bit_extract/bit_extract.cpp index e87124f47f..1f7770ccb5 100644 --- a/samples/0_Intro/bit_extract/bit_extract.cpp +++ b/samples/0_Intro/bit_extract/bit_extract.cpp @@ -54,6 +54,20 @@ int main(int argc, char* argv[]) { size_t N = 1000000; size_t Nbytes = N * sizeof(uint32_t); +#ifdef __HIP_ENABLE_PCH + // Verify hip_pch.o + const char* pch = nullptr; + unsigned int size = 0; + __hipGetPCH(&pch, &size); + printf("pch size: %u\n", size); + if (size == 0) { + printf("__hipGetPCH failed!\n"); + return -1; + } else { + printf("__hipGetPCH succeeded!\n"); + } +#endif + int deviceId; CHECK(hipGetDevice(&deviceId)); hipDeviceProp_t props; diff --git a/samples/0_Intro/square/CMakeLists.txt b/samples/0_Intro/square/CMakeLists.txt index 845c43fd1f..2e101e1470 100644 --- a/samples/0_Intro/square/CMakeLists.txt +++ b/samples/0_Intro/square/CMakeLists.txt @@ -7,6 +7,9 @@ cmake_minimum_required(VERSION 3.10) # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +# create square.cpp +execute_process(COMMAND sh -c "/opt/rocm/hip/bin/hipify-perl ../square.cu > ../square.cpp") + # Find hip find_package(hip) diff --git a/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt b/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt index 0e8020a67a..472b7df592 100644 --- a/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt +++ b/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt @@ -28,3 +28,11 @@ set(MY_NVCC_OPTIONS) set_source_files_properties(${MY_SOURCE_FILES} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1) hip_add_executable(${MY_TARGET_NAME} ${MY_SOURCE_FILES} HIPCC_OPTIONS ${MY_HIPCC_OPTIONS} HCC_OPTIONS ${MY_HCC_OPTIONS} CLANG_OPTIONS ${MY_CLANG_OPTIONS} NVCC_OPTIONS ${MY_NVCC_OPTIONS}) + +# Search for rocm in common locations +list(APPEND CMAKE_PREFIX_PATH ${HIP_PATH} /opt/rocm) +find_package(hip QUIET) +if(TARGET hip::host) + message(STATUS "Found hip::host at ${hip_DIR}") + target_link_libraries(${MY_TARGET_NAME} hip::host) +endif() \ No newline at end of file diff --git a/samples/2_Cookbook/12_cmake_hip_add_executable/Readme.md b/samples/2_Cookbook/12_cmake_hip_add_executable/Readme.md index 4e322fd83e..9aa6b96fab 100644 --- a/samples/2_Cookbook/12_cmake_hip_add_executable/Readme.md +++ b/samples/2_Cookbook/12_cmake_hip_add_executable/Readme.md @@ -37,7 +37,13 @@ Use the following commands to build and execute the sample ``` mkdir build cd build + +For shared lib of hip rt, cmake .. +Or for static lib of hip rt, +cmake -DCMAKE_PREFIX_PATH="/opt/rocm/llvm/lib/cmake" .. + +Then, make ./MatrixTranspose ``` diff --git a/samples/README.md b/samples/README.md index 739045382e..c54ec20b3a 100644 --- a/samples/README.md +++ b/samples/README.md @@ -12,16 +12,22 @@ make 2.CMakeLists.txt can support shared and static libs of hip-rocclr runtime. -To build a sample, type in sample folder, +To build a sample, run in the sample folder, -mkdir build (if build folder is missing) +mkdir -p build && cd build -cd build +rm -rf * (to clear up) + +a. to build with shared libs, run cmake .. +b. to build with static libs, run + +cmake -DCMAKE_PREFIX_PATH="/opt/rocm/llvm/lib/cmake" .. + +Then run, + make -If you want debug version, follow, - -cmake -DCMAKE_BUILD_TYPE=Debug .. \ No newline at end of file +Note that if you want debug version, add "-DCMAKE_BUILD_TYPE=Debug" in cmake cmd. \ No newline at end of file diff --git a/tests/README.md b/tests/README.md index bb822d1d6f..9e549da957 100644 --- a/tests/README.md +++ b/tests/README.md @@ -26,7 +26,7 @@ Copy this to a new test name and modify it. ### HIP Integrated Tester (HIT) -The HIT framework sutomatically finds and adds test cases to the CMAKE testing environment. It achives this by parsing all files in the tests/src folder. +The HIT framework automatically finds and adds test cases to the CMAKE testing environment. It achives this by parsing all files in the tests/src folder. The parser looks for a code block similar to the one below. ``` /* HIT_START @@ -46,8 +46,8 @@ In the above, BUILD commands provide instructions on how to build the test case #### BUILD command The supported syntax for the BUILD command is: -<<<<<<< HEAD -BUILD: %t %s HIPCC_OPTIONS HCC_OPTIONS CLANG_OPTIONS NVCC_OPTIONS EXCLUDE_HIP_PLATFORM EXCLUDE_HIP_RUNTIME EXCLUDE_HIP_COMPILER DEPENDS +``` +BUILD: %t %s HIPCC_OPTIONS HCC_OPTIONS CLANG_OPTIONS NVCC_OPTIONS EXCLUDE_HIP_PLATFORM EXCLUDE_HIP_RUNTIME EXCLUDE_HIP_COMPILER DEPENDS EXCLUDE_HIP_LIB_TYPE ``` %s: refers to current source file name. Additional source files needed for the test can be specified by name (including relative path). %t: refers to target executable named derived by removing the extension from the current source file. Alternatively a target executable name can be specified. @@ -59,6 +59,7 @@ EXCLUDE_HIP_PLATFORM: This can be used to exclude a test case from amd, nvidia o EXCLUDE_HIP_RUNTIME: This can be used to exclude a test case from hcc or rocclr runtime. EXCLUDE_HIP_COMPILER: This can be used to exclude a test case from hcc or clang compiler. EXCLUDE_HIP_RUNTIME AND EXCLUDE_HIP_COMPILER: when both options are specified it excludes test case from particular runtime and compiler. +EXCLUDE_HIP_LIB_TYPE: This can be used to exclude a test case from static or shared libs. DEPENDS: This can be used to specify dependencies that need to be built before building the current target. @@ -66,7 +67,7 @@ DEPENDS: This can be used to specify dependencies that need to be built before b The supported syntax for the BUILD_CMD command is: ``` -BUILD_CMD: EXCLUDE_HIP_PLATFORM EXCLUDE_HIP_RUNTIME EXCLUDE_HIP_COMPILER DEPENDS +BUILD_CMD: EXCLUDE_HIP_PLATFORM EXCLUDE_HIP_RUNTIME EXCLUDE_HIP_COMPILER EXCLUDE_HIP_LIB_TYPE DEPENDS ``` %s: refers to current source file name. Additional source files needed for the test can be specified by name (including relative path). %t: refers to target executable named derived by removing the extension from the current source file. Alternatively a target executable name can be specified. @@ -80,6 +81,7 @@ EXCLUDE_HIP_PLATFORM: This can be used to exclude a test case from amd, nvidia o EXCLUDE_HIP_RUNTIME: This can be used to exclude a test case from hcc or rocclr runtime. EXCLUDE_HIP_COMPILER: This can be used to exclude a test case from hcc or clang compiler. EXCLUDE_HIP_RUNTIME AND EXCLUDE_HIP_COMPILER: when both options are specified it excludes test from particular runtime and compiler. +EXCLUDE_HIP_LIB_TYPE: This can be used to exclude a test case from static or shared libs. DEPENDS: This can be used to specify dependencies that need to be built before building the current target. @@ -87,20 +89,22 @@ DEPENDS: This can be used to specify dependencies that need to be built before b The supported syntax for the TEST command is: ``` -TEST: %t EXCLUDE_HIP_PLATFORM EXCLUDE_HIP_RUNTIME EXCLUDE_HIP_COMPILER +TEST: %t EXCLUDE_HIP_PLATFORM EXCLUDE_HIP_RUNTIME EXCLUDE_HIP_COMPILER EXCLUDE_HIP_LIB_TYPE ``` %t: refers to target executable named derived by removing the extension from the current source file. Alternatively a target executable name can be specified. EXCLUDE_HIP_PLATFORM: This can be used to exclude a test case from amd, nvidia or both platforms. EXCLUDE_HIP_RUNTIME: This can be used to exclude a test case from hcc or rocclr runtime. EXCLUDE_HIP_COMPILER: This can be used to exclude a test case from hcc or clang compiler. EXCLUDE_HIP_RUNTIME AND EXCLUDE_HIP_COMPILER: when both options are specified it excludes test from particular runtime and compiler. +EXCLUDE_HIP_LIB_TYPE: This can be used to exclude a test case from static or shared libs. + Note that if the test has been excluded for a specific platform/runtime/compiler in the BUILD command, it is automatically excluded from the TEST command as well for the sameplatform. #### TEST_NAMED command When using the TEST command, HIT will squash and append the arguments specified to the test executable name to generate the CMAKE test name. Sometimes we might want to specify a more descriptive name. The TEST_NAMED command is used for that. The supported syntax for the TEST_NAMED command is: ``` -TEST: %t CMAKE_TEST_NAME EXCLUDE_HIP_PLATFORM EXCLUDE_HIP_RUNTIME EXCLUDE_HIP_COMPILER +TEST: %t CMAKE_TEST_NAME EXCLUDE_HIP_PLATFORM EXCLUDE_HIP_RUNTIME EXCLUDE_HIP_COMPILER EXCLUDE_HIP_LIB_TYPE ``` diff --git a/tests/hit/HIT.cmake b/tests/hit/HIT.cmake index 839b90befb..786e02675a 100755 --- a/tests/hit/HIT.cmake +++ b/tests/hit/HIT.cmake @@ -3,10 +3,14 @@ find_package(HIP REQUIRED) set(HIP_CTEST_CONFIG_DEFAULT "default") set(HIP_CTEST_CONFIG_PERFORMANCE "performance") - +set(HIP_LIB_TYPE "shared") +if (NOT ${BUILD_SHARED_LIBS}) + set(HIP_LIB_TYPE "static") +endif() +message(STATUS "HIP_LIB_TYPE - ${HIP_LIB_TYPE}") #------------------------------------------------------------------------------- # 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) +macro(PARSE_BUILD_COMMAND _target _sources _hipcc_options _hcc_options _clang_options _nvcc_options _link_options _exclude_platforms _exclude_runtime _exclude_compiler _exclude_lib_type _depends _dir) set(${_target}) set(${_sources}) set(${_hipcc_options}) @@ -17,239 +21,181 @@ macro(PARSE_BUILD_COMMAND _target _sources _hipcc_options _hcc_options _clang_op set(${_exclude_platforms}) set(${_exclude_runtime}) set(${_exclude_compiler}) + set(${_exclude_lib_type}) set(${_depends}) + set(_target_found FALSE) - set(_hipcc_options_found FALSE) - set(_hcc_options_found FALSE) - set(_clang_options_found FALSE) - set(_nvcc_options_found FALSE) - set(_link_options_found FALSE) - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) - set(_depends_found FALSE) + set(_flag "") + foreach(arg ${ARGN}) if(NOT _target_found) set(_target_found TRUE) set(${_target} ${arg}) - elseif("x${arg}" STREQUAL "xHIPCC_OPTIONS") - set(_hipcc_options_found TRUE) - set(_hcc_options_found FALSE) - set(_clang_options_found FALSE) - set(_nvcc_options_found FALSE) - set(_link_options_found FALSE) - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) - set(_depends_found FALSE) - elseif("x${arg}" STREQUAL "xHCC_OPTIONS") - set(_hipcc_options_found FALSE) - set(_hcc_options_found TRUE) - set(_clang_options_found FALSE) - set(_nvcc_options_found FALSE) - set(_link_options_found FALSE) - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) - set(_depends_found FALSE) - elseif("x${arg}" STREQUAL "xCLANG_OPTIONS") - set(_hipcc_options_found FALSE) - set(_hcc_options_found FALSE) - set(_clang_options_found TRUE) - set(_nvcc_options_found FALSE) - set(_link_options_found FALSE) - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) - set(_depends_found FALSE) - elseif("x${arg}" STREQUAL "xNVCC_OPTIONS") - set(_hipcc_options_found FALSE) - set(_hcc_options_found FALSE) - set(_clang_options_found FALSE) - set(_nvcc_options_found TRUE) - set(_link_options_found FALSE) - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) - set(_depends_found FALSE) - elseif("x${arg}" STREQUAL "xLINK_OPTIONS") - set(_hipcc_options_found FALSE) - set(_hcc_options_found FALSE) - set(_clang_options_found FALSE) - set(_nvcc_options_found FALSE) - set(_link_options_found TRUE) - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) - set(_depends_found FALSE) - elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_PLATFORM") - set(_hipcc_options_found FALSE) - set(_hcc_options_found FALSE) - set(_clang_options_found FALSE) - set(_nvcc_options_found FALSE) - set(_link_options_found FALSE) - set(_exclude_platforms_found TRUE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) - set(_depends_found FALSE) - elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_RUNTIME") - set(_hipcc_options_found FALSE) - set(_hcc_options_found FALSE) - set(_clang_options_found FALSE) - set(_nvcc_options_found FALSE) - set(_link_options_found FALSE) - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found TRUE) - set(_exclude_compiler_found FALSE) - set(_depends_found FALSE) - elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_COMPILER") - set(_hipcc_options_found FALSE) - set(_hcc_options_found FALSE) - set(_clang_options_found FALSE) - set(_nvcc_options_found FALSE) - set(_link_options_found FALSE) - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found TRUE) - set(_depends_found FALSE) - elseif("x${arg}" STREQUAL "xDEPENDS") - set(_hipcc_options_found FALSE) - set(_hcc_options_found FALSE) - set(_clang_options_found FALSE) - set(_nvcc_options_found FALSE) - set(_link_options_found FALSE) - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) - set(_depends_found TRUE) + elseif("x${arg}" STREQUAL "xHIPCC_OPTIONS" + OR "x${arg}" STREQUAL "xHCC_OPTIONS" + OR "x${arg}" STREQUAL "xCLANG_OPTIONS" + OR "x${arg}" STREQUAL "xNVCC_OPTIONS" + OR "x${arg}" STREQUAL "xLINK_OPTIONS" + OR "x${arg}" STREQUAL "xEXCLUDE_HIP_PLATFORM" + OR "x${arg}" STREQUAL "xEXCLUDE_HIP_RUNTIME" + OR "x${arg}" STREQUAL "xEXCLUDE_HIP_COMPILER" + OR "x${arg}" STREQUAL "xEXCLUDE_HIP_LIB_TYPE" + OR "x${arg}" STREQUAL "xDEPENDS") + set(_flag ${arg}) + elseif("x${_flag}" STREQUAL "xHIPCC_OPTIONS") + list(APPEND ${_hipcc_options} ${arg}) + elseif("x${_flag}" STREQUAL "xHCC_OPTIONS") + list(APPEND ${_hcc_options} ${arg}) + elseif("x${_flag}" STREQUAL "xCLANG_OPTIONS") + list(APPEND ${_clang_options} ${arg}) + elseif("x${_flag}" STREQUAL "xNVCC_OPTIONS") + list(APPEND ${_nvcc_options} ${arg}) + elseif("x${_flag}" STREQUAL "xLINK_OPTIONS") + list(APPEND ${_link_options} ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_PLATFORM") + list(APPEND ${_exclude_platforms} ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_RUNTIME") + list(APPEND ${_exclude_runtime} ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_COMPILER") + list(APPEND ${_exclude_compiler} ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_LIB_TYPE") + list(APPEND ${_exclude_lib_type} ${arg}) + elseif("x${_flag}" STREQUAL "xDEPENDS") + list(APPEND ${_depends} ${arg}) else() - if(_hipcc_options_found) - list(APPEND ${_hipcc_options} ${arg}) - elseif(_hcc_options_found) - list(APPEND ${_hcc_options} ${arg}) - elseif(_clang_options_found) - list(APPEND ${_clang_options} ${arg}) - elseif(_nvcc_options_found) - list(APPEND ${_nvcc_options} ${arg}) - elseif(_link_options_found) - list(APPEND ${_link_options} ${arg}) - elseif(_exclude_platforms_found) - list(APPEND ${_exclude_platforms} ${arg}) - elseif(_exclude_runtime_found) - list(APPEND ${_exclude_runtime} ${arg}) - elseif(_exclude_compiler_found) - list(APPEND ${_exclude_compiler} ${arg}) - elseif(_depends_found) - list(APPEND ${_depends} ${arg}) - else() - list(APPEND ${_sources} "${_dir}/${arg}") - endif() + list(APPEND ${_sources} "${_dir}/${arg}") endif() endforeach() endmacro() # Helper macro to parse CUSTOM BUILD instructions -macro(PARSE_CUSTOMBUILD_COMMAND _target _buildcmd _exclude_platforms _exclude_runtime _exclude_compiler _depends) +macro(PARSE_CUSTOMBUILD_COMMAND _target _buildcmd _exclude_platforms _exclude_runtime _exclude_compiler _exclude_lib_type _depends) set(${_target}) - set(${_buildcmd} " ") + set(${_buildcmd}) set(${_exclude_platforms}) + set(${_exclude_runtime}) + set(${_exclude_compiler}) + set(${_exclude_lib_type}) set(${_depends}) + set(_target_found FALSE) - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) - set(_depends_found FALSE) + set(_flag "") + foreach(arg ${ARGN}) if(NOT _target_found) set(_target_found TRUE) set(${_target} ${arg}) - elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_PLATFORM") - set(_exclude_platforms_found TRUE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) - set(_depends_found FALSE) - elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_RUNTIME") - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found TRUE) - set(_exclude_compiler_found FALSE) - set(_depends_found FALSE) - elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_COMPILER") - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found TRUE) - set(_depends_found FALSE) - elseif("x${arg}" STREQUAL "xDEPENDS") - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) - set(_depends_found TRUE) + elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_PLATFORM" + OR "x${arg}" STREQUAL "xEXCLUDE_HIP_RUNTIME" + OR "x${arg}" STREQUAL "xEXCLUDE_HIP_COMPILER" + OR "x${arg}" STREQUAL "xEXCLUDE_HIP_LIB_TYPE" + OR "x${arg}" STREQUAL "xDEPENDS") + set(_flag ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_PLATFORM") + list(APPEND ${_exclude_platforms} ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_RUNTIME") + list(APPEND ${_exclude_runtime} ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_COMPILER") + list(APPEND ${_exclude_compiler} ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_LIB_TYPE") + list(APPEND ${_exclude_lib_type} ${arg}) + elseif("x${_flag}" STREQUAL "xDEPENDS") + list(APPEND ${_depends} ${arg}) else() - if(_exclude_platforms_found) - list(APPEND ${_exclude_platforms} ${arg}) - elseif(_exclude_runtime_found) - list(APPEND ${_exclude_runtime} ${arg}) - elseif(_exclude_compiler_found) - list(APPEND ${_exclude_compiler} ${arg}) - elseif(_depends_found) - list(APPEND ${_depends} ${arg}) - else() - list(APPEND ${_buildcmd} ${arg}) - endif() + list(APPEND ${_buildcmd} ${arg}) # always before exclude lists + endif() + endforeach() +endmacro() + +# Helper macro to parse command part of CUSTOM BUILD instructions +macro(PARSE_CUSTOMBUILD_COMMAND_PART _compiler _target _target_type _sources _options) + set(${_compiler}) + set(${_target}) + set(${_target_type} "EXECUTABLE") + set(${_sources}) + set(${_options}) + set(_compiler_found FALSE) + set(_target_found FALSE) + + foreach(arg ${ARGN}) + if(NOT _compiler_found) + set(_compiler_found TRUE) + set(${_compiler} ${arg}) + elseif("x${arg}" STREQUAL "x-o") + set(_target_found TRUE) + elseif(_target_found) + set(${_target} ${arg}) + set(_target_found FALSE) + elseif("x${arg}" STREQUAL "x-c" OR "x${arg}" STREQUAL "x--genco") + set(${_target_type} "OBJECT") + list(APPEND ${_options} ${arg}) + elseif("x${arg}" STREQUAL "x-shared") + # Note: Currently all directed_tests are linux based. + set(${_target_type} "SHARED") + list(APPEND ${_options} ${arg}) + elseif("x${arg}" MATCHES "^x-I") + # -I + list(APPEND ${_options} ${arg}) + elseif("x${arg}" MATCHES "^x.*\.cpp$") + # cpp file + list(APPEND ${_sources} ${arg}) + elseif("x${arg}" MATCHES "^x.*\.c$") + # c file + list(APPEND ${_sources} ${arg}) + else() + list(APPEND ${_options} ${arg}) endif() endforeach() endmacro() # Helper macro to parse TEST instructions -macro(PARSE_TEST_COMMAND _target _arguments _exclude_platforms _exclude_runtime _exclude_compiler) +macro(PARSE_TEST_COMMAND _target _arguments _exclude_platforms _exclude_runtime _exclude_compiler _exclude_lib_type) set(${_target}) set(${_arguments} " ") set(${_exclude_platforms}) set(${_exclude_runtime}) set(${_exclude_compiler}) + set(${_exclude_lib_type}) + set(_target_found FALSE) - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) + set(_flag "") + foreach(arg ${ARGN}) if(NOT _target_found) set(_target_found TRUE) set(${_target} ${arg}) - elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_PLATFORM") - set(_exclude_platforms_found TRUE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) - elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_RUNTIME") - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found TRUE) - set(_exclude_compiler_found FALSE) - elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_COMPILER") - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found TRUE) + elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_PLATFORM" + OR "x${arg}" STREQUAL "xEXCLUDE_HIP_RUNTIME" + OR "x${arg}" STREQUAL "xEXCLUDE_HIP_COMPILER" + OR "x${arg}" STREQUAL "xEXCLUDE_HIP_LIB_TYPE") + set(_flag ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_PLATFORM") + list(APPEND ${_exclude_platforms} ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_RUNTIME") + list(APPEND ${_exclude_runtime} ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_COMPILER") + list(APPEND ${_exclude_compiler} ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_LIB_TYPE") + list(APPEND ${_exclude_lib_type} ${arg}) else() - if(_exclude_platforms_found) - list(APPEND ${_exclude_platforms} ${arg}) - elseif(_exclude_runtime_found) - list(APPEND ${_exclude_runtime} ${arg}) - elseif(_exclude_compiler_found) - list(APPEND ${_exclude_compiler} ${arg}) - else() - list(APPEND ${_arguments} ${arg}) - endif() + list(APPEND ${_arguments} ${arg}) # always before exclude lists endif() endforeach() endmacro() # Helper macro to parse TEST_NAMED instructions -macro(PARSE_TEST_NAMED_COMMAND _target _testname _arguments _exclude_platforms _exclude_runtime _exclude_compiler) +macro(PARSE_TEST_NAMED_COMMAND _target _testname _arguments _exclude_platforms _exclude_runtime _exclude_compiler _exclude_lib_type) set(${_target}) set(${_arguments} " ") set(${_exclude_platforms}) + set(${_exclude_runtime}) + set(${_exclude_compiler}) + set(${_exclude_lib_type}) + set(_target_found FALSE) set(_testname_found FALSE) - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) + set(_flag "") + foreach(arg ${ARGN}) if(NOT _target_found) set(_target_found TRUE) @@ -257,28 +203,21 @@ macro(PARSE_TEST_NAMED_COMMAND _target _testname _arguments _exclude_platforms _ elseif(NOT _testname_found) set(_testname_found TRUE) set(${_testname} ${arg}) - elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_PLATFORM") - set(_exclude_platforms_found TRUE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found FALSE) - elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_RUNTIME") - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found TRUE) - set(_exclude_compiler_found FALSE) - elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_COMPILER") - set(_exclude_platforms_found FALSE) - set(_exclude_runtime_found FALSE) - set(_exclude_compiler_found TRUE) + elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_PLATFORM" + OR "x${arg}" STREQUAL "xEXCLUDE_HIP_RUNTIME" + OR "x${arg}" STREQUAL "xEXCLUDE_HIP_COMPILER" + OR "x${arg}" STREQUAL "xEXCLUDE_HIP_LIB_TYPE") + set(_flag ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_PLATFORM") + list(APPEND ${_exclude_platforms} ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_RUNTIME") + list(APPEND ${_exclude_runtime} ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_COMPILER") + list(APPEND ${_exclude_compiler} ${arg}) + elseif("x${_flag}" STREQUAL "xEXCLUDE_HIP_LIB_TYPE") + list(APPEND ${_exclude_lib_type} ${arg}) else() - if(_exclude_platforms_found) - list(APPEND ${_exclude_platforms} ${arg}) - elseif(_exclude_runtime_found) - list(APPEND ${_exclude_runtime} ${arg}) - elseif(_exclude_compiler_found) - list(APPEND ${_exclude_compiler} ${arg}) - else() - list(APPEND ${_arguments} ${arg}) - endif() + list(APPEND ${_arguments} ${arg}) # always before exclude lists endif() endforeach() endmacro() @@ -329,7 +268,7 @@ macro(HIT_ADD_FILES _config _dir _label _parent) string(REGEX REPLACE "\n" ";" _contents "${_contents}") foreach(_cmd ${_contents}) string(REGEX REPLACE " " ";" _cmd "${_cmd}") - parse_build_command(_target _sources _hipcc_options _hcc_options _clang_options _nvcc_options _link_options _exclude_platforms _exclude_runtime _exclude_compiler _depends ${_dir} ${_cmd}) + parse_build_command(_target _sources _hipcc_options _hcc_options _clang_options _nvcc_options _link_options _exclude_platforms _exclude_runtime _exclude_compiler _exclude_lib_type _depends ${_dir} ${_cmd}) string(REGEX REPLACE "/" "." target ${_label}/${_target}) if("all" IN_LIST _exclude_platforms OR ${HIP_PLATFORM} IN_LIST _exclude_platforms) insert_into_map("_exclude" "${target}" TRUE) @@ -337,7 +276,9 @@ macro(HIT_ADD_FILES _config _dir _label _parent) insert_into_map("_exclude" "${target}" TRUE) elseif(NOT _exclude_compiler AND ${HIP_RUNTIME} IN_LIST _exclude_runtime) insert_into_map("_exclude" "${target}" TRUE) - elseif(_exclude_runtime STREQUAL ${HIP_RUNTIME} AND ${HIP_COMPILER} IN_LIST _exclude_compiler) + elseif(${HIP_RUNTIME} IN_LIST _exclude_runtime AND ${HIP_COMPILER} IN_LIST _exclude_compiler) + insert_into_map("_exclude" "${target}" TRUE) + elseif(${HIP_LIB_TYPE} IN_LIST _exclude_lib_type) insert_into_map("_exclude" "${target}" TRUE) else() set_source_files_properties(${_sources} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1) @@ -368,7 +309,7 @@ macro(HIT_ADD_FILES _config _dir _label _parent) string(REGEX REPLACE "%T" ${_label} _contents "${_contents}") foreach(_cmd ${_contents}) string(REGEX REPLACE " " ";" _cmd "${_cmd}") - parse_custombuild_command(_target _buildcmd _exclude_platforms _exclude_runtime _exclude_compiler _depends ${_cmd}) + parse_custombuild_command(_target _buildcmd _exclude_platforms _exclude_runtime _exclude_compiler _exclude_lib_type _depends ${_cmd}) string(REGEX REPLACE "/" "." target ${_label}/${_target}) if("all" IN_LIST _exclude_platforms OR ${HIP_PLATFORM} IN_LIST _exclude_platforms) insert_into_map("_exclude" "${target}" TRUE) @@ -376,14 +317,33 @@ macro(HIT_ADD_FILES _config _dir _label _parent) insert_into_map("_exclude" "${target}" TRUE) elseif(NOT _exclude_compiler AND ${HIP_RUNTIME} IN_LIST _exclude_runtime) insert_into_map("_exclude" "${target}" TRUE) - elseif(_exclude_runtime STREQUAL ${HIP_RUNTIME} AND ${HIP_COMPILER} IN_LIST _exclude_compiler) + elseif(${HIP_RUNTIME} IN_LIST _exclude_runtime AND ${HIP_COMPILER} IN_LIST _exclude_compiler) + insert_into_map("_exclude" "${target}" TRUE) + elseif(${HIP_LIB_TYPE} IN_LIST _exclude_lib_type) insert_into_map("_exclude" "${target}" TRUE) else() + parse_custombuild_command_part(_compiler _target_r _target_type _sources _options ${_buildcmd}) string(REGEX REPLACE ";" " " _buildcmd "${_buildcmd}") - #string(CONCAT buildscript ${CMAKE_CURRENT_BINARY_DIR}/${target} ".sh") - #file(WRITE ${buildscript} ${_buildcmd}) - #add_custom_target(${target} COMMAND ${buildscript}) - add_custom_target(${target} COMMAND sh -c "${_buildcmd}") + string(REGEX REPLACE ";" " " _options "${_options}") + + set(CHOICE_FLAG "${HIP_LIB_TYPE}" STREQUAL "static" AND "${_compiler}" MATCHES "hipcc$" + AND "${HIP_RUNTIME}" STREQUAL "rocclr" AND "${HIP_COMPILER}" STREQUAL "clang") + if (${CHOICE_FLAG} AND "${_target_type}" STREQUAL "EXECUTABLE") + # message(STATUS "hip_add_executable*:_target_r= ${_target_r} --- target= ${target} --- _sources=${_sources} --- _options=${_options}") + set_source_files_properties(${_sources} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1) + hip_reset_flags() + hip_add_executable(${target} ${_sources} HIPCC_OPTIONS ${_options} EXCLUDE_FROM_ALL) + set_target_properties(${target} PROPERTIES OUTPUT_NAME ${_target_r} RUNTIME_OUTPUT_DIRECTORY "." LINK_DEPENDS "${HIP_LIB_FILES}") + elseif(${CHOICE_FLAG} AND "${_target_type}" STREQUAL "SHARED") + # message(STATUS "hip_add_library*:_target_r= ${_target_r} --- target= ${target} --- _sources=${_sources} --- _options=${_options}") + set_source_files_properties(${_sources} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1) + hip_reset_flags() + hip_add_library(${target} ${_sources} HIPCC_OPTIONS ${_options} EXCLUDE_FROM_ALL ${_target_type}) + set_target_properties(${target} PROPERTIES OUTPUT_NAME ${_target_r} RUNTIME_OUTPUT_DIRECTORY "." LINK_DEPENDS "${HIP_LIB_FILES}" PREFIX "" SUFFIX "") + else() + # message(STATUS "add_custom_target*: target= ${target} _buildcmd= ${_buildcmd}") + add_custom_target(${target} COMMAND sh -c "${_buildcmd}") + endif() add_dependencies(${_parent} ${target}) foreach(_dependency ${_depends}) string(REGEX REPLACE "/" "." _dependency ${_label}/${_dependency}) @@ -401,13 +361,14 @@ macro(HIT_ADD_FILES _config _dir _label _parent) string(REGEX REPLACE "\n" ";" _contents "${_contents}") foreach(_cmd ${_contents}) string(REGEX REPLACE " " ";" _cmd "${_cmd}") - parse_test_command(_target _arguments _exclude_platforms _exclude_runtime _exclude_compiler ${_cmd}) + parse_test_command(_target _arguments _exclude_platforms _exclude_runtime _exclude_compiler _exclude_lib_type ${_cmd}) string(REGEX REPLACE "/" "." target ${_label}/${_target}) read_from_map("_exclude" "${target}" _exclude_test_from_build) if("all" IN_LIST _exclude_platforms OR ${HIP_PLATFORM} IN_LIST _exclude_platforms) elseif(NOT _exclude_runtime AND ${HIP_COMPILER} IN_LIST _exclude_compiler) elseif(NOT _exclude_compiler AND ${HIP_RUNTIME} IN_LIST _exclude_runtime) elseif(${HIP_RUNTIME} IN_LIST _exclude_runtime AND ${HIP_COMPILER} IN_LIST _exclude_compiler) + elseif(${HIP_LIB_TYPE} IN_LIST _exclude_lib_type) elseif(_exclude_test_from_build STREQUAL TRUE) else() make_test(${_config} ${_label}/${_target} ${_arguments}) @@ -423,13 +384,14 @@ macro(HIT_ADD_FILES _config _dir _label _parent) string(REGEX REPLACE "\n" ";" _contents "${_contents}") foreach(_cmd ${_contents}) string(REGEX REPLACE " " ";" _cmd "${_cmd}") - parse_test_named_command(_target _testname _arguments _exclude_platforms _exclude_runtime _exclude_compiler ${_cmd}) + parse_test_named_command(_target _testname _arguments _exclude_platforms _exclude_runtime _exclude_compiler _exclude_lib_type ${_cmd}) string(REGEX REPLACE "/" "." target ${_label}/${_target}) read_from_map("_exclude" "${target}" _exclude_test_from_build) if("all" IN_LIST _exclude_platforms OR ${HIP_PLATFORM} IN_LIST _exclude_platforms) elseif(NOT _exclude_runtime AND ${HIP_COMPILER} IN_LIST _exclude_compiler) elseif(NOT _exclude_compiler AND ${HIP_RUNTIME} IN_LIST _exclude_runtime) elseif(${HIP_RUNTIME} IN_LIST _exclude_runtime AND ${HIP_COMPILER} IN_LIST _exclude_compiler) + elseif(${HIP_LIB_TYPE} IN_LIST _exclude_lib_type) elseif(_exclude_test_from_build STREQUAL TRUE) else() make_named_test(${_config} ${_label}/${_target} ${_label}/${_testname}.tst ${_arguments}) diff --git a/tests/src/dynamicLoading/complex_loading_behavior.cpp b/tests/src/dynamicLoading/complex_loading_behavior.cpp index 000139dc60..86d7e7bba1 100644 --- a/tests/src/dynamicLoading/complex_loading_behavior.cpp +++ b/tests/src/dynamicLoading/complex_loading_behavior.cpp @@ -23,9 +23,9 @@ THE SOFTWARE. */ /* HIT_START - * BUILD_CMD: libLazyLoad_amd %hc %S/%s -o liblazyLoad.so -I%S/.. -fPIC -lpthread -shared -DTEST_SHARED_LIBRARY EXCLUDE_HIP_PLATFORM nvidia + * BUILD_CMD: libLazyLoad_amd %hc %S/%s -o liblazyLoad.so -I%S/.. -fPIC -lpthread -shared -DTEST_SHARED_LIBRARY EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_LIB_TYPE static * BUILD_CMD: libLazyLoad_nvidia %hc %S/%s --std=c++11 -o liblazyLoad.so -I%S/.. -Xcompiler -fPIC -lpthread -shared -DTEST_SHARED_LIBRARY EXCLUDE_HIP_PLATFORM amd - * BUILD_CMD: %t %hc %S/%s --std=c++11 -o %T/%t -I%S/.. -ldl + * BUILD_CMD: %t %hc %S/%s --std=c++11 -o %T/%t -I%S/.. -ldl EXCLUDE_HIP_LIB_TYPE static * TEST: %t * HIT_END */ diff --git a/tests/src/dynamicLoading/hipApiDynamicLoad.cpp b/tests/src/dynamicLoading/hipApiDynamicLoad.cpp index c7b7cc2b93..f9e58582a8 100644 --- a/tests/src/dynamicLoading/hipApiDynamicLoad.cpp +++ b/tests/src/dynamicLoading/hipApiDynamicLoad.cpp @@ -26,7 +26,7 @@ THE SOFTWARE. /* HIT_START * BUILD_CMD: bit_extract_kernel.code %hc --genco %S/bit_extract_kernel.cpp -o bit_extract_kernel.code EXCLUDE_HIP_PLATFORM nvidia - * BUILD_CMD: %t %hc %S/%s -I%S/.. -o %T/%t -ldl EXCLUDE_HIP_PLATFORM nvidia + * BUILD_CMD: %t %hc %S/%s -I%S/.. -o %T/%t -ldl EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_LIB_TYPE static * TEST: %t * HIT_END */ diff --git a/tests/src/g++/hipMalloc.cpp b/tests/src/g++/hipMalloc.cpp index 9d08cf45b5..2f17d024dc 100644 --- a/tests/src/g++/hipMalloc.cpp +++ b/tests/src/g++/hipMalloc.cpp @@ -18,8 +18,8 @@ * */ /* HIT_START - * BUILD_CMD: hipMalloc %cxx -D__HIP_PLATFORM_HCC__ -I%hip-path/include -I/opt/rocm/include %S/%s -Wl,--rpath=%hip-path/lib %hip-path/lib/libamdhip64.so -o %T/%t -std=c++11 EXCLUDE_HIP_PLATFORM nvidia - * TEST: %t EXCLUDE_HIP_PLATFORM nvidia + * BUILD_CMD: hipMalloc %cxx -D__HIP_PLATFORM_HCC__ -I%hip-path/include -I/opt/rocm/include %S/%s -Wl,--rpath=%hip-path/lib %hip-path/lib/libamdhip64.so -o %T/%t -std=c++11 EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_LIB_TYPE static + * TEST: %t EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_LIB_TYPE static * HIT_END */ diff --git a/tests/src/runtimeApi/memory/hipMemset2DAsyncMultiThreadAndKernel.cpp b/tests/src/runtimeApi/memory/hipMemset2DAsyncMultiThreadAndKernel.cpp index 7834545707..4e3dfad062 100644 --- a/tests/src/runtimeApi/memory/hipMemset2DAsyncMultiThreadAndKernel.cpp +++ b/tests/src/runtimeApi/memory/hipMemset2DAsyncMultiThreadAndKernel.cpp @@ -24,7 +24,7 @@ // /* HIT_START - * BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvidia + * BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_LIB_TYPE static * TEST: %t * HIT_END */ diff --git a/tests/src/runtimeApi/memory/hipMemsetAsyncAndKernel.cpp b/tests/src/runtimeApi/memory/hipMemsetAsyncAndKernel.cpp index e4a872f585..a24c9459a6 100644 --- a/tests/src/runtimeApi/memory/hipMemsetAsyncAndKernel.cpp +++ b/tests/src/runtimeApi/memory/hipMemsetAsyncAndKernel.cpp @@ -23,7 +23,7 @@ */ /* HIT_START - * BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvidia + * BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_LIB_TYPE static * TEST: %t * HIT_END */ diff --git a/tests/src/runtimeApi/memory/hipMemsetAsyncMultiThread.cpp b/tests/src/runtimeApi/memory/hipMemsetAsyncMultiThread.cpp index 7685d1c284..490aef8c68 100644 --- a/tests/src/runtimeApi/memory/hipMemsetAsyncMultiThread.cpp +++ b/tests/src/runtimeApi/memory/hipMemsetAsyncMultiThread.cpp @@ -22,7 +22,7 @@ */ /* HIT_START - * BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvidia + * BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_LIB_TYPE static * TEST: %t * HIT_END */