diff --git a/opencl/source/api/api.cpp b/opencl/source/api/api.cpp index 49468cb80c..e8f78b89d6 100644 --- a/opencl/source/api/api.cpp +++ b/opencl/source/api/api.cpp @@ -5389,7 +5389,7 @@ cl_int CL_API_CALL clSetProgramReleaseCallback(cl_program program, reinterpret_cast(pfnNotify)); if (retVal == CL_SUCCESS) { - retVal = pProgram->setReleaseCallback(pfnNotify, userData); + retVal = CL_INVALID_OPERATION; } return retVal; diff --git a/opencl/source/helpers/destructor_callback.h b/opencl/source/helpers/destructor_callback.h index 35357ee301..3c8b7fc4f4 100644 --- a/opencl/source/helpers/destructor_callback.h +++ b/opencl/source/helpers/destructor_callback.h @@ -28,6 +28,5 @@ class DestructorCallback { using ContextDestructorCallback = DestructorCallback; using MemObjDestructorCallback = DestructorCallback; -using ProgramReleaseCallback = DestructorCallback; } // namespace NEO diff --git a/opencl/source/program/program.cpp b/opencl/source/program/program.cpp index 61d54d3ede..a28a27b0ff 100644 --- a/opencl/source/program/program.cpp +++ b/opencl/source/program/program.cpp @@ -113,11 +113,6 @@ Program::Program(ExecutionEnvironment &executionEnvironment, Context *context, b } Program::~Program() { - for (auto callback : releaseCallbacks) { - callback->invoke(this); - delete callback; - } - cleanCurrentKernelInfo(); freeBlockResources(); @@ -271,15 +266,6 @@ cl_int Program::updateSpecializationConstant(cl_uint specId, size_t specSize, co return CL_INVALID_SPEC_ID; } -cl_int Program::setReleaseCallback(void(CL_CALLBACK *funcNotify)(cl_program, void *), - void *userData) { - auto cb = new ProgramReleaseCallback(funcNotify, userData); - - std::unique_lock theLock(mtx); - releaseCallbacks.push_front(cb); - return CL_SUCCESS; -} - void Program::setDevice(Device *device) { this->pDevice = device; } diff --git a/opencl/source/program/program.h b/opencl/source/program/program.h index f00ff3e35d..bc8bdb7f60 100644 --- a/opencl/source/program/program.h +++ b/opencl/source/program/program.h @@ -151,9 +151,6 @@ class Program : public BaseObject<_cl_program> { cl_int setProgramSpecializationConstant(cl_uint specId, size_t specSize, const void *specValue); MOCKABLE_VIRTUAL cl_int updateSpecializationConstant(cl_uint specId, size_t specSize, const void *specValue); - cl_int setReleaseCallback(void(CL_CALLBACK *funcNotify)(cl_program, void *), - void *userData); - size_t getNumKernels() const; const KernelInfo *getKernelInfo(const char *kernelName) const; const KernelInfo *getKernelInfo(size_t ordinal) const; @@ -351,8 +348,6 @@ class Program : public BaseObject<_cl_program> { bool isBuiltIn = false; bool kernelDebugEnabled = false; - - std::list releaseCallbacks; }; } // namespace NEO diff --git a/opencl/test/unit_test/api/cl_set_program_release_callback.inl b/opencl/test/unit_test/api/cl_set_program_release_callback.inl index 10cea0bc6d..89f9e3d82a 100644 --- a/opencl/test/unit_test/api/cl_set_program_release_callback.inl +++ b/opencl/test/unit_test/api/cl_set_program_release_callback.inl @@ -25,13 +25,13 @@ TEST_F(clSetProgramReleaseCallbackTests, givenPfnNotifyNullptrWhenSettingProgram void CL_CALLBACK callback(cl_program, void *){}; -TEST_F(clSetProgramReleaseCallbackTests, WhenSettingProgramReleaseCallbackThenSucccessIsReturned) { +TEST_F(clSetProgramReleaseCallbackTests, WhenSettingProgramReleaseCallbackThenInvalidOperationErrorIsReturned) { auto retVal = clSetProgramReleaseCallback(pProgram, callback, nullptr); - EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(CL_INVALID_OPERATION, retVal); auto userData = reinterpret_cast(0x4321); retVal = clSetProgramReleaseCallback(pProgram, callback, userData); - EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(CL_INVALID_OPERATION, retVal); } } // namespace ULT diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index 3110cd1351..4946d77cc8 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -3115,35 +3115,3 @@ TEST(ProgramReplaceDeviceBinary, GivenBinaryZebinThenUseAsBothPackedAndUnpackedB EXPECT_EQ(0, memcmp(program.packedDeviceBinary.get(), zebin.storage.data(), program.packedDeviceBinarySize)); EXPECT_EQ(0, memcmp(program.unpackedDeviceBinary.get(), zebin.storage.data(), program.unpackedDeviceBinarySize)); } - -TEST(Program, WhenSettingProgramReleaseCallbackThenCallOrderIsPreserved) { - struct UserDataType { - cl_program expectedProgram; - std::vector &vectorToModify; - size_t valueToAdd; - }; - auto callback = [](cl_program program, void *userData) -> void { - auto pUserData = reinterpret_cast(userData); - EXPECT_EQ(pUserData->expectedProgram, program); - pUserData->vectorToModify.push_back(pUserData->valueToAdd); - }; - - MockExecutionEnvironment executionEnvironment; - auto pProgram = new MockProgram{executionEnvironment}; - std::vector callbacksReturnValues; - UserDataType userDataArray[]{ - {pProgram, callbacksReturnValues, 1}, - {pProgram, callbacksReturnValues, 2}, - {pProgram, callbacksReturnValues, 3}}; - - for (auto &userData : userDataArray) { - cl_int retVal = clSetProgramReleaseCallback(pProgram, callback, &userData); - ASSERT_EQ(CL_SUCCESS, retVal); - } - delete pProgram; - - ASSERT_EQ(3u, callbacksReturnValues.size()); - EXPECT_EQ(3u, callbacksReturnValues[0]); - EXPECT_EQ(2u, callbacksReturnValues[1]); - EXPECT_EQ(1u, callbacksReturnValues[2]); -}