mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-22 11:21:47 +08:00
Reorganization directory structure [2/n]
Change-Id: I47962d17d755e80dcd9476e1ed75560f433f6115
This commit is contained in:
committed by
Jaroslaw Chodor
parent
d015d3633f
commit
e8852a68c4
89
opencl/test/unit_test/fixtures/program_fixture.cpp
Normal file
89
opencl/test/unit_test/fixtures/program_fixture.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "fixtures/program_fixture.h"
|
||||
|
||||
#include "opencl/source/program/create.inl"
|
||||
|
||||
#include "mocks/mock_program.h"
|
||||
|
||||
namespace NEO {
|
||||
void ProgramFixture::CreateProgramWithSource(cl_context context,
|
||||
cl_device_id *deviceList,
|
||||
const std::string &sourceFileName) {
|
||||
Cleanup();
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
std::string testFile;
|
||||
|
||||
testFile.append(clFiles);
|
||||
testFile.append(sourceFileName);
|
||||
ASSERT_EQ(true, fileExists(testFile));
|
||||
|
||||
knownSource = loadDataFromFile(
|
||||
testFile.c_str(),
|
||||
knownSourceSize);
|
||||
|
||||
ASSERT_NE(0u, knownSourceSize);
|
||||
ASSERT_NE(nullptr, knownSource);
|
||||
|
||||
const char *sources[1] = {knownSource.get()};
|
||||
pProgram = Program::create<MockProgram>(
|
||||
context,
|
||||
1,
|
||||
sources,
|
||||
&knownSourceSize,
|
||||
retVal);
|
||||
|
||||
ASSERT_NE(nullptr, pProgram);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
void ProgramFixture::CreateProgramFromBinary(cl_context context,
|
||||
cl_device_id *pDeviceList,
|
||||
const std::string &binaryFileName,
|
||||
cl_int &retVal,
|
||||
const std::string &options) {
|
||||
retVal = CL_SUCCESS;
|
||||
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilename(testFile, binaryFileName + "_", ".bin", options);
|
||||
|
||||
knownSource = loadDataFromFile(
|
||||
testFile.c_str(),
|
||||
knownSourceSize);
|
||||
|
||||
ASSERT_NE(0u, knownSourceSize);
|
||||
ASSERT_NE(nullptr, knownSource);
|
||||
|
||||
pProgram = Program::create<MockProgram>(
|
||||
context,
|
||||
1,
|
||||
pDeviceList,
|
||||
&knownSourceSize,
|
||||
(const unsigned char **)&knownSource,
|
||||
nullptr,
|
||||
retVal);
|
||||
}
|
||||
|
||||
void ProgramFixture::CreateProgramFromBinary(cl_context pContext,
|
||||
cl_device_id *pDeviceList,
|
||||
const std::string &binaryFileName,
|
||||
const std::string &options) {
|
||||
Cleanup();
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
CreateProgramFromBinary(
|
||||
pContext,
|
||||
pDeviceList,
|
||||
binaryFileName,
|
||||
retVal,
|
||||
options);
|
||||
|
||||
ASSERT_NE(nullptr, pProgram);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user