@@ -192,6 +192,10 @@ function unsafe_free! end
192192
193193unsafe_free! (:: AbstractArray ) = return
194194
195+ include (" intrinsics.jl" )
196+ import . KernelIntrinsics
197+ export KernelIntrinsics
198+
195199# ##
196200# Kernel language
197201# - @localmem
@@ -458,13 +462,27 @@ end
458462# Internal kernel functions
459463# ##
460464
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
464468
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
468486
469487@inline __index_Local_NTuple (ctx, I... ) = Tuple (__index_Local_Cartesian (ctx, I... ))
470488@inline __index_Group_NTuple (ctx, I... ) = Tuple (__index_Group_Cartesian (ctx, I... ))
0 commit comments