File: KernelCompilerUtils.h

package info (click to toggle)
pocl 7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 29,768 kB
  • sloc: lisp: 151,669; ansic: 135,425; cpp: 65,801; python: 1,846; sh: 1,084; ruby: 255; pascal: 231; tcl: 180; makefile: 174; asm: 81; java: 72; xml: 49
file content (108 lines) | stat: -rw-r--r-- 5,515 bytes parent folder | download
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Misc. helpers for kernel compilation.
//
// Copyright (c) 2024 Pekka Jääskeläinen / Intel Finland Oy
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.

#ifndef POCL_KERNEL_COMPILER_UTILS_H
#define POCL_KERNEL_COMPILER_UTILS_H

#include "config.h"

// Generates the name for the global magic variable for the local id.
#define LID_G_NAME(DIM) (std::string("_local_id_") + (char)('x' + DIM))
// Generates the name for the global magic variable for the global id iterator.
#define GID_G_NAME(DIM) (std::string("_global_id_") + (char)('x' + DIM))
// Generates the name for the global magic variable for the group id.
#define GROUP_ID_G_NAME(DIM) (std::string("_group_id_") + (char)('x' + DIM))
// Generates the name for the global magic variable for the get_num_groups
#define NGROUPS_G_NAME(DIM) (std::string("_num_groups_") + (char)('x' + DIM))
// Generates the name for the global magic variable for the local size.
#define LS_G_NAME(DIM) (std::string("_local_size_") + (char)('x' + DIM))

#ifdef KERNEL_TRIPLE_TARGETS_MSVC_TOOLCHAIN
// Used 'clang -target x86_64-pc-windows-msvc -cl-std=cl3.0 -S -emit-llvm
// -o - some.cl' to generate MSVC-mangled symbols.

// The name of the mangled get_global_id() builtin function.
#define GID_BUILTIN_NAME "?get_global_id@@$$J0YAKI@Z"
// The name of the mangled get_global_size() builtin function.
#define GS_BUILTIN_NAME "?get_local_size@@$$J0YAKI@Z"
// The name of the mangled get_group_id() builtin function.
#define GROUP_ID_BUILTIN_NAME "?get_group_id@@$$J0YAKI@Z"
// The name of the mangled get_local_id() builtin function.
#define LID_BUILTIN_NAME "?get_local_id@@$$J0YAKI@Z"
// The name of the mangled get_local_size() builtin function.
#define LS_BUILTIN_NAME "?get_local_size@@$$J0YAKI@Z"
// The name of the mangled get_local_size() builtin function.
#define GOFF_BUILTIN_NAME "?get_global_offset@@$$J0YAKI@Z"
// The name of the mangled get_enqueued_local_size() builtin function.
#define ENQUEUE_LS_BUILTIN_NAME "?get_enqueued_local_size@@$$J0YAKI@Z"
// The name of the mangled get_num_groups() builtin function.
#define NGROUPS_BUILTIN_NAME "?get_num_groups@@$$J0YAKI@Z"
// The name of the mangled get_work_dim() builtin function.
#define WDIM_BUILTIN_NAME "?get_work_dim@@$$J0YAIXZ"
// The name of the mangled get_global_linear_id() builtin function.
#define GLID_BUILTIN_NAME "?get_global_linear_id@@$$J0YAKXZ"
// The name of the mangled get_local_linear_id() builtin function.
#define LLID_BUILTIN_NAME "?get_local_linear_id@@$$J0YAKXZ"
// The name of the mangled barrier() function.
#define BARRIER_BUILTIN_NAME "?barrier@@$$J0YAXI@Z"

#else
// Assuming Itanium mangling.
// Used 'clang -target x86_64-pc-linux-gnu -cl-std=cl3.0 -S -emit-llvm
// -o - some.cl' to generate Itanium-mangled symbols.

// The name of the mangled get_global_id() builtin function.
#define GID_BUILTIN_NAME "_Z13get_global_idj"
// The name of the mangled get_global_size() builtin function.
#define GS_BUILTIN_NAME "_Z15get_global_sizej"
// The name of the mangled get_group_id() builtin function.
#define GROUP_ID_BUILTIN_NAME "_Z12get_group_idj"
// The name of the mangled get_local_id() builtin function.
#define LID_BUILTIN_NAME "_Z12get_local_idj"
// The name of the mangled get_local_size() builtin function.
#define LS_BUILTIN_NAME "_Z14get_local_sizej"
// The name of the mangled get_local_size() builtin function.
#define GOFF_BUILTIN_NAME "_Z17get_global_offsetj"
// The name of the mangled get_enqueued_local_size() builtin function.
#define ENQUEUE_LS_BUILTIN_NAME "_Z23get_enqueued_local_sizej"
// The name of the mangled get_num_groups() builtin function.
#define NGROUPS_BUILTIN_NAME "_Z14get_num_groupsj"
// The name of the mangled get_work_dim() builtin function.
#define WDIM_BUILTIN_NAME "_Z12get_work_dimv"
// The name of the mangled get_global_linear_id() builtin function.
#define GLID_BUILTIN_NAME "_Z20get_global_linear_idv"
// The name of the mangled get_local_linear_id() builtin function.
#define LLID_BUILTIN_NAME "_Z19get_local_linear_idv"
// The name of the mangled barrier() function.
#define BARRIER_BUILTIN_NAME "_Z7barrierj"
#endif

namespace PoCLMDKind {
/// Metadata used by WILoops:
static constexpr const char RequiredUniformBlock[] = "pocl.bb.required_uniform";
/// Metadata used by CBS:
static constexpr const char Arrayified[] = "pocl.arrayified";
static constexpr const char InnerLoop[] = "pocl.loop.inner";
static constexpr const char WorkItemLoop[] = "pocl.loop.workitem";
}; // namespace PoCLMDKind

#endif