public void GroupedIndex3EntryPoint(int length) { var end = (int)Math.Pow(Accelerator.MaxNumThreadsPerGroup, 1.0 / 3.0); for (int i = 1; i <= end; i <<= 1) { var stride = new Index3(i, i, i); var extent = new GroupedIndex3( new Index3(length, length, length), stride); using var buffer = Accelerator.Allocate <int>(extent.Size); buffer.MemSetToZero(Accelerator.DefaultStream); Execute(extent, buffer.View, stride, extent.GridIdx); var expected = new int[extent.Size]; for (int j = 0; j < length * length * length; ++j) { var gridIdx = Index3.ReconstructIndex(j, extent.GridIdx); for (int k = 0; k < i * i * i; ++k) { var groupIdx = Index3.ReconstructIndex(k, extent.GroupIdx); var idx = (gridIdx * stride + groupIdx).ComputeLinearIndex(extent.GridIdx); expected[idx] = idx; } } Verify(buffer, expected); } }
public void GridDimension(int xMask, int yMask, int zMask) { for (int i = 2; i <= Accelerator.MaxNumThreadsPerGroup; i <<= 1) { using (var buffer = Accelerator.Allocate <int>(3)) { var extent = new GroupedIndex3( new Index3( Math.Max(i * xMask, 1), Math.Max(i * yMask, 1), Math.Max(i * zMask, 1)), Index3.One); Execute(extent, buffer.View); var expected = new int[] { extent.GridIdx.X, extent.GridIdx.Y, extent.GridIdx.Z, }; Verify(buffer, expected); } } }
public void GroupDimension2D(int xMask, int yMask, int zMask) { var end = (int)Math.Sqrt(Accelerator.MaxNumThreadsPerGroup); for (int i = 2; i <= end; i <<= 1) { using (var buffer = Accelerator.Allocate <int>(3)) { var extent = new GroupedIndex3( new Index3(1, 1, 1), new Index3( Math.Max(i * xMask, 1), Math.Max(i * yMask, 1), Math.Max(i * zMask, 1))); Execute(extent, buffer.View); var expected = new int[] { extent.GroupIdx.X, extent.GroupIdx.Y, extent.GroupIdx.Z, }; Verify(buffer, expected); } } }
internal static void GridDimensionKernel( GroupedIndex3 index, ArrayView <int> data) { data[0] = Grid.DimensionX; data[1] = Grid.DimensionY; data[2] = Grid.DimensionZ; }
internal static void GroupedIndex3EntryPointKernel( GroupedIndex3 index, ArrayView <int> output, Index3 stride, Index3 extent) { var idx1 = index.GridIdx.X * stride.X + index.GroupIdx.X; var idx2 = index.GridIdx.Y * stride.Y + index.GroupIdx.Y; var idx3 = index.GridIdx.Z * stride.Z + index.GroupIdx.Z; var idx = ((idx3 * extent.Y) + idx2) * extent.X + idx1; output[idx] = idx; }
internal static void GridDimensionKernel( GroupedIndex3 index, ArrayView <int> data) { data[0] = Grid.DimensionX; data[1] = Grid.DimensionY; data[2] = Grid.DimensionZ; Debug.Assert(Grid.IndexX < Grid.DimensionX); Debug.Assert(Grid.IndexY < Grid.DimensionY); Debug.Assert(Grid.IndexZ < Grid.DimensionZ); Debug.Assert(index.GridIdx.X == Grid.IndexX); Debug.Assert(index.GridIdx.Y == Grid.IndexY); Debug.Assert(index.GridIdx.Z == Grid.IndexZ); Debug.Assert(index.GroupIdx.X == Group.IndexX); Debug.Assert(index.GroupIdx.Y == Group.IndexY); Debug.Assert(index.GroupIdx.Z == Group.IndexZ); }
public void GroupDimension3D() { var end = (int)Math.Pow(Accelerator.MaxNumThreadsPerGroup, 1.0 / 3.0); for (int i = 1; i <= end; i <<= 1) { using var buffer = Accelerator.Allocate <int>(3); var extent = new GroupedIndex3( new Index3(1, 1, 1), new Index3(i, i, i)); Execute(extent, buffer.View); var expected = new int[] { extent.GroupIdx.X, extent.GroupIdx.Y, extent.GroupIdx.Z, }; Verify(buffer, expected); } }
/// <summary> /// Computes the global index of a grouped index (gridIdx, groupIdx). /// </summary> /// <param name="index">The grouped index.</param> /// <returns>The computes global index.</returns> public static Index3 ComputeGlobalIndex(GroupedIndex3 index) { return(ComputeGlobalIndex(index.GridIdx, index.GroupIdx)); }