SWDEV-508863 - Add generic target in compressed fatbin test (#28)

Change-Id: Iae148c3c998b18247624938512918dbb31bc462d
This commit is contained in:
Sang, Tao
2025-05-13 09:34:30 -04:00
committed by GitHub
parent 63c545989b
commit 5a33b33ec8
7 changed files with 79 additions and 16 deletions
+9 -1
View File
@@ -113,7 +113,7 @@ add_custom_target(copyKernelCompressed.code
-I${HIP_PATH}/include/ --rocm-path=${ROCM_PATH}
-I${CMAKE_CURRENT_SOURCE_DIR}/../../include --rocm-path=${ROCM_PATH})
set(OFFLOAD_ARCH_GENERIC_STR "--offload-arch=gfx9-generic --offload-arch=gfx9-4-generic --offload-arch=gfx10-1-generic --offload-arch=gfx10-3-generic --offload-arch=gfx11-generic --offload-arch=gfx12-generic")
set(OFFLOAD_ARCH_GENERIC_STR "--offload-arch=gfx9-generic --offload-arch=gfx9-4-generic:sramecc+:xnack- --offload-arch=gfx9-4-generic:sramecc-:xnack- --offload-arch=gfx9-4-generic:xnack+ --offload-arch=gfx10-1-generic --offload-arch=gfx10-3-generic --offload-arch=gfx11-generic --offload-arch=gfx12-generic")
add_custom_target(copyKernelGenericTarget.code
COMMAND ${CMAKE_CXX_COMPILER} -mcode-object-version=6 --genco ${OFFLOAD_ARCH_GENERIC_STR}
${CMAKE_CURRENT_SOURCE_DIR}/copyKernel.cc
@@ -121,6 +121,12 @@ add_custom_target(copyKernelGenericTarget.code
-I${HIP_PATH}/include/ --rocm-path=${ROCM_PATH}
-I${CMAKE_CURRENT_SOURCE_DIR}/../../include --rocm-path=${ROCM_PATH})
add_custom_target(copyKernelGenericTargetCompressed.code
COMMAND ${CMAKE_CXX_COMPILER} -mcode-object-version=6 --offload-compress --genco ${OFFLOAD_ARCH_GENERIC_STR}
${CMAKE_CURRENT_SOURCE_DIR}/copyKernel.cc
-o ${CMAKE_CURRENT_BINARY_DIR}/../../unit/module/copyKernelGenericTargetCompressed.code
-I${HIP_PATH}/include/ --rocm-path=${ROCM_PATH}
-I${CMAKE_CURRENT_SOURCE_DIR}/../../include --rocm-path=${ROCM_PATH})
set_property(GLOBAL APPEND PROPERTY G_INSTALL_CUSTOM_TARGETS
${CMAKE_CURRENT_BINARY_DIR}/empty_module.code
${CMAKE_CURRENT_BINARY_DIR}/copyKernel.code
@@ -128,6 +134,7 @@ set_property(GLOBAL APPEND PROPERTY G_INSTALL_CUSTOM_TARGETS
${CMAKE_CURRENT_BINARY_DIR}/addKernel.code
${CMAKE_CURRENT_BINARY_DIR}/copyKernelCompressed.code
${CMAKE_CURRENT_BINARY_DIR}/copyKernelGenericTarget.code
${CMAKE_CURRENT_BINARY_DIR}/copyKernelGenericTargetCompressed.code
)
if(UNIX)
@@ -224,6 +231,7 @@ add_dependencies(build_tests copyKernel.code copyKernel.s)
add_dependencies(build_tests addKernel.code)
add_dependencies(build_tests copyKernelCompressed.code)
add_dependencies(build_tests copyKernelGenericTarget.code)
add_dependencies(build_tests copyKernelGenericTargetCompressed.code)
if(UNIX)
add_dependencies(build_tests copiousArgKernel.code copiousArgKernel0.code copiousArgKernel1.code copiousArgKernel2.code
+11 -3
View File
@@ -53,6 +53,7 @@ constexpr auto fileName = "copyKernel.code";
constexpr auto kernel_name = "copy_ker";
constexpr auto fileNameCompressed = "copyKernelCompressed.code";
constexpr auto fileNameGenericTarget = "copyKernelGenericTarget.code";
constexpr auto fileNameGenericTargetCompressed = "copyKernelGenericTargetCompressed.code";
static constexpr auto totalWorkGroups{1024};
static constexpr auto localWorkSize{512};
@@ -192,19 +193,26 @@ TEST_CASE("Unit_hipExtModuleLaunchKernel_UniformWorkGroup") {
// Get module and function from module
hipModule_t Module;
hipFunction_t Function;
SECTION("uncompressed codeobjects") {
SECTION("regular fatbin") {
HIP_CHECK(hipModuleLoad(&Module, fileName));
}
SECTION("compressed codeobjects") {
SECTION("compressed fatbin") {
HIP_CHECK(hipModuleLoad(&Module, fileNameCompressed));
}
SECTION("generic target codeobjects") {
SECTION("generic target in regular fatbin") {
if (!isGenericTargetSupported()) {
fprintf(stderr, "Generic target test is skipped\n");
return;
}
HIP_CHECK(hipModuleLoad(&Module, fileNameGenericTarget));
}
SECTION("generic target in compressed fatbin") {
if (!isGenericTargetSupported()) {
fprintf(stderr, "Generic target test is skipped\n");
return;
}
HIP_CHECK(hipModuleLoad(&Module, fileNameGenericTargetCompressed));
}
HIP_CHECK(hipModuleGetFunction(&Function, Module, kernel_name));
// Allocate resources
int* A = new int[arraylength];
+16 -2
View File
@@ -37,7 +37,7 @@ TEST_CASE("Unit_hipModuleLoadData_Positive_Basic") {
}
#if HT_AMD
SECTION("Load compiled module from file with compressed code objects") {
SECTION("Load compiled module from file with regular target in compressed fatbin") {
const auto loaded_module = LoadModuleIntoBuffer("copyKernelCompressed.code");
HIP_CHECK(hipModuleLoadData(&module, loaded_module.data()));
REQUIRE(module != nullptr);
@@ -47,7 +47,7 @@ TEST_CASE("Unit_hipModuleLoadData_Positive_Basic") {
HIP_CHECK(hipModuleUnload(module));
}
SECTION("Load compiled module from file with generic target code objects") {
SECTION("Load compiled module from file with generic target in regular fatbin") {
if (!isGenericTargetSupported()) {
fprintf(stderr, "Generic target test is skipped\n");
return;
@@ -60,6 +60,20 @@ TEST_CASE("Unit_hipModuleLoadData_Positive_Basic") {
REQUIRE(kernel != nullptr);
HIP_CHECK(hipModuleUnload(module));
}
SECTION("Load compiled module from file with generic target in compressed fatbin") {
if (!isGenericTargetSupported()) {
fprintf(stderr, "Generic target test is skipped\n");
return;
}
const auto loaded_module = LoadModuleIntoBuffer("copyKernelGenericTargetCompressed.code");
HIP_CHECK(hipModuleLoadData(&module, loaded_module.data()));
REQUIRE(module != nullptr);
hipFunction_t kernel = nullptr;
HIP_CHECK(hipModuleGetFunction(&kernel, module, "copy_ker"));
REQUIRE(kernel != nullptr);
HIP_CHECK(hipModuleUnload(module));
}
#endif
SECTION("Load RTCd module") {