Skip to content

Commit 67faf6c

Browse files
KanclerzPiotrigcbot
authored andcommitted
Enable has_printf_calls zeinfo field
This commit enables previously added has_printf_calls field and test for it.
1 parent 17c1de9 commit 67faf6c

File tree

2 files changed

+63
-4
lines changed

2 files changed

+63
-4
lines changed

IGC/AdaptorOCL/OCL/sp/zebin_builder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,8 @@ void ZEBinaryBuilder::addKernelExecEnv(const SOpenCLKernelInfo &annotations, zeI
471471
CPlatform(mPlatform).hasScratchSurface() && IGC_IS_FLAG_ENABLED(SeparateSpillPvtScratchSpace);
472472
env.has_no_stateless_write = (annotations.m_executionEnvironment.StatelessWritesCount == 0);
473473
env.has_stack_calls = annotations.m_executionEnvironment.HasStackCalls;
474-
// env.has_printf_calls = annotations.m_executionEnvironment.HasPrintfCalls;
475-
// env.has_indirect_calls = annotations.m_executionEnvironment.HasIndirectCalls;
474+
env.has_printf_calls = annotations.m_executionEnvironment.HasPrintfCalls;
475+
env.has_indirect_calls = annotations.m_executionEnvironment.HasIndirectCalls;
476476
env.require_disable_eufusion = annotations.m_executionEnvironment.RequireDisableEUFusion;
477477
env.indirect_stateless_count = annotations.m_executionEnvironment.IndirectStatelessCount;
478478
env.inline_data_payload_size = annotations.m_threadPayload.PassInlineDataSize;
@@ -516,8 +516,8 @@ void ZEBinaryBuilder::addFunctionExecEnv(const SOpenCLKernelInfo &annotations,
516516
env.simd_size = annotations.m_executionEnvironment.CompiledSIMDSize;
517517
env.barrier_count = zeFuncAttr.f_BarrierCount;
518518
env.has_rtcalls = zeFuncAttr.f_hasRTCalls;
519-
// env.has_printf_calls = zeFuncAttr.f_hasPrintfCalls;
520-
// env.has_indirect_calls = zeFuncAttr.f_hasIndirectCalls;
519+
env.has_printf_calls = zeFuncAttr.f_hasPrintfCalls;
520+
env.has_indirect_calls = zeFuncAttr.f_hasIndirectCalls;
521521
}
522522

523523
void ZEBinaryBuilder::addLocalIds(uint32_t simdSize, uint32_t grfSize, bool has_local_id_x, bool has_local_id_y,
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*========================== begin_copyright_notice ============================
2+
3+
Copyright (C) 2025 Intel Corporation
4+
5+
SPDX-License-Identifier: MIT
6+
7+
============================= end_copyright_notice ===========================*/
8+
9+
// The test checks if zeinfo "has_printf_calls" and "has_indirect_calls" and it fields are set.
10+
11+
// UNSUPPORTED: sys32
12+
// REQUIRES: pvc-supported, regkeys
13+
14+
// RUN: ocloc compile -file %s -options "-igc_opts 'DumpZEInfoToConsole=1'" \
15+
// RUN: -device pvc | FileCheck %s
16+
17+
// CHECK: kernels:
18+
// CHECK-NEXT: - name: test
19+
// CHECK: execution_env:
20+
// CHECK: has_indirect_calls: true
21+
22+
// CHECK: functions:
23+
// CHECK: - name: even
24+
// CHECK: execution_env
25+
// CHECK: has_printf_calls: true
26+
// CHECK: - name: odd
27+
// CHECK: execution_env
28+
// CHECK: has_printf_calls: true
29+
30+
char *__builtin_IB_get_function_pointer(__constant char *function_name);
31+
void __builtin_IB_call_function_pointer(char *function_pointer,
32+
char *argument_structure);
33+
34+
void even(char *argument_structure) {
35+
int *pio = (int *)argument_structure;
36+
printf("%d", *pio * 2);
37+
}
38+
39+
void odd(char *argument_structure) {
40+
int *pio = (int *)argument_structure;
41+
printf("%d", *pio * 3);
42+
}
43+
44+
#define EVEN_FUNC_NAME "even"
45+
#define ODD_FUNC_NAME "odd"
46+
47+
__kernel void test() {
48+
int gid = (int)get_global_id(0);
49+
50+
char* fp = 0;
51+
if(gid % 2)
52+
fp = __builtin_IB_get_function_pointer(ODD_FUNC_NAME);
53+
else
54+
fp = __builtin_IB_get_function_pointer(EVEN_FUNC_NAME);
55+
56+
int x = 5;
57+
58+
__builtin_IB_call_function_pointer(fp, (char *)&x);
59+
}

0 commit comments

Comments
 (0)