Skip to content

Commit 900818b

Browse files
CMake: refactor compiling test kernels
Change-Id: I50b75a06fa8d3de4e79ad24623738fa582f8f122 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
1 parent b0e7994 commit 900818b

File tree

4 files changed

+39
-65
lines changed

4 files changed

+39
-65
lines changed

unit_tests/CMakeLists.txt

Lines changed: 36 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ endif()
3131
link_libraries(${ASAN_LIBS} ${TSAN_LIBS})
3232

3333
add_custom_target(unit_tests)
34+
add_custom_target(prepare_test_kernels)
3435
add_custom_target(run_unit_tests ALL)
3536

3637
set(IGDRCL_SRCS_tests_local
@@ -175,6 +176,7 @@ endfunction()
175176
add_dependencies(unit_tests
176177
igdrcl_tests
177178
test_dynamic_lib
179+
prepare_test_kernels
178180
)
179181

180182
set_target_properties(igdrcl_tests PROPERTIES FOLDER ${TEST_PROJECTS_FOLDER})
@@ -184,6 +186,7 @@ if(UNIX)
184186
endif()
185187

186188
set_target_properties(unit_tests PROPERTIES FOLDER ${TEST_PROJECTS_FOLDER})
189+
set_target_properties(prepare_test_kernels PROPERTIES FOLDER ${TEST_PROJECTS_FOLDER})
187190
set_target_properties(run_unit_tests PROPERTIES FOLDER ${TEST_PROJECTS_FOLDER})
188191

189192
target_include_directories(igdrcl_tests BEFORE PRIVATE ${NEO_SOURCE_DIR}/core/unit_tests/test_macros${BRANCH_DIR_SUFFIX})
@@ -198,10 +201,10 @@ else()
198201
endif()
199202
endif()
200203

201-
function(neo_gen_kernels target platform_name suffix)
204+
function(neo_gen_kernels platform_name_with_type platform_name suffix)
202205
set(outputdir "${TargetDir}/${suffix}/test_files/${NEO_ARCH}/")
203206

204-
set(results)
207+
set(kernels_to_compile)
205208
foreach(filepath ${ARGN})
206209
get_filename_component(filename ${filepath} NAME)
207210
get_filename_component(basename ${filepath} NAME_WE)
@@ -221,14 +224,14 @@ function(neo_gen_kernels target platform_name suffix)
221224
DEPENDS ${filepath} ocloc
222225
)
223226

224-
list(APPEND results ${output_files})
227+
list(APPEND kernels_to_compile ${output_files})
225228
endforeach()
226-
add_custom_target(${target} DEPENDS ${results} copy_compiler_files)
227-
set_target_properties(${target} PROPERTIES FOLDER "kernels/${suffix}")
229+
list(APPEND kernels_to_compile_${platform_name_with_type} ${kernels_to_compile})
230+
set(kernels_to_compile_${platform_name_with_type} ${kernels_to_compile_${platform_name_with_type}} PARENT_SCOPE)
228231
endfunction()
229232

230-
function(neo_gen_kernels_with_options target platform_name suffix filepath)
231-
set(results)
233+
function(neo_gen_kernels_with_options platform_name_with_type platform_name suffix filepath)
234+
set(kernels_to_compile)
232235
foreach(filearg ${filepath})
233236
get_filename_component(filename ${filearg} NAME)
234237
get_filename_component(basename ${filearg} NAME_WE)
@@ -254,15 +257,15 @@ function(neo_gen_kernels_with_options target platform_name suffix filepath)
254257
DEPENDS ${filearg} ocloc
255258
)
256259

257-
list(APPEND results ${output_files})
260+
list(APPEND kernels_to_compile ${output_files})
258261
endforeach()
259262
endforeach()
260-
add_custom_target(${target} DEPENDS ${results} copy_compiler_files)
261-
set_target_properties(${target} PROPERTIES FOLDER "kernels/${suffix}")
263+
list(APPEND kernels_to_compile_${platform_name_with_type} ${kernels_to_compile})
264+
set(kernels_to_compile_${platform_name_with_type} ${kernels_to_compile_${platform_name_with_type}} PARENT_SCOPE)
262265
endfunction()
263266

