@@ -194,6 +194,10 @@ function unsafe_free! end
194
194
195
195
unsafe_free! (:: AbstractArray ) = return
196
196
197
+ include (" intrinsics.jl" )
198
+ import . KernelIntrinsics
199
+ export KernelIntrinsics
200
+
197
201
# ##
198
202
# Kernel language
199
203
# - @localmem
@@ -460,13 +464,27 @@ end
460
464
# Internal kernel functions
461
465
# ##
462
466
463
- function __index_Local_Linear end
464
- function __index_Group_Linear end
465
- function __index_Global_Linear end
467
+ function __index_Local_Linear (ctx)
468
+ return KernelIntrinsics . get_local_id () . x
469
+ end
466
470
467
- function __index_Local_Cartesian end
468
- function __index_Group_Cartesian end
469
- function __index_Global_Cartesian end
471
+ function __index_Group_Linear (ctx)
472
+ return KernelIntrinsics. get_group_id (). x
473
+ end
474
+
475
+ function __index_Global_Linear (ctx)
476
+ return KernelIntrinsics. get_global_id (). x
477
+ end
478
+
479
+ function __index_Local_Cartesian (ctx)
480
+ return @inbounds workitems (__iterspace (ctx))[KernelIntrinsics. get_local_id (). x]
481
+ end
482
+ function __index_Group_Cartesian (ctx)
483
+ return @inbounds blocks (__iterspace (ctx))[KernelIntrinsics. get_group_id (). x]
484
+ end
485
+ function __index_Global_Cartesian (ctx)
486
+ return @inbounds expand (__iterspace (ctx), KernelIntrinsics. get_group_id (). x, KernelIntrinsics. get_local_id (). x)
487
+ end
470
488
471
489
@inline __index_Local_NTuple (ctx, I... ) = Tuple (__index_Local_Cartesian (ctx, I... ))
472
490
@inline __index_Group_NTuple (ctx, I... ) = Tuple (__index_Group_Cartesian (ctx, I... ))
0 commit comments