Revert "Builtins increase context refcount."

This reverts commit 39d55e5257.

Change-Id: Ib5b38e5a508c5e56e61c7f0ac0b5b8a965d6170d
This commit is contained in:
Zdunowski, Piotr
2018-05-28 16:16:06 +02:00
parent 8296fc9d58
commit 157ffbceb5
47 changed files with 194 additions and 165 deletions

View File

@@ -1229,7 +1229,7 @@ cl_program CL_API_CALL clLinkProgram(cl_context context,
pContext = castToObject<Context>(context);
}
if (pContext != nullptr) {
program = new Program(pContext);
program = new Program(pContext, false);
Program *pProgram = castToObject<Program>(program);
retVal = pProgram->link(numDevices, deviceList, options,
numInputPrograms, inputPrograms,

View File

@@ -86,6 +86,7 @@ SchedulerKernel &BuiltIns::getSchedulerKernel(Context &context) {
auto program = Program::createFromGenBinary(&context,
src.resource.data(),
src.resource.size(),
true,
&retVal);
DEBUG_BREAK_IF(retVal != CL_SUCCESS);
DEBUG_BREAK_IF(!program);
@@ -130,6 +131,7 @@ const SipKernel &BuiltIns::getSipKernel(SipKernelType type, Device &device) {
auto program = Program::createFromGenBinary(nullptr,
sipBinary.data(),
sipBinary.size(),
true,
&retVal);
DEBUG_BREAK_IF(retVal != CL_SUCCESS);
UNRECOVERABLE_IF(program == nullptr);
@@ -198,7 +200,7 @@ Program *BuiltIns::createBuiltInProgram(
Program *pBuiltInProgram = nullptr;
pBuiltInProgram = Program::create(programSourceStr.c_str(), &context, device, nullptr);
pBuiltInProgram = Program::create(programSourceStr.c_str(), &context, device, true, nullptr);
if (pBuiltInProgram) {
std::unordered_map<std::string, BuiltinDispatchInfoBuilder *> builtinsBuilders;

View File

@@ -188,10 +188,10 @@ std::unique_ptr<Program> BuiltinsLib::createProgramFromCode(const BuiltinCode &b
break;
case BuiltinCode::ECodeType::Source:
case BuiltinCode::ECodeType::Intermediate:
ret.reset(Program::create(data, &context, device, &err));
ret.reset(Program::create(data, &context, device, true, &err));
break;
case BuiltinCode::ECodeType::Binary:
ret.reset(Program::createFromGenBinary(&context, data, dataLen, nullptr));
ret.reset(Program::createFromGenBinary(&context, data, dataLen, true, nullptr));
break;
}
return ret;

View File

@@ -26,6 +26,6 @@
namespace OCLRT {
template Program *Program::create<Program>(cl_context, cl_uint, const cl_device_id *, const size_t *, const unsigned char **, cl_int *, cl_int &);
template Program *Program::create<Program>(cl_context, cl_uint, const char **, const size_t *, cl_int &);
template Program *Program::create<Program>(const char *, Context *, Device &, cl_int *);
template Program *Program::create<Program>(const char *, Context *, Device &, bool, cl_int *);
template Program *Program::createFromIL<Program>(Context *, const void *, size_t length, cl_int &);
}

View File

@@ -37,7 +37,7 @@ T *Program::create(
auto pContext = castToObject<Context>(context);
DEBUG_BREAK_IF(!pContext);
auto program = new T(pContext);
auto program = new T(pContext, false);
auto retVal = program->createProgramFromBinary(binaries[0], lengths[0]);
@@ -76,7 +76,7 @@ T *Program::create(
lengths);
if (CL_SUCCESS == retVal) {
program = new T(pContext);
program = new T(pContext, false);
program->sourceCode.swap(combinedString);
}
@@ -89,6 +89,7 @@ T *Program::create(
const char *nullTerminatedString,
Context *context,
Device &device,
bool isBuiltIn,
cl_int *errcodeRet) {
cl_int retVal = CL_SUCCESS;
T *program = nullptr;
@@ -101,7 +102,8 @@ T *Program::create(
program = new T();
program->setSource((char *)nullTerminatedString);
program->context = context;
if (program->context) {
program->isBuiltIn = isBuiltIn;
if (program->context && !program->isBuiltIn) {
program->context->incRefInternal();
}
program->pDevice = &device;
@@ -130,7 +132,7 @@ T *Program::createFromIL(Context *ctx,
return nullptr;
}
T *program = new T(ctx);
T *program = new T(ctx, false);
errcodeRet = program->createProgramFromBinary(il, length);
if (errcodeRet != CL_SUCCESS) {
delete program;

View File

@@ -35,12 +35,12 @@ namespace OCLRT {
const std::string Program::clOptNameClVer("-cl-std=CL");
const std::string Program::clOptNameUniformWgs{"-cl-uniform-work-group-size"};
Program::Program() : Program(nullptr) {
Program::Program() : Program(nullptr, false) {
numDevices = 0;
}
Program::Program(Context *context) : context(context) {
if (this->context) {
Program::Program(Context *context, bool isBuiltIn) : context(context), isBuiltIn(isBuiltIn) {
if (this->context && !this->isBuiltIn) {
this->context->incRefInternal();
}
blockKernelManager = new BlockKernelManager();
@@ -98,7 +98,7 @@ Program::Program(Context *context) : context(context) {
}
Program::~Program() {
if (context) {
if (context && !isBuiltIn) {
context->decRefInternal();
}
delete[] genBinary;

View File

@@ -76,6 +76,7 @@ class Program : public BaseObject<_cl_program> {
const char *nullTerminatedString,
Context *context,
Device &device,
bool isBuiltIn,
cl_int *errcodeRet);
template <typename T = Program>
@@ -83,6 +84,7 @@ class Program : public BaseObject<_cl_program> {
Context *context,
const void *binary,
size_t size,
bool isBuiltIn,
cl_int *errcodeRet) {
cl_int retVal = CL_SUCCESS;
T *program = nullptr;
@@ -92,7 +94,7 @@ class Program : public BaseObject<_cl_program> {
}
if (CL_SUCCESS == retVal) {
program = new T(context);
program = new T(context, isBuiltIn);
program->numDevices = 1;
program->storeGenBinary(binary, size);
program->isCreatedFromBinary = true;
@@ -114,7 +116,7 @@ class Program : public BaseObject<_cl_program> {
size_t length,
cl_int &errcodeRet);
Program(Context *context);
Program(Context *context, bool isBuiltIn);
~Program() override;
Program(const Program &) = delete;
@@ -227,7 +229,9 @@ class Program : public BaseObject<_cl_program> {
bool getAllowNonUniform() const {
return allowNonUniform;
}
bool getIsBuiltIn() const {
return isBuiltIn;
}
uint32_t getProgramOptionVersion() const {
return programOptionVersion;
}
@@ -329,6 +333,7 @@ class Program : public BaseObject<_cl_program> {
Device* pDevice;
cl_uint numDevices;
bool isBuiltIn;
bool kernelDebugEnabled = false;
friend class OfflineCompiler;
// clang-format on

View File

@@ -47,7 +47,7 @@ void api_fixture::SetUp() {
pCommandQueue = new CommandQueue(pContext, pDevice, 0);
pProgram = new MockProgram(pContext);
pProgram = new MockProgram(pContext, false);
pKernel = new MockKernel(pProgram, *pProgram->MockProgram::getKernelInfo(), *pDevice);
ASSERT_NE(nullptr, pKernel);
@@ -76,7 +76,7 @@ void api_fixture_using_aligned_memory_manager::SetUp() {
commandQueue = new CommandQueue(context, devPtr, 0);
program = new MockProgram(ctxPtr);
program = new MockProgram(ctxPtr, false);
Program *prgPtr = reinterpret_cast<Program *>(program);
kernel = new MockKernel(prgPtr, *program->MockProgram::getKernelInfo(), *devPtr);

View File

@@ -93,7 +93,7 @@ TEST_F(clCreateKernelTests, invalidKernel) {
pKernelInfo->isValid = false;
pKernelInfo->name = "CopyBuffer";
MockProgram *pMockProg = new MockProgram(pContext);
MockProgram *pMockProg = new MockProgram(pContext, false);
pMockProg->addKernelInfo(pKernelInfo);
kernel = clCreateKernel(

View File

@@ -52,7 +52,7 @@ struct AUBCopyImage
void TearDown() override {
delete srcImage;
delete dstImage;
context->decRefInternal();
delete context;
CommandStreamFixture::TearDown();
CommandDeviceFixture::TearDown();
}

View File

@@ -113,7 +113,7 @@ struct AubFillImage
void TearDown() override {
delete image;
context->decRefInternal();
delete context;
CommandStreamFixture::TearDown();
CommandDeviceFixture::TearDown();
}

View File

@@ -63,7 +63,7 @@ struct AUBMapImage
void TearDown() override {
delete srcImage;
context->decRefInternal();
delete context;
CommandStreamFixture::TearDown();
CommandDeviceFixture::TearDown();
}

View File

@@ -62,7 +62,7 @@ struct AUBReadImage
void TearDown() override {
delete srcImage;
context->decRefInternal();
delete context;
CommandStreamFixture::TearDown();
CommandDeviceFixture::TearDown();
}

View File

@@ -60,7 +60,7 @@ struct AUBWriteImage
void TearDown() override {
delete dstImage;
context->decRefInternal();
delete context;
CommandStreamFixture::TearDown();
CommandDeviceFixture::TearDown();
}

View File

@@ -832,16 +832,6 @@ TEST_F(BuiltInTests, getBuiltinResourcesForTypeBinary) {
EXPECT_EQ(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::COUNT, BuiltinCode::ECodeType::Binary, *pDevice).size());
}
TEST_F(BuiltInTests, givenCreateProgramFromCodeWhenReferenceCountedContextThenContextRefCountIncreases) {
auto builtinsLib = std::unique_ptr<BuiltinsLib>(new BuiltinsLib());
const BuiltinCode bc = builtinsLib->getBuiltinCode(EBuiltInOps::CopyBufferToBuffer, BuiltinCode::ECodeType::Any, *pDevice);
EXPECT_NE(0u, bc.resource.size());
auto refCount = pContext->getRefInternalCount();
auto program = std::unique_ptr<Program>(BuiltinsLib::createProgramFromCode(bc, *pContext, *pDevice));
EXPECT_EQ(pContext->getRefInternalCount(), refCount + 1);
EXPECT_NE(nullptr, program.get());
}
TEST_F(BuiltInTests, createProgramFromCodeForTypeAny) {
auto builtinsLib = std::unique_ptr<BuiltinsLib>(new BuiltinsLib());
const BuiltinCode bc = builtinsLib->getBuiltinCode(EBuiltInOps::CopyBufferToBuffer, BuiltinCode::ECodeType::Any, *pDevice);
@@ -1490,7 +1480,8 @@ TEST_F(BuiltInTests, getSipKernelReturnsProgramCreatedOutOfIsaAcquiredFromCompil
mockCompilerInterface.overrideGlobalCompilerInterface();
mockCompilerInterface.sipKernelBinaryOverride = mockCompilerInterface.getDummyGenBinary();
cl_int errCode = CL_BUILD_PROGRAM_FAILURE;
auto p = Program::createFromGenBinary(pContext, mockCompilerInterface.sipKernelBinaryOverride.data(), mockCompilerInterface.sipKernelBinaryOverride.size(), &errCode);
auto p = Program::createFromGenBinary(pContext, mockCompilerInterface.sipKernelBinaryOverride.data(), mockCompilerInterface.sipKernelBinaryOverride.size(),
false, &errCode);
ASSERT_EQ(CL_SUCCESS, errCode);
errCode = p->processGenBinary();
ASSERT_EQ(CL_SUCCESS, errCode);

View File

@@ -711,39 +711,35 @@ struct WaitForQueueCompletionTests : public ::testing::Test {
void SetUp() override {
device.reset(Device::create<MockDevice>(*platformDevices));
context = new MockContext(device.get());
}
void TearDown() override {
context->decRefInternal();
context.reset(new MockContext(device.get()));
}
std::unique_ptr<MockDevice> device;
MockContext *context = nullptr;
std::unique_ptr<MockContext> context;
};
HWTEST_F(WaitForQueueCompletionTests, givenBlockingCallAndUnblockedQueueWhenEnqueuedThenCallWaitWithoutQuickKmdSleepRequest) {
std::unique_ptr<MyCmdQueue<FamilyType>> cmdQ(new MyCmdQueue<FamilyType>(context, device.get()));
std::unique_ptr<MyCmdQueue<FamilyType>> cmdQ(new MyCmdQueue<FamilyType>(context.get(), device.get()));
uint32_t tmpPtr = 0;
auto buffer = std::unique_ptr<Buffer>(BufferHelper<>::create(context));
auto buffer = std::unique_ptr<Buffer>(BufferHelper<>::create(context.get()));
cmdQ->enqueueReadBuffer(buffer.get(), CL_TRUE, 0, 1, &tmpPtr, 0, nullptr, nullptr);
EXPECT_EQ(1u, cmdQ->waitUntilCompleteCounter);
EXPECT_FALSE(cmdQ->requestedUseQuickKmdSleep);
}
HWTEST_F(WaitForQueueCompletionTests, givenBlockingCallAndBlockedQueueWhenEnqueuedThenCallWaitWithoutQuickKmdSleepRequest) {
std::unique_ptr<MyCmdQueue<FamilyType>> cmdQ(new MyCmdQueue<FamilyType>(context, device.get()));
std::unique_ptr<MyCmdQueue<FamilyType>> cmdQ(new MyCmdQueue<FamilyType>(context.get(), device.get()));
std::unique_ptr<Event> blockingEvent(new Event(cmdQ.get(), CL_COMMAND_NDRANGE_KERNEL, 0, 0));
cl_event clBlockingEvent = blockingEvent.get();
uint32_t tmpPtr = 0;
auto buffer = std::unique_ptr<Buffer>(BufferHelper<>::create(context));
auto buffer = std::unique_ptr<Buffer>(BufferHelper<>::create(context.get()));
cmdQ->enqueueReadBuffer(buffer.get(), CL_TRUE, 0, 1, &tmpPtr, 1, &clBlockingEvent, nullptr);
EXPECT_EQ(1u, cmdQ->waitUntilCompleteCounter);
EXPECT_FALSE(cmdQ->requestedUseQuickKmdSleep);
}
HWTEST_F(WaitForQueueCompletionTests, whenFinishIsCalledThenCallWaitWithoutQuickKmdSleepRequest) {
std::unique_ptr<MyCmdQueue<FamilyType>> cmdQ(new MyCmdQueue<FamilyType>(context, device.get()));
std::unique_ptr<MyCmdQueue<FamilyType>> cmdQ(new MyCmdQueue<FamilyType>(context.get(), device.get()));
cmdQ->finish(false);
EXPECT_EQ(1u, cmdQ->waitUntilCompleteCounter);
EXPECT_FALSE(cmdQ->requestedUseQuickKmdSleep);

View File

@@ -51,7 +51,7 @@ struct EnqueueReadImageTest : public CommandEnqueueFixture,
virtual void TearDown(void) override {
delete srcImage;
delete[] dstPtr;
context->decRefInternal();
delete context;
CommandEnqueueFixture::TearDown();
}

View File

@@ -467,7 +467,7 @@ TEST_F(EnqueueSvmTest, enqueueTaskWithKernelExecInfo_success) {
GraphicsAllocation *pSvmAlloc = context->getSVMAllocsManager()->getSVMAlloc(ptrSVM);
EXPECT_NE(nullptr, ptrSVM);
std::unique_ptr<Program> program(Program::create("FillBufferBytes", context, *pDevice, &retVal));
std::unique_ptr<Program> program(Program::create("FillBufferBytes", context, *pDevice, true, &retVal));
cl_device_id device = pDevice;
program->build(1, &device, nullptr, nullptr, nullptr, false);
std::unique_ptr<Kernel> kernel(Kernel::create<MockKernel>(program.get(), *program->getKernelInfo("FillBufferBytes"), &retVal));
@@ -494,7 +494,7 @@ TEST_F(EnqueueSvmTest, givenEnqueueTaskBlockedOnUserEventWhenItIsEnqueuedThenSur
GraphicsAllocation *pSvmAlloc = context->getSVMAllocsManager()->getSVMAlloc(ptrSVM);
EXPECT_NE(nullptr, ptrSVM);
std::unique_ptr<Program> program(Program::create("FillBufferBytes", context, *pDevice, &retVal));
std::unique_ptr<Program> program(Program::create("FillBufferBytes", context, *pDevice, true, &retVal));
cl_device_id device = pDevice;
program->build(1, &device, nullptr, nullptr, nullptr, false);
std::unique_ptr<Kernel> kernel(Kernel::create<MockKernel>(program.get(), *program->getKernelInfo("FillBufferBytes"), &retVal));

View File

@@ -50,7 +50,7 @@ struct EnqueueWriteImageTest : public CommandEnqueueFixture,
virtual void TearDown(void) override {
delete dstImage;
delete[] srcPtr;
context->decRefInternal();
delete context;
CommandEnqueueFixture::TearDown();
}

View File

@@ -128,7 +128,7 @@ HWTEST_F(GetSizeRequiredImageTest, enqueueCopyReadAndWriteImage) {
auto usedBeforeIOH = ioh.getUsed();
auto usedBeforeSSH = ssh.getUsed();
std::unique_ptr<Program> program(Program::create("CopyImageToImage3d", context, *pDevice, nullptr));
std::unique_ptr<Program> program(Program::create("CopyImageToImage3d", context, *pDevice, true, nullptr));
cl_device_id device = pDevice;
program->build(1, &device, nullptr, nullptr, nullptr, false);
std::unique_ptr<Kernel> kernel(Kernel::create<MockKernel>(program.get(), *program->getKernelInfo("CopyImageToImage3d"), nullptr));

View File

@@ -119,7 +119,7 @@ struct MultipleMapBufferTest : public DeviceFixture, public ::testing::Test {
}
void TearDown() override {
context->decRefInternal();
delete context;
DeviceFixture::TearDown();
}

View File

@@ -123,7 +123,7 @@ struct MultipleMapImageTest : public DeviceFixture, public ::testing::Test {
}
void TearDown() override {
context->decRefInternal();
delete context;
DeviceFixture::TearDown();
}

View File

@@ -352,7 +352,7 @@ TEST_F(CompilerInterfaceCachedTests, canInjectCache) {
}
TEST_F(CompilerInterfaceCachedTests, notCachedAndIgcFailed) {
MockContext context(pDevice, true);
MockProgram program(&context);
MockProgram program(&context, false);
BinaryCacheMock cache;
TranslationArgs inputArgs;
@@ -383,7 +383,7 @@ TEST_F(CompilerInterfaceCachedTests, notCachedAndIgcFailed) {
TEST_F(CompilerInterfaceCachedTests, wasCached) {
MockContext context(pDevice, true);
MockProgram program(&context);
MockProgram program(&context, false);
BinaryCacheMock cache;
TranslationArgs inputArgs;
@@ -414,7 +414,7 @@ TEST_F(CompilerInterfaceCachedTests, wasCached) {
TEST_F(CompilerInterfaceCachedTests, builtThenCached) {
MockContext context(pDevice, true);
MockProgram program(&context);
MockProgram program(&context, false);
BinaryCacheMock cache;
TranslationArgs inputArgs;
@@ -444,7 +444,7 @@ TEST_F(CompilerInterfaceCachedTests, builtThenCached) {
TEST_F(CompilerInterfaceCachedTests, givenKernelWithoutIncludesAndBinaryInCacheWhenCompilationRequestedThenFCLIsNotCalled) {
MockContext context(pDevice, true);
MockProgram program(&context);
MockProgram program(&context, false);
BinaryCacheMock cache;
TranslationArgs inputArgs;
@@ -478,7 +478,7 @@ TEST_F(CompilerInterfaceCachedTests, givenKernelWithoutIncludesAndBinaryInCacheW
TEST_F(CompilerInterfaceCachedTests, givenKernelWithIncludesAndBinaryInCacheWhenCompilationRequestedThenFCLIsCalled) {
MockContext context(pDevice, true);
MockProgram program(&context);
MockProgram program(&context, false);
BinaryCacheMock cache;
TranslationArgs inputArgs;

View File

@@ -79,7 +79,7 @@ class CompilerInterfaceTest : public DeviceFixture,
cl_device_id clDevice = pDevice;
pContext = Context::create<MockContext>(nullptr, DeviceVector(&clDevice, 1), nullptr, nullptr, retVal);
pProgram = new Program(pContext);
pProgram = new Program(pContext, false);
inputArgs.pInput = (char *)pSource;
inputArgs.InputSize = (uint32_t)sourceSize;
@@ -479,7 +479,7 @@ TEST_F(CompilerInterfaceTest, igcBuildFailure) {
TEST_F(CompilerInterfaceTest, CompileAndLinkSpirToIsa) {
// compile and link from SPIR binary to gen ISA
MockProgram program(pContext);
MockProgram program(pContext, false);
char binary[] = "BC\xc0\xde ";
auto retVal = program.createProgramFromBinary(binary, sizeof(binary));
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -491,7 +491,7 @@ TEST_F(CompilerInterfaceTest, CompileAndLinkSpirToIsa) {
TEST_F(CompilerInterfaceTest, BuildSpirToIsa) {
// build from SPIR binary to gen ISA
MockProgram program(pContext);
MockProgram program(pContext, false);
char binary[] = "BC\xc0\xde ";
auto retVal = program.createProgramFromBinary(binary, sizeof(binary));
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -501,7 +501,7 @@ TEST_F(CompilerInterfaceTest, BuildSpirToIsa) {
TEST_F(CompilerInterfaceTest, BuildSpirvToIsa) {
// build from SPIR binary to gen ISA
MockProgram program(pContext);
MockProgram program(pContext, false);
uint64_t spirv[16] = {0x03022307};
auto retVal = program.createProgramFromBinary(spirv, sizeof(spirv));
EXPECT_EQ(CL_SUCCESS, retVal);

View File

@@ -28,7 +28,7 @@ namespace OCLRT {
template OCLRT::MockProgram *Program::create<MockProgram>(cl_context, cl_uint, const char **, const size_t *, cl_int &);
template OCLRT::MockProgram *Program::create<MockProgram>(cl_context, cl_uint, const cl_device_id *, const size_t *, const unsigned char **, cl_int *, cl_int &);
template OCLRT::MockProgram *Program::create<MockProgram>(const char *, Context *, Device &, cl_int *);
template OCLRT::MockProgram *Program::create<MockProgram>(const char *, Context *, Device &, bool, cl_int *);
template void ProgramFixture::CreateProgramFromBinary<Program>(cl_context, cl_device_id *, const std::string &, const std::string &);
template void ProgramFixture::CreateProgramFromBinary<Program>(cl_context, cl_device_id *, const std::string &, cl_int &, const std::string &);
template void ProgramFixture::CreateProgramFromBinary<MockProgram>(cl_context, cl_device_id *, const std::string &, const std::string &);

View File

@@ -49,7 +49,7 @@ class ScenarioTest : public ::testing::Test,
cl_device_id clDevice = pDevice;
context = Context::create<MockContext>(nullptr, DeviceVector(&clDevice, 1), nullptr, nullptr, retVal);
commandQueue = new MockCommandQueue(context, pDevice, 0);
program = new MockProgram(context);
program = new MockProgram(context, false);
kernelInternals = new MockKernelWithInternals(*pDevice, context);
kernel = kernelInternals->mockKernel;

View File

@@ -819,7 +819,7 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenKernelWithoutSSHIsUsedThenK
// Prepare a kernel without SSH
char binary[1024] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'};
size_t binSize = 10;
Program *pProgram = Program::createFromGenBinary(pContext, &binary[0], binSize, &retVal);
Program *pProgram = Program::createFromGenBinary(pContext, &binary[0], binSize, false, &retVal);
ASSERT_NE(nullptr, pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -907,7 +907,7 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenKernelWithExecEnvIsUsedThen
// Prepare a kernel with fake Execution Environment
char binary[1024] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'};
size_t binSize = 10;
Program *pProgram = Program::createFromGenBinary(pContext, &binary[0], binSize, &retVal);
Program *pProgram = Program::createFromGenBinary(pContext, &binary[0], binSize, false, &retVal);
ASSERT_NE(nullptr, pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -1793,7 +1793,7 @@ TEST_F(GTPinTests, givenInitializedGTPinInterfaceWhenLowMemoryConditionOccursThe
// Prepare a program with one kernel having Stateless Private Surface
char binary[1024] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'};
size_t binSize = 10;
Program *pProgram = Program::createFromGenBinary(pContext, &binary[0], binSize, &retVal);
Program *pProgram = Program::createFromGenBinary(pContext, &binary[0], binSize, false, &retVal);
ASSERT_NE(nullptr, pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);

View File

@@ -79,7 +79,7 @@ class DispatchInfoBuilderFixture : public ContextFixture, public DeviceFixture {
pKernelInfo->kernelArgInfo[2].kernelArgPatchInfoVector[0].crossthreadOffset = 0x50;
pKernelInfo->kernelArgInfo[2].kernelArgPatchInfoVector[0].size = (uint32_t)sizeof(void *);
pProgram = new MockProgram(pContext);
pProgram = new MockProgram(pContext, false);
pKernel = new MockKernel(pProgram, *pKernelInfo, *pDevice);
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());

View File

@@ -51,7 +51,7 @@ class DispatchInfoFixture : public ContextFixture, public DeviceFixture {
pKernelInfo->patchInfo.mediavfestate = pMediaVFEstate;
pPrintfSurface = new SPatchAllocateStatelessPrintfSurface();
pKernelInfo->patchInfo.pAllocateStatelessPrintfSurface = pPrintfSurface;
pProgram = new MockProgram(pContext);
pProgram = new MockProgram(pContext, false);
pKernel = new MockKernel(pProgram, *pKernelInfo, *pDevice);
pKernel->slmTotalSize = 128;

View File

@@ -183,7 +183,7 @@ HWTEST_F(KernelCommandsTest, givenSendCrossThreadDataWhenWhenAddPatchInfoComment
CommandQueueHw<FamilyType> cmdQ(pContext, pDevice, 0);
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
std::unique_ptr<KernelInfo> kernelInfo(KernelInfo::create());
std::unique_ptr<MockKernel> kernel(new MockKernel(&program, *kernelInfo, *pDevice));
@@ -238,7 +238,7 @@ HWTEST_F(KernelCommandsTest, givenSendCrossThreadDataWhenWhenAddPatchInfoComment
CommandQueueHw<FamilyType> cmdQ(pContext, pDevice, 0);
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
std::unique_ptr<KernelInfo> kernelInfo(KernelInfo::create());
std::unique_ptr<MockKernel> kernel(new MockKernel(&program, *kernelInfo, *pDevice));
@@ -462,7 +462,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, KernelCommandsTest, usedBindingTableStatePointersFor
// create program with valid context
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
// setup global memory
char globalBuffer[16];
@@ -586,7 +586,7 @@ HWTEST_F(KernelCommandsTest, setBindingTableStatesForKernelWithBuffersNotRequiri
// create program with valid context
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
// create kernel
MockKernel *pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
@@ -645,7 +645,7 @@ HWTEST_F(KernelCommandsTest, setBindingTableStatesForNoSurfaces) {
// create program with valid context
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
// create kernel
MockKernel *pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);

View File

@@ -94,7 +94,7 @@ class CloneKernelFixture : public ContextFixture, public DeviceFixture {
pKernelInfo->kernelArgInfo[0].offsetVmeSadAdjustMode = 0x14;
pKernelInfo->kernelArgInfo[0].offsetVmeSearchPathType = 0x1c;
pProgram = new MockProgram(pContext);
pProgram = new MockProgram(pContext, false);
pSourceKernel = new MockKernel(pProgram, *pKernelInfo, *pDevice);
ASSERT_EQ(CL_SUCCESS, pSourceKernel->initialize());

View File

@@ -75,7 +75,7 @@ class KernelArgAcceleratorFixture : public ContextFixture, public DeviceFixture
pKernelInfo->kernelArgInfo[0].offsetVmeSadAdjustMode = 0x14;
pKernelInfo->kernelArgInfo[0].offsetVmeSearchPathType = 0x1c;
pProgram = new MockProgram(pContext);
pProgram = new MockProgram(pContext, false);
pKernel = new MockKernel(pProgram, *pKernelInfo, *pDevice);
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());

View File

@@ -60,7 +60,7 @@ void KernelArgBufferFixture::SetUp() {
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset = 0x30;
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].size = (uint32_t)sizeof(void *);
pProgram = new MockProgram(pContext);
pProgram = new MockProgram(pContext, false);
pKernel = new MockKernel(pProgram, *pKernelInfo, *pDevice);
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());

View File

@@ -69,7 +69,7 @@ class KernelArgPipeFixture : public ContextFixture, public DeviceFixture {
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset = 0x30;
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].size = (uint32_t)sizeof(void *);
pProgram = new MockProgram(pContext);
pProgram = new MockProgram(pContext, false);
pKernel = new MockKernel(pProgram, *pKernelInfo, *pDevice);
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());

View File

@@ -68,7 +68,7 @@ class KernelArgSvmFixture_ : public ContextFixture, public DeviceFixture {
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset = 0x30;
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].size = (uint32_t)sizeof(void *);
pProgram = new MockProgram(pContext);
pProgram = new MockProgram(pContext, false);
pKernel = new MockKernel(pProgram, *pKernelInfo, *pDevice);
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());

View File

@@ -31,8 +31,8 @@ class PatchedKernelTest : public ::testing::Test {
public:
void SetUp() override {
device.reset(MockDevice::create<MockDevice>(nullptr));
context = new MockContext(device.get());
program.reset(Program::create("FillBufferBytes", context, *device.get(), &retVal));
context.reset(new MockContext(device.get()));
program.reset(Program::create("FillBufferBytes", context.get(), *device.get(), true, &retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
cl_device_id clDevice = device.get();
program->build(1, &clDevice, nullptr, nullptr, nullptr, false);
@@ -40,10 +40,10 @@ class PatchedKernelTest : public ::testing::Test {
EXPECT_EQ(CL_SUCCESS, retVal);
}
void TearDown() override {
context->decRefInternal();
context.reset();
}
MockContext *context = nullptr;
std::unique_ptr<MockContext> context;
std::unique_ptr<MockDevice> device;
std::unique_ptr<Program> program;
std::unique_ptr<Kernel> kernel;
@@ -55,7 +55,7 @@ TEST_F(PatchedKernelTest, givenKernelWithoutPatchedArgsWhenIsPatchedIsCalledThen
}
TEST_F(PatchedKernelTest, givenKernelWithAllArgsSetWithBufferWhenIsPatchedIsCalledThenReturnsTrue) {
auto buffer = clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(int), nullptr, &retVal);
auto buffer = clCreateBuffer(context.get(), CL_MEM_READ_ONLY, sizeof(int), nullptr, &retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
auto argsNum = kernel->getKernelArgsNumber();
for (uint32_t i = 0; i < argsNum; i++) {
@@ -66,7 +66,7 @@ TEST_F(PatchedKernelTest, givenKernelWithAllArgsSetWithBufferWhenIsPatchedIsCall
}
TEST_F(PatchedKernelTest, givenKernelWithoutAllArgsSetWhenIsPatchedIsCalledThenReturnsFalse) {
auto buffer = clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(int), nullptr, &retVal);
auto buffer = clCreateBuffer(context.get(), CL_MEM_READ_ONLY, sizeof(int), nullptr, &retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
auto argsNum = kernel->getKernelArgsNumber();
for (uint32_t i = 0; i < argsNum; i++) {
@@ -103,7 +103,7 @@ TEST_F(PatchedKernelTest, givenKernelWithAllArgsSetWithSvmWhenIsPatchedIsCalledT
TEST_F(PatchedKernelTest, givenKernelWithOneArgumentToPatchWhichIsNonzeroIndexedWhenThatArgumentIsSetThenKernelIsPatched) {
uint32_t size = sizeof(int);
MockKernelWithInternals mockKernel(*device.get(), context);
MockKernelWithInternals mockKernel(*device.get(), context.get());
EXPECT_EQ(0u, mockKernel.kernelInfo.argumentsToPatchNum);
mockKernel.kernelInfo.storeKernelArgPatchInfo(1, 0, 0, 0, 0);
EXPECT_EQ(1u, mockKernel.kernelInfo.argumentsToPatchNum);

View File

@@ -488,7 +488,7 @@ TEST_F(KernelPrivateSurfaceTest, testPrivateSurface) {
// create kernel
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
MockKernel *pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
@@ -528,7 +528,7 @@ TEST_F(KernelPrivateSurfaceTest, givenKernelWithPrivateSurfaceThatIsInUseByGpuWh
pKernelInfo->patchInfo.executionEnvironment = &tokenEE;
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
std::unique_ptr<MockKernel> pKernel(new MockKernel(&program, *pKernelInfo, *pDevice));
pKernel->initialize();
@@ -572,7 +572,7 @@ TEST_F(KernelPrivateSurfaceTest, testPrivateSurfaceAllocationFailure) {
// create kernel
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
MemoryManagementFixture::InjectedFunction method = [&](size_t failureIndex) {
MockKernel *pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
@@ -619,7 +619,7 @@ TEST_F(KernelPrivateSurfaceTest, given32BitDeviceWhenKernelIsCreatedThenPrivateS
// create kernel
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
MockKernel *pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
@@ -652,7 +652,7 @@ HWTEST_F(KernelPrivateSurfaceTest, givenStatefulKernelWhenKernelIsCreatedThenPri
pKernelInfo->patchInfo.pAllocateStatelessPrivateSurface = &AllocateStatelessPrivateMemorySurface;
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
// create kernel
MockKernel *pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
@@ -703,7 +703,7 @@ TEST_F(KernelPrivateSurfaceTest, givenStatelessKernelWhenKernelIsCreatedThenPriv
GraphicsAllocation gfxAlloc(buffer, sizeof(buffer));
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
program.setConstantSurface(&gfxAlloc);
// create kernel
@@ -751,7 +751,7 @@ TEST_F(KernelPrivateSurfaceTest, GivenKernelWhenPrivateSurfaceTooBigAndGpuPointe
pKernelInfo->patchInfo.pAllocateStatelessPrivateSurface = pAllocateStatelessPrivateSurface.get();
pKernelInfo->patchInfo.executionEnvironment = executionEnvironment.get();
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
std::unique_ptr<MockKernel> pKernel(new MockKernel(&program, *pKernelInfo, *pDevice));
pKernelInfo->gpuPointerSize = 4;
pDevice->getMemoryManager()->setForce32BitAllocations(false);
@@ -769,7 +769,7 @@ TEST_F(KernelPrivateSurfaceTest, GivenKernelWhenPrivateSurfaceTooBigAndGpuPointe
pKernelInfo->patchInfo.pAllocateStatelessPrivateSurface = pAllocateStatelessPrivateSurface.get();
pKernelInfo->patchInfo.executionEnvironment = executionEnvironment.get();
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
std::unique_ptr<MockKernel> pKernel(new MockKernel(&program, *pKernelInfo, *pDevice));
pKernelInfo->gpuPointerSize = 4;
pDevice->getMemoryManager()->setForce32BitAllocations(true);
@@ -787,7 +787,7 @@ TEST_F(KernelPrivateSurfaceTest, GivenKernelWhenPrivateSurfaceTooBigAndGpuPointe
pKernelInfo->patchInfo.pAllocateStatelessPrivateSurface = pAllocateStatelessPrivateSurface.get();
pKernelInfo->patchInfo.executionEnvironment = executionEnvironment.get();
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
std::unique_ptr<MockKernel> pKernel(new MockKernel(&program, *pKernelInfo, *pDevice));
pKernelInfo->gpuPointerSize = 8;
pDevice->getMemoryManager()->setForce32BitAllocations(true);
@@ -825,7 +825,7 @@ TEST_F(KernelGlobalSurfaceTest, givenBuiltInKernelWhenKernelIsCreatedThenGlobalS
// create kernel
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
program.setGlobalSurface(&gfxAlloc);
MockKernel *pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
@@ -906,7 +906,7 @@ HWTEST_F(KernelGlobalSurfaceTest, givenStatefulKernelWhenKernelIsCreatedThenGlob
void *bufferAddress = gfxAlloc.getUnderlyingBuffer();
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
program.setGlobalSurface(&gfxAlloc);
// create kernel
@@ -1084,7 +1084,7 @@ HWTEST_F(KernelConstantSurfaceTest, givenStatefulKernelWhenKernelIsCreatedThenCo
void *bufferAddress = gfxAlloc.getUnderlyingBuffer();
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
program.setConstantSurface(&gfxAlloc);
// create kernel
@@ -1173,7 +1173,7 @@ HWTEST_F(KernelEventPoolSurfaceTest, givenStatefulKernelWhenKernelIsCreatedThenE
pKernelInfo->patchInfo.pAllocateStatelessEventPoolSurface = &AllocateStatelessEventPoolSurface;
// create kernel
MockProgram program(&context);
MockProgram program(&context, false);
MockKernel *pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
// setup surface state heap
@@ -1226,7 +1226,7 @@ HWTEST_F(KernelEventPoolSurfaceTest, givenStatefulKernelWhenEventPoolIsPatchedTh
pKernelInfo->patchInfo.pAllocateStatelessEventPoolSurface = &AllocateStatelessEventPoolSurface;
// create kernel
MockProgram program(&context);
MockProgram program(&context, false);
MockKernel *pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
// setup surface state heap
@@ -1388,7 +1388,7 @@ HWTEST_F(KernelDefaultDeviceQueueSurfaceTest, givenStatefulKernelWhenKernelIsCre
pKernelInfo->patchInfo.pAllocateStatelessDefaultDeviceQueueSurface = &AllocateStatelessDefaultDeviceQueueSurface;
// create kernel
MockProgram program(&context);
MockProgram program(&context, false);
MockKernel *pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
// setup surface state heap
@@ -1441,7 +1441,7 @@ HWTEST_F(KernelDefaultDeviceQueueSurfaceTest, givenStatefulKernelWhenDefaultDevi
pKernelInfo->patchInfo.pAllocateStatelessDefaultDeviceQueueSurface = &AllocateStatelessDefaultDeviceQueueSurface;
// create kernel
MockProgram program(&context);
MockProgram program(&context, false);
MockKernel *pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
// setup surface state heap
@@ -2189,7 +2189,7 @@ TEST(KernelTest, givenKernelWithKernelInfoWith32bitPointerSizeThenReport32bit) {
info.gpuPointerSize = 4;
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
std::unique_ptr<MockDevice> device(Device::create<OCLRT::MockDevice>(nullptr));
std::unique_ptr<MockKernel> kernel(new MockKernel(&program, info, *device.get()));
@@ -2201,7 +2201,7 @@ TEST(KernelTest, givenKernelWithKernelInfoWith64bitPointerSizeThenReport64bit) {
info.gpuPointerSize = 8;
MockContext context;
MockProgram program(&context);
MockProgram program(&context, false);
std::unique_ptr<MockDevice> device(Device::create<OCLRT::MockDevice>(nullptr));
std::unique_ptr<MockKernel> kernel(new MockKernel(&program, info, *device.get()));

View File

@@ -79,7 +79,7 @@ class BufferSetArgTest : public ContextFixture,
pKernelInfo->heapInfo.pKernelHeader = &kernelHeader;
pKernelInfo->usesSsh = true;
pProgram = new MockProgram(pContext);
pProgram = new MockProgram(pContext, false);
pKernel = new MockKernel(pProgram, *pKernelInfo, *pDevice);
ASSERT_NE(nullptr, pKernel);

View File

@@ -32,16 +32,12 @@ class ImageHostPtrTransferTests : public testing::Test {
public:
void SetUp() override {
device.reset(Device::create<MockDevice>(*platformDevices));
context = new MockContext(device.get());
}
void TearDown() override {
context->decRefInternal();
context.reset(new MockContext(device.get()));
}
template <typename ImageTraits>
void createImageAndSetTestParams() {
image.reset(ImageHelper<ImageUseHostPtr<ImageTraits>>::create(context));
image.reset(ImageHelper<ImageUseHostPtr<ImageTraits>>::create(context.get()));
imgDesc = &image->getImageDesc();
@@ -69,7 +65,7 @@ class ImageHostPtrTransferTests : public testing::Test {
}
std::unique_ptr<MockDevice> device;
MockContext *context = nullptr;
std::unique_ptr<MockContext> context;
std::unique_ptr<Image> image;
const cl_image_desc *imgDesc = nullptr;

View File

@@ -276,7 +276,7 @@ class MockKernelWithInternals {
mockContext = context;
}
mockProgram = new MockProgram(context);
mockProgram = new MockProgram(context, false);
mockKernel = new MockKernel(mockProgram, kernelInfo, deviceArg);
mockKernel->setCrossThreadData(&crossThreadData, sizeof(crossThreadData));
mockKernel->setSshLocal(&sshLocal, sizeof(sshLocal));

View File

@@ -25,18 +25,20 @@
#include "runtime/helpers/options.h"
#include "runtime/helpers/string.h"
#include "runtime/program/program.h"
#include "runtime/context/context.h"
namespace OCLRT {
class GraphicsAllocation;
////////////////////////////////////////////////////////////////////////////////
// Program - Core implementation
////////////////////////////////////////////////////////////////////////////////
class MockProgram : public Program {
public:
using Program::isKernelDebugEnabled;
MockProgram() : Program() {}
MockProgram(Context *context) : Program(context) {}
MockProgram(Context *context, bool isBuiltinKernel) : Program(context, isBuiltinKernel) {}
~MockProgram() {
if (contextSet)
context = nullptr;
@@ -86,7 +88,6 @@ class MockProgram : public Program {
void setContext(Context *context) {
this->context = context;
contextSet = true;
this->context->incRefInternal();
}
void SetBuildStatus(cl_build_status st) { buildStatus = st; }
@@ -165,7 +166,7 @@ inline Program *getSipProgramWithCustomBinary() {
pKHdr->CheckSum = static_cast<uint32_t>(hashValue & 0xFFFFFFFF);
auto errCode = CL_SUCCESS;
auto program = Program::createFromGenBinary(nullptr, binary, totalSize, &errCode);
auto program = Program::createFromGenBinary(nullptr, binary, totalSize, false, &errCode);
UNRECOVERABLE_IF(errCode != CL_SUCCESS);
errCode = program->processGenBinary();
UNRECOVERABLE_IF(errCode != CL_SUCCESS);

View File

@@ -564,7 +564,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsBuffer) {
auto buffer = BufferHelper<>::create(&context);
cl_mem clObj = buffer;
MockProgram program(&context);
MockProgram program(&context, false);
auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create());
auto device = unique_ptr<Device>(Device::create<OCLRT::Device>(nullptr, false));
auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device));

View File

@@ -55,7 +55,7 @@ inline cl_int GetDecodeErrorCode(const std::vector<char> &binary, bool allowUnha
prog.reset(OCLRT::Program::createFromGenBinary<PT>(nullptr,
binary.data(),
binary.size(),
&errorCode));
false, &errorCode));
prog->allowUnhandledTokens = allowUnhandledTokens;
prog->lastUnhandledTokenFound = defaultUnhandledTokenId;
auto ret = prog->processGenBinary();

View File

@@ -42,7 +42,7 @@ TEST(PrintfHandlerTest, givenNotPreparedPrintfHandlerWhenGetSurfaceIsCalledThenR
KernelInfo *pKernelInfo = new KernelInfo();
pKernelInfo->patchInfo.pAllocateStatelessPrintfSurface = pPrintfSurface;
MockProgram *pProgram = new MockProgram(&context);
MockProgram *pProgram = new MockProgram(&context, false);
MockKernel *pKernel = new MockKernel(pProgram, *pKernelInfo, *device);
MockMultiDispatchInfo multiDispatchInfo(pKernel);
@@ -68,7 +68,7 @@ TEST(PrintfHandlerTest, givenPreparedPrintfHandlerWhenGetSurfaceIsCalledThenResu
KernelInfo *pKernelInfo = new KernelInfo();
pKernelInfo->patchInfo.pAllocateStatelessPrintfSurface = pPrintfSurface;
MockProgram *pProgram = new MockProgram(&context);
MockProgram *pProgram = new MockProgram(&context, false);
uint64_t crossThread[10];
MockKernel *pKernel = new MockKernel(pProgram, *pKernelInfo, *device);

View File

@@ -1613,7 +1613,7 @@ TEST(ProgramFromBinaryTests, givenBinaryWithInvalidICBEThenErrorIsReturned) {
{
// whatever method we choose CL_INVALID_BINARY is always returned
std::unique_ptr<Program> pProgram(Program::createFromGenBinary(nullptr, &binHeader, binSize, &retVal));
std::unique_ptr<Program> pProgram(Program::createFromGenBinary(nullptr, &binHeader, binSize, false, &retVal));
ASSERT_NE(nullptr, pProgram.get());
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -1624,7 +1624,7 @@ TEST(ProgramFromBinaryTests, givenBinaryWithInvalidICBEThenErrorIsReturned) {
class FailProgram : public Program {
public:
FailProgram(Context *context) : Program(context) {}
FailProgram(Context *context, bool isBuiltIn = false) : Program(context, isBuiltIn) {}
cl_int rebuildProgramFromLLVM() override {
return CL_INVALID_PROGRAM;
}
@@ -1653,7 +1653,7 @@ TEST(ProgramFromBinaryTests, CreateWithBinary_FailRecompile) {
binHeader.PatchListSize = 0;
size_t binSize = sizeof(SProgramBinaryHeader);
std::unique_ptr<FailProgram> pProgram(FailProgram::createFromGenBinary<FailProgram>(nullptr, &binHeader, binSize, &retVal));
std::unique_ptr<FailProgram> pProgram(FailProgram::createFromGenBinary<FailProgram>(nullptr, &binHeader, binSize, false, &retVal));
ASSERT_NE(nullptr, pProgram.get());
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -1665,7 +1665,7 @@ TEST(ProgramFromBinaryTests, CreateWithBinary_FailRecompile) {
TEST(ProgramFromBinaryTests, givenEmptyProgramThenErrorIsReturned) {
class TestedProgram : public Program {
public:
TestedProgram(Context *context) : Program(context) {}
TestedProgram(Context *context, bool isBuiltIn) : Program(context, isBuiltIn) {}
char *setGenBinary(char *binary) {
auto res = genBinary;
genBinary = binary;
@@ -1688,7 +1688,7 @@ TEST(ProgramFromBinaryTests, givenEmptyProgramThenErrorIsReturned) {
binHeader.PatchListSize = 0;
size_t binSize = sizeof(SProgramBinaryHeader);
std::unique_ptr<TestedProgram> pProgram(TestedProgram::createFromGenBinary<TestedProgram>(nullptr, &binHeader, binSize, &retVal));
std::unique_ptr<TestedProgram> pProgram(TestedProgram::createFromGenBinary<TestedProgram>(nullptr, &binHeader, binSize, false, &retVal));
ASSERT_NE(nullptr, pProgram.get());
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -1717,7 +1717,7 @@ TEST_F(ProgramTests, ProgramCtorSetsProperInternalOptions) {
DebugManager.flags.DisableStatelessToStatefulOptimization.set(false);
if (pDevice) {
MockProgram program(pContext);
MockProgram program(pContext, false);
char paramValue[32];
pDevice->getDeviceInfo(CL_DEVICE_VERSION, 32, paramValue, 0);
if (strstr(paramValue, "2.1")) {
@@ -1740,7 +1740,7 @@ TEST_F(ProgramTests, ProgramCtorSetsProperInternalOptionsForced20) {
pDevice->getMutableDeviceInfo()->clVersion = "OpenCL 2.0 ";
if (pDevice) {
MockProgram program(pContext);
MockProgram program(pContext, false);
char paramValue[32];
pDevice->getDeviceInfo(CL_DEVICE_VERSION, 32, paramValue, 0);
ASSERT_EQ(std::string(paramValue), "OpenCL 2.0 ");
@@ -1755,7 +1755,7 @@ TEST_F(ProgramTests, ProgramCtorSetsProperInternalOptionsWhenStatelessToStateful
DebugManager.flags.DisableStatelessToStatefulOptimization.set(true);
if (pDevice) {
MockProgram program(pContext);
MockProgram program(pContext, false);
char paramValue[32];
pDevice->getDeviceInfo(CL_DEVICE_VERSION, 32, paramValue, 0);
if (strstr(paramValue, "2.1")) {
@@ -1784,7 +1784,7 @@ TEST_F(ProgramTests, ProgramCtorSetsProperInternalOptionsWhenForcing32BitAddress
DebugManager.flags.DisableStatelessToStatefulOptimization.set(false);
if (pDevice) {
const_cast<DeviceInfo *>(&pDevice->getDeviceInfo())->force32BitAddressess = true;
MockProgram program(pContext);
MockProgram program(pContext, false);
char paramValue[32];
pDevice->getDeviceInfo(CL_DEVICE_VERSION, 32, paramValue, 0);
if (strstr(paramValue, "2.1")) {
@@ -1809,7 +1809,7 @@ TEST_F(ProgramTests, BuiltinProgramCreateSetsProperInternalOptions) {
DebugManager.flags.DisableStatelessToStatefulOptimization.set(false);
if (pDevice) {
MockProgram *pProgram = Program::create<MockProgram>("", pContext, *pDevice, nullptr);
MockProgram *pProgram = Program::create<MockProgram>("", pContext, *pDevice, true, nullptr);
EXPECT_THAT(pProgram->getInternalOptions(), testing::HasSubstr(std::string("")));
delete pProgram;
@@ -1825,7 +1825,7 @@ TEST_F(ProgramTests, BuiltinProgramCreateSetsProperInternalOptionsWhenStatelessT
DebugManager.flags.DisableStatelessToStatefulOptimization.set(true);
if (pDevice) {
MockProgram *pProgram = Program::create<MockProgram>("", pContext, *pDevice, nullptr);
MockProgram *pProgram = Program::create<MockProgram>("", pContext, *pDevice, true, nullptr);
EXPECT_THAT(pProgram->getInternalOptions(), testing::HasSubstr(std::string("-cl-intel-greater-than-4GB-buffer-required")));
delete pProgram;
@@ -1836,7 +1836,7 @@ TEST_F(ProgramTests, BuiltinProgramCreateSetsProperInternalOptionsWhenStatelessT
}
TEST_F(ProgramTests, givenProgramWhenItIsCompiledThenItAlwyasHavePreserveVec3TypeInternalOptionSet) {
std::unique_ptr<MockProgram> pProgram(Program::create<MockProgram>("", pContext, *pDevice, nullptr));
std::unique_ptr<MockProgram> pProgram(Program::create<MockProgram>("", pContext, *pDevice, true, nullptr));
EXPECT_THAT(pProgram->getInternalOptions(), testing::HasSubstr(std::string("-fpreserve-vec3-type ")));
}
@@ -1847,7 +1847,7 @@ TEST_F(ProgramTests, BuiltinProgramCreateSetsProperInternalOptionsWhenForcing32B
DebugManager.flags.DisableStatelessToStatefulOptimization.set(false);
if (pDevice) {
const_cast<DeviceInfo *>(&pDevice->getDeviceInfo())->force32BitAddressess = true;
MockProgram *pProgram = Program::create<MockProgram>("", pContext, *pDevice, nullptr);
MockProgram *pProgram = Program::create<MockProgram>("", pContext, *pDevice, true, nullptr);
if (is32bit) {
EXPECT_THAT(pProgram->getInternalOptions(), testing::HasSubstr(std::string("-cl-intel-greater-than-4GB-buffer-required")));
} else {
@@ -1867,7 +1867,7 @@ TEST_F(ProgramTests, BuiltinProgramCreateSetsProperInternalOptionsEnablingStatel
DebugManager.flags.EnableStatelessToStatefulBufferOffsetOpt.set(true);
if (pDevice) {
MockProgram *pProgram = Program::create<MockProgram>("", pContext, *pDevice, nullptr);
MockProgram *pProgram = Program::create<MockProgram>("", pContext, *pDevice, true, nullptr);
EXPECT_THAT(pProgram->getInternalOptions(), testing::HasSubstr(std::string("-cl-intel-has-buffer-offset-arg ")));
delete pProgram;
@@ -1879,7 +1879,7 @@ TEST_F(ProgramTests, BuiltinProgramCreateSetsProperInternalOptionsEnablingStatel
TEST_F(ProgramTests, ProgramCtorSetsProperProgramScopePatchListSize) {
MockProgram program(pContext);
MockProgram program(pContext, false);
EXPECT_EQ((size_t)0, program.getProgramScopePatchListSize());
}
@@ -1888,7 +1888,7 @@ TEST_F(ProgramTests, GivenContextWhenCreateProgramThenIncrementContextRefCount)
auto initialInternalRefCount = pContext->getRefInternalCount();
MockProgram tempProgram;
MockProgram *program = new MockProgram(pContext);
MockProgram *program = new MockProgram(pContext, false);
EXPECT_EQ(pContext->getReference(), initialApiRefCount);
EXPECT_EQ(pContext->getRefInternalCount(), initialInternalRefCount + 1);
@@ -1901,8 +1901,10 @@ TEST_F(ProgramTests, GivenContextWhenCreateProgramFromSourceThenIncrementContext
auto initialApiRefCount = pContext->getReference();
auto initialInternalRefCount = pContext->getRefInternalCount();
auto tempProgram = Program::create("", nullptr, *pDevice, nullptr);
auto program = Program::create("", pContext, *pDevice, nullptr);
auto tempProgram = Program::create("", nullptr, *pDevice, false, nullptr);
EXPECT_FALSE(tempProgram->getIsBuiltIn());
auto program = Program::create("", pContext, *pDevice, false, nullptr);
EXPECT_FALSE(program->getIsBuiltIn());
EXPECT_EQ(pContext->getReference(), initialApiRefCount);
EXPECT_EQ(pContext->getRefInternalCount(), initialInternalRefCount + 1);
@@ -1914,21 +1916,40 @@ TEST_F(ProgramTests, GivenContextWhenCreateProgramFromSourceThenIncrementContext
EXPECT_EQ(pContext->getRefInternalCount(), initialInternalRefCount);
}
TEST_F(ProgramTests, GivenContextWhenCreateBuiltInProgramFromSourceThenDontIncrementContextRefCount) {
auto initialApiRefCount = pContext->getReference();
auto initialInternalRefCount = pContext->getRefInternalCount();
auto tempProgram = Program::create("", nullptr, *pDevice, true, nullptr);
EXPECT_TRUE(tempProgram->getIsBuiltIn());
auto program = Program::create("", pContext, *pDevice, true, nullptr);
EXPECT_TRUE(program->getIsBuiltIn());
EXPECT_EQ(pContext->getReference(), initialApiRefCount);
EXPECT_EQ(pContext->getRefInternalCount(), initialInternalRefCount);
program->release();
EXPECT_EQ(pContext->getReference(), initialApiRefCount);
EXPECT_EQ(pContext->getRefInternalCount(), initialInternalRefCount);
tempProgram->release();
EXPECT_EQ(pContext->getReference(), initialApiRefCount);
EXPECT_EQ(pContext->getRefInternalCount(), initialInternalRefCount);
}
TEST_F(ProgramTests, ProgramCreateT3Success) {
cl_int retVal = CL_DEVICE_NOT_FOUND;
Program *pProgram = Program::create("", pContext, *pDevice, &retVal);
Program *pProgram = Program::create("", pContext, *pDevice, false, &retVal);
EXPECT_NE(nullptr, pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
delete pProgram;
pProgram = Program::create("", pContext, *pDevice, nullptr);
pProgram = Program::create("", pContext, *pDevice, false, nullptr);
EXPECT_NE(nullptr, pProgram);
delete pProgram;
}
TEST_F(ProgramTests, ProgramFromGenBinaryWithNullBinary) {
cl_int retVal = CL_SUCCESS;
Program *pProgram = Program::createFromGenBinary(pContext, nullptr, 0, &retVal);
Program *pProgram = Program::createFromGenBinary(pContext, nullptr, 0, false, &retVal);
EXPECT_EQ(nullptr, pProgram);
EXPECT_NE(CL_SUCCESS, retVal);
}
@@ -1938,11 +1959,12 @@ TEST_F(ProgramTests, ProgramFromGenBinary) {
char binary[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'};
size_t size = 10;
Program *pProgram = Program::createFromGenBinary(pContext, binary, size, &retVal);
Program *pProgram = Program::createFromGenBinary(pContext, binary, size, false, &retVal);
EXPECT_NE(nullptr, pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ((uint32_t)CL_PROGRAM_BINARY_TYPE_EXECUTABLE, (uint32_t)pProgram->getProgramBinaryType());
EXPECT_FALSE(pProgram->getIsBuiltIn());
cl_device_id deviceId = pContext->getDevice(0);
cl_build_status status = 0;
@@ -1953,11 +1975,25 @@ TEST_F(ProgramTests, ProgramFromGenBinary) {
delete pProgram;
}
TEST_F(ProgramTests, ProgramFromGenBinaryWithBuiltInFlagSet) {
cl_int retVal = CL_INVALID_BINARY;
char binary[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'};
size_t size = 10;
Program *pProgram = Program::createFromGenBinary(pContext, binary, size, true, &retVal);
EXPECT_NE(nullptr, pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(pProgram->getIsBuiltIn());
delete pProgram;
}
TEST_F(ProgramTests, ProgramFromGenBinaryWithoutRetVal) {
char binary[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'};
size_t size = 10;
Program *pProgram = Program::createFromGenBinary(pContext, binary, size, nullptr);
Program *pProgram = Program::createFromGenBinary(pContext, binary, size, false, nullptr);
EXPECT_NE(nullptr, pProgram);
EXPECT_EQ((uint32_t)CL_PROGRAM_BINARY_TYPE_EXECUTABLE, (uint32_t)pProgram->getProgramBinaryType());
@@ -1975,7 +2011,7 @@ TEST_F(ProgramTests, ProgramFromGenBinaryWithNullcontext) {
char binary[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'};
size_t size = 10;
Program *pProgram = Program::createFromGenBinary(nullptr, binary, size, &retVal);
Program *pProgram = Program::createFromGenBinary(nullptr, binary, size, false, &retVal);
EXPECT_NE(nullptr, pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ((uint32_t)CL_PROGRAM_BINARY_TYPE_EXECUTABLE, (uint32_t)pProgram->getProgramBinaryType());
@@ -1994,7 +2030,7 @@ TEST_F(ProgramTests, ProgramFromGenBinaryWithPATCH_TOKEN_GLOBAL_MEMORY_OBJECT_KE
char genBin[1024] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'};
size_t binSize = 10;
Program *pProgram = Program::createFromGenBinary(nullptr, &genBin[0], binSize, &retVal);
Program *pProgram = Program::createFromGenBinary(nullptr, &genBin[0], binSize, false, &retVal);
EXPECT_NE(nullptr, pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ((uint32_t)CL_PROGRAM_BINARY_TYPE_EXECUTABLE, (uint32_t)pProgram->getProgramBinaryType());
@@ -2059,7 +2095,7 @@ TEST_F(ProgramTests, ProgramFromGenBinaryWithPATCH_TOKEN_GTPIN_FREE_GRF_INFO) {
char genBin[1024] = {1, 2, 3, 4, 5, 6, 7, 8, 9, '\0'};
size_t binSize = 10;
Program *pProgram = Program::createFromGenBinary(nullptr, &genBin[0], binSize, &retVal);
Program *pProgram = Program::createFromGenBinary(nullptr, &genBin[0], binSize, false, &retVal);
EXPECT_NE(nullptr, pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ((uint32_t)CL_PROGRAM_BINARY_TYPE_EXECUTABLE, (uint32_t)pProgram->getProgramBinaryType());
@@ -2471,7 +2507,7 @@ TEST_F(ProgramTests, GetProgramCompilerVersion) {
}
TEST_F(ProgramTests, GivenZeroPrivateSizeInBlockWhenAllocateBlockProvateSurfacesCalledThenNoSurfaceIsCreated) {
MockProgram *program = new MockProgram(pContext);
MockProgram *program = new MockProgram(pContext, false);
uint32_t crossThreadOffsetBlock = 0;
@@ -2497,7 +2533,7 @@ TEST_F(ProgramTests, GivenZeroPrivateSizeInBlockWhenAllocateBlockProvateSurfaces
}
TEST_F(ProgramTests, GivenNonZeroPrivateSizeInBlockWhenAllocateBlockProvateSurfacesCalledThenSurfaceIsCreated) {
MockProgram *program = new MockProgram(pContext);
MockProgram *program = new MockProgram(pContext, false);
uint32_t crossThreadOffsetBlock = 0;
@@ -2523,7 +2559,7 @@ TEST_F(ProgramTests, GivenNonZeroPrivateSizeInBlockWhenAllocateBlockProvateSurfa
}
TEST_F(ProgramTests, GivenNonZeroPrivateSizeInBlockWhenAllocateBlockProvateSurfacesCalledThenSecondSurfaceIsNotCreated) {
MockProgram *program = new MockProgram(pContext);
MockProgram *program = new MockProgram(pContext, false);
uint32_t crossThreadOffsetBlock = 0;
@@ -2557,7 +2593,7 @@ TEST_F(ProgramTests, GivenNonZeroPrivateSizeInBlockWhenAllocateBlockProvateSurfa
}
TEST_F(ProgramTests, givenProgramWithBlockKernelsWhenfreeBlockResourcesisCalledThenFreeGraphhicsAllocationsFromBlockKernelManagerIsCalled) {
MockProgram *program = new MockProgram(pContext);
MockProgram *program = new MockProgram(pContext, false);
uint32_t crossThreadOffsetBlock = 0;
@@ -2604,7 +2640,7 @@ TEST_F(Program32BitTests, givenDeviceWithForce32BitAddressingOnWhenBultinIsCreat
}
TEST_F(Program32BitTests, givenDeviceWithForce32BitAddressingOnWhenProgramIsCreatedThen32bitFlagIsPassedAsInternalOption) {
MockProgram pProgram(pContext);
MockProgram pProgram(pContext, false);
auto &internalOptions = pProgram.getInternalOptions();
std::string s1 = internalOptions;
size_t pos = s1.find("-m32");
@@ -2618,7 +2654,7 @@ TEST_F(Program32BitTests, givenDeviceWithForce32BitAddressingOnWhenProgramIsCrea
TEST_F(Program32BitTests, givenDeviceWhenProgramIsCreatedThenProgramCountInDeviceIncreases) {
auto device = pContext->getDevice(0);
EXPECT_EQ(0u, device->getProgramCount());
MockProgram pProgram(pContext);
MockProgram pProgram(pContext, false);
EXPECT_EQ(1u, device->getProgramCount());
}
@@ -2632,8 +2668,8 @@ TEST_F(ProgramTests, givenNewProgramTheStatelessToStatefulBufferOffsetOtimizatio
template <int32_t ErrCodeToReturn, bool spirv = true>
struct CreateProgramFromBinaryMock : MockProgram {
using MockProgram::MockProgram;
CreateProgramFromBinaryMock(Context *context)
: MockProgram(context) {
CreateProgramFromBinaryMock(Context *context, bool isBuiltIn)
: MockProgram(context, isBuiltIn) {
}
cl_int createProgramFromBinary(const void *pBinary,
@@ -2765,7 +2801,7 @@ TEST_F(ProgramTests, linkingTwoValidSpirvProgramsReturnsValidProgram) {
}
TEST_F(ProgramTests, givenSeparateBlockKernelsWhenNoParentAndSubgroupKernelsThenSeparateNoneKernel) {
MockProgram program(pContext);
MockProgram program(pContext, false);
EXPECT_EQ(0u, program.getKernelInfoArray().size());
EXPECT_EQ(0u, program.getParentKernelInfoArray().size());
@@ -2778,7 +2814,7 @@ TEST_F(ProgramTests, givenSeparateBlockKernelsWhenNoParentAndSubgroupKernelsThen
}
TEST_F(ProgramTests, givenSeparateBlockKernelsWhenRegularKernelsThenSeparateNoneKernel) {
MockProgram program(pContext);
MockProgram program(pContext, false);
auto pRegularKernel1Info = KernelInfo::create();
pRegularKernel1Info->name = "regular_kernel_1";
@@ -2800,7 +2836,7 @@ TEST_F(ProgramTests, givenSeparateBlockKernelsWhenRegularKernelsThenSeparateNone
}
TEST_F(ProgramTests, givenSeparateBlockKernelsWhenChildLikeKernelWithoutParentKernelThenSeparateNoneKernel) {
MockProgram program(pContext);
MockProgram program(pContext, false);
auto pParentKernelInfo = KernelInfo::create();
pParentKernelInfo->name = "another_parent_kernel";
@@ -2824,7 +2860,7 @@ TEST_F(ProgramTests, givenSeparateBlockKernelsWhenChildLikeKernelWithoutParentKe
}
TEST_F(ProgramTests, givenSeparateBlockKernelsWhenChildLikeKernelWithoutSubgroupKernelThenSeparateNoneKernel) {
MockProgram program(pContext);
MockProgram program(pContext, false);
auto pSubgroupKernelInfo = KernelInfo::create();
pSubgroupKernelInfo->name = "another_subgroup_kernel";
@@ -2848,7 +2884,7 @@ TEST_F(ProgramTests, givenSeparateBlockKernelsWhenChildLikeKernelWithoutSubgroup
}
TEST_F(ProgramTests, givenSeparateBlockKernelsWhenParentKernelWithChildKernelThenSeparateChildKernel) {
MockProgram program(pContext);
MockProgram program(pContext, false);
auto pParentKernelInfo = KernelInfo::create();
pParentKernelInfo->name = "parent_kernel";
@@ -2872,7 +2908,7 @@ TEST_F(ProgramTests, givenSeparateBlockKernelsWhenParentKernelWithChildKernelThe
}
TEST_F(ProgramTests, givenSeparateBlockKernelsWhenSubgroupKernelWithChildKernelThenSeparateChildKernel) {
MockProgram program(pContext);
MockProgram program(pContext, false);
auto pSubgroupKernelInfo = KernelInfo::create();
pSubgroupKernelInfo->name = "subgroup_kernel";
@@ -2896,7 +2932,7 @@ TEST_F(ProgramTests, givenSeparateBlockKernelsWhenSubgroupKernelWithChildKernelT
}
TEST(SimpleProgramTests, givenDefaultProgramWhenSetDeviceIsCalledThenDeviceIsSet) {
MockProgram pProgram(nullptr);
MockProgram pProgram(nullptr, false);
EXPECT_EQ(nullptr, pProgram.getDevicePtr());
auto dummyDevice = (Device *)0x1337;
pProgram.SetDevice(dummyDevice);

View File

@@ -118,7 +118,7 @@ TEST_F(ProgramWithBlockKernelsTest, GivenKernelWithBlockKernelsWhenProgramIsLink
ASSERT_NE(nullptr, pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
Program *programLinked = new Program(pContext);
Program *programLinked = new Program(pContext, false);
cl_program program = pProgram;
retVal = pProgram->compile(1, &device, buildOptions, 0, nullptr, nullptr, nullptr, nullptr);

View File

@@ -38,12 +38,12 @@
using namespace OCLRT;
TEST_F(ProgramTests, givenDeafultProgramObjectWhenKernelDebugEnabledIsQueriedThenFalseIsReturned) {
MockProgram program(pContext);
MockProgram program(pContext, false);
EXPECT_FALSE(program.isKernelDebugEnabled());
}
TEST_F(ProgramTests, givenProgramObjectWhenEnableKernelDebugIsCalledThenProgramHasKernelDebugEnabled) {
MockProgram program(pContext);
MockProgram program(pContext, false);
program.enableKernelDebug();
EXPECT_TRUE(program.isKernelDebugEnabled());
}