|
| 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