Skip to content

Commit e31699d

Browse files
aratajewsys_zuul
authored andcommitted
Support for syncBuffer implicit argument
Change-Id: I3c6ad0ed1e2c9c8f3f929a4c188495c0f02553c6
1 parent 1da27e3 commit e31699d

File tree

16 files changed

+153
-2
lines changed

16 files changed

+153
-2
lines changed

IGC/AdaptorCommon/ImplicitArgs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ ImplicitArgs::ImplicitArgs(const llvm::Function& func , const MetaDataUtils* pMd
300300
IMPLICIT_ARGS.push_back(ImplicitArg(ImplicitArg::STAGE_IN_GRID_ORIGIN, "stageInGridOrigin", ImplicitArg::INT, WIAnalysis::UNIFORM, 3, ImplicitArg::ALIGN_GRF, true));
301301
IMPLICIT_ARGS.push_back(ImplicitArg(ImplicitArg::STAGE_IN_GRID_SIZE, "stageInGridSize", ImplicitArg::INT, WIAnalysis::UNIFORM, 3, ImplicitArg::ALIGN_GRF, true));
302302

303+
IMPLICIT_ARGS.push_back(ImplicitArg(ImplicitArg::SYNC_BUFFER, "syncBuffer", ImplicitArg::GLOBALPTR, WIAnalysis::UNIFORM, 1, ImplicitArg::ALIGN_PTR, false));
303304

304305
assert(IMPLICIT_ARGS.size() == ImplicitArg::NUM_IMPLICIT_ARGS && "Mismatch in NUM_IMPLICIT_ARGS and IMPLICIT_ARGS vector");
305306

IGC/AdaptorCommon/ImplicitArgs.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ namespace IGC
122122
STAGE_IN_GRID_ORIGIN,
123123
STAGE_IN_GRID_SIZE,
124124

125+
SYNC_BUFFER,
125126

126127
NUM_IMPLICIT_ARGS
127128
};

IGC/AdaptorOCL/OCL/KernelAnnotations.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ struct PrintfBufferAnnotation : KernelArgumentAnnotation
222222
DWORD PayloadPosition;
223223
};
224224

225+
// Annotation for sync buffer.
226+
struct SyncBufferAnnotation : KernelArgumentAnnotation
227+
{
228+
DWORD DataSize;
229+
DWORD PayloadPosition;
230+
};
231+
225232
// Generated by front end
226233
struct KernelConstantRegisterAnnotation
227234
{

IGC/AdaptorOCL/OCL/Patch/patch_parser.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,27 @@ void DebugPatchList(
10051005
}
10061006
break;
10071007

1008+
case iOpenCL::PATCH_TOKEN_ALLOCATE_SYNC_BUFFER:
1009+
{
1010+
const iOpenCL::SPatchAllocateSyncBuffer* pPatchItem =
1011+
(const iOpenCL::SPatchAllocateSyncBuffer*)pHeader;
1012+
1013+
ICBE_DPF_STR(output, GFXDBG_HARDWARE,
1014+
"PATCH_TOKEN_ALLOCATE_SYNC_BUFFER (%08X) (size = %d)\n",
1015+
pPatchItem->Token,
1016+
pPatchItem->Size);
1017+
ICBE_DPF_STR(output, GFXDBG_HARDWARE,
1018+
"\tSurfaceStateHeapOffset = %d\n",
1019+
pPatchItem->SurfaceStateHeapOffset);
1020+
ICBE_DPF_STR(output, GFXDBG_HARDWARE,
1021+
"\tDataParamOffset = %d\n",
1022+
pPatchItem->DataParamOffset);
1023+
ICBE_DPF_STR(output, GFXDBG_HARDWARE,
1024+
"\tDataParamSize = %d\n",
1025+
pPatchItem->DataParamSize);
1026+
}
1027+
break;
1028+
10081029
// Stateless Tokens
10091030
case iOpenCL::PATCH_TOKEN_STATELESS_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT:
10101031
{

IGC/AdaptorOCL/OCL/sp/sp_g8.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,21 @@ RETVAL CGen8OpenCLStateProcessor::CreateSurfaceStateHeap(
758758
false)));
759759
}
760760

761+
if (annotations.m_syncBufferAnnotation != NULL)
762+
{
763+
unsigned int bti = annotations.m_argIndexMap.at(annotations.m_syncBufferAnnotation->ArgumentNumber);
764+
context.Surface.SurfaceOffset[bti] = (DWORD)membuf.Size();
765+
766+
SurfaceStates.insert(
767+
std::make_pair(
768+
bti,
769+
SurfaceState(
770+
SURFACE_BUFFER,
771+
SURFACE_FORMAT_RAW,
772+
0,
773+
false)));
774+
}
775+
761776
// If GT-Pin is enabled, assign btis to GT-Pin's surfaces
762777
if (gtpinEnabled)
763778
{
@@ -1659,6 +1674,32 @@ RETVAL CGen8OpenCLStateProcessor::CreatePatchList(
16591674
}
16601675
}
16611676

