@@ -194,6 +194,10 @@ function unsafe_free! end
194194
195195unsafe_free! (:: AbstractArray ) =  return 
196196
197+ include (" intrinsics.jl"  )
198+ import  . KernelIntrinsics
199+ export  KernelIntrinsics
200+ 
197201# ##
198202#  Kernel language
199203#  - @localmem
@@ -460,13 +464,27 @@ end
460464#  Internal kernel functions
461465# ##
462466
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 
466470
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 
470488
471489@inline  __index_Local_NTuple (ctx, I... ) =  Tuple (__index_Local_Cartesian (ctx, I... ))
472490@inline  __index_Group_NTuple (ctx, I... ) =  Tuple (__index_Group_Cartesian (ctx, I... ))
0 commit comments