Exemple #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Creates a <see cref="ComputeKernel"/> for every <c>kernel</c> function in
        /// <see cref="ComputeProgram"/>.
        /// </summary>
        ///
        /// <remarks>
        /// <see cref="ComputeKernel"/>s are not created for any <c>kernel</c> functions in
        /// <see cref="ComputeProgram"/> that do not have the same function definition across all
        /// <see cref="ComputeProgram.Devices"/> for which a program executable has been successfully
        /// built.
        /// </remarks>
        ///
        /// <returns>   The collection of created <see cref="ComputeKernel"/>s. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public ICollection <ComputeKernel> CreateAllKernels()
        {
            ICollection <ComputeKernel> kernels = new Collection <ComputeKernel>();

            CLKernelHandle[] kernelHandles;

            ComputeErrorCode error = CL12.CreateKernelsInProgram(Handle, 0, null, out var kernelsCount);

            ComputeException.ThrowOnError(error);

            kernelHandles = new CLKernelHandle[kernelsCount];
            error         = CL12.CreateKernelsInProgram(Handle, kernelsCount, kernelHandles, out kernelsCount);
            ComputeException.ThrowOnError(error);

            for (int i = 0; i < kernelsCount; i++)
            {
                kernels.Add(new ComputeKernel(kernelHandles[i], this));
            }

            return(kernels);
        }