1
1
# Work-Item Functions
2
+ #
3
+ # https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_Env.html#_built_in_variables
2
4
3
5
# NOTE: these functions now unsafely truncate to Int to avoid top bit checks.
4
6
# we should probably use range metadata instead.
5
7
6
8
# 1D values
7
- for (julia_name, (spirv_name, offset)) in [
9
+ for (julia_name, (spirv_name, julia_type, offset)) in [
8
10
# indices
9
- :get_global_linear_id => (:BuiltInGlobalLinearId , 1 ),
10
- :get_local_linear_id => (:BuiltInLocalInvocationIndex , 1 ),
11
- :get_sub_group_id => (:BuiltInSubgroupId , 1 ),
12
- :get_sub_group_local_id => (:BuiltInSubgroupLocalInvocationId , 1 ),
11
+ :get_global_linear_id => (:BuiltInGlobalLinearId , Csize_t, 1 ),
12
+ :get_local_linear_id => (:BuiltInLocalInvocationIndex , Csize_t, 1 ),
13
+ :get_sub_group_id => (:BuiltInSubgroupId , UInt32, 1 ),
14
+ :get_sub_group_local_id => (:BuiltInSubgroupLocalInvocationId , UInt32, 1 ),
13
15
# sizes
14
- :get_work_dim => (:BuiltInWorkDim , 0 ),
15
- :get_sub_group_size => (:BuiltInSubgroupSize , 0 ),
16
- :get_max_sub_group_size => (:BuiltInSubgroupMaxSize , 0 ),
17
- :get_num_sub_groups => (:BuiltInNumSubgroups , 0 ),
18
- :get_enqueued_num_sub_groups => (:BuiltInNumEnqueuedSubgroups , 0 )]
16
+ :get_work_dim => (:BuiltInWorkDim , UInt32, 0 ),
17
+ :get_sub_group_size => (:BuiltInSubgroupSize , UInt32, 0 ),
18
+ :get_max_sub_group_size => (:BuiltInSubgroupMaxSize , UInt32, 0 ),
19
+ :get_num_sub_groups => (:BuiltInNumSubgroups , UInt32, 0 ),
20
+ :get_enqueued_num_sub_groups => (:BuiltInNumEnqueuedSubgroups , UInt32, 0 )]
19
21
gvar_name = Symbol (" @__spirv_$(spirv_name) " )
20
- width = Int === Int64 ? 64 : 32
22
+ width = sizeof (julia_type) * 8
21
23
@eval begin
22
24
export $ julia_name
23
25
@device_function $ julia_name () =
@@ -28,7 +30,7 @@ for (julia_name, (spirv_name, offset)) in [
28
30
ret i$(width) %val
29
31
}
30
32
attributes #0 = { alwaysinline }
31
- """ , " entry" ), UInt , Tuple{}) % Int + $ offset
33
+ """ , " entry" ), $ julia_type , Tuple{}) % Int + $ offset
32
34
end
33
35
end
34
36
0 commit comments