264-
function(neo_gen_kernels_with_internal_options target platform_name suffix filepath)
265-
set(results)
267+
function(neo_gen_kernels_with_internal_options platform_name_with_type platform_name suffix filepath)
268+
set(kernels_to_compile)
266269
foreach(filearg ${filepath})
267270
get_filename_component(filename ${filearg} NAME)
268271
get_filename_component(basename ${filearg} NAME_WE)
@@ -287,26 +290,25 @@ function(neo_gen_kernels_with_internal_options target platform_name suffix filep
287290
DEPENDS ${filearg} ocloc
288291
)
289292

290-
list(APPEND results ${output_files})
293+
list(APPEND kernels_to_compile ${output_files})
291294
endforeach()
292295
endforeach()
293-
add_custom_target(${target} DEPENDS ${results} copy_compiler_files)
294-
set_target_properties(${target} PROPERTIES FOLDER "kernels/${suffix}")
296+
list(APPEND kernels_to_compile_${platform_name_with_type} ${kernels_to_compile})
297+
set(kernels_to_compile_${platform_name_with_type} ${kernels_to_compile_${platform_name_with_type}} PARENT_SCOPE)
295298
endfunction()
296299

297300
set(TEST_KERNEL_kernel_debug_enable
298301
"-cl-kernel-debug-enable"
299302
)
300303

301-
function(neo_gen_kernel_with_kernel_debug_options target platform_name suffix filepath)
304+
function(neo_gen_kernel_with_kernel_debug_options platform_name_with_type platform_name suffix filepath)
302305
get_filename_component(filename ${filepath} NAME)
303306
get_filename_component(basename ${filepath} NAME_WE)
304307
get_filename_component(base_workdir ${filepath} DIRECTORY)
305308

306309
set(outputdir "${TargetDir}/${suffix}/test_files/${NEO_ARCH}/")
307310
set(workdir "${CMAKE_CURRENT_SOURCE_DIR}/${base_workdir}/")
308311

309-
set(results)
310312
string(REPLACE " " "_" argwospaces ${TEST_KERNEL_kernel_debug_enable})
311313

312314
set(outputpath_base "${outputdir}/${argwospaces}_${suffix}")
@@ -324,19 +326,17 @@ function(neo_gen_kernel_with_kernel_debug_options target platform_name suffix fi
324326
DEPENDS ${filepath} ocloc
325327
)
326328

327-
list(APPEND results ${output_files})
328-
add_custom_target(${target} DEPENDS ${results} copy_compiler_files)
329-
set_target_properties(${target} PROPERTIES FOLDER "kernels/${suffix}")
329+
list(APPEND kernels_to_compile_${platform_name_with_type} ${output_files})
330+
set(kernels_to_compile_${platform_name_with_type} ${kernels_to_compile_${platform_name_with_type}} PARENT_SCOPE)
330331
endfunction()
331332

332-
function(neo_gen_kernel_from_ll target platform_name suffix filepath output_name compile_options)
333+
function(neo_gen_kernel_from_ll platform_name_with_type platform_name suffix filepath output_name compile_options)
333334
get_filename_component(filename ${filepath} NAME)
334335
get_filename_component(basename ${filepath} NAME_WE)
335336

336337
set(outputdir "${TargetDir}/${suffix}/test_files/${NEO_ARCH}")
337338
set(workdir "${CMAKE_CURRENT_SOURCE_DIR}/test_files/")
338339

