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