Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NFC] Refactor kernel_compiler_spirv tests
Updates the test to load the SPIR-V module files using CMake instead of `std::ifstream`. This change makes the test binary more portable since it now contains the required SPIR-V modules. Signed-off-by: Michael Aziz <michael.aziz@intel.com>
- Loading branch information
Showing
2 changed files
with
28 additions
and
25 deletions.
There are no files selected for viewing
19 changes: 13 additions & 6 deletions
19
tests/extension/oneapi_kernel_compiler_spirv/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
function(load_spirv SPIRV_FILE RESULT) | ||
file(READ ${SPIRV_FILE} bytes HEX) | ||
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1, " values ${bytes}) | ||
string(REGEX REPLACE ", $" "" values ${values}) | ||
set(${RESULT} ${values} PARENT_SCOPE) | ||
endfunction() | ||
|
||
if(SYCL_CTS_ENABLE_EXT_ONEAPI_KERNEL_COMPILER_SPIRV_TESTS) | ||
file(GLOB test_cases_list *.cpp) | ||
|
||
file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/kernels.spv" KERNELS_PATH) | ||
file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/kernels_fp16.spv" KERNELS_FP16_PATH) | ||
file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/kernels_fp64.spv" KERNELS_FP64_PATH) | ||
add_compile_definitions(KERNELS_PATH="${KERNELS_PATH}") | ||
add_compile_definitions(KERNELS_FP16_PATH="${KERNELS_FP16_PATH}") | ||
add_compile_definitions(KERNELS_FP64_PATH="${KERNELS_FP64_PATH}") | ||
load_spirv("${CMAKE_CURRENT_SOURCE_DIR}/kernels.spv" KERNELS) | ||
load_spirv("${CMAKE_CURRENT_SOURCE_DIR}/kernels_fp16.spv" KERNELS_FP16) | ||
load_spirv("${CMAKE_CURRENT_SOURCE_DIR}/kernels_fp64.spv" KERNELS_FP64) | ||
add_compile_definitions(KERNELS=${KERNELS}) | ||
add_compile_definitions(KERNELS_FP16=${KERNELS_FP16}) | ||
add_compile_definitions(KERNELS_FP64=${KERNELS_FP64}) | ||
|
||
add_cts_test(${test_cases_list}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters