Skip to content

Commit 24e349d

Browse files
Alexey Baturosys_zuul
authored andcommitted
introduce support for CM printf on OCL/L0 runtime
Change-Id: Ib69991f4a96599163b0c9565124a908373186b0f
1 parent 527a59a commit 24e349d

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

IGC/AdaptorOCL/cmc.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,17 @@ static void generatePatchTokens(const cmc_kernel_info *info, CMKernel& kernel)
353353
// Setup argument to BTI mapping.
354354
kernel.m_kernelInfo.m_argIndexMap.clear();
355355

356+
for (unsigned i = 0; i < info->num_print_strings; i++) {
357+
assert(info->print_string_descs);
358+
cmc_ocl_print_string& SI = info->print_string_descs[i];
359+
iOpenCL::PrintfStringAnnotation* stringAnnotation = new iOpenCL::PrintfStringAnnotation;
360+
stringAnnotation->Index = i;
361+
stringAnnotation->StringSize = sizeof(SI.s);
362+
stringAnnotation->StringData = new char[cmc_ocl_print_string::max_width];
363+
std::copy(SI.s, SI.s + cmc_ocl_print_string::max_width, stringAnnotation->StringData);
364+
kernel.m_kernelInfo.m_printfStringAnnotations.push_back(stringAnnotation);
365+
}
366+
356367
for (unsigned i = 0; i < info->num_args; ++i) {
357368
assert(info->arg_descs);
358369
cmc_arg_info& AI = info->arg_descs[i];
@@ -397,6 +408,14 @@ static void generatePatchTokens(const cmc_kernel_info *info, CMKernel& kernel)
397408
kernel.createImageAnnotation(AI.index, AI.BTI, 3, isWriteable);
398409
kernel.m_kernelInfo.m_argIndexMap[AI.index] = AI.BTI;
399410
break;
411+
case cmc_arg_kind::PrintBuffer:
412+
kernel.m_kernelInfo.m_printfBufferAnnotation = new iOpenCL::PrintfBufferAnnotation();
413+
kernel.m_kernelInfo.m_printfBufferAnnotation->AnnotationSize = sizeof(kernel.m_kernelInfo.m_printfBufferAnnotation);
414+
kernel.m_kernelInfo.m_argIndexMap[AI.index] = 255;
415+
kernel.m_kernelInfo.m_printfBufferAnnotation->PayloadPosition = AI.offset - constantPayloadStart;
416+
kernel.m_kernelInfo.m_printfBufferAnnotation->Index = 0;
417+
kernel.m_kernelInfo.m_printfBufferAnnotation->DataSize = 8;
418+
break;
400419
}
401420
}
402421

IGC/AdaptorOCL/igcmc.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ enum class cmc_arg_kind : int32_t {
4343
Sampler,
4444
Image1d,
4545
Image2d,
46-
Image3d
46+
Image3d,
47+
PrintBuffer // IMPLICIT_PRINTF_BUFFER
4748
};
4849

4950
struct cmc_arg_info {
@@ -66,6 +67,11 @@ struct cmc_arg_info {
6667
cmc_access_kind access = cmc_access_kind::undef;
6768
};
6869

70+
struct cmc_ocl_print_string {
71+
static constexpr unsigned max_width = 128;
72+
char s[max_width];
73+
};
74+
6975
// compilation interface bewteen cmc and igc
7076
struct cmc_kernel_info {
7177
/// The kernel name.
@@ -77,6 +83,12 @@ struct cmc_kernel_info {
7783
/// The kernel argument info.
7884
cmc_arg_info *arg_descs;
7985

86+
/// number of format strings in the kernel
87+
unsigned num_print_strings;
88+
89+
/// The kernel format string storage
90+
cmc_ocl_print_string *print_string_descs;
91+
8092
// ThreadPayload
8193
bool HasLocalIDx = false;
8294
bool HasLocalIDy = false;

0 commit comments

Comments
 (0)