|
8 | 8 | #include "opencl/test/unit_test/program/program_tests.h" |
9 | 9 |
|
10 | 10 | #include "shared/source/command_stream/command_stream_receiver_hw.h" |
| 11 | +#include "shared/source/compiler_interface/compiler_warnings/compiler_warnings.h" |
11 | 12 | #include "shared/source/compiler_interface/intermediate_representations.h" |
12 | 13 | #include "shared/source/device_binary_format/elf/elf_decoder.h" |
13 | 14 | #include "shared/source/device_binary_format/elf/ocl_elf.h" |
@@ -2577,6 +2578,76 @@ TEST_F(ProgramTests, givenProgramWithSpirvWhenRebuildProgramIsCalledThenSpirvPat |
2577 | 2578 | EXPECT_EQ(IGC::CodeType::oclGenBin, compilerInterface->requestedTranslationCtxs[0].second); |
2578 | 2579 | } |
2579 | 2580 |
|
| 2581 | +TEST_F(ProgramTests, givenProgramWithSpirvWhenRebuildIsCalledThenRebuildWarningIsIssued) { |
| 2582 | + const auto program{clUniquePtr(new MockProgram(toClDeviceVector(*pClDevice)))}; |
| 2583 | + uint32_t spirv[16] = {0x03022307, 0x23471113, 0x17192329}; |
| 2584 | + program->irBinary = makeCopy(spirv, sizeof(spirv)); |
| 2585 | + program->irBinarySize = sizeof(spirv); |
| 2586 | + program->isSpirV = true; |
| 2587 | + |
| 2588 | + const auto buildResult{program->rebuildProgramFromIr()}; |
| 2589 | + ASSERT_EQ(CL_SUCCESS, buildResult); |
| 2590 | + |
| 2591 | + const std::string buildLog{program->getBuildLog(pClDevice->getRootDeviceIndex())}; |
| 2592 | + const auto containsWarning{buildLog.find(CompilerWarnings::recompiledFromIr.data()) != std::string::npos}; |
| 2593 | + |
| 2594 | + EXPECT_TRUE(containsWarning); |
| 2595 | +} |
| 2596 | + |
| 2597 | +TEST_F(ProgramTests, givenProgramWithSpirvWhenRebuildIsCalledButSuppressFlagIsEnabledThenRebuildWarningIsNotIssued) { |
| 2598 | + const auto program{clUniquePtr(new MockProgram(toClDeviceVector(*pClDevice)))}; |
| 2599 | + uint32_t spirv[16] = {0x03022307, 0x23471113, 0x17192329}; |
| 2600 | + program->irBinary = makeCopy(spirv, sizeof(spirv)); |
| 2601 | + program->irBinarySize = sizeof(spirv); |
| 2602 | + program->isSpirV = true; |
| 2603 | + |
| 2604 | + const auto buildOptions{CompilerOptions::noRecompiledFromIr}; |
| 2605 | + program->setBuildOptions(buildOptions.data()); |
| 2606 | + |
| 2607 | + const auto buildResult{program->rebuildProgramFromIr()}; |
| 2608 | + ASSERT_EQ(CL_SUCCESS, buildResult); |
| 2609 | + |
| 2610 | + const std::string buildLog{program->getBuildLog(pClDevice->getRootDeviceIndex())}; |
| 2611 | + const auto containsWarning{buildLog.find(CompilerWarnings::recompiledFromIr.data()) != std::string::npos}; |
| 2612 | + |
| 2613 | + EXPECT_FALSE(containsWarning); |
| 2614 | +} |
| 2615 | + |
| 2616 | +TEST_F(ProgramTests, givenProgramWithSpirvWhenRecompileIsCalledThenRebuildWarningIsIssued) { |
| 2617 | + const auto program{clUniquePtr(new MockProgram(toClDeviceVector(*pClDevice)))}; |
| 2618 | + uint32_t spirv[16] = {0x03022307, 0x23471113, 0x17192329}; |
| 2619 | + program->irBinary = makeCopy(spirv, sizeof(spirv)); |
| 2620 | + program->irBinarySize = sizeof(spirv); |
| 2621 | + program->isSpirV = true; |
| 2622 | + |
| 2623 | + const auto compileResult{program->recompile()}; |
| 2624 | + ASSERT_EQ(CL_SUCCESS, compileResult); |
| 2625 | + |
| 2626 | + const std::string buildLog{program->getBuildLog(pClDevice->getRootDeviceIndex())}; |
| 2627 | + const auto containsWarning{buildLog.find(CompilerWarnings::recompiledFromIr.data()) != std::string::npos}; |
| 2628 | + |
| 2629 | + EXPECT_TRUE(containsWarning); |
| 2630 | +} |
| 2631 | + |
| 2632 | +TEST_F(ProgramTests, givenProgramWithSpirvWhenRecompileIsCalledButSuppressFlagIsEnabledThenRebuildWarningIsNotIssued) { |
| 2633 | + const auto program{clUniquePtr(new MockProgram(toClDeviceVector(*pClDevice)))}; |
| 2634 | + uint32_t spirv[16] = {0x03022307, 0x23471113, 0x17192329}; |
| 2635 | + program->irBinary = makeCopy(spirv, sizeof(spirv)); |
| 2636 | + program->irBinarySize = sizeof(spirv); |
| 2637 | + program->isSpirV = true; |
| 2638 | + |
| 2639 | + const auto buildOptions{CompilerOptions::noRecompiledFromIr}; |
| 2640 | + program->setBuildOptions(buildOptions.data()); |
| 2641 | + |
| 2642 | + const auto compileResult{program->recompile()}; |
| 2643 | + ASSERT_EQ(CL_SUCCESS, compileResult); |
| 2644 | + |
| 2645 | + const std::string buildLog{program->getBuildLog(pClDevice->getRootDeviceIndex())}; |
| 2646 | + const auto containsWarning{buildLog.find(CompilerWarnings::recompiledFromIr.data()) != std::string::npos}; |
| 2647 | + |
| 2648 | + EXPECT_FALSE(containsWarning); |
| 2649 | +} |
| 2650 | + |
2580 | 2651 | TEST_F(ProgramTests, whenRebuildingProgramThenStoreDeviceBinaryProperly) { |
2581 | 2652 | auto compilerInterface = new MockCompilerInterface(); |
2582 | 2653 | pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->compilerInterface.reset(compilerInterface); |
@@ -2766,6 +2837,25 @@ TEST(CreateProgramFromBinaryTests, givenBinaryProgramBuiltInWhenKernelRebulildIs |
2766 | 2837 | EXPECT_EQ(nullptr, pProgram->buildInfos[rootDeviceIndex].packedDeviceBinary); |
2767 | 2838 | EXPECT_EQ(0U, pProgram->buildInfos[rootDeviceIndex].packedDeviceBinarySize); |
2768 | 2839 | } |
| 2840 | + |
| 2841 | +TEST(CreateProgramFromBinaryTests, givenBinaryProgramBuiltInWhenKernelRebulildIsForcedThenRebuildWarningIsEnabled) { |
| 2842 | + DebugManagerStateRestore dbgRestorer{}; |
| 2843 | + DebugManager.flags.RebuildPrecompiledKernels.set(true); |
| 2844 | + |
| 2845 | + PatchTokensTestData::ValidEmptyProgram programTokens; |
| 2846 | + cl_int retVal{CL_INVALID_BINARY}; |
| 2847 | + |
| 2848 | + const auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr)); |
| 2849 | + std::unique_ptr<MockProgram> pProgram(Program::createBuiltInFromGenBinary<MockProgram>(nullptr, toClDeviceVector(*clDevice), programTokens.storage.data(), programTokens.storage.size(), &retVal)); |
| 2850 | + ASSERT_NE(nullptr, pProgram.get()); |
| 2851 | + ASSERT_EQ(CL_SUCCESS, retVal); |
| 2852 | + |
| 2853 | + retVal = pProgram->createProgramFromBinary(programTokens.storage.data(), programTokens.storage.size(), *clDevice); |
| 2854 | + ASSERT_EQ(CL_SUCCESS, retVal); |
| 2855 | + |
| 2856 | + ASSERT_TRUE(pProgram->shouldWarnAboutRebuild); |
| 2857 | +} |
| 2858 | + |
2769 | 2859 | TEST(CreateProgramFromBinaryTests, givenBinaryProgramNotBuiltInWhenBuiltInKernelRebulildIsForcedThenDeviceBinaryIsUsed) { |
2770 | 2860 | DebugManagerStateRestore dbgRestorer; |
2771 | 2861 | DebugManager.flags.RebuildPrecompiledKernels.set(true); |
|
0 commit comments