339-
set(results)
340340
set(outputpath_base "${outputdir}/${output_name}_${suffix}")
341341
set(output_files
342342
${outputpath_base}.bin
@@ -351,10 +351,8 @@ function(neo_gen_kernel_from_ll target platform_name suffix filepath output_name
351351
DEPENDS ${filepath} ocloc
352352
)
353353

354-
list(APPEND results ${output_files})
355-
356-
add_custom_target(${target} DEPENDS ${results} copy_compiler_files)
357-
set_target_properties(${target} PROPERTIES FOLDER "kernels/${suffix}")
354+
list(APPEND kernels_to_compile_${platform_name_with_type} ${output_files})
355+
set(kernels_to_compile_${platform_name_with_type} ${kernels_to_compile_${platform_name_with_type}} PARENT_SCOPE)
358356
endfunction()
359357

360358
set(TEST_KERNEL test_files/CopyBuffer_simd8.cl)
@@ -450,25 +448,6 @@ endmacro()
450448
macro(macro_for_each_platform)
451449
PLATFORM_TESTED_WITH_APPVERIFIER(${GEN_TYPE} ${PLATFORM_IT} TESTED_WITH_APPVERIFIER)
452450
apply_macro_for_each_test_config("UNIT_TESTS")
453-
foreach(PLATFORM_TYPE ${PLATFORM_TYPES})
454-
if(${PLATFORM_IT}_IS_${PLATFORM_TYPE})
455-
get_family_name_with_type(${GEN_TYPE} ${PLATFORM_TYPE})
456-
add_dependencies(unit_tests test_kernels_${family_name_with_type})
457-
add_dependencies(unit_tests test_kernel_${family_name_with_type})
458-
add_dependencies(unit_tests test_kernel_stateless_${family_name_with_type})
459-
if(NOT ("${GEN_TYPE_LOWER}" STREQUAL "gen8"))
460-
add_dependencies(unit_tests test_kernel_debug_enable_${family_name_with_type})
461-
endif()
462-
PLATFORM_HAS_2_0(${GEN_TYPE} ${PLATFORM_IT} PLATFORM_SUPPORTS_2_0)
463-
if(PLATFORM_SUPPORTS_2_0)
464-
add_dependencies(unit_tests test_kernel_2_0_${family_name_with_type})
465-
endif()
466-
PLATFORM_HAS_VME(${GEN_TYPE} ${PLATFORM_IT} PLATFORM_SUPPORTS_VME)
467-
if(PLATFORM_SUPPORTS_VME)
468-
add_dependencies(unit_tests test_kernel_vme_${family_name_with_type})
469-
endif()
470-
endif()
471-
endforeach()
472451
endmacro()
473452

474453
macro(macro_for_each_gen)
@@ -481,17 +460,17 @@ macro(macro_for_each_gen)
481460
set(PLATFORM_VME_LOWER ${DEFAULT_SUPPORTED_VME_${GEN_TYPE}_${PLATFORM_TYPE}_PLATFORM})
482461

483462
if(MSVC OR CMAKE_SIZEOF_VOID_P EQUAL 8)
484-
neo_gen_kernels(test_kernels_${family_name_with_type} ${PLATFORM_LOWER} ${family_name_with_type} ${TEST_KERNELS})
485-
neo_gen_kernels_with_options(test_kernel_${family_name_with_type} ${PLATFORM_LOWER} ${family_name_with_type} ${TEST_KERNEL} ${TEST_KERNEL_options})
463+
neo_gen_kernels(${family_name_with_type} ${PLATFORM_LOWER} ${family_name_with_type} ${TEST_KERNELS})
464+
neo_gen_kernels_with_options(${family_name_with_type} ${PLATFORM_LOWER} ${family_name_with_type} ${TEST_KERNEL} ${TEST_KERNEL_options})
486465
# Temporarily disabled debug kernel generation on gen8
487466
if(NOT ("${GEN_TYPE_LOWER}" STREQUAL "gen8"))
488-
neo_gen_kernel_with_kernel_debug_options(test_kernel_debug_enable_${family_name_with_type} ${PLATFORM_LOWER} ${family_name_with_type} ${TEST_KERNEL})
467+
neo_gen_kernel_with_kernel_debug_options(${family_name_with_type} ${PLATFORM_LOWER} ${family_name_with_type} ${TEST_KERNEL})
489468
endif()
490469
# Gen9lp needs extra -m32 flag
491470
if( ("${GEN_TYPE_LOWER}" STREQUAL "gen9") AND ("${PLATFORM_TYPE_LOWER}" STREQUAL "lp"))
492-
neo_gen_kernels_with_internal_options(test_kernel_stateless_${family_name_with_type} ${PLATFORM_LOWER} ${family_name_with_type} ${TEST_KERNEL_STATELESS} ${TEST_KERNEL_STATELESS_internal_options_gen9lp})
471+
neo_gen_kernels_with_internal_options(${family_name_with_type} ${PLATFORM_LOWER} ${family_name_with_type} ${TEST_KERNEL_STATELESS} ${TEST_KERNEL_STATELESS_internal_options_gen9lp})
493472
else()
494-
neo_gen_kernels_with_internal_options(test_kernel_stateless_${family_name_with_type} ${PLATFORM_LOWER} ${family_name_with_type} ${TEST_KERNEL_STATELESS} ${TEST_KERNEL_STATELESS_internal_options})
473+
neo_gen_kernels_with_internal_options(${family_name_with_type} ${PLATFORM_LOWER} ${family_name_with_type} ${TEST_KERNEL_STATELESS} ${TEST_KERNEL_STATELESS_internal_options})
495474
endif()
496475
set(sip_kernel_file_name)
497476
set(sip_kernel_output_file)
@@ -503,20 +482,21 @@ macro(macro_for_each_gen)
503482

504483
# Temporarily disabled sip kernel generation
505484
# if("${GEN_TYPE_LOWER}" STREQUAL "gen9" )
506-
# neo_gen_kernel_from_ll(test_kernel_sip_debug_local_${family_name_with_type} ${PLATFORM_LOWER} ${family_name_with_type} ${sip_kernel_file_name} ${sip_debug_local_kernel_output_file} ${TEST_KERNEL_SIP_DEBUG_LOCAL_options})
507-
# add_dependencies(unit_tests test_kernel_sip_debug_local_${family_name_with_type})
485+
# neo_gen_kernel_from_ll(${family_name_with_type} ${PLATFORM_LOWER} ${family_name_with_type} ${sip_kernel_file_name} ${sip_debug_local_kernel_output_file} ${TEST_KERNEL_SIP_DEBUG_LOCAL_options})
508486
# endif()
509487

510-
# neo_gen_kernel_from_ll(test_kernel_sip_debug_${family_name_with_type} ${PLATFORM_LOWER} ${family_name_with_type} ${sip_kernel_file_name} ${sip_debug_kernel_output_file} ${TEST_KERNEL_SIP_DEBUG_options})
511-
# add_dependencies(unit_tests test_kernel_sip_debug_${family_name_with_type})
488+
# neo_gen_kernel_from_ll(${family_name_with_type} ${PLATFORM_LOWER} ${family_name_with_type} ${sip_kernel_file_name} ${sip_debug_kernel_output_file} ${TEST_KERNEL_SIP_DEBUG_options})
512489

513490
if(PLATFORM_2_0_LOWER)
514-
neo_gen_kernels_with_options(test_kernel_2_0_${family_name_with_type} ${PLATFORM_2_0_LOWER} ${family_name_with_type} "${TEST_KERNEL_2_0}" ${TEST_KERNEL_2_0_options})
491+
neo_gen_kernels_with_options(${family_name_with_type} ${PLATFORM_2_0_LOWER} ${family_name_with_type} "${TEST_KERNEL_2_0}" ${TEST_KERNEL_2_0_options})
515492
endif()
516493
if(PLATFORM_VME_LOWER)
517-
neo_gen_kernels(test_kernel_vme_${family_name_with_type} ${PLATFORM_VME_LOWER} ${family_name_with_type} ${TEST_KERNEL_VME})
494+
neo_gen_kernels(${family_name_with_type} ${PLATFORM_VME_LOWER} ${family_name_with_type} ${TEST_KERNEL_VME})
518495
endif()
519496
endif()
497+
add_custom_target(prepare_test_kernels_${family_name_with_type} DEPENDS ${kernels_to_compile_${family_name_with_type}} copy_compiler_files)
498+
set_target_properties(prepare_test_kernels_${family_name_with_type} PROPERTIES FOLDER "${PLATFORM_SPECIFIC_TARGETS_FOLDER}/${family_name_with_type}")
499+
add_dependencies(prepare_test_kernels prepare_test_kernels_${family_name_with_type})
520500
endif()
521501
endforeach()
522502
apply_macro_for_each_platform()

unit_tests/aub_tests/CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,7 @@ macro(macro_for_each_test_config)
7777
foreach(PLATFORM_TYPE ${PLATFORM_TYPES})
7878
if(${PLATFORM_IT}_IS_${PLATFORM_TYPE})
7979
get_family_name_with_type(${GEN_TYPE} ${PLATFORM_TYPE})
80-
add_dependencies(${PLATFORM_IT_LOWER}_aub_tests test_kernels_${family_name_with_type})
81-
add_dependencies(${PLATFORM_IT_LOWER}_aub_tests test_kernel_${family_name_with_type})
82-
add_dependencies(${PLATFORM_IT_LOWER}_aub_tests test_kernel_stateless_${family_name_with_type})
83-
PLATFORM_HAS_2_0(${GEN_TYPE} ${PLATFORM_IT} PLATFORM_SUPPORTS_2_0)
84-
if(PLATFORM_SUPPORTS_2_0)
85-
add_dependencies(${PLATFORM_IT_LOWER}_aub_tests test_kernel_2_0_${family_name_with_type})
86-
endif()
80+
add_dependencies(${PLATFORM_IT_LOWER}_aub_tests prepare_test_kernels_${family_name_with_type})
8781
endif()
8882
endforeach()
8983
add_custom_target(run_${PLATFORM_IT_LOWER}_aub_tests ALL DEPENDS ${PLATFORM_IT_LOWER}_aub_tests)

unit_tests/mt_tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ macro(macro_for_each_test_config)
8282
foreach(PLATFORM_TYPE ${PLATFORM_TYPES})
8383
if(${PLATFORM_IT}_IS_${PLATFORM_TYPE})
8484
get_family_name_with_type(${GEN_TYPE} ${PLATFORM_TYPE})
85-
add_dependencies(run_${PLATFORM_IT_LOWER}_mt_unit_tests test_kernels_${family_name_with_type})
85+
add_dependencies(run_${PLATFORM_IT_LOWER}_mt_unit_tests prepare_test_kernels_${family_name_with_type})
8686
endif()
8787
endforeach()
8888
endif()

unit_tests/offline_compiler/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ macro(macro_for_each_platform)
103103
foreach(PLATFORM_TYPE ${PLATFORM_TYPES})
104104
if(${PLATFORM_IT}_IS_${PLATFORM_TYPE})
105105
get_family_name_with_type(${GEN_TYPE} ${PLATFORM_TYPE})
106-
add_dependencies(run_ocloc_tests test_kernels_${family_name_with_type})
106+
add_dependencies(run_ocloc_tests prepare_test_kernels_${family_name_with_type})
107107
neo_copy_test_files(copy_test_files_${family_name_with_type} ${family_name_with_type})
108108
add_dependencies(run_ocloc_tests copy_test_files_${family_name_with_type})
109109
set(run_tests_cmd ocloc_tests --device ${CLOC_DEFAULT_DEVICE} --family_type ${family_name_with_type})

0 commit comments

Comments
 (0)