Skip to content

Commit 392277f

Browse files
Enable 'Pass info between GT-Pin and IGC', after being reverted
This reverts commit ea92874. Change-Id: I4994b30f059012a5e89d899665af5c24b8ac8b18
1 parent d17879d commit 392277f

File tree

14 files changed

+208
-14
lines changed

14 files changed

+208
-14
lines changed

runtime/compiler_interface/compiler_interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ cl_int CompilerInterface::build(
145145
auto igcTranslationCtx = createIgcTranslationCtx(device, intermediateCodeType, IGC::CodeType::oclGenBin);
146146

147147
auto igcOutput = translate(igcTranslationCtx.get(), intermediateRepresentation.get(),
148-
fclOptions.get(), fclInternalOptions.get());
148+
fclOptions.get(), fclInternalOptions.get(), inputArgs.GTPinInput);
149149

150150
if (igcOutput == nullptr) {
151151
return CL_OUT_OF_HOST_MEMORY;

runtime/compiler_interface/compiler_interface.inl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,24 @@ inline CIF::RAII::UPtr_t<IGC::OclTranslationOutputTagOCL> translate(TranslationC
4949

5050
return ret;
5151
}
52+
template <typename TranslationCtx>
53+
inline CIF::RAII::UPtr_t<IGC::OclTranslationOutputTagOCL> translate(TranslationCtx *tCtx, CIFBuffer *src, CIFBuffer *options,
54+
CIFBuffer *internalOptions, void *gtpinInit) {
55+
if (false == OCLRT::areNotNullptr(tCtx, src, options, internalOptions)) {
56+
return nullptr;
57+
}
58+
59+
auto ret = tCtx->Translate(src, options, internalOptions, nullptr, 0, gtpinInit);
60+
if (ret == nullptr) {
61+
return nullptr; // assume OOM or internal error
62+
}
63+
64+
if ((ret->GetOutput() == nullptr) || (ret->GetBuildLog() == nullptr) || (ret->GetDebugData() == nullptr)) {
65+
return nullptr; // assume OOM or internal error
66+
}
67+
68+
return ret;
69+
}
5270

5371
CIF::CIFMain *createMainNoSanitize(CIF::CreateCIFMainFunc_t createFunc);
5472

runtime/gtpin/gtpin_callback_stubs.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,15 @@ void gtpinNotifyUpdateResidencyList(void *pKernel, void *pResidencyVector) {
5555

5656
void gtpinNotifyPlatformShutdown() {
5757
}
58+
59+
void *gtpinGetIgcInit() {
60+
return nullptr;
61+
}
62+
63+
void setIgcInfo(const void *igcInfo) {
64+
}
65+
66+
const void *gtpinGetIgcInfo() {
67+
return nullptr;
68+
}
5869
} // namespace OCLRT

runtime/gtpin/gtpin_callbacks.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "runtime/mem_obj/buffer.h"
3535
#include "runtime/memory_manager/surface.h"
3636
#include "runtime/platform/platform.h"
37+
#include "runtime/program/program.h"
3738
#include "runtime/utilities/spinlock.h"
3839
#include <deque>
3940
#include <vector>
@@ -44,7 +45,8 @@ namespace OCLRT {
4445

4546
extern gtpin::ocl::gtpin_events_t GTPinCallbacks;
4647

47-
igc_init_t *pIgcInfo = nullptr;
48+
igc_init_t *pIgcInit = nullptr;
49+
const igc_info_t *pIgcInfo = nullptr;
4850
std::atomic<int> sequenceCount(1);
4951
CommandQueue *pCmdQueueForFlushTask = nullptr;
5052
std::deque<gtpinkexec_t> kernelExecQueue;
@@ -59,7 +61,7 @@ void gtpinNotifyContextCreate(cl_context context) {
5961
GTPinHwHelper &gtpinHelper = GTPinHwHelper::get(genFamily);
6062
gtpinPlatformInfo.gen_version = (gtpin::GTPIN_GEN_VERSION)gtpinHelper.getGenVersion();
6163
gtpinPlatformInfo.device_id = static_cast<uint32_t>(pDevice->getHardwareInfo().pPlatform->usDeviceID);
62-
(*GTPinCallbacks.onContextCreate)((context_handle_t)context, &gtpinPlatformInfo, &pIgcInfo);
64+
(*GTPinCallbacks.onContextCreate)((context_handle_t)context, &gtpinPlatformInfo, &pIgcInit);
6365
}
6466
}
6567

@@ -90,7 +92,8 @@ void gtpinNotifyKernelCreate(cl_kernel kernel) {
9092
Context *pContext = &(pKernel->getContext());
9193
cl_context context = (cl_context)pContext;
9294
auto &kernelInfo = pKernel->getKernelInfo();
93-
instrument_params_in_t paramsIn;
95+
instrument_params_in_t paramsIn = {};
96+
9497
paramsIn.kernel_type = GTPIN_KERNEL_TYPE_CS;
9598
paramsIn.simd = (GTPIN_SIMD_WIDTH)kernelInfo.getMaxSimdSize();
9699
paramsIn.orig_kernel_binary = (uint8_t *)pKernel->getKernelHeap();
@@ -99,7 +102,9 @@ void gtpinNotifyKernelCreate(cl_kernel kernel) {
99102
paramsIn.buffer_desc.BTI = static_cast<uint32_t>(gtpinBTI);
100103
paramsIn.igc_hash_id = kernelInfo.heapInfo.pKernelHeader->ShaderHashCode;
101104
paramsIn.kernel_name = (char *)kernelInfo.name.c_str();
102-
paramsIn.igc_info = nullptr;
105+
paramsIn.igc_info = pIgcInfo;
106+
paramsIn.debug_data = pKernel->getProgram()->getDebugData();
107+
paramsIn.debug_data_size = static_cast<uint32_t>(pKernel->getProgram()->getDebugDataSize());
103108
instrument_params_out_t paramsOut = {0};
104109
(*GTPinCallbacks.onKernelCreate)((context_handle_t)(cl_context)context, &paramsIn, &paramsOut);
105110
// Substitute ISA of created kernel with instrumented code
@@ -245,4 +250,15 @@ void gtpinNotifyPlatformShutdown() {
245250
kernelExecQueue.clear();
246251
}
247252
}
253+
void *gtpinGetIgcInit() {
254+
return pIgcInit;
255+
}
256+
257+
void setIgcInfo(const void *igcInfo) {
258+
pIgcInfo = reinterpret_cast<const igc_info_t *>(igcInfo);
259+
}
260+
261+
const void *gtpinGetIgcInfo() {
262+
return pIgcInfo;
263+
}
248264
} // namespace OCLRT

runtime/gtpin/gtpin_init.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ gtpin::ocl::gtpin_events_t GTPinCallbacks = {0};
3636
} // namespace OCLRT
3737

