private readonly ref TRandomProvider GetRandomProvider() { // Compute the global warp index int groupIndex = Group.LinearIndex; int warpIndex = Warp.ComputeWarpIdx(groupIndex); int groupStride = XMath.DivRoundUp(Group.Dimension.Size, Warp.WarpSize); int groupOffset = Grid.LinearIndex * groupStride; int providerIndex = groupOffset + warpIndex; // Access the underlying provider Trace.Assert( providerIndex < randomProviders.Length, "Current warp does not have a valid RNG provider"); return(ref randomProviders[providerIndex]); }