Exemple #1
0
        internal static void WarpShuffleKernel(
            Index1 index,
            ArrayView <int> data)
        {
            var targetIdx = Warp.WarpSize - 1;

            data[index] = Warp.Shuffle(Warp.LaneIdx, targetIdx);
        }
Exemple #2
0
        internal static void WarpShuffleKernel(
            Index1D index,
            ArrayView1D <int, Stride1D.Dense> data)
        {
            var targetIdx = Warp.WarpSize - 1;

            data[index] = Warp.Shuffle(Warp.LaneIdx, targetIdx);
        }
Exemple #3
0
        /// <summary>
        /// A kernel demonstrating the generic ILGPU shuffle functionality: The compiler
        /// automatically generates the required shuffle instructions (even for complex
        /// user-defined data types).
        /// </summary>
        /// <param name="index">The current thread index.</param>
        /// <param name="dataView">The view pointing to our memory buffer.</param>
        /// <param name="value">The value to shuffle.</param>
        static void ShuffleGeneric <T>(
            ArrayView <T> dataView,           // A view to a chunk of memory (1D in this case)
            T value)                          // A constant value
            where T : unmanaged
        {
            // Use intrinsic shuffle functionality to shuffle the
            // given value from line 0. This does not make much sense in this
            // case since all values will have the same value. However,
            // this demonstrates the generic flexibility of the shuffle instructions.
            value = Warp.Shuffle(value, 0);

            dataView[Grid.GlobalIndex.X] = value;
        }