Ocloc compile: return zebin format as is

If igc returns a zebin format ocloc should return it as it is.
This commit is contained in:
Krystian Chmielewski
2021-01-12 12:56:17 +01:00
committed by Compute-Runtime-Automation
parent af1bf59c43
commit db371ab6b9
3 changed files with 20 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2018-2020 Intel Corporation
# Copyright (C) 2018-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@@ -61,6 +61,7 @@ set(IGDRCL_SRCS_offline_compiler_tests
${NEO_SHARED_DIRECTORY}/helpers/file_io.cpp
${NEO_SHARED_DIRECTORY}/memory_manager/deferred_deleter.cpp
${NEO_SHARED_DIRECTORY}/memory_manager/deferred_deleter.h
${NEO_SHARED_TEST_DIRECTORY}/unit_test/device_binary_format/zebin_tests.h
${NEO_SHARED_TEST_DIRECTORY}/unit_test/helpers/test_files.cpp
${IGDRCL_SRCS_cloc}
${IGDRCL_SRCS_offline_compiler_mock}

View File

@@ -11,6 +11,7 @@
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/file_io.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/test/unit_test/device_binary_format/zebin_tests.h"
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
#include "opencl/source/platform/extensions.h"
@@ -1474,5 +1475,16 @@ TEST(OclocCompile, givenNoDeviceAndInternalOptionsOptionWhenCompilingToSpirvThen
EXPECT_EQ(0, retVal);
EXPECT_THAT(ocloc.internalOptions.c_str(), testing::HasSubstr("-ocl-version=300 -cl-ext=-all,+cl_khr_3d_image_writes -cl-ext=+custom_param"));
}
TEST(OclocCompile, givenPackedDeviceBinaryFormatWhenGeneratingElfBinaryItIsReturnedAsItIs) {
MockOfflineCompiler ocloc;
ZebinTestData::ValidEmptyProgram zebin;
// genBinary is deleted in ocloc's destructor
ocloc.genBinary = new char[zebin.storage.size()];
ocloc.genBinarySize = zebin.storage.size();
memcpy_s(ocloc.genBinary, ocloc.genBinarySize, zebin.storage.data(), zebin.storage.size());
ASSERT_EQ(true, ocloc.generateElfBinary());
EXPECT_EQ(0, memcmp(zebin.storage.data(), ocloc.elfBinary.data(), zebin.storage.size()));
}
} // namespace NEO

View File

@@ -903,6 +903,12 @@ bool OfflineCompiler::generateElfBinary() {
return false;
}
// return "as is" if zebin format
if (isDeviceBinaryFormat<DeviceBinaryFormat::Zebin>(ArrayRef<uint8_t>(reinterpret_cast<uint8_t *>(genBinary), genBinarySize))) {
this->elfBinary = std::vector<uint8_t>(genBinary, genBinary + genBinarySize);
return true;
}
SingleDeviceBinary binary = {};
binary.buildOptions = this->options;
binary.intermediateRepresentation = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(this->irBinary), this->irBinarySize);