1677+
// Patch for Sync Buffer Offset
1678+
if (retValue.Success)
1679+
{
1680+
if (annotations.m_syncBufferAnnotation != nullptr)
1681+
{
1682+
iOpenCL::SyncBufferAnnotation* syncBufAnn = annotations.m_syncBufferAnnotation;
1683+
1684+
iOpenCL::SPatchAllocateSyncBuffer patch;
1685+
memset(&patch, 0, sizeof(patch));
1686+
1687+
unsigned int bti = annotations.m_argIndexMap.at(syncBufAnn->ArgumentNumber);
1688+
1689+
patch.Token = iOpenCL::PATCH_TOKEN_ALLOCATE_SYNC_BUFFER;
1690+
patch.Size = sizeof(patch);
1691+
patch.SurfaceStateHeapOffset = context.Surface.SurfaceOffset[bti];
1692+
patch.DataParamOffset = syncBufAnn->PayloadPosition;
1693+
patch.DataParamSize = syncBufAnn->DataSize;
1694+
1695+
dataParameterStreamSize = std::max(
1696+
dataParameterStreamSize,
1697+
syncBufAnn->PayloadPosition + syncBufAnn->DataSize);
1698+
1699+
retValue = AddPatchItem(patch, membuf);
1700+
}
1701+
}
1702+
16621703
// Pointer inputs with initializer
16631704
if( retValue.Success )
16641705
{

IGC/AdaptorOCL/ocl_igc_shared/executable_format/patch_list.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Abstract: Contains common patch structure definitions
3333

3434
namespace iOpenCL
3535
{
36-
const uint32_t CURRENT_ICBE_VERSION = 1061;
36+
const uint32_t CURRENT_ICBE_VERSION = 1062;
3737

3838
const uint32_t MAGIC_CL = 0x494E5443; // 'I', 'N', 'T', 'C'
3939
const uint32_t INVALID_INDEX = 0xFFFFFFFF;
@@ -150,12 +150,13 @@ enum PATCH_TOKEN
150150
PATCH_TOKEN_PROGRAM_SYMBOL_TABLE, // 53 @SPatchFunctionTableInfo@
151151
PATCH_TOKEN_PROGRAM_RELOCATION_TABLE, // 54 @SPatchFunctionTableInfo@
152152
PATCH_TOKEN_MEDIA_VFE_STATE_SLOT1, // 55 @SPatchMediaVFEState of slot1@
153+
PATCH_TOKEN_ALLOCATE_SYNC_BUFFER, // 56 @SPatchAllocateSyncBuffer@
153154

154155
NUM_PATCH_TOKENS
155156
};
156157

157158
// Update CURRENT_ICBE_VERSION when modifying the patch list
158-
static_assert( NUM_PATCH_TOKENS == 56, "NUM_PATCH_TOKENS has invalid value");
159+
static_assert( NUM_PATCH_TOKENS == 57, "NUM_PATCH_TOKENS has invalid value");
159160

160161
/*****************************************************************************\
161162
ENUM: IMAGE_MEMORY_OBJECT_TYPE

IGC/AdaptorOCL/ocl_igc_shared/executable_format/patch_shared.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,17 @@ struct SPatchAllocateStatelessPrintfSurface :
444444
// Update CURRENT_ICBE_VERSION when modifying the patch list
445445
static_assert( sizeof( SPatchAllocateStatelessPrintfSurface ) == ( 16 + sizeof( SPatchItemHeader ) ) , "The size of SPatchAllocateStatelessPrintfSurface is not what is expected" );
446446

447+
struct SPatchAllocateSyncBuffer :
448+
SPatchItemHeader
449+
{
450+
uint32_t SurfaceStateHeapOffset;
451+
uint32_t DataParamOffset;
452+
uint32_t DataParamSize;
453+
};
454+
455+
// Update CURRENT_ICBE_VERSION when modifying the patch list
456+
static_assert( sizeof( SPatchAllocateSyncBuffer ) == ( 12 + sizeof( SPatchItemHeader ) ), "The size of SPatchAllocateSyncBuffer is not what is expected" );
457+
447458
/*****************************************************************************\
448459
STRUCT: SPatchAllocateStatelessPrivateSurface
449460
\*****************************************************************************/

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ namespace IGC
194194
m_kernelInfo.m_printfBufferAnnotation = nullptr;
195195
}
196196

