コード例 #1
0
        /// <summary>
        /// Creates a new instance of an atomic reduction handler using the provided
        /// shuffle-down and reduction logics.
        /// </summary>
        /// <typeparam name="T">The underlying type of the reduction.</typeparam>
        /// <typeparam name="TShuffleDown">The type of the shuffle logic.</typeparam>
        /// <typeparam name="TReduction">The type of the reduction logic.</typeparam>
        /// <param name="accelerator">The accelerator.</param>
        /// <param name="shuffleDown">The shuffle logic.</param>
        /// <param name="reduction">The reduction logic.</param>
        /// <returns>The created reduction handler.</returns>
        public static AtomicReduction <T> CreateAtomicReduction <T, TShuffleDown, TReduction>(
            this Accelerator accelerator,
            TShuffleDown shuffleDown,
            TReduction reduction)
            where T : struct
            where TShuffleDown : struct, IShuffleDown <T>
            where TReduction : struct, IAtomicReduction <T>
        {
            var reductionDel = accelerator.CreateAtomicReduction <T, TShuffleDown, TReduction>();

            return((stream, input, output) =>
            {
                reductionDel(stream, input, output, shuffleDown, reduction);
            });
        }
コード例 #2
0
 /// <summary>
 /// Performs a reduction using an atomic reduction logic.
 /// </summary>
 /// <typeparam name="T">The underlying type of the reduction.</typeparam>
 /// <typeparam name="TShuffleDown">The type of the shuffle logic.</typeparam>
 /// <typeparam name="TReduction">The type of the reduction logic.</typeparam>
 /// <param name="accelerator">The accelerator.</param>
 /// <param name="stream">The accelerator stream.</param>
 /// <param name="input">The input elements to reduce.</param>
 /// <param name="output">The output view to store the reduced value.</param>
 /// <param name="shuffleDown">The shuffle logic.</param>
 /// <param name="reduction">The reduction logic.</param>
 public static void AtomicReduce <T, TShuffleDown, TReduction>(
     this Accelerator accelerator,
     AcceleratorStream stream,
     ArrayView <T> input,
     ArrayView <T> output,
     TShuffleDown shuffleDown,
     TReduction reduction)
     where T : struct
     where TShuffleDown : struct, IShuffleDown <T>
     where TReduction : struct, IAtomicReduction <T>
 {
     accelerator.CreateAtomicReduction <T, TShuffleDown, TReduction>()(
         stream,
         input,
         output,
         shuffleDown,
         reduction);
 }