Exemplo n.º 1
0
        public static void FloatKernel(GpuArrayWrite <float> output, d3 gridDim,
                                       d3 blockDim, d3 blockId, d3 threadId)
        {
            var index       = blockId.d3Dex(gridDim) * blockDim.Volume() + threadId.d3Dex(blockDim);
            var totalVolume = blockDim.Volume() * gridDim.Volume();

            output.AddGpuData(
                val: (2 * index - totalVolume) / (float)totalVolume,
                index: index, block: blockId, thread: threadId);
        }
Exemplo n.º 2
0
 public static void RunGpuKernel(d3 blocks, d3 threads, Action <d3, d3, d3, d3> kernel)
 {
     foreach (var blockId in blocks.Raster())
     {
         foreach (var threadId in threads.Raster())
         {
             kernel(blocks, threads, blockId, threadId);
         }
     }
 }
Exemplo n.º 3
0
Arquivo: d3.cs Projeto: tp-nscan/Mite
 public static IEnumerable <d3> Raster(this d3 bounds)
 {
     for (var iBx = 0; iBx < bounds.X; iBx++)
     {
         for (var iBy = 0; iBy < bounds.Y; iBy++)
         {
             for (var iBz = 0; iBz < bounds.Z; iBz++)
             {
                 yield return(new d3(x: iBx, y: iBy, z: iBz));
             }
         }
     }
 }
Exemplo n.º 4
0
 public void AddGpuData(T val, int index, d3 block, d3 thread)
 {
     _array[index].Add(new GpuData <T>(index: index, order: _array[index].Count(), val: val, block: block, thread: thread));
 }
Exemplo n.º 5
0
 public static int d3Dex(this d3 d3Id, d3 d3Dim)
 {
     return(d3Id.X + d3Id.Y * d3Dim.X + d3Id.Z * d3Dim.X * d3Dim.Y);
 }
Exemplo n.º 6
0
 public static Action <d3, d3, d3, d3> FloatKernelWrap(GpuArrayWrite <float> gpuArrayWrite,
                                                       d3 gridDim, d3 blockDim)
 {
     return((d3 gd, d3 bd, d3 blockId, d3 threadId) =>
            FloatKernel(gpuArrayWrite, gd, bd, blockId, threadId));
 }
Exemplo n.º 7
0
 public static void IntKernel(GpuArrayWrite <int> output, d3 gridDim,
                              d3 blockDim, d3 blockId, d3 threadId)
 {
     output.AddGpuData(1, blockId.X * blockDim.X + threadId.X, blockId, threadId);
 }
Exemplo n.º 8
0
Arquivo: d3.cs Projeto: tp-nscan/Mite
 public static int Volume(this d3 what)
 {
     return(what.X * what.Y * what.Z);
 }