Exemplo n.º 1
0
        internal static void WarpShuffleXorKernel(
            Index1 index,
            ArrayView <int> data)
        {
            var value = Warp.LaneIdx;

            for (int laneMask = Warp.WarpSize / 2; laneMask > 0; laneMask >>= 1)
            {
                var shuffled = Warp.ShuffleXor(value, laneMask);
                value += shuffled;
            }
            data[index] = value;
        }
Exemplo n.º 2
0
        public static T AllReduce <T, TReduction>(T value)
            where T : unmanaged
            where TReduction : IScanReduceOperation <T>
        {
            TReduction reduction = default;

            for (int laneMask = Warp.WarpSize / 2; laneMask > 0; laneMask >>= 1)
            {
                var shuffled = Warp.ShuffleXor(value, laneMask);
                value = reduction.Apply(value, shuffled);
            }
            return(value);
        }