Ejemplo n.º 1
0
        public static unsafe CLError LaunchKernelWithStreamBinding(
            CLStream stream,
            CLKernel kernel,
            int gridDimX,
            int gridDimY,
            int gridDimZ,
            int blockDimX,
            int blockDimY,
            int blockDimZ)
        {
            var binding = stream.BindScoped();

            IntPtr *globalWorkSizes = stackalloc IntPtr[3];

            globalWorkSizes[0] = new IntPtr(gridDimX);
            globalWorkSizes[1] = new IntPtr(gridDimY);
            globalWorkSizes[2] = new IntPtr(gridDimZ);

            IntPtr *localWorkSizes = stackalloc IntPtr[3];

            localWorkSizes[0] = new IntPtr(blockDimX);
            localWorkSizes[1] = new IntPtr(blockDimY);
            localWorkSizes[2] = new IntPtr(blockDimZ);

            var result = LaunchKernelUnsafe(
                stream.CommandQueue,
                kernel.KernelPtr,
                3,
                null,
                globalWorkSizes,
                localWorkSizes);

            binding.Recover();
            return(result);
        }
Ejemplo n.º 2
0
        internal static unsafe CLError LaunchKernelWithStreamBinding(
            CLStream stream,
            CLKernel kernel,
            RuntimeKernelConfig config)
        {
            var binding = stream.BindScoped();

            var gridDim  = config.GridDim;
            var blockDim = config.GroupDim;

            IntPtr *globalWorkSizes = stackalloc IntPtr[3];

            globalWorkSizes[0] = new IntPtr(gridDim.X * blockDim.X);
            globalWorkSizes[1] = new IntPtr(gridDim.Y * blockDim.Y);
            globalWorkSizes[2] = new IntPtr(gridDim.Z * blockDim.Z);

            IntPtr *localWorkSizes = stackalloc IntPtr[3];

            localWorkSizes[0] = new IntPtr(blockDim.X);
            localWorkSizes[1] = new IntPtr(blockDim.Y);
            localWorkSizes[2] = new IntPtr(blockDim.Z);

            var result = LaunchKernelUnsafe(
                stream.CommandQueue,
                kernel.KernelPtr,
                3,
                null,
                globalWorkSizes,
                localWorkSizes);

            binding.Recover();
            return(result);
        }
Ejemplo n.º 3
0
 public readonly CLError PreLaunchKernel(
     CLStream stream,
     CLKernel kernel,
     RuntimeKernelConfig config) =>
 SetKernelArgumentUnsafeWithKernel(
     kernel,
     0,
     config.SharedMemoryConfig.DynamicArraySize,
     null);
Ejemplo n.º 4
0
 public readonly CLError PreLaunchKernel(
     CLStream stream,
     CLKernel kernel,
     RuntimeKernelConfig config) =>
 CLError.CL_SUCCESS;