Beispiel #1
0
        /// <summary>
        /// An explicitly grouped kernel that uses high-level group extensions.
        /// Use the available scan/reduce operations in the namespace ILGPU.Algorithms.ScanReduceOperations.
        /// </summary>
        static void KernelWithGroupExtensions(ArrayView2D <int, Stride2D.DenseX> data)
        {
            var globalIndex = Grid.GlobalIndex.X;

            // Use the all-reduce algorithm to perform a reduction over all lanes in a warp.
            // Every lane in the warp will receive the resulting value.
            // Use WarpExtensions.Reduce for faster performance, if you need to have the result
            // in the first lane only.
            data[globalIndex, 0] = GroupExtensions.AllReduce <int, AddInt32>(1);

            // Perform an exclusive scan over all lanes in the whole warp.
            data[globalIndex, 1] = GroupExtensions.ExclusiveScan <int, AddInt32>(1);

            // Perform an inclusive scan over all lanes in the whole warp.
            data[globalIndex, 2] = GroupExtensions.InclusiveScan <int, AddInt32>(1);

            // Perform a all reduction using a different reduction logic.
            data[globalIndex, 3] = GroupExtensions.AllReduce <int, MinInt32>(Group.IdxX + 1);
        }