@@ -188,6 +188,10 @@ function unsafe_free! end
188188
189189unsafe_free! (:: AbstractArray ) = return
190190
191+ include (" intrinsics.jl" )
192+ import . KernelIntrinsics
193+ export KernelIntrinsics
194+
191195# ##
192196# Kernel language
193197# - @localmem
@@ -454,13 +458,27 @@ end
454458# Internal kernel functions
455459# ##
456460
457- function __index_Local_Linear end
458- function __index_Group_Linear end
459- function __index_Global_Linear end
461+ function __index_Local_Linear (ctx)
462+ return KernelIntrinsics . get_local_id () . x
463+ end
460464
461- function __index_Local_Cartesian end
462- function __index_Group_Cartesian end
463- function __index_Global_Cartesian end
465+ function __index_Group_Linear (ctx)
466+ return KernelIntrinsics. get_group_id (). x
467+ end
468+
469+ function __index_Global_Linear (ctx)
470+ return KernelIntrinsics. get_global_id (). x
471+ end
472+
473+ function __index_Local_Cartesian (ctx)
474+ return @inbounds workitems (__iterspace (ctx))[KernelIntrinsics. get_local_id (). x]
475+ end
476+ function __index_Group_Cartesian (ctx)
477+ return @inbounds blocks (__iterspace (ctx))[KernelIntrinsics. get_group_id (). x]
478+ end
479+ function __index_Global_Cartesian (ctx)
480+ return @inbounds expand (__iterspace (ctx), KernelIntrinsics. get_group_id (). x, KernelIntrinsics. get_local_id (). x)
481+ end
464482
465483@inline __index_Local_NTuple (ctx, I... ) = Tuple (__index_Local_Cartesian (ctx, I... ))
466484@inline __index_Group_NTuple (ctx, I... ) = Tuple (__index_Group_Cartesian (ctx, I... ))
0 commit comments