mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Refactoring Level Zero ULTs in order to use standalone spirv builtins
Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
c8d1e082dd
commit
4804eca86d
@@ -5,7 +5,7 @@
|
||||
#
|
||||
|
||||
set(SHARED_TEST_PROJECTS_FOLDER "neo shared")
|
||||
if(NOT SKIP_NEO_UNIT_TESTS AND NOT SKIP_UNIT_TESTS)
|
||||
if(NOT SKIP_UNIT_TESTS)
|
||||
|
||||
set(TARGET_NAME neo_shared_tests)
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "config.h"
|
||||
|
||||
std::string testFiles("test_files/" NEO_ARCH "/");
|
||||
std::string testFilesNoRev("test_files/" NEO_ARCH "/");
|
||||
std::string clFiles("test_files/");
|
||||
std::string binaryNameSuffix("");
|
||||
|
||||
@@ -30,3 +31,19 @@ void retrieveBinaryKernelFilename(std::string &outputFilename, const std::string
|
||||
retrieveBinaryKernelFilename(outputFilename, kernelName, ".spv", options);
|
||||
}
|
||||
}
|
||||
|
||||
void retrieveBinaryKernelFilenameNoRevision(std::string &outputFilename, const std::string &kernelName, const std::string &extension, const std::string &options) {
|
||||
if (outputFilename.length() > 0) {
|
||||
outputFilename.clear();
|
||||
}
|
||||
outputFilename.reserve(2 * testFilesNoRev.length());
|
||||
outputFilename.append(testFilesNoRev);
|
||||
outputFilename.append(kernelName);
|
||||
outputFilename.append(binaryNameSuffix);
|
||||
outputFilename.append(extension);
|
||||
outputFilename.append(options);
|
||||
|
||||
if (!fileExists(outputFilename) && (extension == ".bc")) {
|
||||
retrieveBinaryKernelFilename(outputFilename, kernelName, ".spv", options);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,9 @@
|
||||
#include <string>
|
||||
|
||||
extern std::string testFiles;
|
||||
extern std::string testFilesNoRev;
|
||||
extern std::string clFiles;
|
||||
extern std::string binaryNameSuffix;
|
||||
|
||||
void retrieveBinaryKernelFilename(std::string &outputFilename, const std::string &kernelName, const std::string &extension, const std::string &options = "");
|
||||
void retrieveBinaryKernelFilenameNoRevision(std::string &outputFilename, const std::string &kernelName, const std::string &extension, const std::string &options = "");
|
||||
|
||||
@@ -8,6 +8,8 @@ set(NEO_CORE_tests_mocks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_command_stream_receiver.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_command_stream_receiver.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_compiler_interface_spirv.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_compiler_interface_spirv.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_direct_submission_hw.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_direct_submission_diagnostic_collector.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_dispatch_kernel_encoder_interface.cpp
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/unit_test/mocks/mock_compiler_interface_spirv.h"
|
||||
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/test/unit_test/helpers/test_files.h"
|
||||
|
||||
#include "opencl/test/unit_test/global_environment.h"
|
||||
#include "opencl/test/unit_test/helpers/kernel_binary_helper.h"
|
||||
|
||||
namespace NEO {
|
||||
TranslationOutput::ErrorCode MockCompilerInterfaceSpirv::compile(const NEO::Device &device, const TranslationInput &input, TranslationOutput &output) {
|
||||
std::string kernelName;
|
||||
retrieveBinaryKernelFilename(kernelName, KernelBinaryHelper::BUILT_INS + "_", ".gen");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(
|
||||
kernelName.c_str(),
|
||||
size);
|
||||
output.deviceBinary.mem = std::move(src);
|
||||
output.deviceBinary.size = size;
|
||||
output.intermediateCodeType = IGC::CodeType::spirV;
|
||||
|
||||
return TranslationOutput::ErrorCode::Success;
|
||||
}
|
||||
TranslationOutput::ErrorCode MockCompilerInterfaceSpirv::build(const NEO::Device &device, const TranslationInput &input, TranslationOutput &out) {
|
||||
return this->compile(device, input, out);
|
||||
}
|
||||
} // namespace NEO
|
||||
18
shared/test/unit_test/mocks/mock_compiler_interface_spirv.h
Normal file
18
shared/test/unit_test/mocks/mock_compiler_interface_spirv.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/test/unit_test/mocks/mock_compiler_interface.h"
|
||||
|
||||
#include "cif/common/cif_main.h"
|
||||
|
||||
namespace NEO {
|
||||
class MockCompilerInterfaceSpirv : public MockCompilerInterface {
|
||||
TranslationOutput::ErrorCode compile(const NEO::Device &device, const TranslationInput &input, TranslationOutput &output) override;
|
||||
TranslationOutput::ErrorCode build(const NEO::Device &device, const TranslationInput &input, TranslationOutput &out) override;
|
||||
};
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user