diff --git a/opencl/source/program/process_device_binary.cpp b/opencl/source/program/process_device_binary.cpp index 2b3c0fb93b..39e953891f 100644 --- a/opencl/source/program/process_device_binary.cpp +++ b/opencl/source/program/process_device_binary.cpp @@ -15,6 +15,7 @@ #include "shared/source/helpers/aligned_memory.h" #include "shared/source/helpers/compiler_product_helper.h" #include "shared/source/helpers/debug_helpers.h" +#include "shared/source/helpers/file_io.h" #include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/ptr_math.h" #include "shared/source/helpers/string.h" @@ -204,6 +205,10 @@ cl_int Program::processGenBinary(const ClDevice &clDevice) { } else { return CL_INVALID_BINARY; } + } else { + if (NEO::debugManager.flags.DumpZEBin.get() == 1 && isDeviceBinaryFormat(ArrayRef(reinterpret_cast(this->buildInfos[rootDeviceIndex].unpackedDeviceBinary.get()), this->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize))) { + dumpFileIncrement(this->buildInfos[rootDeviceIndex].unpackedDeviceBinary.get(), this->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize, "dumped_zebin_module", ".elf"); + } } cleanCurrentKernelInfo(rootDeviceIndex); diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index 5b416a5921..0174777252 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -33,6 +33,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/gtest_helpers.h" #include "shared/test/common/helpers/kernel_binary_helper.h" +#include "shared/test/common/helpers/mock_file_io.h" #include "shared/test/common/helpers/test_files.h" #include "shared/test/common/libult/global_environment.h" #include "shared/test/common/libult/ult_command_stream_receiver.h" @@ -1018,6 +1019,26 @@ TEST_F(ProgramFromSourceTest, WhenCompilingProgramWithOpenClC30ThenFeaturesAreAd EXPECT_TRUE(hasSubstr(pCompilerInterface->buildInternalOptions, extensionsWithFeaturesOption)); } +TEST_F(ProgramFromSourceTest, GivenDumpZEBinWhenBuildingProgramFromSourceThenZebinIsDumped) { + DebugManagerStateRestore restorer; + debugManager.flags.DumpZEBin.set(1); + + KernelBinaryHelper kbHelper(binaryFileName, true); + + createProgramWithSource( + pContext, + sourceFileName); + + std::string fileName = "dumped_zebin_module.elf"; + EXPECT_FALSE(virtualFileExists(fileName)); + + retVal = pProgram->build(pProgram->getDevices(), nullptr); + EXPECT_EQ(CL_SUCCESS, retVal); + + EXPECT_TRUE(virtualFileExists(fileName)); + removeVirtualFile(fileName); +} + class Callback { public: Callback() {