mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
CMake: correct test kernels naming + minor improvements
- For test kernels compiled with options passed, change their naming to following convention: {basename}_{options_passed}_{suffix}. - Correct CMake variables naming. - Refactor logic of retrieving test kernels' data (also in compilers mock) - In relation to previous changes: do not generate unnecessary .gen binary for L0 test kernel Related-To: NEO-7285 Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
ceff16084d
commit
b41eed8438
@ -22,7 +22,6 @@ function(level_zero_generate_kernels target_list platform_name suffix revision_i
|
||||
if(NOT NEO_DISABLE_BUILTINS_COMPILATION)
|
||||
set(output_files
|
||||
${outputpath_base}.bin
|
||||
${outputpath_base}.gen
|
||||
${outputpath_base}.spv
|
||||
${outputpath_base}.dbg
|
||||
)
|
||||
@ -37,15 +36,15 @@ function(level_zero_generate_kernels target_list platform_name suffix revision_i
|
||||
|
||||
list(APPEND ${target_list} ${output_files})
|
||||
else()
|
||||
foreach(_file_name "bin" "gen" "spv" "dbg")
|
||||
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${relativeDir}/${basename}_${suffix}.${_file_name}")
|
||||
foreach(extension "bin" "spv" "dbg")
|
||||
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${relativeDir}/${basename}_${suffix}.${extension}")
|
||||
add_custom_command(
|
||||
OUTPUT ${outputpath_base}.${_file_name}
|
||||
OUTPUT ${outputpath_base}.${extension}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_file_prebuilt} ${outputdir}
|
||||
)
|
||||
|
||||
list(APPEND ${target_list} ${outputpath_base}.${_file_name})
|
||||
list(APPEND ${target_list} ${outputpath_base}.${extension})
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
@ -72,7 +71,6 @@ function(level_zero_generate_kernels_with_internal_options target_list platform_
|
||||
if(NOT NEO_DISABLE_BUILTINS_COMPILATION)
|
||||
set(output_files
|
||||
${outputpath_base}.bin
|
||||
${outputpath_base}.gen
|
||||
${outputpath_base}.spv
|
||||
${outputpath_base}.dbg
|
||||
)
|
||||
@ -89,15 +87,15 @@ function(level_zero_generate_kernels_with_internal_options target_list platform_
|
||||
|
||||
list(APPEND ${target_list} ${output_files})
|
||||
else()
|
||||
foreach(_file_name "bin" "gen" "spv" "dbg")
|
||||
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${relativeDir}/${prefix}_${basename}_${suffix}.${_file_name}")
|
||||
foreach(extension "bin" "spv" "dbg")
|
||||
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${relativeDir}/${prefix}_${basename}_${suffix}.${extension}")
|
||||
add_custom_command(
|
||||
OUTPUT ${outputpath_base}.${_file_name}
|
||||
OUTPUT ${outputpath_base}.${extension}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_file_prebuilt} ${outputdir}
|
||||
)
|
||||
|
||||
list(APPEND ${target_list} ${outputpath_base}.${_file_name})
|
||||
list(APPEND ${target_list} ${outputpath_base}.${extension})
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
|
@ -38,7 +38,7 @@ components:
|
||||
dest_dir: kernels_bin
|
||||
type: git
|
||||
branch: kernels_bin
|
||||
revision: 1941-290
|
||||
revision: 1941-293
|
||||
kmdaf:
|
||||
branch: kmdaf
|
||||
dest_dir: kmdaf
|
||||
|
@ -154,15 +154,15 @@ function(neo_gen_kernels platform_name_with_type platform_name revision_id suffi
|
||||
|
||||
list(APPEND kernels_to_compile ${output_files})
|
||||
else()
|
||||
foreach(_file_name "spv" "bin" "gen")
|
||||
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${basename}_${suffix}.${_file_name}")
|
||||
foreach(extension "spv" "bin" "gen")
|
||||
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${basename}_${suffix}.${extension}")
|
||||
add_custom_command(
|
||||
OUTPUT ${outputpath_base}.${_file_name}
|
||||
OUTPUT ${outputpath_base}.${extension}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_file_prebuilt} ${outputdir}
|
||||
)
|
||||
|
||||
list(APPEND kernels_to_compile_${platform_name_with_type}_${revision_id} ${outputpath_base}.${_file_name})
|
||||
list(APPEND kernels_to_compile_${platform_name_with_type}_${revision_id} ${outputpath_base}.${extension})
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
@ -183,32 +183,32 @@ function(neo_gen_kernels_with_options platform_name_with_type platform_name revi
|
||||
|
||||
foreach(arg ${ARGN})
|
||||
string(REPLACE " " "_" argwospaces ${arg})
|
||||
|
||||
set(outputpath_base "${outputdir}/${basename}_${suffix}")
|
||||
set(base_filename ${basename}_${argwospaces})
|
||||
set(outputpath_base "${outputdir}/${base_filename}_${suffix}")
|
||||
if(NOT NEO_DISABLE_BUILTINS_COMPILATION)
|
||||
set(output_files
|
||||
${outputpath_base}.spv${argwospaces}
|
||||
${outputpath_base}.bin${argwospaces}
|
||||
${outputpath_base}.gen${argwospaces}
|
||||
${outputpath_base}.spv
|
||||
${outputpath_base}.bin
|
||||
${outputpath_base}.gen
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${output_files}
|
||||
COMMAND ${ocloc_cmd_prefix} -gen_file -file ${absolute_filepath} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -revision_id ${revision_id} -options ${arg} -options_name
|
||||
COMMAND ${ocloc_cmd_prefix} -gen_file -file ${absolute_filepath} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -revision_id ${revision_id} -options ${arg} -output ${base_filename}
|
||||
WORKING_DIRECTORY ${workdir}
|
||||
DEPENDS ${filearg} ocloc
|
||||
)
|
||||
list(APPEND kernels_to_compile ${output_files})
|
||||
else()
|
||||
foreach(_file_name "spv" "bin" "gen")
|
||||
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${basename}_${suffix}.${_file_name}${argwospaces}")
|
||||
foreach(extension "spv" "bin" "gen")
|
||||
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${base_filename}_${suffix}.${extension}")
|
||||
add_custom_command(
|
||||
OUTPUT ${outputpath_base}.${_file_name}${argwospaces}
|
||||
OUTPUT ${outputpath_base}_${suffix}.${extension}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_file_prebuilt} ${outputdir}
|
||||
)
|
||||
|
||||
list(APPEND kernels_to_compile_${platform_name_with_type}_${revision_id} ${outputpath_base}.${_file_name}${argwospaces})
|
||||
list(APPEND kernels_to_compile_${platform_name_with_type}_${revision_id} ${outputpath_base}_${suffix}.${extension})
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
@ -253,15 +253,15 @@ function(neo_gen_kernels_with_internal_options platform_name_with_type platform_
|
||||
)
|
||||
list(APPEND kernels_to_compile_${platform_name_with_type}_${revision_id} ${output_files})
|
||||
else()
|
||||
foreach(_file_name "spv" "bin" "gen")
|
||||
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${basename}_${suffix}.${_file_name}")
|
||||
foreach(extension "spv" "bin" "gen")
|
||||
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${basename}_${suffix}.${extension}")
|
||||
add_custom_command(
|
||||
OUTPUT ${outputpath_base}.${_file_name}
|
||||
OUTPUT ${outputpath_base}.${extension}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_file_prebuilt} ${outputdir}
|
||||
)
|
||||
|
||||
list(APPEND kernels_to_compile_${platform_name_with_type}_${revision_id} ${outputpath_base}.${_file_name})
|
||||
list(APPEND kernels_to_compile_${platform_name_with_type}_${revision_id} ${outputpath_base}.${extension})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
@ -301,15 +301,15 @@ function(neo_gen_kernel_with_kernel_debug_options platform_name_with_type platfo
|
||||
)
|
||||
list(APPEND kernels_to_compile_${platform_name_with_type}_${revision_id} ${output_files})
|
||||
else()
|
||||
foreach(_file_name "spv" "bin" "gen" "dbg")
|
||||
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${argwospaces}_${suffix}.${_file_name}")
|
||||
foreach(extension "spv" "bin" "gen" "dbg")
|
||||
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${argwospaces}_${suffix}.${extension}")
|
||||
add_custom_command(
|
||||
OUTPUT ${outputpath_base}.${_file_name}
|
||||
OUTPUT ${outputpath_base}.${extension}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_file_prebuilt} ${outputdir}
|
||||
)
|
||||
|
||||
list(APPEND kernels_to_compile_${platform_name_with_type}_${revision_id} ${outputpath_base}.${_file_name})
|
||||
list(APPEND kernels_to_compile_${platform_name_with_type}_${revision_id} ${outputpath_base}.${extension})
|
||||
endforeach()
|
||||
endif()
|
||||
set(kernels_to_compile_${platform_name_with_type}_${revision_id} ${kernels_to_compile_${platform_name_with_type}_${revision_id}} PARENT_SCOPE)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -22,6 +22,9 @@ KernelBinaryHelper::KernelBinaryHelper(const std::string &name, bool appendOptio
|
||||
retrieveBinaryKernelFilename(fclDebugVars.fileName, name + "_", ".bc");
|
||||
retrieveBinaryKernelFilename(igcDebugVars.fileName, name + "_", ".gen");
|
||||
|
||||
appendBinaryNameSuffix(fclDebugVars.fileNameSuffix);
|
||||
appendBinaryNameSuffix(igcDebugVars.fileNameSuffix);
|
||||
|
||||
fclDebugVars.appendOptionsToFileName = appendOptionsToFileName;
|
||||
igcDebugVars.appendOptionsToFileName = appendOptionsToFileName;
|
||||
|
||||
|
@ -26,9 +26,12 @@ void retrieveBinaryKernelFilename(std::string &outputFilename, const std::string
|
||||
outputFilename.reserve(2 * testFiles.length());
|
||||
outputFilename.append(testFiles);
|
||||
outputFilename.append(kernelName);
|
||||
if (false == options.empty()) {
|
||||
outputFilename.append(options);
|
||||
outputFilename.append("_");
|
||||
}
|
||||
outputFilename.append(binaryNameSuffix);
|
||||
outputFilename.append(extension);
|
||||
outputFilename.append(options);
|
||||
|
||||
if (!fileExists(outputFilename) && (extension == ".bc")) {
|
||||
retrieveBinaryKernelFilename(outputFilename, kernelName, ".spv", options);
|
||||
@ -50,3 +53,7 @@ void retrieveBinaryKernelFilenameApiSpecific(std::string &outputFilename, const
|
||||
retrieveBinaryKernelFilename(outputFilename, kernelName, ".spv", options);
|
||||
}
|
||||
}
|
||||
|
||||
void appendBinaryNameSuffix(std::string &outputFileNameSuffix) {
|
||||
outputFileNameSuffix.append(binaryNameSuffix);
|
||||
}
|
@ -17,3 +17,4 @@ extern std::string binaryNameSuffix;
|
||||
|
||||
void retrieveBinaryKernelFilename(std::string &outputFilename, const std::string &kernelName, const std::string &extension, const std::string &options = "");
|
||||
void retrieveBinaryKernelFilenameApiSpecific(std::string &outputFilename, const std::string &kernelName, const std::string &extension, const std::string &options = "");
|
||||
void appendBinaryNameSuffix(std::string &outputFileNameSuffix);
|
@ -420,30 +420,41 @@ void translate(bool usingIgc, CIF::Builtins::BufferSimple *src, CIF::Builtins::B
|
||||
}
|
||||
}
|
||||
|
||||
std::string inputFile = "";
|
||||
inputFile.append(debugVars.fileName);
|
||||
|
||||
std::string debugFile;
|
||||
auto pos = inputFile.rfind(".");
|
||||
debugFile = inputFile.substr(0, pos);
|
||||
debugFile.append(".dbg");
|
||||
|
||||
if (debugVars.appendOptionsToFileName &&
|
||||
options->GetSizeRaw()) {
|
||||
std::string inputFile{}, debugFile{};
|
||||
std::string opts(options->GetMemory<char>(), options->GetMemory<char>() + options->GetSize<char>());
|
||||
if (false == debugVars.fileName.empty()) {
|
||||
auto fileBaseName = debugVars.fileName;
|
||||
auto pos = debugVars.fileName.rfind(".");
|
||||
auto extension = debugVars.fileName.substr(pos, debugVars.fileName.length());
|
||||
if (false == debugVars.fileNameSuffix.empty()) {
|
||||
pos = debugVars.fileName.rfind(debugVars.fileNameSuffix);
|
||||
}
|
||||
fileBaseName = fileBaseName.substr(0, pos);
|
||||
|
||||
if (debugVars.appendOptionsToFileName && false == opts.empty()) {
|
||||
// handle special option "-create-library" - just erase it
|
||||
size_t pos = opts.find(CompilerOptions::createLibrary.data(), 0);
|
||||
if (pos != std::string::npos) {
|
||||
opts.erase(pos, CompilerOptions::createLibrary.length());
|
||||
auto optPos = opts.find(CompilerOptions::createLibrary.data(), 0);
|
||||
if (optPos != std::string::npos) {
|
||||
opts.erase(optPos, CompilerOptions::createLibrary.length());
|
||||
}
|
||||
std::replace(opts.begin(), opts.end(), ' ', '_');
|
||||
inputFile.append(opts);
|
||||
|
||||
if (debugVars.debugDataToReturn == nullptr) {
|
||||
debugFile.append(opts);
|
||||
}
|
||||
}
|
||||
|
||||
inputFile.append(fileBaseName);
|
||||
debugFile.append(fileBaseName);
|
||||
|
||||
if (debugVars.appendOptionsToFileName && false == opts.empty()) {
|
||||
auto optString = opts + "_";
|
||||
inputFile.append(optString);
|
||||
debugFile.append(optString);
|
||||
}
|
||||
if (false == debugVars.fileNameSuffix.empty()) {
|
||||
inputFile.append(debugVars.fileNameSuffix);
|
||||
debugFile.append(debugVars.fileNameSuffix);
|
||||
}
|
||||
inputFile.append(extension);
|
||||
debugFile.append(".dbg");
|
||||
}
|
||||
if ((debugVars.binaryToReturn != nullptr) || (debugVars.binaryToReturnSize != 0)) {
|
||||
out->setOutput(debugVars.binaryToReturn, debugVars.binaryToReturnSize);
|
||||
} else {
|
||||
|
@ -46,6 +46,7 @@ struct MockCompilerDebugVars {
|
||||
std::string *receivedInput = nullptr;
|
||||
|
||||
std::string fileName;
|
||||
std::string fileNameSuffix;
|
||||
std::string translationContextCreationError;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user