Exemplo n.º 1
0
        internal static void WarpBarrierKernel(ArrayView <int> data)
        {
            var idx = Grid.GlobalIndex.X;

            Warp.Barrier();
            data[idx] = idx;
        }
Exemplo n.º 2
0
        internal static void WarpBarrierKernel(ArrayView1D <int, Stride1D.Dense> data)
        {
            var idx = Grid.GlobalIndex.X;

            Warp.Barrier();
            data[idx] = idx;
        }
Exemplo n.º 3
0
        internal static void WarpBarrierKernel(
            GroupedIndex index,
            ArrayView <int> data)
        {
            var idx = index.GridIdx * Group.DimensionX + index.GroupIdx;

            Warp.Barrier();
            data[idx] = idx;
        }
Exemplo n.º 4
0
        internal static void DivergentWarpBarrierKernel(
            ArrayView1D <int, Stride1D.Dense> data)
        {
            // Divergent warp execution involving barriers
            var sharedMemory = ILGPU.SharedMemory.Allocate <int>(4);

            switch (Warp.WarpIdx)
            {
            case 0:
                sharedMemory[0] = 0;
                Warp.Barrier();
                break;

            case 1:
                sharedMemory[1] = 1;
                Warp.Barrier();
                break;

            case 2:
                sharedMemory[2] = 2;
                Warp.Barrier();
                break;

            case 3:
                sharedMemory[3] = 3;
                Warp.Barrier();
                break;
            }

            // Warp wide barrier
            int value = Warp.LaneIdx;

            Warp.Barrier();

            // Read shared memory
            int index = Grid.GlobalIndex.X;

            data[index] = sharedMemory[Warp.WarpIdx] * Warp.WarpSize + value;
        }
Exemplo n.º 5
0
 /// <summary>
 /// Performs a warp-wide barrier.
 /// </summary>
 public readonly void Barrier() => Warp.Barrier();