197+
// Sync Buffer Annotation
198+
if (m_kernelInfo.m_syncBufferAnnotation != nullptr)
199+
{
200+
delete m_kernelInfo.m_syncBufferAnnotation;
201+
m_kernelInfo.m_syncBufferAnnotation = nullptr;
202+
}
203+
197204
// StartGASAnnotationAnnotation
198205
if (m_kernelInfo.m_startGAS != nullptr)
199206
{
@@ -1147,6 +1154,23 @@ namespace IGC
11471154
m_kernelInfo.m_threadPayload.UnusedPerThreadConstantPresent = true;
11481155
break;
11491156

1157+
case KernelArg::ArgType::IMPLICIT_SYNC_BUFFER:
1158+
{
1159+
int argNo = kernelArg->getAssociatedArgNo();
1160+
SOpenCLKernelInfo::SResourceInfo resInfo = getResourceInfo(argNo);
1161+
m_kernelInfo.m_argIndexMap[argNo] = getBTI(resInfo);
1162+
1163+
iOpenCL::SyncBufferAnnotation* syncBuffer = new iOpenCL::SyncBufferAnnotation();
1164+
1165+
syncBuffer->AnnotationSize = sizeof(syncBuffer);
1166+
syncBuffer->ArgumentNumber = argNo;
1167+
syncBuffer->PayloadPosition = payloadPosition;
1168+
syncBuffer->DataSize = kernelArg->getAllocateSize();
1169+
1170+
m_kernelInfo.m_syncBufferAnnotation = syncBuffer;
1171+
}
1172+
break;
1173+
11501174
case KernelArg::ArgType::IMPLICIT_PRINTF_BUFFER:
11511175
{
11521176
int argNo = kernelArg->getAssociatedArgNo();
@@ -1408,6 +1432,7 @@ namespace IGC
14081432
m_kernelInfo.m_threadPayload.HasLocalID = false;
14091433
m_kernelInfo.m_threadPayload.UnusedPerThreadConstantPresent = false;
14101434
m_kernelInfo.m_printfBufferAnnotation = nullptr;
1435+
m_kernelInfo.m_syncBufferAnnotation = nullptr;
14111436
m_kernelInfo.m_threadPayload.HasStageInGridOrigin = false;
14121437
m_kernelInfo.m_threadPayload.HasStageInGridSize = false;
14131438

IGC/Compiler/CodeGenPublic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ namespace IGC
513513
SOpenCLKernelInfo()
514514
{
515515
m_printfBufferAnnotation = nullptr;
516+
m_syncBufferAnnotation = nullptr;
516517
m_startGAS = nullptr;
517518
m_WindowSizeGAS = nullptr;
518519
m_PrivateMemSize = nullptr;
@@ -537,6 +538,7 @@ namespace IGC
537538
std::vector<iOpenCL::PrintfStringAnnotation*> m_printfStringAnnotations;
538539

539540
iOpenCL::PrintfBufferAnnotation* m_printfBufferAnnotation;
541+
iOpenCL::SyncBufferAnnotation* m_syncBufferAnnotation;
540542
iOpenCL::StartGASAnnotation* m_startGAS = NULL;
541543
iOpenCL::WindowSizeGASAnnotation* m_WindowSizeGAS = NULL;
542544
iOpenCL::PrivateMemSizeAnnotation* m_PrivateMemSize = NULL;

IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ KernelArg::ArgType KernelArg::calcArgType(const ImplicitArg& arg) const
244244
return KernelArg::ArgType::IMPLICIT_CONSTANT_BASE;
245245
case ImplicitArg::PRINTF_BUFFER:
246246
return KernelArg::ArgType::IMPLICIT_PRINTF_BUFFER;
247+
case ImplicitArg::SYNC_BUFFER:
248+
return KernelArg::ArgType::IMPLICIT_SYNC_BUFFER;
247249
case ImplicitArg::BUFFER_OFFSET:
248250
return KernelArg::ArgType::IMPLICIT_BUFFER_OFFSET;
249251
case ImplicitArg::GLOBAL_BASE:
@@ -763,6 +765,7 @@ KernelArgsOrder::KernelArgsOrder(InputType layout)
763765
KernelArg::ArgType::IMPLICIT_GLOBAL_BASE,
764766
KernelArg::ArgType::IMPLICIT_PRIVATE_BASE,
765767
KernelArg::ArgType::IMPLICIT_PRINTF_BUFFER,
768+
KernelArg::ArgType::IMPLICIT_SYNC_BUFFER,
766769
KernelArg::ArgType::IMPLICIT_BUFFER_OFFSET,
767770
KernelArg::ArgType::IMPLICIT_WORK_DIM,
768771
KernelArg::ArgType::IMPLICIT_NUM_GROUPS,
@@ -873,6 +876,7 @@ KernelArgsOrder::KernelArgsOrder(InputType layout)
873876
KernelArg::ArgType::IMPLICIT_GLOBAL_BASE,
874877
KernelArg::ArgType::IMPLICIT_PRIVATE_BASE,
875878
KernelArg::ArgType::IMPLICIT_PRINTF_BUFFER,
879+
KernelArg::ArgType::IMPLICIT_SYNC_BUFFER,
876880
KernelArg::ArgType::IMPLICIT_BUFFER_OFFSET,
877881
KernelArg::ArgType::IMPLICIT_WORK_DIM,
878882
KernelArg::ArgType::IMPLICIT_NUM_GROUPS,

0 commit comments

Comments
 (0)