3838
GTPIN_DI_STATUS GTPin_Init(gtpin::ocl::gtpin_events_t *pGtpinEvents, driver_services_t *pDriverServices,
39-
uint32_t *pDriverVersion) {
39+
interface_version_t *pDriverVersion) {
4040
if (isGTPinInitialized) {
4141
return GTPIN_DI_ERROR_INSTANCE_ALREADY_CREATED;
4242
}
4343
if (pDriverVersion != nullptr) {
4444
// GT-Pin is asking to obtain GT-Pin Interface version that is supported
45-
*pDriverVersion = gtpin::ocl::GTPIN_OCL_INTERFACE_VERSION;
45+
pDriverVersion->common = gtpin::GTPIN_COMMON_INTERFACE_VERSION;
46+
pDriverVersion->specific = gtpin::ocl::GTPIN_OCL_INTERFACE_VERSION;
4647

4748
if ((pDriverServices == nullptr) || (pGtpinEvents == nullptr)) {
4849
return GTPIN_DI_SUCCESS;

runtime/gtpin/gtpin_init.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
extern "C" {
2828
#endif
2929

30-
gtpin::GTPIN_DI_STATUS GTPin_Init(gtpin::ocl::gtpin_events_t *pGtpinEvents, gtpin::driver_services_t *pDriverServices, uint32_t *pDriverVersion);
30+
gtpin::GTPIN_DI_STATUS GTPin_Init(gtpin::ocl::gtpin_events_t *pGtpinEvents, gtpin::driver_services_t *pDriverServices, gtpin::interface_version_t *pDriverVersion);
3131

3232
#ifdef __cplusplus
3333
}

runtime/gtpin/gtpin_notify.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ void gtpinNotifyMakeResident(void *pKernel, void *pCommandStreamReceiver);
3636
void gtpinNotifyUpdateResidencyList(void *pKernel, void *pResidencyVector);
3737
void gtpinNotifyPlatformShutdown();
3838
inline bool gtpinIsGTPinInitialized() { return isGTPinInitialized; }
39+
void *gtpinGetIgcInit();
40+
void setIgcInfo(const void *igcInfo);
41+
const void *gtpinGetIgcInfo();
3942
} // namespace OCLRT

runtime/program/build.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "runtime/platform/platform.h"
2727
#include "runtime/source_level_debugger/source_level_debugger.h"
2828
#include "runtime/helpers/validators.h"
29+
#include "runtime/gtpin/gtpin_notify.h"
2930
#include "program.h"
3031
#include <cstring>
3132

@@ -121,6 +122,7 @@ cl_int Program::build(
121122
inputArgs.InternalOptionsSize = (uint32_t)internalOptions.length();
122123
inputArgs.pTracingOptions = nullptr;
123124
inputArgs.TracingOptionsCount = 0;
125+
inputArgs.GTPinInput = gtpinGetIgcInit();
124126
DBG_LOG(LogApiCalls,
125127
"Build Options", inputArgs.pOptions,
126128
"\nBuild Internal Options", inputArgs.pInternalOptions);

runtime/program/process_gen_binary.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "runtime/helpers/string.h"
3232
#include "runtime/kernel/kernel.h"
3333
#include "runtime/memory_manager/memory_manager.h"
34+
#include "runtime/gtpin/gtpin_notify.h"
3435

3536
#include <algorithm>
3637

@@ -790,7 +791,13 @@ cl_int Program::parsePatchList(KernelInfo &kernelInfo) {
790791
"\n .Offset", pPatchToken->Offset,
791792
"\n .PerThreadSystemThreadSurfaceSize", pPatchToken->PerThreadSystemThreadSurfaceSize);
792793
} break;
793-
794+
case PATCH_TOKEN_GTPIN_INFO: {
795+
setIgcInfo(ptrOffset(pCurPatchListPtr, sizeof(SPatchItemHeader)));
796+
DBG_LOG(LogPatchTokens,
797+
"\n.PATCH_TOKEN_GTPIN_INFO", pPatch->Token,
798+
"\n .Size", pPatch->Size);
799+
break;
800+
}
794801
default:
795802
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, " Program::parsePatchList. Unknown Patch Token: %d\n", pPatch->Token);
796803
if (false == isSafeToSkipUnhandledToken(pPatch->Token)) {

runtime/program/program.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,14 @@ class Program : public BaseObject<_cl_program> {
246246
return kernelDebugEnabled;
247247
}
248248

249+
char *getDebugData() {
250+
return debugData;
251+
}
252+
253+
size_t getDebugDataSize() {
254+
return debugDataSize;
255+
}
256+
249257
protected:
250258
Program();
251259

0 commit comments

Comments
 (0)