diff --git a/unit_tests/api/cl_build_program_tests.cpp b/unit_tests/api/cl_build_program_tests.cpp index 2972483544..2981599dff 100644 --- a/unit_tests/api/cl_build_program_tests.cpp +++ b/unit_tests/api/cl_build_program_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -22,17 +22,12 @@ #include "config.h" #include "cl_api_tests.h" -#include "runtime/helpers/base_object.h" #include "runtime/compiler_interface/compiler_interface.h" #include "runtime/context/context.h" -#include "runtime/device/device.h" #include "runtime/helpers/file_io.h" -#include "runtime/helpers/hw_info.h" -#include "runtime/helpers/options.h" #include "runtime/program/program.h" #include "unit_tests/helpers/kernel_binary_helper.h" #include "unit_tests/helpers/test_files.h" -#include "unit_tests/helpers/memory_management.h" using namespace OCLRT; @@ -97,11 +92,8 @@ TEST_F(clBuildProgramTests, FromBinaryBasic) { cl_int binaryStatus = CL_SUCCESS; void *pBinary = nullptr; size_t binarySize = 0; - - std::string testFile(testFiles); - testFile.append("CopyBuffer_simd8_"); - testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - testFile.append(".bin"); + std::string testFile; + retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin"); binarySize = loadDataFromFile( testFile.c_str(), @@ -145,11 +137,8 @@ TEST_F(clBuildProgramTests, GivenProgramCreatedFromBinaryWhenBuildProgramWithOpt cl_int binaryStatus = CL_SUCCESS; void *pBinary = nullptr; size_t binarySize = 0; - - std::string testFile(testFiles); - testFile.append("CopyBuffer_simd8_"); - testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - testFile.append(".bin"); + std::string testFile; + retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin"); binarySize = loadDataFromFile( testFile.c_str(), @@ -204,11 +193,8 @@ TEST_F(clBuildProgramTests, FromBinarySpir) { size_t binarySize = 0; KernelBinaryHelper kbHeler("CopyBuffer_simd8", false); - - std::string testFile(testFiles); - testFile.append("CopyBuffer_simd8_"); - testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - testFile.append(".bc"); + std::string testFile; + retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bc"); binarySize = loadDataFromFile( testFile.c_str(), diff --git a/unit_tests/api/cl_clone_kernel_tests.cpp b/unit_tests/api/cl_clone_kernel_tests.cpp index 5c821289f6..c33ecc9787 100644 --- a/unit_tests/api/cl_clone_kernel_tests.cpp +++ b/unit_tests/api/cl_clone_kernel_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -23,8 +23,6 @@ #include "cl_api_tests.h" #include "runtime/context/context.h" #include "runtime/helpers/file_io.h" -#include "runtime/helpers/hw_info.h" -#include "runtime/helpers/options.h" #include "unit_tests/helpers/test_files.h" using namespace OCLRT; @@ -50,11 +48,8 @@ TEST_F(clCloneKernelTests, returnsSuccess) { cl_int binaryStatus = CL_SUCCESS; void *pBinary = nullptr; size_t binarySize = 0; - - std::string testFile(testFiles); - testFile.append("CopyBuffer_simd8_"); - testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - testFile.append(".bin"); + std::string testFile; + retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin"); binarySize = loadDataFromFile( testFile.c_str(), diff --git a/unit_tests/api/cl_create_kernel_tests.cpp b/unit_tests/api/cl_create_kernel_tests.cpp index ad9246242d..e315756e0e 100644 --- a/unit_tests/api/cl_create_kernel_tests.cpp +++ b/unit_tests/api/cl_create_kernel_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -23,8 +23,6 @@ #include "cl_api_tests.h" #include "runtime/context/context.h" #include "runtime/helpers/file_io.h" -#include "runtime/helpers/hw_info.h" -#include "runtime/helpers/options.h" #include "unit_tests/helpers/test_files.h" #include "unit_tests/mocks/mock_program.h" @@ -40,11 +38,8 @@ TEST_F(clCreateKernelTests, returnsSuccess) { cl_int binaryStatus = CL_SUCCESS; void *pBinary = nullptr; size_t binarySize = 0; - - std::string testFile(testFiles); - testFile.append("CopyBuffer_simd8_"); - testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - testFile.append(".bin"); + std::string testFile; + retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin"); binarySize = loadDataFromFile( testFile.c_str(), @@ -118,11 +113,8 @@ TEST_F(clCreateKernelTests, invalidParams) { cl_int binaryStatus = CL_SUCCESS; void *pBinary = nullptr; size_t binarySize = 0; - - std::string testFile(testFiles); - testFile.append("CopyBuffer_simd8_"); - testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - testFile.append(".bin"); + std::string testFile; + retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin"); binarySize = loadDataFromFile( testFile.c_str(), diff --git a/unit_tests/api/cl_create_kernels_in_program_tests.cpp b/unit_tests/api/cl_create_kernels_in_program_tests.cpp index 31983f6f6a..70a95f8227 100644 --- a/unit_tests/api/cl_create_kernels_in_program_tests.cpp +++ b/unit_tests/api/cl_create_kernels_in_program_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -23,8 +23,6 @@ #include "cl_api_tests.h" #include "runtime/context/context.h" #include "runtime/helpers/file_io.h" -#include "runtime/helpers/hw_info.h" -#include "runtime/helpers/options.h" #include "unit_tests/helpers/test_files.h" using namespace OCLRT; @@ -32,11 +30,8 @@ using namespace OCLRT; struct clCreateKernelsInProgramTests : public api_tests { void SetUp() override { api_tests::SetUp(); - - std::string testFile(testFiles); - testFile.append("CopyBuffer_simd8_"); - testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - testFile.append(".bin"); + std::string testFile; + retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin"); auto binarySize = loadDataFromFile( testFile.c_str(), diff --git a/unit_tests/api/cl_create_program_with_binary_tests.cpp b/unit_tests/api/cl_create_program_with_binary_tests.cpp index 149fb77945..1fbfd539f5 100644 --- a/unit_tests/api/cl_create_program_with_binary_tests.cpp +++ b/unit_tests/api/cl_create_program_with_binary_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -23,8 +23,6 @@ #include "cl_api_tests.h" #include "runtime/context/context.h" #include "runtime/helpers/file_io.h" -#include "runtime/helpers/hw_info.h" -#include "runtime/helpers/options.h" #include "unit_tests/helpers/test_files.h" using namespace OCLRT; @@ -40,11 +38,9 @@ TEST_F(clCreateProgramWithBinaryTests, returnsSuccess) { cl_int binaryStatus = CL_INVALID_VALUE; void *pBinary = nullptr; size_t binarySize = 0; + std::string testFile; + retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin"); - std::string testFile(testFiles); - testFile.append("CopyBuffer_simd8_"); - testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - testFile.append(".bin"); ASSERT_EQ(true, fileExists(testFile)); binarySize = loadDataFromFile( diff --git a/unit_tests/api/cl_release_kernel_tests.cpp b/unit_tests/api/cl_release_kernel_tests.cpp index b28d36c979..8ee1070315 100644 --- a/unit_tests/api/cl_release_kernel_tests.cpp +++ b/unit_tests/api/cl_release_kernel_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -23,8 +23,6 @@ #include "cl_api_tests.h" #include "runtime/context/context.h" #include "runtime/helpers/file_io.h" -#include "runtime/helpers/hw_info.h" -#include "runtime/helpers/options.h" #include "unit_tests/helpers/test_files.h" using namespace OCLRT; @@ -44,11 +42,8 @@ TEST_F(clReleaseKernelTests, retainAndrelease) { cl_int binaryStatus = CL_SUCCESS; void *binary = nullptr; size_t binarySize = 0; - - std::string testFile(testFiles); - testFile.append("CopyBuffer_simd8_"); - testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - testFile.append(".bin"); + std::string testFile; + retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin"); binarySize = loadDataFromFile(testFile.c_str(), binary); diff --git a/unit_tests/aub_tests/fixtures/run_kernel_fixture.h b/unit_tests/aub_tests/fixtures/run_kernel_fixture.h index a188bca6c5..5e593bf074 100644 --- a/unit_tests/aub_tests/fixtures/run_kernel_fixture.h +++ b/unit_tests/aub_tests/fixtures/run_kernel_fixture.h @@ -64,17 +64,14 @@ class RunKernelFixture : public CommandEnqueueAUBFixture { protected: Program *CreateProgramFromBinary( - const std::string &BinaryFileName) { - std::string testFile; + const std::string &binaryFileName) { cl_int retVal = CL_SUCCESS; - testFile.append(testFiles); - testFile.append(BinaryFileName); - EXPECT_EQ(true, fileExists(testFile)); + EXPECT_EQ(true, fileExists(binaryFileName)); void *pSource = nullptr; size_t sourceSize = loadDataFromFile( - testFile.c_str(), + binaryFileName.c_str(), pSource); EXPECT_NE(0u, sourceSize); @@ -99,39 +96,5 @@ class RunKernelFixture : public CommandEnqueueAUBFixture { return pProgram; } - - Program *CreateProgramFromSource( - const std::string &SourceFileName) { - cl_int retVal = CL_SUCCESS; - std::string testFile; - - testFile.append(testFiles); - testFile.append(SourceFileName); - EXPECT_EQ(true, fileExists(testFile)); - - void *pSource = nullptr; - size_t sourceSize = loadDataFromFile( - testFile.c_str(), - pSource); - - EXPECT_NE(0u, sourceSize); - EXPECT_NE(nullptr, pSource); - - Program *pProgram = nullptr; - - pProgram = Program::create( - context, - 1, - (const char **)(&pSource), - &sourceSize, - retVal); - - EXPECT_NE(nullptr, pProgram); - EXPECT_EQ(CL_SUCCESS, retVal); - - deleteDataReadFromFile(pSource); - - return pProgram; - } }; } diff --git a/unit_tests/aub_tests/gen9/skl/command_queue/run_kernel_aub_tests_skl.cpp b/unit_tests/aub_tests/gen9/skl/command_queue/run_kernel_aub_tests_skl.cpp index 09d48daff8..2d7a172591 100644 --- a/unit_tests/aub_tests/gen9/skl/command_queue/run_kernel_aub_tests_skl.cpp +++ b/unit_tests/aub_tests/gen9/skl/command_queue/run_kernel_aub_tests_skl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -20,13 +20,8 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include "runtime/memory_manager/os_agnostic_memory_manager.h" -#include "runtime/memory_manager/surface.h" -#include "unit_tests/fixtures/run_kernel_fixture.h" #include "unit_tests/fixtures/two_walker_fixture.h" #include "unit_tests/aub_tests/fixtures/run_kernel_fixture.h" -#include "CL/cl_ext.h" -#include "CL/cl.h" using namespace OCLRT; @@ -56,10 +51,9 @@ SKLTEST_F(AUBRunKernelIntegrateTest, ooqExecution) { cl_event *event2 = nullptr; cl_int retVal = CL_FALSE; - // we would need real compiler for this - //Program* pProgram = CreateProgramFromSource( "simple_kernels.cl" ); - - Program *pProgram = CreateProgramFromBinary(std::string("simple_kernels_") + pDevice->getProductAbbrev() + ".bin"); + std::string kernelFilename; + retrieveBinaryKernelFilename(kernelFilename, "simple_kernels_", ".bin"); + Program *pProgram = CreateProgramFromBinary(kernelFilename); ASSERT_NE(nullptr, pProgram); cl_device_id device = pDevice; @@ -284,8 +278,9 @@ SKLTEST_F(AUBRunKernelIntegrateTest, deviceSideVme) { const int MV_BUFFER_SIZE = testWidth * mbHeight / 4; const int RESIDUALS_BUFFER_SIZE = MV_BUFFER_SIZE; - Program *pProgram = CreateProgramFromBinary( - std::string("vme_kernels_") + pDevice->getProductAbbrev() + ".bin"); + std::string kernelFilename; + retrieveBinaryKernelFilename(kernelFilename, "vme_kernels_", ".bin"); + Program *pProgram = CreateProgramFromBinary(kernelFilename); ASSERT_NE(nullptr, pProgram); cl_device_id device = pDevice; diff --git a/unit_tests/built_ins/sip_tests.cpp b/unit_tests/built_ins/sip_tests.cpp index 61950305c7..4656829d2a 100644 --- a/unit_tests/built_ins/sip_tests.cpp +++ b/unit_tests/built_ins/sip_tests.cpp @@ -142,9 +142,8 @@ TEST(DebugSip, DISABLED_givenBuiltInsWhenDbgCsrSipIsRequestedThanCorrectSipKerne EXPECT_NE(nullptr, mockDevice); MockCompilerDebugVars igcDebugVars; - auto product = mockDevice->getProductAbbrev(); std::string name = "sip_dummy_kernel_debug"; - std::string builtInFileRoot = testFiles + getDebugSipKernelNameWithBitnessAndProductSuffix(name, product); + std::string builtInFileRoot = testFiles + getDebugSipKernelNameWithBitnessAndProductSuffix(name, binaryNameSuffix.c_str()); std::string builtInGenFile = builtInFileRoot; builtInGenFile.append(".gen"); diff --git a/unit_tests/context/driver_diagnostics_tests.h b/unit_tests/context/driver_diagnostics_tests.h index a6854f90de..84e7dfa6a8 100644 --- a/unit_tests/context/driver_diagnostics_tests.h +++ b/unit_tests/context/driver_diagnostics_tests.h @@ -242,7 +242,7 @@ struct PerformanceHintEnqueueKernelTest : public PerformanceHintEnqueueTest, void SetUp() override { PerformanceHintEnqueueTest::SetUp(); cl_device_id device = pPlatform->getDevice(0); - CreateProgramFromBinary(context, &device, std::string("CopyBuffer_simd32")); + CreateProgramFromBinary(context, &device, "CopyBuffer_simd32"); retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false); ASSERT_EQ(CL_SUCCESS, retVal); kernel = Kernel::create(pProgram, *pProgram->getKernelInfo("CopyBuffer"), &retVal); @@ -278,7 +278,7 @@ struct PerformanceHintEnqueueKernelPrintfTest : public PerformanceHintEnqueueTes void SetUp() override { PerformanceHintEnqueueTest::SetUp(); cl_device_id device = pPlatform->getDevice(0); - CreateProgramFromBinary(context, &device, std::string("printf")); + CreateProgramFromBinary(context, &device, "printf"); retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false); ASSERT_EQ(CL_SUCCESS, retVal); kernel = Kernel::create(pProgram, *pProgram->getKernelInfo("test"), &retVal); diff --git a/unit_tests/device/device_tests.cpp b/unit_tests/device/device_tests.cpp index 50ee7aaaff..11ebe077e5 100644 --- a/unit_tests/device/device_tests.cpp +++ b/unit_tests/device/device_tests.cpp @@ -40,6 +40,12 @@ TEST_F(DeviceTest, Create) { EXPECT_NE(nullptr, pDevice); } +TEST_F(DeviceTest, givenDeviceWhenGetProductAbbrevThenReturnsHardwarePrefix) { + const auto productAbbrev = pDevice->getProductAbbrev(); + const auto hwPrefix = hardwarePrefix[pDevice->getHardwareInfo().pPlatform->eProductFamily]; + EXPECT_EQ(hwPrefix, productAbbrev); +} + TEST_F(DeviceTest, getCommandStreamReceiver) { EXPECT_NE(nullptr, &pDevice->getCommandStreamReceiver()); } diff --git a/unit_tests/fixtures/built_in_fixture.cpp b/unit_tests/fixtures/built_in_fixture.cpp index e309a9c0bd..f98732b31e 100644 --- a/unit_tests/fixtures/built_in_fixture.cpp +++ b/unit_tests/fixtures/built_in_fixture.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -21,8 +21,6 @@ */ #include "runtime/built_ins/built_ins.h" -#include "runtime/compiler_interface/compiler_interface.h" -#include "runtime/device/device.h" #include "unit_tests/fixtures/built_in_fixture.h" #include "unit_tests/helpers/kernel_binary_helper.h" #include "unit_tests/helpers/test_files.h" @@ -43,18 +41,8 @@ void BuiltInFixture::SetUp(Device *pDevice) { MockCompilerDebugVars fclDebugVars; MockCompilerDebugVars igcDebugVars; - std::string builtInFileRoot = testFiles + KernelBinaryHelper::BUILT_INS; - std::string builtInBcFile = builtInFileRoot + "_"; - std::string builtInGenFile = builtInFileRoot + "_"; - - auto product = pDevice->getProductAbbrev(); - builtInBcFile.append(product); - builtInGenFile.append(product); - builtInBcFile.append(".bc"); - builtInGenFile.append(".gen"); - - fclDebugVars.fileName = builtInBcFile; - igcDebugVars.fileName = builtInGenFile; + retrieveBinaryKernelFilename(fclDebugVars.fileName, KernelBinaryHelper::BUILT_INS + "_", ".bc"); + retrieveBinaryKernelFilename(igcDebugVars.fileName, KernelBinaryHelper::BUILT_INS + "_", ".gen"); gEnvironment->fclPushDebugVars(fclDebugVars); gEnvironment->igcPushDebugVars(igcDebugVars); diff --git a/unit_tests/fixtures/program_fixture.h b/unit_tests/fixtures/program_fixture.h index f47fbdd8b3..ba91d8ff74 100644 --- a/unit_tests/fixtures/program_fixture.h +++ b/unit_tests/fixtures/program_fixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -22,9 +22,7 @@ #pragma once #include "gtest/gtest.h" -#include "runtime/device/device.h" #include "runtime/helpers/file_io.h" -#include "runtime/platform/platform.h" #include "runtime/program/program.h" #include "unit_tests/helpers/test_files.h" diff --git a/unit_tests/fixtures/program_fixture.inl b/unit_tests/fixtures/program_fixture.inl index 563614dc6b..f2a8b78721 100644 --- a/unit_tests/fixtures/program_fixture.inl +++ b/unit_tests/fixtures/program_fixture.inl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -31,16 +31,10 @@ void ProgramFixture::CreateProgramFromBinary(cl_context context, cl_int &retVal, const std::string &options) { Cleanup(); - std::string testFile; retVal = CL_SUCCESS; - Context *pContext = castToObject(context); - testFile.append(testFiles); - testFile.append(binaryFileName); - testFile.append("_"); - testFile.append(pContext->getDevice(0)->getProductAbbrev()); - testFile.append(".bin"); - testFile.append(options); + std::string testFile; + retrieveBinaryKernelFilename(testFile, binaryFileName + "_", ".bin", options); knownSourceSize = loadDataFromFile( testFile.c_str(), diff --git a/unit_tests/fixtures/run_kernel_fixture.h b/unit_tests/fixtures/run_kernel_fixture.h index 78566bb0cd..4ae10a1c9d 100644 --- a/unit_tests/fixtures/run_kernel_fixture.h +++ b/unit_tests/fixtures/run_kernel_fixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -22,7 +22,6 @@ #pragma once -#include "runtime/device/device.h" #include "unit_tests/global_environment.h" #include "unit_tests/helpers/test_files.h" @@ -33,27 +32,16 @@ struct CommandStreamFixture; // helper functions to enforce MockCompiler input files inline void overwriteBuiltInBinaryName( Device *pDevice, - const char *filename, + const std::string &filename, bool appendOptionsToFileName = false) { // set mock compiler to return expected kernel... MockCompilerDebugVars fclDebugVars; MockCompilerDebugVars igcDebugVars; - std::string builtInFileRoot = testFiles; - builtInFileRoot.append(filename); - std::string builtInBcFile = builtInFileRoot + "_"; - std::string builtInGenFile = builtInFileRoot + "_"; - - auto product = pDevice->getProductAbbrev(); - builtInBcFile.append(product); - builtInGenFile.append(product); - builtInBcFile.append(".bc"); - builtInGenFile.append(".gen"); - - fclDebugVars.fileName = builtInBcFile; + retrieveBinaryKernelFilename(fclDebugVars.fileName, filename + "_", ".bc"); fclDebugVars.appendOptionsToFileName = appendOptionsToFileName; - igcDebugVars.fileName = builtInGenFile; + retrieveBinaryKernelFilename(igcDebugVars.fileName, filename + "_", ".gen"); igcDebugVars.appendOptionsToFileName = appendOptionsToFileName; gEnvironment->fclPushDebugVars(fclDebugVars); diff --git a/unit_tests/gen9/sip_tests_gen9.cpp b/unit_tests/gen9/sip_tests_gen9.cpp index 363dd53ed2..b49fd2fcbc 100644 --- a/unit_tests/gen9/sip_tests_gen9.cpp +++ b/unit_tests/gen9/sip_tests_gen9.cpp @@ -41,9 +41,8 @@ GEN9TEST_F(gen9SipTests, DISABLED_givenDebugCsrSipKernelWithLocalMemoryWhenAsked EXPECT_NE(nullptr, mockDevice); MockCompilerDebugVars igcDebugVars; - auto product = mockDevice->getProductAbbrev(); std::string name = "sip_dummy_kernel_debug"; - std::string builtInFileRoot = testFiles + getDebugSipKernelNameWithBitnessAndProductSuffix(name, product); + std::string builtInFileRoot = testFiles + getDebugSipKernelNameWithBitnessAndProductSuffix(name, binaryNameSuffix.c_str()); std::string builtInGenFile = builtInFileRoot; builtInGenFile.append(".gen"); diff --git a/unit_tests/helpers/kernel_binary_helper.cpp b/unit_tests/helpers/kernel_binary_helper.cpp index b01c11c3fd..638ca03e2b 100644 --- a/unit_tests/helpers/kernel_binary_helper.cpp +++ b/unit_tests/helpers/kernel_binary_helper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -35,18 +35,8 @@ KernelBinaryHelper::KernelBinaryHelper(const std::string &name, bool appendOptio MockCompilerDebugVars fclDebugVars; MockCompilerDebugVars igcDebugVars; - std::string builtInFileRoot = testFiles + name + "_"; - std::string builtInBcFile = builtInFileRoot; - std::string builtInGenFile = builtInFileRoot; - - auto product = hardwarePrefix[productFamily]; - builtInBcFile.append(product); - builtInGenFile.append(product); - builtInBcFile.append(".bc"); - builtInGenFile.append(".gen"); - - fclDebugVars.fileName = builtInBcFile; - igcDebugVars.fileName = builtInGenFile; + retrieveBinaryKernelFilename(fclDebugVars.fileName, name + "_", ".bc"); + retrieveBinaryKernelFilename(igcDebugVars.fileName, name + "_", ".gen"); fclDebugVars.appendOptionsToFileName = appendOptionsToFileName; igcDebugVars.appendOptionsToFileName = appendOptionsToFileName; diff --git a/unit_tests/helpers/test_files.cpp b/unit_tests/helpers/test_files.cpp index 761c3cb314..c390be1bfa 100644 --- a/unit_tests/helpers/test_files.cpp +++ b/unit_tests/helpers/test_files.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -28,3 +28,16 @@ std::string testFiles("test_files/x64/"); std::string testFiles("test_files/x86/"); #endif std::string clFiles("test_files/"); +std::string binaryNameSuffix(""); + +void retrieveBinaryKernelFilename(std::string &outputFilename, const std::string &kernelName, const std::string &extension, const std::string &options) { + if (outputFilename.length() > 0) { + outputFilename.clear(); + } + outputFilename.reserve(2 * testFiles.length()); + outputFilename.append(testFiles); + outputFilename.append(kernelName); + outputFilename.append(binaryNameSuffix); + outputFilename.append(extension); + outputFilename.append(options); +} \ No newline at end of file diff --git a/unit_tests/helpers/test_files.h b/unit_tests/helpers/test_files.h index 64b9e63a05..66f5195a6e 100644 --- a/unit_tests/helpers/test_files.h +++ b/unit_tests/helpers/test_files.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -25,3 +25,6 @@ extern std::string testFiles; 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 = ""); diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index 91e4dfd38c..3447bcc17e 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -271,23 +271,6 @@ int main(int argc, char **argv) { return -1; } - // we look for test files always relative to binary location - // this simplifies multi-process execution and using different - // working directories - std::string nTestFiles = getRunPath(argv[0]); - nTestFiles.append("/"); - nTestFiles.append(hardwarePrefix[productFamily]); - nTestFiles.append("/"); - nTestFiles.append(testFiles); - testFiles = nTestFiles; - - std::string nClFiles = getRunPath(argv[0]); - nClFiles.append("/"); - nClFiles.append(hardwarePrefix[productFamily]); - nClFiles.append("/"); - nClFiles.append(clFiles); - clFiles = nClFiles; - #ifdef WIN32 #include if (_chdir(hardwarePrefix[productFamily])) { @@ -302,12 +285,6 @@ int main(int argc, char **argv) { uint32_t threadsPerEu = 7; PLATFORM platform; - std::string baseFile = nTestFiles + "15895692906525787409_"; - baseFile = baseFile + hardwarePrefix[productFamily]; - - auto fclMockFile = baseFile + ".bc"; - auto igcMockFile = baseFile + ".gen"; - auto hardwareInfo = hardwareInfoTable[productFamily]; if (!hardwareInfo) { return -1; @@ -340,6 +317,22 @@ int main(int argc, char **argv) { device.pSysInfo = >SystemInfo; device.capabilityTable = hardwareInfo->capabilityTable; + binaryNameSuffix.append(hardwarePrefix[productFamily]); + + std::string nBinaryKernelFiles = getRunPath(argv[0]); + nBinaryKernelFiles.append("/"); + nBinaryKernelFiles.append(binaryNameSuffix); + nBinaryKernelFiles.append("/"); + nBinaryKernelFiles.append(testFiles); + testFiles = nBinaryKernelFiles; + + std::string nClFiles = getRunPath(argv[0]); + nClFiles.append("/"); + nClFiles.append(hardwarePrefix[productFamily]); + nClFiles.append("/"); + nClFiles.append(clFiles); + clFiles = nClFiles; + auto pDevices = new const HardwareInfo *[numDevices]; for (decltype(numDevices) i = 0; i < numDevices; ++i) { pDevices[i] = &device; @@ -365,10 +358,10 @@ int main(int argc, char **argv) { MockCompilerDebugVars fclDebugVars; MockCompilerDebugVars igcDebugVars; - fclDebugVars.fileName = fclMockFile; - igcDebugVars.fileName = igcMockFile; + retrieveBinaryKernelFilename(fclDebugVars.fileName, "15895692906525787409_", ".bc"); + retrieveBinaryKernelFilename(igcDebugVars.fileName, "15895692906525787409_", ".gen"); - gEnvironment->setMockFileNames(fclMockFile, igcMockFile); + gEnvironment->setMockFileNames(fclDebugVars.fileName, igcDebugVars.fileName); gEnvironment->setDefaultDebugVars(fclDebugVars, igcDebugVars, device); // globally override-disable preemption to speed-up test execution diff --git a/unit_tests/mocks/mock_sip.cpp b/unit_tests/mocks/mock_sip.cpp index 3c6050fdb8..8a209ef327 100644 --- a/unit_tests/mocks/mock_sip.cpp +++ b/unit_tests/mocks/mock_sip.cpp @@ -44,10 +44,8 @@ std::vector MockSipKernel::getDummyGenBinary() { return dummyBinaryForSip; } std::vector MockSipKernel::getBinary() { - std::string testFile(testFiles); - testFile.append("CopyBuffer_simd8_"); - testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - testFile.append(".gen"); + std::string testFile; + retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".gen"); void *binary = nullptr; auto binarySize = loadDataFromFile(testFile.c_str(), binary); diff --git a/unit_tests/offline_compiler/environment.h b/unit_tests/offline_compiler/environment.h index dc7d090758..a457397dc1 100644 --- a/unit_tests/offline_compiler/environment.h +++ b/unit_tests/offline_compiler/environment.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -36,8 +36,8 @@ class Environment : public ::testing::Environment { void SetInputFileName( const std::string filename) { - igcDebugVars.fileName = testFiles + filename + "_" + devicePrefix + ".gen"; - fclDebugVars.fileName = testFiles + filename + "_" + devicePrefix + ".bc"; + retrieveBinaryKernelFilename(igcDebugVars.fileName, filename + "_", ".gen"); + retrieveBinaryKernelFilename(fclDebugVars.fileName, filename + "_", ".bc"); OCLRT::setIgcDebugVars(igcDebugVars); OCLRT::setFclDebugVars(fclDebugVars); diff --git a/unit_tests/offline_compiler/main.cpp b/unit_tests/offline_compiler/main.cpp index ff94460482..7bda72b93e 100644 --- a/unit_tests/offline_compiler/main.cpp +++ b/unit_tests/offline_compiler/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -95,6 +95,7 @@ int main(int argc, char **argv) { nTestFiles.append("/"); nTestFiles.append(testFiles); testFiles = nTestFiles; + binaryNameSuffix.append(devicePrefix); #ifdef WIN32 #include diff --git a/unit_tests/program/process_elf_binary_tests.cpp b/unit_tests/program/process_elf_binary_tests.cpp index 76c2c2e865..1f1d840ef4 100644 --- a/unit_tests/program/process_elf_binary_tests.cpp +++ b/unit_tests/program/process_elf_binary_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -21,8 +21,6 @@ */ #include "runtime/helpers/file_io.h" -#include "runtime/helpers/hw_info.h" -#include "runtime/helpers/options.h" #include "runtime/program/program.h" #include "runtime/helpers/string.h" #include "unit_tests/helpers/test_files.h" @@ -60,10 +58,8 @@ TEST_F(ProcessElfBinaryTests, InvalidBinary) { TEST_F(ProcessElfBinaryTests, ValidBinary) { uint32_t binaryVersion; void *pBinary = nullptr; - std::string filePath = testFiles; - filePath.append("CopyBuffer_simd8_"); - filePath.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - filePath.append(".bin"); + std::string filePath; + retrieveBinaryKernelFilename(filePath, "CopyBuffer_simd8_", ".bin"); size_t binarySize = loadDataFromFile(filePath.c_str(), pBinary); cl_int retVal = processElfBinary(pBinary, binarySize, binaryVersion); @@ -138,10 +134,8 @@ class ProcessElfBinaryTestsWithBinaryType : public Program, TEST_P(ProcessElfBinaryTestsWithBinaryType, GivenBinaryTypeWhenResolveProgramThenProgramIsProperlyResolved) { uint32_t binaryVersion; void *pBinary = nullptr; - std::string filePath = testFiles; - filePath.append("CopyBuffer_simd8_"); - filePath.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - filePath.append(".bin"); + std::string filePath; + retrieveBinaryKernelFilename(filePath, "CopyBuffer_simd8_", ".bin"); size_t binarySize = loadDataFromFile(filePath.c_str(), pBinary); cl_int retVal = processElfBinary(pBinary, binarySize, binaryVersion); @@ -182,10 +176,8 @@ INSTANTIATE_TEST_CASE_P(ResolveBinaryTests, TEST_F(ProcessElfBinaryTests, BackToBack) { uint32_t binaryVersion; void *pBinary = nullptr; - std::string filePath = testFiles; - filePath.append("CopyBuffer_simd8_"); - filePath.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - filePath.append(".bin"); + std::string filePath; + retrieveBinaryKernelFilename(filePath, "CopyBuffer_simd8_", ".bin"); size_t binarySize = loadDataFromFile(filePath.c_str(), pBinary); cl_int retVal = processElfBinary(pBinary, binarySize, binaryVersion); @@ -195,12 +187,10 @@ TEST_F(ProcessElfBinaryTests, BackToBack) { EXPECT_NE(0u, binaryVersion); deleteDataReadFromFile(pBinary); - filePath = testFiles; - filePath.append("simple_arg_int_"); - filePath.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - filePath.append(".bin"); + std::string filePath2; + retrieveBinaryKernelFilename(filePath2, "simple_arg_int_", ".bin"); - binarySize = loadDataFromFile(filePath.c_str(), pBinary); + binarySize = loadDataFromFile(filePath2.c_str(), pBinary); retVal = processElfBinary(pBinary, binarySize, binaryVersion); EXPECT_EQ(CL_SUCCESS, retVal); @@ -212,10 +202,8 @@ TEST_F(ProcessElfBinaryTests, BackToBack) { TEST_F(ProcessElfBinaryTests, BuildOptionsEmpty) { uint32_t binaryVersion; void *pBinary = nullptr; - std::string filePath = testFiles; - filePath.append("simple_kernels_"); - filePath.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - filePath.append(".bin"); + std::string filePath; + retrieveBinaryKernelFilename(filePath, "simple_kernels_", ".bin"); size_t binarySize = loadDataFromFile(filePath.c_str(), pBinary); cl_int retVal = processElfBinary(pBinary, binarySize, binaryVersion); @@ -230,10 +218,8 @@ TEST_F(ProcessElfBinaryTests, BuildOptionsEmpty) { TEST_F(ProcessElfBinaryTests, BuildOptionsNotEmpty) { uint32_t binaryVersion; void *pBinary = nullptr; - std::string filePath = testFiles; - filePath.append("simple_kernels_opts_"); - filePath.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - filePath.append(".bin"); + std::string filePath; + retrieveBinaryKernelFilename(filePath, "simple_kernels_opts_", ".bin"); size_t binarySize = loadDataFromFile(filePath.c_str(), pBinary); cl_int retVal = processElfBinary(pBinary, binarySize, binaryVersion); diff --git a/unit_tests/program/program_tests.cpp b/unit_tests/program/program_tests.cpp index fa6528a707..3494c6c8d8 100644 --- a/unit_tests/program/program_tests.cpp +++ b/unit_tests/program/program_tests.cpp @@ -2181,10 +2181,8 @@ TEST_F(ProgramTests, ValidBinaryWithIGCVersionEqual0) { // Load a binary program file void *pBinary = nullptr; - std::string filePath = testFiles; - filePath.append("CopyBuffer_simd8_"); - filePath.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - filePath.append(".bin"); + std::string filePath; + retrieveBinaryKernelFilename(filePath, "CopyBuffer_simd8_", ".bin"); size_t binarySize = loadDataFromFile(filePath.c_str(), pBinary); EXPECT_NE(0u, binarySize); @@ -2255,10 +2253,8 @@ TEST_F(ProgramTests, RebuildBinaryButNoCompilerInterface) { // Load a binary program file void *pBinary = nullptr; - std::string filePath = testFiles; - filePath.append("CopyBuffer_simd8_"); - filePath.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - filePath.append(".bin"); + std::string filePath; + retrieveBinaryKernelFilename(filePath, "CopyBuffer_simd8_", ".bin"); size_t binarySize = loadDataFromFile(filePath.c_str(), pBinary); EXPECT_NE(0u, binarySize); @@ -2312,10 +2308,8 @@ TEST_F(ProgramTests, RebuildBinaryWithRebuildError) { // Load a binary program file void *pBinary = nullptr; - std::string filePath = testFiles; - filePath.append("CopyBuffer_simd8_"); - filePath.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - filePath.append(".bin"); + std::string filePath; + retrieveBinaryKernelFilename(filePath, "CopyBuffer_simd8_", ".bin"); size_t binarySize = loadDataFromFile(filePath.c_str(), pBinary); EXPECT_NE(0u, binarySize); @@ -2452,10 +2446,8 @@ TEST_F(ProgramTests, RebuildBinaryWithProcessGenBinaryError) { // Load a binary program file void *pBinary = nullptr; - std::string filePath = testFiles; - filePath.append("CopyBuffer_simd8_"); - filePath.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]); - filePath.append(".bin"); + std::string filePath; + retrieveBinaryKernelFilename(filePath, "CopyBuffer_simd8_", ".bin"); size_t binarySize = loadDataFromFile(filePath.c_str(), pBinary); EXPECT_NE(0u, binarySize);