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:
Kacper Nowak
2022-08-31 19:16:06 +00:00
committed by Compute-Runtime-Automation
parent ceff16084d
commit b41eed8438
8 changed files with 76 additions and 55 deletions

View File

@ -22,7 +22,6 @@ function(level_zero_generate_kernels target_list platform_name suffix revision_i
if(NOT NEO_DISABLE_BUILTINS_COMPILATION) if(NOT NEO_DISABLE_BUILTINS_COMPILATION)
set(output_files set(output_files
${outputpath_base}.bin ${outputpath_base}.bin
${outputpath_base}.gen
${outputpath_base}.spv ${outputpath_base}.spv
${outputpath_base}.dbg ${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}) list(APPEND ${target_list} ${output_files})
else() else()
foreach(_file_name "bin" "gen" "spv" "dbg") foreach(extension "bin" "spv" "dbg")
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${relativeDir}/${basename}_${suffix}.${_file_name}") set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${relativeDir}/${basename}_${suffix}.${extension}")
add_custom_command( add_custom_command(
OUTPUT ${outputpath_base}.${_file_name} OUTPUT ${outputpath_base}.${extension}
COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir} COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_file_prebuilt} ${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() endforeach()
endif() endif()
endforeach() endforeach()
@ -72,7 +71,6 @@ function(level_zero_generate_kernels_with_internal_options target_list platform_
if(NOT NEO_DISABLE_BUILTINS_COMPILATION) if(NOT NEO_DISABLE_BUILTINS_COMPILATION)
set(output_files set(output_files
${outputpath_base}.bin ${outputpath_base}.bin
${outputpath_base}.gen
${outputpath_base}.spv ${outputpath_base}.spv
${outputpath_base}.dbg ${outputpath_base}.dbg
) )
@ -89,15 +87,15 @@ function(level_zero_generate_kernels_with_internal_options target_list platform_
list(APPEND ${target_list} ${output_files}) list(APPEND ${target_list} ${output_files})
else() else()
foreach(_file_name "bin" "gen" "spv" "dbg") foreach(extension "bin" "spv" "dbg")
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${relativeDir}/${prefix}_${basename}_${suffix}.${_file_name}") set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${relativeDir}/${prefix}_${basename}_${suffix}.${extension}")
add_custom_command( add_custom_command(
OUTPUT ${outputpath_base}.${_file_name} OUTPUT ${outputpath_base}.${extension}
COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir} COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_file_prebuilt} ${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() endforeach()
endif() endif()
endforeach() endforeach()

View File

@ -38,7 +38,7 @@ components:
dest_dir: kernels_bin dest_dir: kernels_bin
type: git type: git
branch: kernels_bin branch: kernels_bin
revision: 1941-290 revision: 1941-293
kmdaf: kmdaf:
branch: kmdaf branch: kmdaf
dest_dir: kmdaf dest_dir: kmdaf

View File

@ -154,15 +154,15 @@ function(neo_gen_kernels platform_name_with_type platform_name revision_id suffi
list(APPEND kernels_to_compile ${output_files}) list(APPEND kernels_to_compile ${output_files})
else() else()
foreach(_file_name "spv" "bin" "gen") foreach(extension "spv" "bin" "gen")
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${basename}_${suffix}.${_file_name}") set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${basename}_${suffix}.${extension}")
add_custom_command( add_custom_command(
OUTPUT ${outputpath_base}.${_file_name} OUTPUT ${outputpath_base}.${extension}
COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir} COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_file_prebuilt} ${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() endforeach()
endif() endif()
endforeach() endforeach()
@ -183,32 +183,32 @@ function(neo_gen_kernels_with_options platform_name_with_type platform_name revi
foreach(arg ${ARGN}) foreach(arg ${ARGN})
string(REPLACE " " "_" argwospaces ${arg}) string(REPLACE " " "_" argwospaces ${arg})
set(base_filename ${basename}_${argwospaces})
set(outputpath_base "${outputdir}/${basename}_${suffix}") set(outputpath_base "${outputdir}/${base_filename}_${suffix}")
if(NOT NEO_DISABLE_BUILTINS_COMPILATION) if(NOT NEO_DISABLE_BUILTINS_COMPILATION)
set(output_files set(output_files
${outputpath_base}.spv${argwospaces} ${outputpath_base}.spv
${outputpath_base}.bin${argwospaces} ${outputpath_base}.bin
${outputpath_base}.gen${argwospaces} ${outputpath_base}.gen
) )
add_custom_command( add_custom_command(
OUTPUT ${output_files} 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} WORKING_DIRECTORY ${workdir}
DEPENDS ${filearg} ocloc DEPENDS ${filearg} ocloc
) )
list(APPEND kernels_to_compile ${output_files}) list(APPEND kernels_to_compile ${output_files})
else() else()
foreach(_file_name "spv" "bin" "gen") foreach(extension "spv" "bin" "gen")
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${basename}_${suffix}.${_file_name}${argwospaces}") set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${base_filename}_${suffix}.${extension}")
add_custom_command( 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 make_directory ${outputdir}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_file_prebuilt} ${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() endforeach()
endif() endif()
endforeach() 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}) list(APPEND kernels_to_compile_${platform_name_with_type}_${revision_id} ${output_files})
else() else()
foreach(_file_name "spv" "bin" "gen") foreach(extension "spv" "bin" "gen")
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${basename}_${suffix}.${_file_name}") set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${basename}_${suffix}.${extension}")
add_custom_command( add_custom_command(
OUTPUT ${outputpath_base}.${_file_name} OUTPUT ${outputpath_base}.${extension}
COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir} COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_file_prebuilt} ${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() endforeach()
endif() 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}) list(APPEND kernels_to_compile_${platform_name_with_type}_${revision_id} ${output_files})
else() else()
foreach(_file_name "spv" "bin" "gen" "dbg") foreach(extension "spv" "bin" "gen" "dbg")
set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${argwospaces}_${suffix}.${_file_name}") set(_file_prebuilt "${NEO_KERNELS_BIN_DIR}/${suffix}/${revision_id}/test_files/${NEO_ARCH}/${argwospaces}_${suffix}.${extension}")
add_custom_command( add_custom_command(
OUTPUT ${outputpath_base}.${_file_name} OUTPUT ${outputpath_base}.${extension}
COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir} COMMAND ${CMAKE_COMMAND} -E make_directory ${outputdir}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_file_prebuilt} ${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() endforeach()
endif() endif()
set(kernels_to_compile_${platform_name_with_type}_${revision_id} ${kernels_to_compile_${platform_name_with_type}_${revision_id}} PARENT_SCOPE) set(kernels_to_compile_${platform_name_with_type}_${revision_id} ${kernels_to_compile_${platform_name_with_type}_${revision_id}} PARENT_SCOPE)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018-2021 Intel Corporation * Copyright (C) 2018-2022 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -22,6 +22,9 @@ KernelBinaryHelper::KernelBinaryHelper(const std::string &name, bool appendOptio
retrieveBinaryKernelFilename(fclDebugVars.fileName, name + "_", ".bc"); retrieveBinaryKernelFilename(fclDebugVars.fileName, name + "_", ".bc");
retrieveBinaryKernelFilename(igcDebugVars.fileName, name + "_", ".gen"); retrieveBinaryKernelFilename(igcDebugVars.fileName, name + "_", ".gen");
appendBinaryNameSuffix(fclDebugVars.fileNameSuffix);
appendBinaryNameSuffix(igcDebugVars.fileNameSuffix);
fclDebugVars.appendOptionsToFileName = appendOptionsToFileName; fclDebugVars.appendOptionsToFileName = appendOptionsToFileName;
igcDebugVars.appendOptionsToFileName = appendOptionsToFileName; igcDebugVars.appendOptionsToFileName = appendOptionsToFileName;

View File

@ -26,9 +26,12 @@ void retrieveBinaryKernelFilename(std::string &outputFilename, const std::string
outputFilename.reserve(2 * testFiles.length()); outputFilename.reserve(2 * testFiles.length());
outputFilename.append(testFiles); outputFilename.append(testFiles);
outputFilename.append(kernelName); outputFilename.append(kernelName);
if (false == options.empty()) {
outputFilename.append(options);
outputFilename.append("_");
}
outputFilename.append(binaryNameSuffix); outputFilename.append(binaryNameSuffix);
outputFilename.append(extension); outputFilename.append(extension);
outputFilename.append(options);
if (!fileExists(outputFilename) && (extension == ".bc")) { if (!fileExists(outputFilename) && (extension == ".bc")) {
retrieveBinaryKernelFilename(outputFilename, kernelName, ".spv", options); retrieveBinaryKernelFilename(outputFilename, kernelName, ".spv", options);
@ -50,3 +53,7 @@ void retrieveBinaryKernelFilenameApiSpecific(std::string &outputFilename, const
retrieveBinaryKernelFilename(outputFilename, kernelName, ".spv", options); retrieveBinaryKernelFilename(outputFilename, kernelName, ".spv", options);
} }
} }
void appendBinaryNameSuffix(std::string &outputFileNameSuffix) {
outputFileNameSuffix.append(binaryNameSuffix);
}

View File

@ -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 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 retrieveBinaryKernelFilenameApiSpecific(std::string &outputFilename, const std::string &kernelName, const std::string &extension, const std::string &options = "");
void appendBinaryNameSuffix(std::string &outputFileNameSuffix);

View File

@ -420,30 +420,41 @@ void translate(bool usingIgc, CIF::Builtins::BufferSimple *src, CIF::Builtins::B
} }
} }
std::string inputFile = ""; std::string inputFile{}, debugFile{};
inputFile.append(debugVars.fileName); std::string opts(options->GetMemory<char>(), options->GetMemory<char>() + options->GetSize<char>());
if (false == debugVars.fileName.empty()) {
std::string debugFile; auto fileBaseName = debugVars.fileName;
auto pos = inputFile.rfind("."); auto pos = debugVars.fileName.rfind(".");
debugFile = inputFile.substr(0, pos); auto extension = debugVars.fileName.substr(pos, debugVars.fileName.length());
debugFile.append(".dbg"); if (false == debugVars.fileNameSuffix.empty()) {
pos = debugVars.fileName.rfind(debugVars.fileNameSuffix);
if (debugVars.appendOptionsToFileName &&
options->GetSizeRaw()) {
std::string opts(options->GetMemory<char>(), options->GetMemory<char>() + options->GetSize<char>());
// 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());
} }
std::replace(opts.begin(), opts.end(), ' ', '_'); fileBaseName = fileBaseName.substr(0, pos);
inputFile.append(opts);
if (debugVars.debugDataToReturn == nullptr) { if (debugVars.appendOptionsToFileName && false == opts.empty()) {
debugFile.append(opts); // handle special option "-create-library" - just erase it
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(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)) { if ((debugVars.binaryToReturn != nullptr) || (debugVars.binaryToReturnSize != 0)) {
out->setOutput(debugVars.binaryToReturn, debugVars.binaryToReturnSize); out->setOutput(debugVars.binaryToReturn, debugVars.binaryToReturnSize);
} else { } else {

View File

@ -46,6 +46,7 @@ struct MockCompilerDebugVars {
std::string *receivedInput = nullptr; std::string *receivedInput = nullptr;
std::string fileName; std::string fileName;
std::string fileNameSuffix;
std::string translationContextCreationError; std::string translationContextCreationError;
}; };