Skip to content

Commit 478a978

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web' (18 commits)
2 parents 9440610 + d629065 commit 478a978

File tree

78 files changed

+1429
-1281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1429
-1281
lines changed

libclc/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ endif()
260260
find_package( Python3 REQUIRED COMPONENTS Interpreter )
261261
file( TO_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/utils/gen_convert.py script_loc )
262262
file( TO_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libspirv/lib/generic/gen_convert.py spirv_script_loc )
263+
file( TO_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libspirv/lib/generic/gen_convert_common.py spirv_common_script_loc )
263264
add_custom_command(
264265
OUTPUT convert.cl
265266
COMMAND ${Python3_EXECUTABLE} ${script_loc} > convert.cl
@@ -277,7 +278,7 @@ set_target_properties( generate-clc-convert.cl PROPERTIES FOLDER "libclc/Sourceg
277278
add_custom_command(
278279
OUTPUT spirv-convert.cl
279280
COMMAND ${Python3_EXECUTABLE} ${spirv_script_loc} > spirv-convert.cl
280-
DEPENDS ${spirv_script_loc} )
281+
DEPENDS ${spirv_script_loc} ${spirv_common_script_loc} )
281282
add_custom_target( generate-spirv-convert.cl DEPENDS spirv-convert.cl )
282283
set_target_properties( generate-spirv-convert.cl PROPERTIES FOLDER "libclc/Sourcegenning" )
283284

libclc/generic/gen_convert_common.py

Lines changed: 0 additions & 117 deletions
This file was deleted.

libclc/libspirv/lib/generic/gen_convert.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
from os.path import dirname, join, abspath
2020

21-
sys.path.insert(0, abspath(join(dirname(__file__), "..", "..", "..", "generic")))
22-
2321
from gen_convert_common import (
2422
types,
2523
int_types,
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# This file contains common variables and helper functions used by the
2+
# `gen_convert.py` in both the libclc and libspirv libraries.
3+
4+
types = [
5+
"char",
6+
"schar",
7+
"uchar",
8+
"short",
9+
"ushort",
10+
"int",
11+
"uint",
12+
"long",
13+
"ulong",
14+
"half",
15+
"float",
16+
"double",
17+
]
18+
int_types = [
19+
"char",
20+
"schar",
21+
"uchar",
22+
"short",
23+
"ushort",
24+
"int",
25+
"uint",
26+
"long",
27+
"ulong",
28+
]
29+
unsigned_types = ["uchar", "ushort", "uint", "ulong"]
30+
signed_types = ["char", "schar", "short", "int", "long"]
31+
float_types = ["half", "float", "double"]
32+
int64_types = ["long", "ulong"]
33+
float64_types = ["double"]
34+
float16_types = ["half"]
35+
vector_sizes = ["", "2", "3", "4", "8", "16"]
36+
half_sizes = [("2", ""), ("4", "2"), ("8", "4"), ("16", "8")]
37+
38+
saturation = ["", "_sat"]
39+
rounding_modes = ["_rtz", "_rte", "_rtp", "_rtn"]
40+
float_prefix = {"float": "FLT_", "double": "DBL_"}
41+
float_suffix = {"float": "f", "double": ""}
42+
43+
bool_type = {
44+
"char": "char",
45+
"schar": "schar",
46+
"uchar": "schar",
47+
"short": "short",
48+
"ushort": "short",
49+
"int": "int",
50+
"uint": "int",
51+
"long": "long",
52+
"ulong": "long",
53+
"half": "short",
54+
"float": "int",
55+
"double": "long",
56+
}
57+
58+
unsigned_type = {
59+
"char": "uchar",
60+
"schar": "uchar",
61+
"uchar": "uchar",
62+
"short": "ushort",
63+
"ushort": "ushort",
64+
"int": "uint",
65+
"uint": "uint",
66+
"long": "ulong",
67+
"ulong": "ulong",
68+
}
69+
70+
sizeof_type = {
71+
"char": 1,
72+
"schar": 1,
73+
"uchar": 1,
74+
"short": 2,
75+
"ushort": 2,
76+
"int": 4,
77+
"uint": 4,
78+
"long": 8,
79+
"ulong": 8,
80+
"half": 2,
81+
"float": 4,
82+
"double": 8,
83+
}
84+
85+
limit_max = {
86+
"char": "CHAR_MAX",
87+
"schar": "CHAR_MAX",
88+
"uchar": "UCHAR_MAX",
89+
"short": "SHRT_MAX",
90+
"ushort": "USHRT_MAX",
91+
"int": "INT_MAX",
92+
"uint": "UINT_MAX",
93+
"long": "LONG_MAX",
94+
"ulong": "ULONG_MAX",
95+
"half": "0x1.ffcp+15",
96+
}
97+
98+
limit_min = {
99+
"char": "CHAR_MIN",
100+
"schar": "CHAR_MIN",
101+
"uchar": "0",
102+
"short": "SHRT_MIN",
103+
"ushort": "0",
104+
"int": "INT_MIN",
105+
"uint": "0",
106+
"long": "LONG_MIN",
107+
"ulong": "0",
108+
"half": "-0x1.ffcp+15",
109+
}
110+
111+
112+
def conditional_guard(src, dst):
113+
"""
114+
This function will optionally print a header guard for `cl_khr_fp64` if a 64-bit type is used
115+
as the source or destination and return a bool that indicates whether this guard will need
116+
closed after the calling function has finished printing functions that use the 64-bit
117+
source/destination type.
118+
"""
119+
int64_count = 0
120+
float64_count = 0
121+
float16_count = 0
122+
if src in int64_types or dst in int64_types:
123+
int64_count = 1
124+
if src in float64_types or dst in float64_types:
125+
float64_count = 1
126+
if src in float16_types or dst in float16_types:
127+
float16_count = 1
128+
if float16_count > 0:
129+
print("#ifdef cl_khr_fp16")
130+
if float64_count > 0:
131+
# In embedded profile, if cl_khr_fp64 is supported cles_khr_int64 has to be
132+
print("#ifdef cl_khr_fp64")
133+
return 1 + float16_count
134+
elif int64_count > 0:
135+
print("#if defined cles_khr_int64 || !defined(__EMBEDDED_PROFILE__)")
136+
return 1 + float16_count
137+
return float16_count
138+
139+
140+
def close_conditional_guard(close_conditional):
141+
"""
142+
This function will close conditional guard opened by conditional_guard.
143+
"""
144+
for _ in range(close_conditional):
145+
print("#endif")
146+
147+
148+
def clc_core_fn_name(dst, size="", mode="", sat=""):
149+
"""
150+
This helper function returns the correct clc core conversion function name
151+
for a given source and destination type, with optional size, mode
152+
and saturation arguments.
153+
"""
154+
return "__clc_convert_{DST}{N}{SAT}{MODE}".format(
155+
DST=dst, N=size, SAT=sat, MODE=mode
156+
)

0 commit comments

Comments
 (0)