Revert "refactor: Unify GTPin initialization logic between APIs"

This reverts commit 68a5108e05.

Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
Compute-Runtime-Validation
2023-08-07 04:04:44 +02:00
committed by Compute-Runtime-Automation
parent 68a5108e05
commit 65df34bbc7
18 changed files with 102 additions and 158 deletions

View File

@@ -297,7 +297,6 @@ cl_int CL_API_CALL clGetDeviceIDs(cl_platform_id platform,
/* If no suitable device, set a error. */
if (retNum == 0)
retVal = CL_DEVICE_NOT_FOUND;
} while (false);
TRACING_EXIT(ClGetDeviceIDs, &retVal);
return retVal;
@@ -439,13 +438,6 @@ cl_context CL_API_CALL clCreateContext(const cl_context_properties *properties,
break;
}
}
/* At this point we can safely notify GTPin to allow initialization */
EnvironmentVariableReader envReader;
if (envReader.getSetting("ZET_ENABLE_PROGRAM_INSTRUMENTATION", false)) {
if (false == pPlatform->notifyGtpinInit()) {
retVal = CL_INVALID_OPERATION;
}
}
if (CL_SUCCESS != retVal) {
break;
}

View File

@@ -17,7 +17,6 @@
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/helpers/get_info.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/pin/pin.h"
#include "shared/source/source_level_debugger/source_level_debugger.h"
#include "opencl/source/api/api.h"
@@ -186,17 +185,6 @@ bool Platform::initialize(std::vector<std::unique_ptr<Device>> devices) {
return true;
}
bool Platform::notifyGtpinInit() {
bool res = false;
auto notifyGTPin = [](bool &res) {
const std::string gtpinFuncName{"OpenGTPinOCL"};
res = PinContext::init(gtpinFuncName);
return;
};
std::call_once(this->oclInitGTPinOnce, notifyGTPin, res);
return res;
}
void Platform::fillGlobalDispatchTable() {
sharingFactory.fillGlobalDispatchTable();
}

View File

@@ -48,7 +48,6 @@ class Platform : public BaseObject<_cl_platform_id> {
MOCKABLE_VIRTUAL bool initialize(std::vector<std::unique_ptr<Device>> devices);
bool isInitialized();
bool notifyGtpinInit();
size_t getNumDevices() const;
ClDevice **getClDevices();
@@ -72,7 +71,6 @@ class Platform : public BaseObject<_cl_platform_id> {
ClDeviceVector clDevices;
ExecutionEnvironment &executionEnvironment;
std::once_flag initializeExtensionsWithVersionOnce;
std::once_flag oclInitGTPinOnce;
};
extern std::vector<std::unique_ptr<Platform>> *platformsImpl;

View File

@@ -6,9 +6,6 @@
*/
#include "shared/source/helpers/ptr_math.h"
#include "shared/source/pin/pin.h"
#include "shared/test/common/mocks/mock_io_functions.h"
#include "shared/test/common/mocks/mock_os_library.h"
#include "opencl/test/unit_test/api/cl_api_tests.h"
#include "opencl/test/unit_test/mocks/mock_platform.h"
@@ -250,43 +247,4 @@ TEST_F(ClCreateContextTests, GivenDevicesFromDifferentPlatformsWhenCreatingConte
EXPECT_EQ(CL_INVALID_DEVICE, retVal);
EXPECT_EQ(nullptr, clContext);
}
TEST_F(ClCreateContextTests, givenProgramInstrumentationEnabledAndSuccesfulGtpinNotifyingWhenCreatingContextThenReturnSuccess) {
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZET_ENABLE_PROGRAM_INSTRUMENTATION", "1"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
uint32_t (*openPinHandler)(void *) = [](void *arg) -> uint32_t { return 0; };
auto newPtr = new MockOsLibrary(reinterpret_cast<void *>(openPinHandler), false);
MockOsLibrary::loadLibraryNewObject = newPtr;
NEO::PinContext::osLibraryLoadFunction = MockOsLibrary::load;
auto context = clCreateContext(nullptr, 1u, &testedClDevice, nullptr, nullptr, &retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
ASSERT_NE(nullptr, context);
retVal = clReleaseContext(context);
EXPECT_EQ(CL_SUCCESS, retVal);
MockOsLibrary::loadLibraryNewObject = nullptr;
delete newPtr;
}
TEST_F(ClCreateContextTests, givenProgramInstrumentationEnabledAndFailedGtpinNotifyingWhenCreatingContextThenReturnError) {
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZET_ENABLE_PROGRAM_INSTRUMENTATION", "1"}};
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
uint32_t (*openPinHandler)(void *) = [](void *arg) -> uint32_t { return -1; }; // bad gtpin handler
auto newPtr = new MockOsLibrary(reinterpret_cast<void *>(openPinHandler), false);
MockOsLibrary::loadLibraryNewObject = newPtr;
NEO::PinContext::osLibraryLoadFunction = MockOsLibrary::load;
auto context = clCreateContext(nullptr, 1u, &testedClDevice, nullptr, nullptr, &retVal);
EXPECT_EQ(CL_INVALID_OPERATION, retVal);
EXPECT_EQ(nullptr, context);
MockOsLibrary::loadLibraryNewObject = nullptr;
delete newPtr;
}
} // namespace ULT