From 3e5d68deabcd4cfed0c8d2f32f84927ce9011446 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Mon, 8 Nov 2021 20:14:43 +0000 Subject: [PATCH] CMake cleanup: define cmd prefix for ocloc in one place rename cloc_cmd_prefix -> ocloc_cmd_prefix rename __cloc__options -> __ocloc__options Signed-off-by: Mateusz Jablonski --- CMakeLists.txt | 1 + cmake/ocloc_cmd_prefix.cmake | 15 +++++++++ level_zero/core/test/common/gen_kernel.cmake | 15 ++------- .../source/built_ins/kernels/CMakeLists.txt | 17 ++-------- .../source/scheduler/scheduler_binary.cmake | 25 ++++---------- opencl/test/unit_test/CMakeLists.txt | 22 +++---------- .../source/built_ins/kernels/CMakeLists.txt | 33 +++---------------- shared/test/common/test_files/CMakeLists.txt | 14 +------- 8 files changed, 39 insertions(+), 103 deletions(-) create mode 100644 cmake/ocloc_cmd_prefix.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f2ab3828bb..2e9fc8a316 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -748,6 +748,7 @@ endif() add_subdirectory_unique(${OCLOC_DIRECTORY} ${NEO_BUILD_DIR}/offline_compiler) target_compile_definitions(ocloc_lib PRIVATE MOCKABLE_VIRTUAL=) +include(cmake/ocloc_cmd_prefix.cmake) if(DONT_CARE_OF_VIRTUALS) set(NEO_SHARED_RELEASE_LIB_NAME "neo_shared") diff --git a/cmake/ocloc_cmd_prefix.cmake b/cmake/ocloc_cmd_prefix.cmake new file mode 100644 index 0000000000..9b6bd3cd3e --- /dev/null +++ b/cmake/ocloc_cmd_prefix.cmake @@ -0,0 +1,15 @@ +# +# Copyright (C) 2021 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(WIN32) + set(ocloc_cmd_prefix ocloc) +else() + if(DEFINED NEO__IGC_LIBRARY_PATH) + set(ocloc_cmd_prefix LD_LIBRARY_PATH=${NEO__IGC_LIBRARY_PATH}:$ $) + else() + set(ocloc_cmd_prefix LD_LIBRARY_PATH=$ $) + endif() +endif() diff --git a/level_zero/core/test/common/gen_kernel.cmake b/level_zero/core/test/common/gen_kernel.cmake index d1af78248a..b639e2359b 100644 --- a/level_zero/core/test/common/gen_kernel.cmake +++ b/level_zero/core/test/common/gen_kernel.cmake @@ -7,17 +7,6 @@ function(level_zero_gen_kernels target_list platform_name suffix options) if(NOT NEO_DISABLE_BUILTINS_COMPILATION) - if(NOT DEFINED cloc_cmd_prefix) - if(WIN32) - set(cloc_cmd_prefix ocloc) - else() - if(DEFINED NEO__IGC_LIBRARY_PATH) - set(cloc_cmd_prefix LD_LIBRARY_PATH=${NEO__IGC_LIBRARY_PATH}:$ $) - else() - set(cloc_cmd_prefix LD_LIBRARY_PATH=$ $) - endif() - endif() - endif() list(APPEND results copy_compiler_files) endif() @@ -36,9 +25,9 @@ function(level_zero_gen_kernels target_list platform_name suffix options) ) add_custom_command( - COMMAND echo generate ${cloc_cmd_prefix} -q -file ${filename} -device ${platform_name} -out_dir ${outputdir} -options "${options}" + COMMAND echo generate ${ocloc_cmd_prefix} -q -file ${filename} -device ${platform_name} -out_dir ${outputdir} -options "${options}" OUTPUT ${output_files} - COMMAND ${cloc_cmd_prefix} -q -file ${filename} -device ${platform_name} -out_dir ${outputdir} -options "${options}" + COMMAND ${ocloc_cmd_prefix} -q -file ${filename} -device ${platform_name} -out_dir ${outputdir} -options "${options}" WORKING_DIRECTORY ${workdir} DEPENDS ${filepath} ocloc ) diff --git a/opencl/source/built_ins/kernels/CMakeLists.txt b/opencl/source/built_ins/kernels/CMakeLists.txt index 2ae85a3ff6..ae23d31df6 100644 --- a/opencl/source/built_ins/kernels/CMakeLists.txt +++ b/opencl/source/built_ins/kernels/CMakeLists.txt @@ -24,7 +24,7 @@ if(NOT NEO_DISABLE_BUILTINS_COMPILATION) ) if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - list(APPEND __cloc__options__ "-D DEBUG") + list(APPEND __ocloc__options__ "-D DEBUG") endif() set(BUILTINS_INCLUDE_DIR ${TargetDir} PARENT_SCOPE) @@ -61,22 +61,11 @@ if(NOT NEO_DISABLE_BUILTINS_COMPILATION) unset(BUILTIN_CPP) # set variable outside function set(BUILTIN_CPP built_ins/${NEO_ARCH}/${gen_type_lower}/${BASENAME}_${family_name_with_type}.cpp PARENT_SCOPE) - if(NOT DEFINED cloc_cmd_prefix) - if(WIN32) - set(cloc_cmd_prefix ocloc) - else() - if(DEFINED NEO__IGC_LIBRARY_PATH) - set(cloc_cmd_prefix LD_LIBRARY_PATH=${NEO__IGC_LIBRARY_PATH}:$ $) - else() - set(cloc_cmd_prefix LD_LIBRARY_PATH=$ $) - endif() - endif() - endif() - list(APPEND __cloc__options__ "-cl-kernel-arg-info") + list(APPEND __ocloc__options__ "-cl-kernel-arg-info") add_custom_command( OUTPUT ${OUTPUT_FILES} - COMMAND ${cloc_cmd_prefix} -q -file ${FILENAME} -device ${DEFAULT_SUPPORTED_${gen_type}_${platform_type}_PLATFORM} ${builtin_options} -${bits} -out_dir ${OUTPUTDIR} -options "$" + COMMAND ${ocloc_cmd_prefix} -q -file ${FILENAME} -device ${DEFAULT_SUPPORTED_${gen_type}_${platform_type}_PLATFORM} ${builtin_options} -${bits} -out_dir ${OUTPUTDIR} -options "$" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${builtin} ocloc copy_compiler_files ) diff --git a/opencl/source/scheduler/scheduler_binary.cmake b/opencl/source/scheduler/scheduler_binary.cmake index 2ba769e02a..daefa7a315 100644 --- a/opencl/source/scheduler/scheduler_binary.cmake +++ b/opencl/source/scheduler/scheduler_binary.cmake @@ -11,11 +11,11 @@ set_target_properties(scheduler PROPERTIES FOLDER "${OPENCL_RUNTIME_PROJECTS_FOL set(SCHEDULER_KERNEL scheduler.cl) if(DEFINED NEO__IGC_INCLUDE_DIR) - list(APPEND __cloc__options__ "-I$") + list(APPEND __ocloc__options__ "-I$") endif() if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - list(APPEND __cloc__options__ "-D DEBUG") + list(APPEND __ocloc__options__ "-D DEBUG") endif() set(SCHEDULER_INCLUDE_DIR ${TargetDir}) @@ -25,7 +25,7 @@ function(compile_kernel target gen_type platform_type kernel) string(TOLOWER ${gen_type} gen_type_lower) # get filename set(OUTPUTDIR "${SCHEDULER_OUTDIR_WITH_ARCH}/${gen_type_lower}") - list(APPEND __cloc__options__ "-I ../${gen_type_lower}") + list(APPEND __ocloc__options__ "-I ../${gen_type_lower}") get_filename_component(BASENAME ${kernel} NAME_WE) @@ -33,23 +33,12 @@ function(compile_kernel target gen_type platform_type kernel) set(SCHEDULER_CPP "${OUTPUTDIR}/${BASENAME}_${family_name_with_type}.cpp") - if(NOT DEFINED cloc_cmd_prefix) - if(WIN32) - set(cloc_cmd_prefix ocloc) - else() - if(DEFINED NEO__IGC_LIBRARY_PATH) - set(cloc_cmd_prefix LD_LIBRARY_PATH=${NEO__IGC_LIBRARY_PATH}:$ $) - else() - set(cloc_cmd_prefix LD_LIBRARY_PATH=$ $) - endif() - endif() - endif() - list(APPEND __cloc__options__ "-cl-kernel-arg-info") - list(APPEND __cloc__options__ "-cl-std=CL2.0") - list(APPEND __cloc__options__ "-cl-intel-disable-a64WA") + list(APPEND __ocloc__options__ "-cl-kernel-arg-info") + list(APPEND __ocloc__options__ "-cl-std=CL2.0") + list(APPEND __ocloc__options__ "-cl-intel-disable-a64WA") add_custom_command( OUTPUT ${OUTPUTPATH} - COMMAND ${cloc_cmd_prefix} -q -file ${kernel} -device ${DEFAULT_SUPPORTED_${gen_type}_${platform_type}_PLATFORM} -cl-intel-greater-than-4GB-buffer-required -${NEO_BITS} -out_dir ${OUTPUTDIR} -cpp_file -options "$" -internal_options "-cl-intel-no-spill" + COMMAND ${ocloc_cmd_prefix} -q -file ${kernel} -device ${DEFAULT_SUPPORTED_${gen_type}_${platform_type}_PLATFORM} -cl-intel-greater-than-4GB-buffer-required -${NEO_BITS} -out_dir ${OUTPUTDIR} -cpp_file -options "$" -internal_options "-cl-intel-no-spill" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${kernel} ocloc copy_compiler_files ) diff --git a/opencl/test/unit_test/CMakeLists.txt b/opencl/test/unit_test/CMakeLists.txt index 31893d9cb7..7cee4f81d0 100644 --- a/opencl/test/unit_test/CMakeLists.txt +++ b/opencl/test/unit_test/CMakeLists.txt @@ -178,18 +178,6 @@ target_include_directories(igdrcl_tests BEFORE PRIVATE ${NEO_SHARED_TEST_DIRECTORY}/common/helpers/includes${BRANCH_DIR_SUFFIX} ) -if(NOT DEFINED cloc_cmd_prefix) - if(WIN32) - set(cloc_cmd_prefix ocloc) - else() - if(DEFINED NEO__IGC_LIBRARY_PATH) - set(cloc_cmd_prefix LD_LIBRARY_PATH=${NEO__IGC_LIBRARY_PATH}:$ $) - else() - set(cloc_cmd_prefix LD_LIBRARY_PATH=$ $) - endif() - endif() -endif() - function(neo_gen_kernels platform_name_with_type platform_name revision_id suffix) set(outputdir "${TargetDir}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/") @@ -209,7 +197,7 @@ function(neo_gen_kernels platform_name_with_type platform_name revision_id suffi add_custom_command( OUTPUT ${output_files} - COMMAND ${cloc_cmd_prefix} -q -file ${filename} -device ${platform_name} -${NEO_BITS} -revision_id ${revision_id} -out_dir ${outputdir} + COMMAND ${ocloc_cmd_prefix} -q -file ${filename} -device ${platform_name} -${NEO_BITS} -revision_id ${revision_id} -out_dir ${outputdir} WORKING_DIRECTORY ${workdir} DEPENDS ${filepath} ocloc ) @@ -255,7 +243,7 @@ function(neo_gen_kernels_with_options platform_name_with_type platform_name revi add_custom_command( OUTPUT ${output_files} - COMMAND ${cloc_cmd_prefix} -file ${filename} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -revision_id ${revision_id} -options ${arg} -options_name + COMMAND ${ocloc_cmd_prefix} -file ${filename} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -revision_id ${revision_id} -options ${arg} -options_name WORKING_DIRECTORY ${workdir} DEPENDS ${filearg} ocloc ) @@ -307,7 +295,7 @@ function(neo_gen_kernels_with_internal_options platform_name_with_type platform_ add_custom_command( OUTPUT ${output_files} - COMMAND ${cloc_cmd_prefix} -file ${filename} -device ${platform_name} -revision_id ${revision_id} -${NEO_BITS} -out_dir ${outputdir} ${output_name} -internal_options ${ARGN} + COMMAND ${ocloc_cmd_prefix} -file ${filename} -device ${platform_name} -revision_id ${revision_id} -${NEO_BITS} -out_dir ${outputdir} ${output_name} -internal_options ${ARGN} WORKING_DIRECTORY ${workdir} DEPENDS ${filearg} ocloc ) @@ -353,7 +341,7 @@ function(neo_gen_kernel_with_kernel_debug_options platform_name_with_type platfo ) add_custom_command( OUTPUT ${output_files} - COMMAND ${cloc_cmd_prefix} -q -file ${filename} -device ${platform_name} -revision_id ${revision_id} -${NEO_BITS} -out_dir ${outputdir} -output ${argwospaces} -internal_options ${TEST_KERNEL_kernel_debug_enable} -options "-g" + COMMAND ${ocloc_cmd_prefix} -q -file ${filename} -device ${platform_name} -revision_id ${revision_id} -${NEO_BITS} -out_dir ${outputdir} -output ${argwospaces} -internal_options ${TEST_KERNEL_kernel_debug_enable} -options "-g" WORKING_DIRECTORY ${workdir} DEPENDS ${filepath} ocloc ) @@ -389,7 +377,7 @@ function(neo_gen_kernel_from_ll platform_name_with_type platform_name suffix fil add_custom_command( OUTPUT ${output_files} - COMMAND ${cloc_cmd_prefix} -q -file ${filename} -output ${output_name} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -internal_options ${compile_options} -llvm_input + COMMAND ${ocloc_cmd_prefix} -q -file ${filename} -output ${output_name} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -internal_options ${compile_options} -llvm_input WORKING_DIRECTORY ${workdir} DEPENDS ${filepath} ocloc ) diff --git a/shared/source/built_ins/kernels/CMakeLists.txt b/shared/source/built_ins/kernels/CMakeLists.txt index d7f923187c..c1a09ed0ac 100644 --- a/shared/source/built_ins/kernels/CMakeLists.txt +++ b/shared/source/built_ins/kernels/CMakeLists.txt @@ -35,7 +35,7 @@ if(NOT NEO_DISABLE_BUILTINS_COMPILATION) ) if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - list(APPEND __cloc__options__ "-D DEBUG") + list(APPEND __ocloc__options__ "-D DEBUG") endif() set(BUILTINS_INCLUDE_DIR ${TargetDir} PARENT_SCOPE) @@ -64,22 +64,11 @@ if(NOT NEO_DISABLE_BUILTINS_COMPILATION) ${OUTPUTDIR}/${mode}_${BASENAME}_${family_name_with_type}.spv ) - if(NOT DEFINED cloc_cmd_prefix) - if(WIN32) - set(cloc_cmd_prefix ocloc) - else() - if(DEFINED NEO__IGC_LIBRARY_PATH) - set(cloc_cmd_prefix LD_LIBRARY_PATH=${NEO__IGC_LIBRARY_PATH}:$ $) - else() - set(cloc_cmd_prefix LD_LIBRARY_PATH=$ $) - endif() - endif() - endif() - list(APPEND __cloc__options__ "-cl-kernel-arg-info") + list(APPEND __ocloc__options__ "-cl-kernel-arg-info") set(INTERNAL_OPTIONS "${${mode}_OPTIONS}") add_custom_command( OUTPUT ${OUTPUT_FILE_SPV} - COMMAND ${cloc_cmd_prefix} -q -file ${FILENAME} -spv_only -device ${DEFAULT_SUPPORTED_${gen_type}_${platform_type}_PLATFORM} ${builtin_options} -${bits} -output ${mode}_${BASENAME} -out_dir ${OUTPUTDIR} ${INTERNAL_OPTIONS} -options "$" + COMMAND ${ocloc_cmd_prefix} -q -file ${FILENAME} -spv_only -device ${DEFAULT_SUPPORTED_${gen_type}_${platform_type}_PLATFORM} ${builtin_options} -${bits} -output ${mode}_${BASENAME} -out_dir ${OUTPUTDIR} ${INTERNAL_OPTIONS} -options "$" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${builtin} ocloc copy_compiler_files ) @@ -95,7 +84,7 @@ if(NOT NEO_DISABLE_BUILTINS_COMPILATION) list(APPEND BUILTINS_COMMANDS "${OUTPUT_FILE_CPP}") add_custom_command( OUTPUT ${OUTPUT_FILES_BINARIES} - COMMAND ${cloc_cmd_prefix} -q -file ${OUTPUT_FILE_SPV} -spirv_input -device ${DEFAULT_SUPPORTED_${gen_type}_${platform_type}_PLATFORM} ${builtin_options} -${bits} -output ${mode}_${BASENAME}_${REVISION_ID} -out_dir ${OUTPUTDIR} -revision_id ${REVISION_ID} ${INTERNAL_OPTIONS} -options "$" + COMMAND ${ocloc_cmd_prefix} -q -file ${OUTPUT_FILE_SPV} -spirv_input -device ${DEFAULT_SUPPORTED_${gen_type}_${platform_type}_PLATFORM} ${builtin_options} -${bits} -output ${mode}_${BASENAME}_${REVISION_ID} -out_dir ${OUTPUTDIR} -revision_id ${REVISION_ID} ${INTERNAL_OPTIONS} -options "$" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${OUTPUT_FILE_SPV} ocloc copy_compiler_files ) @@ -110,18 +99,6 @@ if(NOT NEO_DISABLE_BUILTINS_COMPILATION) endfunction() function(generate_cpp_spirv builtin) - if(NOT DEFINED cloc_cmd_prefix) - if(WIN32) - set(cloc_cmd_prefix $) - else() - if(DEFINED NEO__IGC_LIBRARY_PATH) - set(cloc_cmd_prefix LD_LIBRARY_PATH=${NEO__IGC_LIBRARY_PATH}:$ $) - else() - set(cloc_cmd_prefix LD_LIBRARY_PATH=$ $) - endif() - endif() - endif() - get_filename_component(BASENAME ${builtin} NAME_WE) get_filename_component(DIR ${builtin} DIRECTORY) @@ -139,7 +116,7 @@ if(NOT NEO_DISABLE_BUILTINS_COMPILATION) set(OUTPUT_LIST_CPP_FILES ${OUTPUT_LIST_CPP_FILES} ${OUTPUT_FILE_CPP} PARENT_SCOPE) add_custom_command( OUTPUT ${GENERATED_SPV_INPUT} - COMMAND ${cloc_cmd_prefix} -q -spv_only -file ${INPUT_FILENAME} -out_dir ${OUTPUTDIR} -output_no_suffix -options "-cl-kernel-arg-info" + COMMAND ${ocloc_cmd_prefix} -q -spv_only -file ${INPUT_FILENAME} -out_dir ${OUTPUTDIR} -output_no_suffix -options "-cl-kernel-arg-info" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${INPUT_FILENAME} ocloc copy_compiler_files ) diff --git a/shared/test/common/test_files/CMakeLists.txt b/shared/test/common/test_files/CMakeLists.txt index bd26771475..e7d627c3e0 100644 --- a/shared/test/common/test_files/CMakeLists.txt +++ b/shared/test/common/test_files/CMakeLists.txt @@ -5,18 +5,6 @@ # set(SHARED_TEST_PROJECTS_SUB_FOLDER "prepare test files") -if(NOT DEFINED cloc_cmd_prefix) - if(WIN32) - set(cloc_cmd_prefix ocloc) - else() - if(DEFINED NEO__IGC_LIBRARY_PATH) - set(cloc_cmd_prefix LD_LIBRARY_PATH=${NEO__IGC_LIBRARY_PATH}:$ $) - else() - set(cloc_cmd_prefix LD_LIBRARY_PATH=$ $) - endif() - endif() -endif() - function(compile_kernels_gen platform_name_with_type revision_id platform_name suffix) set(outputdir "${TargetDir}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/") @@ -38,7 +26,7 @@ function(compile_kernels_gen platform_name_with_type revision_id platform_name s add_custom_command( OUTPUT ${output_files} - COMMAND ${cloc_cmd_prefix} -file ${filename} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -revision_id ${revision_id} + COMMAND ${ocloc_cmd_prefix} -file ${filename} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -revision_id ${revision_id} WORKING_DIRECTORY ${workdir} DEPENDS ${filepath} ocloc copy_compiler_files )