internal OpenCLKernel(CLKernelHandle handle, OpenCLProgram program) { Handle = handle; SetID(Handle.Value); context = program.Context; functionName = GetStringInfo <CLKernelHandle, OpenCLKernelInfo>(Handle, OpenCLKernelInfo.FunctionName, CL10.GetKernelInfo); this.program = program; //Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information"); }
internal OpenCLKernel(string functionName, OpenCLProgram program) { OpenCLErrorCode error = OpenCLErrorCode.Success; Handle = CL10.CreateKernel(program.Handle, functionName, out error); OpenCLException.ThrowOnError(error); SetID(Handle.Value); context = program.Context; this.functionName = functionName; this.program = program; //Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information"); }
private static OpenCLProgram LoadProgram(OpenCLContext context, OpenCLDevice device, string resourceName) { var source = GetProgramSourceFromResource(Assembly.GetExecutingAssembly(), resourceName); var program = new OpenCLProgram(context, source); try { program.Build(new List<OpenCLDevice> {device}, string.Empty, null, IntPtr.Zero); } catch (BuildProgramFailureOpenCLException) { var buildLog = program.GetBuildLog(device); throw new ApplicationException($"Error building program \"{resourceName}\":{Environment.NewLine}{buildLog}"); } return program; }