hip-tests: Enable standalone test targets with cmake (#2189)

Co-authored-by: Rahul Manocha <rmanocha@amd.com>
このコミットが含まれているのは:
Rahul Manocha
2025-12-09 11:07:42 -08:00
committed by GitHub
コミット af5c453551
18個のファイルの変更60行の追加46行の削除
+44 -4
ファイルの表示
@@ -14,14 +14,55 @@ function(hip_add_exe_to_target)
"${args}"
"${list_args}"
)
hip_gen_exe_target(
NAME ${_NAME}
TEST_TARGET_NAME ${_TEST_TARGET_NAME}
TEST_SRC ${_TEST_SRC}
LINKER_LIBS ${_LINKER_LIBS}
COMMON_SHARED_SRC ${_COMMON_SHARED_SRC}
COMPILE_OPTIONS ${_COMPILE_OPTIONS}
PROPERTY ${_PROPERTY}
STANDALONE_FLAG 0
)
# If STANDALONE_TESTS==1, also generate per-file targets
if(STANDALONE_TESTS EQUAL "1")
hip_gen_exe_target(
NAME ${_NAME}
TEST_TARGET_NAME ${_TEST_TARGET_NAME}
TEST_SRC ${_TEST_SRC}
LINKER_LIBS ${_LINKER_LIBS}
COMMON_SHARED_SRC ${_COMMON_SHARED_SRC}
COMPILE_OPTIONS ${_COMPILE_OPTIONS}
PROPERTY ${_PROPERTY}
STANDALONE_FLAG 1
)
endif()
endfunction()
function(hip_gen_exe_target)
set(options)
set(args NAME TEST_TARGET_NAME PLATFORM COMPILE_OPTIONS STANDALONE_FLAG)
set(list_args TEST_SRC LINKER_LIBS COMMON_SHARED_SRC PROPERTY)
cmake_parse_arguments(
PARSE_ARGV 0
"" # variable prefix
"${options}"
"${args}"
"${list_args}"
)
foreach(SRC_NAME ${TEST_SRC})
if(NOT STANDALONE_TESTS EQUAL "1")
if(NOT _STANDALONE_FLAG EQUAL "1")
set(_EXE_NAME ${_NAME})
set(SRC_NAME ${TEST_SRC})
else()
# strip extension of src and use exe name as src name
get_filename_component(_EXE_NAME ${SRC_NAME} NAME_WLE)
if(TARGET ${_EXE_NAME})
message(WARNING "Duplicate per-file target name detected: ${_EXE_NAME}. Skipping this target!")
continue()
endif()
endif()
# Create shared lib of all tests
@@ -79,9 +120,8 @@ function(hip_add_exe_to_target)
file(GLOB CTEST_INC_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_EXE_NAME}-*_include.cmake")
set_property(GLOBAL APPEND PROPERTY G_INSTALL_CTEST_INCLUDE_FILES ${CTEST_INC_FILES})
if(NOT STANDALONE_TESTS EQUAL "1")
if(NOT _STANDALONE_FLAG EQUAL "1")
break()
endif()
endforeach()
endfunction()
endfunction()
-26
ファイルの表示
@@ -1,26 +0,0 @@
/*
* Copyright (C) Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define CATCH_CONFIG_MAIN
#include <catch.hpp>
#include <cmd_options.hh>
CmdOptions cmd_options;
+7 -7
ファイルの表示
@@ -18,7 +18,7 @@ if(HIP_PLATFORM MATCHES "amd")
TEST_SRC ${TEST_SRC}
TEST_TARGET_NAME build_tests)
set(OFFLOAD_ARCH_GENERIC_STR
set(OFFLOAD_ARCH_GENERIC_STR
--offload-arch=gfx9-generic
--offload-arch=gfx9-4-generic:sramecc+:xnack-
--offload-arch=gfx9-4-generic:sramecc-:xnack-
@@ -76,11 +76,11 @@ if(HIP_PLATFORM MATCHES "amd")
set(TEST_SRC
hipSquareGenericTarget.cc
)
hip_add_exe_to_target(NAME hipSquareGenericTarget
hip_add_exe_to_target(NAME hipSquareGenericTargetDefault
TEST_SRC ${TEST_SRC}
TEST_TARGET_NAME build_tests)
set_target_properties(hipSquareGenericTarget PROPERTIES COMPILE_FLAGS "-mcode-object-version=6 ${DISABLE_GENERIC_TARGET_ONLY}")
target_compile_options(hipSquareGenericTarget PUBLIC ${OFFLOAD_ARCH_GENERIC_STR})
set_target_properties(hipSquareGenericTargetDefault PROPERTIES COMPILE_FLAGS "-mcode-object-version=6 ${DISABLE_GENERIC_TARGET_ONLY}")
target_compile_options(hipSquareGenericTargetDefault PUBLIC ${OFFLOAD_ARCH_GENERIC_STR})
hip_add_exe_to_target(NAME hipSquareGenericTargetCompressed
TEST_SRC ${TEST_SRC}
@@ -88,10 +88,10 @@ if(HIP_PLATFORM MATCHES "amd")
set_target_properties(hipSquareGenericTargetCompressed PROPERTIES COMPILE_FLAGS " -DGENERIC_COMPRESSED ${DISABLE_GENERIC_TARGET_ONLY} -mcode-object-version=6 --offload-compress")
target_compile_options(hipSquareGenericTargetCompressed PUBLIC ${OFFLOAD_ARCH_GENERIC_STR})
add_dependencies(hipSquareGenericTarget hipSquareGenericTargetCompressed)
add_dependencies(hipSquareGenericTargetDefault hipSquareGenericTargetCompressed)
if(BUILD_SHARED_LIBS)
add_dependencies(hipSquareGenericTarget hipSquareGenericTargetOnly)
add_dependencies(hipSquareGenericTarget hipSquareGenericTargetOnlyCompressed)
add_dependencies(hipSquareGenericTargetDefault hipSquareGenericTargetOnly)
add_dependencies(hipSquareGenericTargetDefault hipSquareGenericTargetOnlyCompressed)
endif()
# SWDEV-548807 skip building hipSpirvTest
+1 -1
ファイルの表示
@@ -66,7 +66,7 @@ endif()
# AMD only tests
set(AMD_TEST_SRC
unsafeAtomicAdd.cc
unsafeAtomicAddDevice.cc
mbcnt.cc
bitExtract.cc
bitInsert.cc
+1 -1
ファイルの表示
@@ -32,7 +32,7 @@ hip_add_exe_to_target(NAME dynamicLoading
TEST_TARGET_NAME build_tests)
if(HIP_PLATFORM MATCHES "amd")
add_custom_target(libLazyLoad.so COMMAND ${CMAKE_HIP_COMPILER} -fPIC -lpthread -shared
add_custom_target(libLazyLoad.so COMMAND ${CMAKE_HIP_COMPILER} -fPIC -lpthread -shared
${OFFLOAD_ARCH_LIST} -x hip ${CMAKE_CURRENT_SOURCE_DIR}/liblazyLoad.cc
-I${CMAKE_CURRENT_SOURCE_DIR}/../../include ${HIP_PATH_OPT}
-I${Catch2_SOURCE_DIR}/src -I${Catch2_BINARY_DIR}/generated-includes
+1 -1
ファイルの表示
@@ -1,6 +1,6 @@
set(TEST_SRC
execution_control_common.cc
hipFuncGetAttributes.cc
hipFuncGetAttributesBasic.cc
hipLaunchKernel.cc
hipLaunchCooperativeKernel.cc
hipLaunchCooperativeKernelMultiDevice.cc
+1 -1
ファイルの表示
@@ -139,7 +139,7 @@ set(TEST_SRC
hipGraphDestroy.cc
hipStreamUpdateCaptureDependencies.cc
hipThreadExchangeStreamCaptureMode.cc
hipLaunchHostFunc.cc
hipLaunchHostFuncWithGraph.cc
hipStreamGetCaptureInfo_v2_old.cc
hipUserObjectCreate.cc
hipUserObjectRelease.cc
+2 -2
ファイルの表示
@@ -32,7 +32,7 @@ set(TEST_SRC
hipTestConstant.cc
hipTestGlobalVariable.cc
hipTestMemKernel.cc
launch_bounds.cc
hipLaunchBoundsBasic.cc
hipAutoThreadIdx.cc
hipLaunchKernelEx.cc
)
@@ -44,7 +44,7 @@ endif()
# only for AMD
if(HIP_PLATFORM MATCHES "amd")
set(AMD_SRC
hipExtLaunchKernelGGL.cc
hipExtLaunchKernelGGLBasic.cc
hipSetupArgument.cc
hipConfigureCall.cc
)
+1 -1
ファイルの表示
@@ -27,8 +27,8 @@ set(COMMON_SHARED_SRC DriverContext.cc)
# But this exposes several problems with hipcc and build system on windows.
# While those are fixed, this hack should allow us to pass windows CI.
set(TEST_SRC
memset.cc
malloc.cc
hipMemsetBasic.cc
hipMemcpy2DToArray.cc
hipMemcpy2DToArray_old.cc
hipMemcpy2DToArrayAsync.cc
+2 -2
ファイルの表示
@@ -349,13 +349,13 @@ set(TEST_SRC
hipFuncSetAttribute.cc
hipFuncGetAttributes.cc
hipFuncSetSharedMemConfig.cc
hipManagedKeyword.cc
hipManagedKeywordBasic.cc
hipModule.cc
hipModuleLoadMultProcessOnMultGPU.cc
)
set(AMD_TEST_SRC
hipExtLaunchKernelGGL.cc
hipExtLaunchMultiKernelMultiDevice.cc
hipExtLaunchMultiKernelMultiDevFunctional.cc
)
if(HIP_PLATFORM MATCHES "amd")