Skip to content

Commit 5909a6b

Browse files
Add support for GT-Pin Callbacks [3/n]
Change-Id: Iea4b49efc9a666fde310ece15a9c69686d22f627
1 parent 3e9a43f commit 5909a6b

33 files changed

+1993
-44
lines changed

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
neoDependenciesRev='735095-769'
33
strategy='EQUAL'
44
allowedF=43
5-
allowedCD=341
5+
allowedCD=340

runtime/api/api.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ cl_int CL_API_CALL clReleaseContext(cl_context context) {
359359
Context *pContext = castToObject<Context>(context);
360360
if (pContext) {
361361
pContext->release();
362-
gtpinNotifyContextDestroy(context);
363362
return CL_SUCCESS;
364363
}
365364

@@ -1294,7 +1293,6 @@ cl_kernel CL_API_CALL clCreateKernel(cl_program clProgram,
12941293
Program *pProgram = nullptr;
12951294
cl_kernel kernel = nullptr;
12961295
cl_int retVal = CL_SUCCESS;
1297-
12981296
DBG_LOG_INPUTS("clProgram", clProgram, "kernelName", kernelName);
12991297

13001298
do {
@@ -1350,6 +1348,9 @@ cl_int CL_API_CALL clCreateKernelsInProgram(cl_program clProgram,
13501348
program,
13511349
*kernelInfo,
13521350
nullptr);
1351+
if (kernels[ordinal] != nullptr) {
1352+
gtpinNotifyKernelCreate(kernels[ordinal]);
1353+
}
13531354
}
13541355
}
13551356

@@ -2559,6 +2560,11 @@ cl_int CL_API_CALL clEnqueueNDRangeKernel(cl_command_queue commandQueue,
25592560
return retVal;
25602561
}
25612562

2563+
auto pKernel = castToObjectOrAbort<Kernel>(kernel);
2564+
TakeOwnershipWrapper<Kernel> kernelOwnership(*pKernel, gtpinIsGTPinInitialized());
2565+
2566+
gtpinNotifyKernelSubmit(kernel, pCommandQueue);
2567+
25622568
retVal = pCommandQueue->enqueueKernel(
25632569
kernel,
25642570
workDim,
@@ -3767,6 +3773,9 @@ cl_kernel CL_API_CALL clCloneKernel(cl_kernel sourceKernel,
37673773
if (errcodeRet) {
37683774
*errcodeRet = retVal;
37693775
}
3776+
if (pClonedKernel != nullptr) {
3777+
gtpinNotifyKernelCreate(pClonedKernel);
3778+
}
37703779

37713780
return pClonedKernel;
37723781
}

runtime/command_queue/command_queue.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "runtime/device_queue/device_queue.h"
2929
#include "runtime/event/event.h"
3030
#include "runtime/event/event_builder.h"
31+
#include "runtime/gtpin/gtpin_notify.h"
3132
#include "runtime/helpers/aligned_memory.h"
3233
#include "runtime/helpers/array_count.h"
3334
#include "runtime/helpers/get_info.h"

runtime/command_queue/enqueue_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "runtime/command_queue/dispatch_walker.h"
2828
#include "runtime/command_stream/command_stream_receiver.h"
2929
#include "runtime/event/event_builder.h"
30+
#include "runtime/gtpin/gtpin_notify.h"
3031
#include "runtime/helpers/kernel_commands.h"
3132
#include "runtime/helpers/dispatch_info_builder.h"
3233
#include "runtime/mem_obj/buffer.h"
@@ -549,6 +550,8 @@ CompletionStamp CommandQueueHw<GfxFamily>::enqueueNonBlocked(
549550

550551
DEBUG_BREAK_IF(taskLevel >= Event::eventNotReady);
551552

553+
gtpinNotifyPreFlushTask(this);
554+
552555
CompletionStamp completionStamp = commandStreamReceiver.flushTask(
553556
commandStream,
554557
commandStreamStart,

runtime/command_stream/command_stream_receiver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "runtime/command_stream/command_stream_receiver.h"
2525
#include "runtime/command_stream/preemption.h"
2626
#include "runtime/device/device.h"
27+
#include "runtime/gtpin/gtpin_notify.h"
2728
#include "runtime/memory_manager/memory_manager.h"
2829
#include "runtime/helpers/cache_policy.h"
2930
#include "runtime/os_interface/os_interface.h"
@@ -192,6 +193,7 @@ bool CommandStreamReceiver::waitForCompletionWithTimeout(bool enableTimeout, int
192193
}
193194
}
194195
if (*getTagAddress() >= taskCountToWait) {
196+
gtpinNotifyTaskCompletion(taskCountToWait);
195197
return true;
196198
}
197199
return false;

runtime/command_stream/command_stream_receiver_hw.inl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "runtime/command_stream/command_stream_receiver_hw.h"
2424
#include "runtime/command_stream/linear_stream.h"
2525
#include "runtime/device/device.h"
26+
#include "runtime/gtpin/gtpin_notify.h"
2627
#include "runtime/helpers/cache_policy.h"
2728
#include "runtime/helpers/preamble.h"
2829
#include "runtime/helpers/ptr_math.h"
@@ -377,6 +378,9 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
377378
engineType};
378379

379380
this->taskLevel += levelClosed ? 1 : 0;
381+
382+
gtpinNotifyFlushTask(completionStamp.taskCount);
383+
380384
return completionStamp;
381385
}
382386

runtime/context/context.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "runtime/device/device.h"
2626
#include "runtime/device_queue/device_queue.h"
2727
#include "runtime/mem_obj/image.h"
28+
#include "runtime/gtpin/gtpin_notify.h"
2829
#include "runtime/helpers/get_info.h"
2930
#include "runtime/helpers/ptr_math.h"
3031
#include "runtime/platform/platform.h"
@@ -71,6 +72,7 @@ Context::~Context() {
7172
if (memoryManager && memoryManager->isAsyncDeleterEnabled()) {
7273
memoryManager->getDeferredDeleter()->removeClient();
7374
}
75+
gtpinNotifyContextDestroy((cl_context)this);
7476
}
7577

7678
DeviceQueue *Context::getDefaultDeviceQueue() {

runtime/gen8/gtpin_setup_gen8.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "gtpin_ocl_interface.h"
2424
#include "runtime/gtpin/gtpin_hw_helper.h"
25+
#include "runtime/gtpin/gtpin_hw_helper.inl"
2526

2627
namespace OCLRT {
2728

runtime/gen9/gtpin_setup_gen9.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "gtpin_ocl_interface.h"
2424
#include "runtime/gtpin/gtpin_hw_helper.h"
25+
#include "runtime/gtpin/gtpin_hw_helper.inl"
2526

2627
namespace OCLRT {
2728

runtime/gtpin/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ if(GTPIN_HEADERS_DIR)
2626
${CMAKE_CURRENT_SOURCE_DIR}/gtpin_helpers.h
2727
${CMAKE_CURRENT_SOURCE_DIR}/gtpin_hw_helper.cpp
2828
${CMAKE_CURRENT_SOURCE_DIR}/gtpin_hw_helper.h
29+
${CMAKE_CURRENT_SOURCE_DIR}/gtpin_hw_helper.inl
2930
${CMAKE_CURRENT_SOURCE_DIR}/gtpin_init.cpp
3031
${CMAKE_CURRENT_SOURCE_DIR}/gtpin_init.h
3132
${CMAKE_CURRENT_SOURCE_DIR}/gtpin_notify.h
33+
${CMAKE_CURRENT_SOURCE_DIR}/gtpin_defs.h
3234
PARENT_SCOPE
3335
)
3436
else()

runtime/gtpin/gtpin_callback_stubs.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,29 @@ void gtpinNotifyContextDestroy(cl_context context) {
3232

3333
void gtpinNotifyKernelCreate(cl_kernel kernel) {
3434
}
35+
36+
void gtpinNotifyKernelSubmit(cl_kernel kernel, void *pCmdQueue) {
37+
}
38+
39+
void gtpinNotifyPreFlushTask(void *pCmdQueue) {
40+
}
41+
42+
void gtpinNotifyFlushTask(uint32_t flushedTaskCount) {
43+
}
44+
45+
void gtpinNotifyTaskCompletion(uint32_t completedTaskCount) {
46+
}
47+
48+
void gtpinNotifyMakeResident(void *pKernel, void *pCommandStreamReceiver) {
49+
}
50+
51+
void gtpinNotifyUpdateResidencyList(void *pKernel, void *pResidencyVector) {
52+
}
53+
54+
void gtpinNotifyPlatformShutdown() {
55+
}
56+
57+
bool gtpinIsGTPinInitialized() {
58+
return false;
59+
}
3560
}

0 commit comments

Comments
 (0)