File: task_vars.ispc

package info (click to toggle)
ispc 1.28.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 97,620 kB
  • sloc: cpp: 77,067; python: 8,303; yacc: 3,337; lex: 1,126; ansic: 631; sh: 475; makefile: 17
file content (81 lines) | stat: -rw-r--r-- 3,106 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// The test checks compiler diagnostics when task-related primitives like
// (taskIndex, taskCount etc) are used in not standard ways:
// 1. as a function parameter
// 2. as a function name
// 3. as a local variable
// Compiler should produce a proper error and not crash. The diagnostics should
// be the same for CPU and Xe targets.

// RUN: not %{ispc} %s -o %t.o --nowrap -DEXPORT_FUNC 2>&1 | FileCheck %s -check-prefix=CHECK-EXPORT_EXTERN_FUNC
// RUN: not %{ispc} %s -o %t.o --target=gen9-x8 --nowrap -DEXPORT_FUNC 2>&1 | FileCheck %s -check-prefix=CHECK-EXPORT_EXTERN_FUNC

// RUN: not %{ispc} %s -o %t.o --nowrap -DTASK_FUNC 2>&1 | FileCheck %s -check-prefix=CHECK-TASK_FUNC
// RUN: not %{ispc} %s -o %t.o --target=gen9-x8 --nowrap -DTASK_FUNC 2>&1 | FileCheck %s -check-prefix=CHECK-TASK_FUNC

// RUN: not %{ispc} %s -o %t.o --nowrap 2>&1 | FileCheck %s -check-prefix=CHECK-EXPORT_EXTERN_FUNC
// RUN: not %{ispc} %s -o %t.o --target=gen9-x8 --nowrap 2>&1 | FileCheck %s -check-prefix=CHECK-EXPORT_EXTERN_FUNC

// CHECK-EXPORT_EXTERN_FUNC: Error: Undeclared symbol "taskIndex0".
// CHECK-EXPORT_EXTERN_FUNC: Error: Undeclared symbol "taskIndex1".
// CHECK-EXPORT_EXTERN_FUNC: Error: Undeclared symbol "taskIndex2".
// CHECK-EXPORT_EXTERN_FUNC: Error: Undeclared symbol "threadIndex".
// CHECK-EXPORT_EXTERN_FUNC: Error: Undeclared symbol "threadCount".
// CHECK-EXPORT_EXTERN_FUNC: Warning: Function parameter "taskIndex" shadows a function declared in global scope.
// CHECK-EXPORT_EXTERN_FUNC-NOT: FATAL ERROR

// CHECK-TASK_FUNC: Error: Ignoring redeclaration of symbol "taskIndex".
// CHECK-TASK_FUNC: Warning: Symbol "taskCount" shadows symbol declared in outer scope.
// CHECK-TASK_FUNC: Warning: Function parameter "taskIndex" shadows a function declared in global scope.
// CHECK-TASK_FUNC: Error: Ignoring redeclaration of symbol "taskIndex".
// CHECK-TASK_FUNC-NOT: FATAL ERROR

// REQUIRES: XE_ENABLED

#ifdef EXPORT_FUNC
export void export_fn1(const uniform int taskIndex) { }

export void export_fn2(uniform int res[]) {
    res[0] = taskIndex0 * taskIndex1 * taskIndex2;
    res[1] = threadIndex + threadCount;
}

export void export_fn3(uniform int res[]) {
    uniform int taskCount = programCount;
    res[0] = taskCount;
}

int taskIndex();
export void export_fn4(uniform int* uniform taskIndex) { }

#elif TASK_FUNC
task void task_fn1(const uniform int taskIndex) { }

task void task_fn2(uniform int res[]) {
    res[0] = taskIndex0 * taskIndex1 * taskIndex2;
    res[1] = threadIndex + threadCount;
}

task void task_fn3(uniform int res[]) {
    uniform int taskCount = programCount;
    res[0] = taskCount;
}

int taskIndex();
task void task_fn4(uniform int* uniform taskIndex) { }

#else
extern void extern_fn1(const uniform int taskIndex) { }

extern void extern_fn2(uniform int res[]) {
    res[0] = taskIndex0 * taskIndex1 * taskIndex2;
    res[1] = threadIndex + threadCount;
}

extern void extern_fn3(uniform int res[]) {
    uniform int taskCount = programCount;
    res[0] = taskCount;
}

int taskIndex();
extern void extern_fn4(uniform int* uniform taskIndex) { }
#endif