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

@@ -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