@@ -189,6 +189,10 @@ function unsafe_free! end
189189
190190unsafe_free! (:: AbstractArray ) = return
191191
192+ include (" intrinsics.jl" )
193+ import . KernelIntrinsics
194+ export KernelIntrinsics
195+
192196# ##
193197# Kernel language
194198# - @localmem
@@ -447,13 +451,27 @@ end
447451# Internal kernel functions
448452# ##
449453
450- function __index_Local_Linear end
451- function __index_Group_Linear end
452- function __index_Global_Linear end
454+ function __index_Local_Linear (ctx)
455+ return KernelIntrinsics . get_local_id () . x
456+ end
453457
454- function __index_Local_Cartesian end
455- function __index_Group_Cartesian end
456- function __index_Global_Cartesian end
458+ function __index_Group_Linear (ctx)
459+ return KernelIntrinsics. get_group_id (). x
460+ end
461+
462+ function __index_Global_Linear (ctx)
463+ return KernelIntrinsics. get_global_id (). x
464+ end
465+
466+ function __index_Local_Cartesian (ctx)
467+ return @inbounds workitems (__iterspace (ctx))[KernelIntrinsics. get_local_id (). x]
468+ end
469+ function __index_Group_Cartesian (ctx)
470+ return @inbounds blocks (__iterspace (ctx))[KernelIntrinsics. get_group_id (). x]
471+ end
472+ function __index_Global_Cartesian (ctx)
473+ return @inbounds expand (__iterspace (ctx), KernelIntrinsics. get_group_id (). x, KernelIntrinsics. get_local_id (). x)
474+ end
457475
458476@inline __index_Local_NTuple (ctx, I... ) = Tuple (__index_Local_Cartesian (ctx, I... ))
459477@inline __index_Group_NTuple (ctx, I... ) = Tuple (__index_Group_Cartesian (ctx, I... ))
0 commit comments