/// <summary> /// Loads the given OpenCL kernel. /// </summary> /// <param name="accelerator">The associated accelerator.</param> /// <param name="name">The name of the entry-point function.</param> /// <param name="source">The OpenCL source code.</param> /// <param name="version">The OpenCL C version.</param> /// <param name="programPtr">The created program pointer.</param> /// <param name="kernelPtr">The created kernel pointer.</param> /// <param name="errorLog">The error log (if any).</param> /// <returns> /// True, if the program and the kernel could be loaded successfully. /// </returns> public static CLError LoadKernel( CLAccelerator accelerator, string name, string source, CLCVersion version, out IntPtr programPtr, out IntPtr kernelPtr, out string errorLog) { errorLog = null; kernelPtr = IntPtr.Zero; var programError = CurrentAPI.CreateProgram( accelerator.NativePtr, source, out programPtr); if (programError != CLError.CL_SUCCESS) { return(programError); } // Specify the OpenCL C version. string options = "-cl-std=" + version.ToString(); var buildError = CurrentAPI.BuildProgram( programPtr, accelerator.DeviceId, options); if (buildError != CLError.CL_SUCCESS) { CLException.ThrowIfFailed( CurrentAPI.GetProgramBuildLog( programPtr, accelerator.DeviceId, out errorLog)); CLException.ThrowIfFailed( CurrentAPI.ReleaseProgram(programPtr)); programPtr = IntPtr.Zero; return(buildError); } return(CurrentAPI.CreateKernel( programPtr, name, out kernelPtr)); }