@@ -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
@@ -450,13 +454,27 @@ end
450454#  Internal kernel functions
451455# ##
452456
453- function  __index_Local_Linear  end 
454- function  __index_Group_Linear  end 
455- function  __index_Global_Linear  end 
457+ function  __index_Local_Linear (ctx) 
458+      return  KernelIntrinsics . get_local_id () . x 
459+ end 
456460
457- function  __index_Local_Cartesian end 
458- function  __index_Group_Cartesian end 
459- function  __index_Global_Cartesian end 
461+ function  __index_Group_Linear (ctx)
462+     return  KernelIntrinsics. get_group_id (). x
463+ end 
464+ 
465+ function  __index_Global_Linear (ctx)
466+     return  KernelIntrinsics. get_global_id (). x
467+ end 
468+ 
469+ function  __index_Local_Cartesian (ctx)
470+     return  @inbounds  workitems (__iterspace (ctx))[KernelIntrinsics. get_local_id (). x]
471+ end 
472+ function  __index_Group_Cartesian (ctx)
473+     return  @inbounds  blocks (__iterspace (ctx))[KernelIntrinsics. get_group_id (). x]
474+ end 
475+ function  __index_Global_Cartesian (ctx)
476+     return  @inbounds  expand (__iterspace (ctx), KernelIntrinsics. get_group_id (). x, KernelIntrinsics. get_local_id (). x)
477+ end 
460478
461479@inline  __index_Local_NTuple (ctx, I... ) =  Tuple (__index_Local_Cartesian (ctx, I... ))
462480@inline  __index_Group_NTuple (ctx, I... ) =  Tuple (__index_Group_Cartesian (ctx, I... ))
0 commit comments