Skip to content

Commit 180de34

Browse files
Define variable with binary name suffix
use this variable in tests as it is set once in main.cpp create function to get binary kernel filename Change-Id: Ibf7b4c2d390caefda4a5d7fc4667006e7f2edde8
1 parent 103fe67 commit 180de34

25 files changed

+124
-259
lines changed

unit_tests/api/cl_build_program_tests.cpp

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -22,17 +22,12 @@
2222

2323
#include "config.h"
2424
#include "cl_api_tests.h"
25-
#include "runtime/helpers/base_object.h"
2625
#include "runtime/compiler_interface/compiler_interface.h"
2726
#include "runtime/context/context.h"
28-
#include "runtime/device/device.h"
2927
#include "runtime/helpers/file_io.h"
30-
#include "runtime/helpers/hw_info.h"
31-
#include "runtime/helpers/options.h"
3228
#include "runtime/program/program.h"
3329
#include "unit_tests/helpers/kernel_binary_helper.h"
3430
#include "unit_tests/helpers/test_files.h"
35-
#include "unit_tests/helpers/memory_management.h"
3631

3732
using namespace OCLRT;
3833

@@ -97,11 +92,8 @@ TEST_F(clBuildProgramTests, FromBinaryBasic) {
9792
cl_int binaryStatus = CL_SUCCESS;
9893
void *pBinary = nullptr;
9994
size_t binarySize = 0;
100-
101-
std::string testFile(testFiles);
102-
testFile.append("CopyBuffer_simd8_");
103-
testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]);
104-
testFile.append(".bin");
95+
std::string testFile;
96+
retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin");
10597

10698
binarySize = loadDataFromFile(
10799
testFile.c_str(),
@@ -145,11 +137,8 @@ TEST_F(clBuildProgramTests, GivenProgramCreatedFromBinaryWhenBuildProgramWithOpt
145137
cl_int binaryStatus = CL_SUCCESS;
146138
void *pBinary = nullptr;
147139
size_t binarySize = 0;
148-
149-
std::string testFile(testFiles);
150-
testFile.append("CopyBuffer_simd8_");
151-
testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]);
152-
testFile.append(".bin");
140+
std::string testFile;
141+
retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin");
153142

154143
binarySize = loadDataFromFile(
155144
testFile.c_str(),
@@ -204,11 +193,8 @@ TEST_F(clBuildProgramTests, FromBinarySpir) {
204193
size_t binarySize = 0;
205194

206195
KernelBinaryHelper kbHeler("CopyBuffer_simd8", false);
207-
208-
std::string testFile(testFiles);
209-
testFile.append("CopyBuffer_simd8_");
210-
testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]);
211-
testFile.append(".bc");
196+
std::string testFile;
197+
retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bc");
212198

213199
binarySize = loadDataFromFile(
214200
testFile.c_str(),

unit_tests/api/cl_clone_kernel_tests.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -23,8 +23,6 @@
2323
#include "cl_api_tests.h"
2424
#include "runtime/context/context.h"
2525
#include "runtime/helpers/file_io.h"
26-
#include "runtime/helpers/hw_info.h"
27-
#include "runtime/helpers/options.h"
2826
#include "unit_tests/helpers/test_files.h"
2927

3028
using namespace OCLRT;
@@ -50,11 +48,8 @@ TEST_F(clCloneKernelTests, returnsSuccess) {
5048
cl_int binaryStatus = CL_SUCCESS;
5149
void *pBinary = nullptr;
5250
size_t binarySize = 0;
53-
54-
std::string testFile(testFiles);
55-
testFile.append("CopyBuffer_simd8_");
56-
testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]);
57-
testFile.append(".bin");
51+
std::string testFile;
52+
retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin");
5853

5954
binarySize = loadDataFromFile(
6055
testFile.c_str(),

unit_tests/api/cl_create_kernel_tests.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -23,8 +23,6 @@
2323
#include "cl_api_tests.h"
2424
#include "runtime/context/context.h"
2525
#include "runtime/helpers/file_io.h"
26-
#include "runtime/helpers/hw_info.h"
27-
#include "runtime/helpers/options.h"
2826
#include "unit_tests/helpers/test_files.h"
2927
#include "unit_tests/mocks/mock_program.h"
3028

@@ -40,11 +38,8 @@ TEST_F(clCreateKernelTests, returnsSuccess) {
4038
cl_int binaryStatus = CL_SUCCESS;
4139
void *pBinary = nullptr;
4240
size_t binarySize = 0;
43-
44-
std::string testFile(testFiles);
45-
testFile.append("CopyBuffer_simd8_");
46-
testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]);
47-
testFile.append(".bin");
41+
std::string testFile;
42+
retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin");
4843

4944
binarySize = loadDataFromFile(
5045
testFile.c_str(),
@@ -118,11 +113,8 @@ TEST_F(clCreateKernelTests, invalidParams) {
118113
cl_int binaryStatus = CL_SUCCESS;
119114
void *pBinary = nullptr;
120115
size_t binarySize = 0;
121-
122-
std::string testFile(testFiles);
123-
testFile.append("CopyBuffer_simd8_");
124-
testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]);
125-
testFile.append(".bin");
116+
std::string testFile;
117+
retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin");
126118

