示例#1
0
        /// <summary>
        /// Executes an implicitly linked kernel with the given arguments.
        /// </summary>
        /// <typeparam name="TIndex">The index type.</typeparam>
        /// <param name="dimension">The dimension.</param>
        /// <param name="arguments">The arguments.</param>
        public void Execute <TIndex, T1, T2>(TIndex dimension, params object[] arguments)
            where TIndex : struct, IIndex
            where T1 : unmanaged
            where T2 : unmanaged
        {
            var kernelMethod = KernelMethodAttribute.GetKernelMethod(new Type[]
            {
                typeof(T1),
                typeof(T2)
            });

            Execute(kernelMethod, dimension, arguments);
        }
示例#2
0
        public void SpecializedExplicitKernel <T>(T value)
            where T : unmanaged, IEquatable <T>
        {
            var method = KernelMethodAttribute.GetKernelMethod(
                new Type[] { typeof(T) });
            var kernel = Accelerator.LoadKernel(
                new Action <ArrayView1D <T, Stride1D.Dense>, SpecializedValue <T> >(
                    SpecializedExplicitValueKernel));

            using var buffer = Accelerator.Allocate1D <T>(1);
            kernel(
                Accelerator.DefaultStream,
                (1, 1),
                buffer.View,
                new SpecializedValue <T>(value));
            Accelerator.Synchronize();

            var expected = new T[] { value };

            Verify(buffer.View, expected);
        }