[OFFLOAD] Enable Level Zero unittests (#185492)
This commit is contained in:
parent
a15dcd4117
commit
0e122bea82
@ -102,6 +102,24 @@ function(add_offload_test_device_code test_filename test_name)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Try to build with support for Level Zero SPIRV devices.
|
||||
if("level_zero" IN_LIST LIBOMPTARGET_PLUGINS_TO_BUILD)
|
||||
set(spirv_compile_flags ${OFFLOAD_TESTS_UNPARSED_ARGUMENTS})
|
||||
set(output_file "${CMAKE_CURRENT_BINARY_DIR}/${test_name}.spirv64.bin")
|
||||
# TODO: Building for specific devices is not implemented yet.
|
||||
# TODO: Remove the -ffreestanding flag once libc can be built for spirv64.
|
||||
add_custom_command(
|
||||
OUTPUT ${output_file}
|
||||
COMMAND ${CMAKE_CXX_COMPILER}
|
||||
-I${OFFLOAD_UNITTESTS_DIR}
|
||||
--target=spirv64-intel
|
||||
-ffreestanding
|
||||
-nogpulib -flto ${spirv_compile_flags} ${SRC_PATH} -o ${output_file}
|
||||
DEPENDS ${SRC_PATH}
|
||||
)
|
||||
add_custom_target(${test_name}.spirv64 DEPENDS ${output_file})
|
||||
endif()
|
||||
|
||||
# Create a single dependency target for the device code.
|
||||
add_custom_target(${test_name}.bin)
|
||||
if(TARGET ${test_name}.amdgpu)
|
||||
@ -110,6 +128,9 @@ function(add_offload_test_device_code test_filename test_name)
|
||||
if(TARGET ${test_name}.nvptx64)
|
||||
add_dependencies(${test_name}.bin ${test_name}.nvptx64)
|
||||
endif()
|
||||
if(TARGET ${test_name}.spirv64)
|
||||
add_dependencies(${test_name}.bin ${test_name}.spirv64)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(add_offload_unittest test_dirname)
|
||||
|
||||
@ -179,6 +179,8 @@ bool TestEnvironment::loadDeviceBinary(
|
||||
FileExtension = ".amdgpu.bin";
|
||||
} else if (Backend == OL_PLATFORM_BACKEND_CUDA) {
|
||||
FileExtension = ".nvptx64.bin";
|
||||
} else if (Backend == OL_PLATFORM_BACKEND_LEVEL_ZERO) {
|
||||
FileExtension = ".spirv64.bin";
|
||||
} else {
|
||||
errs() << "Unsupported platform type for a device binary test.\n";
|
||||
return false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user