127119
binarySize = loadDataFromFile(
128120
testFile.c_str(),

unit_tests/api/cl_create_kernels_in_program_tests.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -23,20 +23,15 @@
2323
#include "cl_api_tests.h"
2424
#include "runtime/context/context.h"
2525
#include "runtime/helpers/file_io.h"
26-
#include "runtime/helpers/hw_info.h"
27-
#include "runtime/helpers/options.h"
2826
#include "unit_tests/helpers/test_files.h"
2927

3028
using namespace OCLRT;
3129

3230
struct clCreateKernelsInProgramTests : public api_tests {
3331
void SetUp() override {
3432
api_tests::SetUp();
35-
36-
std::string testFile(testFiles);
37-
testFile.append("CopyBuffer_simd8_");
38-
testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]);
39-
testFile.append(".bin");
33+
std::string testFile;
34+
retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin");
4035

4136
auto binarySize = loadDataFromFile(
4237
testFile.c_str(),

unit_tests/api/cl_create_program_with_binary_tests.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -23,8 +23,6 @@
2323
#include "cl_api_tests.h"
2424
#include "runtime/context/context.h"
2525
#include "runtime/helpers/file_io.h"
26-
#include "runtime/helpers/hw_info.h"
27-
#include "runtime/helpers/options.h"
2826
#include "unit_tests/helpers/test_files.h"
2927

3028
using namespace OCLRT;
@@ -40,11 +38,9 @@ TEST_F(clCreateProgramWithBinaryTests, returnsSuccess) {
4038
cl_int binaryStatus = CL_INVALID_VALUE;
4139
void *pBinary = nullptr;
4240
size_t binarySize = 0;
41+
std::string testFile;
42+
retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin");
4343

44-
std::string testFile(testFiles);
45-
testFile.append("CopyBuffer_simd8_");
46-
testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]);
47-
testFile.append(".bin");
4844
ASSERT_EQ(true, fileExists(testFile));
4945

5046
binarySize = loadDataFromFile(

unit_tests/api/cl_release_kernel_tests.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -23,8 +23,6 @@
2323
#include "cl_api_tests.h"
2424
#include "runtime/context/context.h"
2525
#include "runtime/helpers/file_io.h"
26-
#include "runtime/helpers/hw_info.h"
27-
#include "runtime/helpers/options.h"
2826
#include "unit_tests/helpers/test_files.h"
2927

3028
using namespace OCLRT;
@@ -44,11 +42,8 @@ TEST_F(clReleaseKernelTests, retainAndrelease) {
4442
cl_int binaryStatus = CL_SUCCESS;
4543
void *binary = nullptr;
4644
size_t binarySize = 0;
47-
48-
std::string testFile(testFiles);
49-
testFile.append("CopyBuffer_simd8_");
50-
testFile.append(hardwarePrefix[platformDevices[0]->pPlatform->eProductFamily]);
51-
testFile.append(".bin");
45+
std::string testFile;
46+
retrieveBinaryKernelFilename(testFile, "CopyBuffer_simd8_", ".bin");
5247

5348
binarySize = loadDataFromFile(testFile.c_str(), binary);
5449

unit_tests/aub_tests/fixtures/run_kernel_fixture.h

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,14 @@ class RunKernelFixture : public CommandEnqueueAUBFixture {
6464

6565
protected:
6666
Program *CreateProgramFromBinary(
67-
const std::string &BinaryFileName) {
68-
std::string testFile;
67+
const std::string &binaryFileName) {
6968
cl_int retVal = CL_SUCCESS;
7069

71-
testFile.append(testFiles);
72-
testFile.append(BinaryFileName);
73-
EXPECT_EQ(true, fileExists(testFile));
70+
EXPECT_EQ(true, fileExists(binaryFileName));
7471

7572
void *pSource = nullptr;
7673
size_t sourceSize = loadDataFromFile(
77-
testFile.c_str(),
74+
binaryFileName.c_str(),
7875
pSource);
7976

8077
EXPECT_NE(0u, sourceSize);
@@ -99,39 +96,5 @@ class RunKernelFixture : public CommandEnqueueAUBFixture {
9996

10097
return pProgram;
10198
}
102-
103-
Program *CreateProgramFromSource(
104-
const std::string &SourceFileName) {
105-
cl_int retVal = CL_SUCCESS;
106-
std::string testFile;
107-
108-
testFile.append(testFiles);
109-
testFile.append(SourceFileName);
110-
EXPECT_EQ(true, fileExists(testFile));
111-
112-
void *pSource = nullptr;
113-
size_t sourceSize = loadDataFromFile(
114-
testFile.c_str(),
115-
pSource);
116-
117-
EXPECT_NE(0u, sourceSize);
118-
EXPECT_NE(nullptr, pSource);
119-
120-
Program *pProgram = nullptr;
121-
122-
pProgram = Program::create(
123-
context,
124-
1,
125-
(const char **)(&pSource),
126-
&sourceSize,
127-
retVal);
128-
129-
EXPECT_NE(nullptr, pProgram);
130-
EXPECT_EQ(CL_SUCCESS, retVal);
131-
132-
deleteDataReadFromFile(pSource);
133-
134-
return pProgram;
135-
}
13699
};
137100
}

unit_tests/aub_tests/gen9/skl/command_queue/run_kernel_aub_tests_skl.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -20,13 +20,8 @@
2020
* OTHER DEALINGS IN THE SOFTWARE.
2121
*/
2222

23-
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
24-
#include "runtime/memory_manager/surface.h"
25-
#include "unit_tests/fixtures/run_kernel_fixture.h"
2623
#include "unit_tests/fixtures/two_walker_fixture.h"
2724
#include "unit_tests/aub_tests/fixtures/run_kernel_fixture.h"
28-
#include "CL/cl_ext.h"
29-
#include "CL/cl.h"
3025

3126
using namespace OCLRT;
3227

@@ -56,10 +51,9 @@ SKLTEST_F(AUBRunKernelIntegrateTest, ooqExecution) {
5651
cl_event *event2 = nullptr;
5752
cl_int retVal = CL_FALSE;
5853

59-
// we would need real compiler for this
60-
//Program* pProgram = CreateProgramFromSource( "simple_kernels.cl" );
61-
62-
Program *pProgram = CreateProgramFromBinary(std::string("simple_kernels_") + pDevice->getProductAbbrev() + ".bin");
54+
std::string kernelFilename;
55+
retrieveBinaryKernelFilename(kernelFilename, "simple_kernels_", ".bin");
56+
Program *pProgram = CreateProgramFromBinary(kernelFilename);
6357
ASSERT_NE(nullptr, pProgram);
6458

6559
cl_device_id device = pDevice;
@@ -284,8 +278,9 @@ SKLTEST_F(AUBRunKernelIntegrateTest, deviceSideVme) {
284278
const int MV_BUFFER_SIZE = testWidth * mbHeight / 4;
285279
const int RESIDUALS_BUFFER_SIZE = MV_BUFFER_SIZE;
286280

287-
Program *pProgram = CreateProgramFromBinary(
288-
std::string("vme_kernels_") + pDevice->getProductAbbrev() + ".bin");
281+
std::string kernelFilename;
282+
retrieveBinaryKernelFilename(kernelFilename, "vme_kernels_", ".bin");
283+
Program *pProgram = CreateProgramFromBinary(kernelFilename);
289284
ASSERT_NE(nullptr, pProgram);
290285

291286
cl_device_id device = pDevice;

unit_tests/built_ins/sip_tests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,8 @@ TEST(DebugSip, DISABLED_givenBuiltInsWhenDbgCsrSipIsRequestedThanCorrectSipKerne
142142
EXPECT_NE(nullptr, mockDevice);
143143
MockCompilerDebugVars igcDebugVars;
144144

145-
auto product = mockDevice->getProductAbbrev();
146145
std::string name = "sip_dummy_kernel_debug";
147-
std::string builtInFileRoot = testFiles + getDebugSipKernelNameWithBitnessAndProductSuffix(name, product);
146+
std::string builtInFileRoot = testFiles + getDebugSipKernelNameWithBitnessAndProductSuffix(name, binaryNameSuffix.c_str());
148147
std::string builtInGenFile = builtInFileRoot;
149148
builtInGenFile.append(".gen");
150149

unit_tests/context/driver_diagnostics_tests.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ struct PerformanceHintEnqueueKernelTest : public PerformanceHintEnqueueTest,
242242
void SetUp() override {
243243
PerformanceHintEnqueueTest::SetUp();
244244
cl_device_id device = pPlatform->getDevice(0);
245-
CreateProgramFromBinary<Program>(context, &device, std::string("CopyBuffer_simd32"));
245+
CreateProgramFromBinary<Program>(context, &device, "CopyBuffer_simd32");
246246
retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false);
247247
ASSERT_EQ(CL_SUCCESS, retVal);
248248
kernel = Kernel::create<MockKernel>(pProgram, *pProgram->getKernelInfo("CopyBuffer"), &retVal);
@@ -278,7 +278,7 @@ struct PerformanceHintEnqueueKernelPrintfTest : public PerformanceHintEnqueueTes
278278
void SetUp() override {
279279
PerformanceHintEnqueueTest::SetUp();
280280
cl_device_id device = pPlatform->getDevice(0);
281-
CreateProgramFromBinary<Program>(context, &device, std::string("printf"));
281+
CreateProgramFromBinary<Program>(context, &device, "printf");
282282
retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false);
283283
ASSERT_EQ(CL_SUCCESS, retVal);
284284
kernel = Kernel::create(pProgram, *pProgram->getKernelInfo("test"), &retVal);

0 commit comments

Comments
 (0)