mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
fix: check if tracing_exit was called before return from api call
Related-To: GSD-9415, NEO-12719 Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
fdaaab01e9
commit
df7e5191ed
@@ -384,10 +384,12 @@ cl_int CL_API_CALL clRetainDevice(cl_device_id device) {
|
||||
|
||||
cl_int CL_API_CALL clReleaseDevice(cl_device_id device) {
|
||||
TRACING_ENTER(ClReleaseDevice, &device);
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
if (wasPlatformTeardownCalled) {
|
||||
TRACING_EXIT(ClReleaseDevice, &retVal);
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
cl_int retVal = CL_INVALID_DEVICE;
|
||||
retVal = CL_INVALID_DEVICE;
|
||||
API_ENTER(&retVal);
|
||||
DBG_LOG_INPUTS("device", device);
|
||||
auto pDevice = castToObject<ClDevice>(device);
|
||||
@@ -523,10 +525,11 @@ cl_int CL_API_CALL clRetainContext(cl_context context) {
|
||||
|
||||
cl_int CL_API_CALL clReleaseContext(cl_context context) {
|
||||
TRACING_ENTER(ClReleaseContext, &context);
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
if (wasPlatformTeardownCalled) {
|
||||
TRACING_EXIT(ClReleaseContext, &retVal);
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
API_ENTER(&retVal);
|
||||
DBG_LOG_INPUTS("context", context);
|
||||
Context *pContext = castToObject<Context>(context);
|
||||
@@ -643,10 +646,12 @@ cl_int CL_API_CALL clRetainCommandQueue(cl_command_queue commandQueue) {
|
||||
|
||||
cl_int CL_API_CALL clReleaseCommandQueue(cl_command_queue commandQueue) {
|
||||
TRACING_ENTER(ClReleaseCommandQueue, &commandQueue);
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
if (wasPlatformTeardownCalled) {
|
||||
TRACING_EXIT(ClReleaseCommandQueue, &retVal);
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
cl_int retVal = CL_INVALID_COMMAND_QUEUE;
|
||||
retVal = CL_INVALID_COMMAND_QUEUE;
|
||||
API_ENTER(&retVal);
|
||||
DBG_LOG_INPUTS("commandQueue", commandQueue);
|
||||
|
||||
@@ -1125,10 +1130,12 @@ cl_int CL_API_CALL clRetainMemObject(cl_mem memobj) {
|
||||
|
||||
cl_int CL_API_CALL clReleaseMemObject(cl_mem memobj) {
|
||||
TRACING_ENTER(ClReleaseMemObject, &memobj);
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
if (wasPlatformTeardownCalled) {
|
||||
TRACING_EXIT(ClReleaseMemObject, &retVal);
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
cl_int retVal = CL_INVALID_MEM_OBJECT;
|
||||
retVal = CL_INVALID_MEM_OBJECT;
|
||||
API_ENTER(&retVal);
|
||||
|
||||
DBG_LOG_INPUTS("memobj", memobj);
|
||||
@@ -1352,10 +1359,11 @@ cl_int CL_API_CALL clRetainSampler(cl_sampler sampler) {
|
||||
|
||||
cl_int CL_API_CALL clReleaseSampler(cl_sampler sampler) {
|
||||
TRACING_ENTER(ClReleaseSampler, &sampler);
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
if (wasPlatformTeardownCalled) {
|
||||
TRACING_EXIT(ClReleaseSampler, &retVal);
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
API_ENTER(&retVal);
|
||||
DBG_LOG_INPUTS("sampler", sampler);
|
||||
auto pSampler = castToObject<Sampler>(sampler);
|
||||
@@ -1553,10 +1561,11 @@ cl_int CL_API_CALL clRetainProgram(cl_program program) {
|
||||
|
||||
cl_int CL_API_CALL clReleaseProgram(cl_program program) {
|
||||
TRACING_ENTER(ClReleaseProgram, &program);
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
if (wasPlatformTeardownCalled) {
|
||||
TRACING_EXIT(ClReleaseProgram, &retVal);
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
API_ENTER(&retVal);
|
||||
DBG_LOG_INPUTS("program", program);
|
||||
auto pProgram = castToObject<Program>(program);
|
||||
@@ -1897,10 +1906,11 @@ cl_int CL_API_CALL clRetainKernel(cl_kernel kernel) {
|
||||
|
||||
cl_int CL_API_CALL clReleaseKernel(cl_kernel kernel) {
|
||||
TRACING_ENTER(ClReleaseKernel, &kernel);
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
if (wasPlatformTeardownCalled) {
|
||||
TRACING_EXIT(ClReleaseKernel, &retVal);
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
API_ENTER(&retVal);
|
||||
DBG_LOG_INPUTS("kernel", kernel);
|
||||
auto pMultiDeviceKernel = castToObject<MultiDeviceKernel>(kernel);
|
||||
@@ -2194,10 +2204,11 @@ cl_int CL_API_CALL clRetainEvent(cl_event event) {
|
||||
|
||||
cl_int CL_API_CALL clReleaseEvent(cl_event event) {
|
||||
TRACING_ENTER(ClReleaseEvent, &event);
|
||||
auto retVal = CL_SUCCESS;
|
||||
if (wasPlatformTeardownCalled) {
|
||||
TRACING_EXIT(ClReleaseEvent, &retVal);
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
auto retVal = CL_SUCCESS;
|
||||
API_ENTER(&retVal);
|
||||
auto pEvent = castToObject<Event>(event);
|
||||
DBG_LOG_INPUTS("cl_event", event, "Event", pEvent);
|
||||
@@ -4534,10 +4545,11 @@ cl_int CL_API_CALL clReleaseAcceleratorINTEL(
|
||||
cl_accelerator_intel accelerator) {
|
||||
|
||||
TRACING_ENTER(ClReleaseAcceleratorINTEL, &accelerator);
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
if (wasPlatformTeardownCalled) {
|
||||
TRACING_EXIT(ClReleaseAcceleratorINTEL, &retVal);
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
API_ENTER(&retVal);
|
||||
DBG_LOG_INPUTS("accelerator", accelerator);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
||||
#include "shared/source/utilities/cpuintrinsics.h"
|
||||
|
||||
#include "opencl/source/tracing/tracing_handle.h"
|
||||
@@ -29,9 +30,23 @@ namespace HostSideTracing {
|
||||
|
||||
inline thread_local bool tracingInProgress = false;
|
||||
|
||||
class CheckIfExitCalled : public NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
~CheckIfExitCalled() {
|
||||
UNRECOVERABLE_IF(!tracingExited);
|
||||
}
|
||||
void exit() {
|
||||
tracingExited = true;
|
||||
}
|
||||
|
||||
private:
|
||||
bool tracingExited = false;
|
||||
};
|
||||
|
||||
#define TRACING_ENTER(name, ...) \
|
||||
bool isHostSideTracingEnabled_##name = false; \
|
||||
bool currentlyTracedCall = false; \
|
||||
HostSideTracing::CheckIfExitCalled checkIfExited; \
|
||||
HostSideTracing::name##Tracer tracer_##name; \
|
||||
if (TRACING_GET_ENABLED_BIT(HostSideTracing::tracingState.load(std::memory_order_acquire)) && (false == HostSideTracing::tracingInProgress)) { \
|
||||
HostSideTracing::tracingInProgress = true; \
|
||||
@@ -50,7 +65,8 @@ inline thread_local bool tracingInProgress = false;
|
||||
} \
|
||||
HostSideTracing::tracingInProgress = false; \
|
||||
currentlyTracedCall = false; \
|
||||
}
|
||||
} \
|
||||
checkIfExited.exit();
|
||||
|
||||
enum TracingNotifyState {
|
||||
TRACING_NOTIFY_STATE_NOTHING_CALLED = 0,
|
||||
|
||||
Reference in New Issue
Block a user