//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Creates a new <see cref="ComputeProgram"/> from an array of source code strings. /// </summary> /// /// <remarks> /// The created <see cref="ComputeProgram"/> is associated with the /// <see cref="ComputeContext.Devices"/>. /// </remarks> /// /// <param name="context"> A <see cref="ComputeContext"/>. </param> /// <param name="source"> The source code lines for the <see cref="ComputeProgram"/>. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// public ComputeProgram(ComputeContext context, string[] source) { Ensure.Argument(context).NotNull("context is null"); Handle = CL12.CreateProgramWithSource(context.Handle, source.Length, source, null, out var error); ComputeException.ThrowOnError(error); this.context = context; devices = context.Devices; this.source = new ReadOnlyCollection <string>(source); RILogManager.Default?.SendTrace("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information"); }
/// <summary> /// Creates a new <see cref="ComputeProgram"/> from a source code string. /// </summary> /// <param name="context"> A <see cref="ComputeContext"/>. </param> /// <param name="source"> The source code for the <see cref="ComputeProgram"/>. </param> /// <remarks> The created <see cref="ComputeProgram"/> is associated with the <see cref="ComputeContext.Devices"/>. </remarks> public ComputeProgram(ComputeContext context, string source) { ComputeErrorCode error = ComputeErrorCode.Success; Handle = CL12.CreateProgramWithSource(context.Handle, 1, new string[] { source }, null, out error); ComputeException.ThrowOnError(error); SetID(Handle.Value); this.context = context; this.devices = context.Devices; this.source = new ReadOnlyCollection <string>(new string[] { source }); Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information"); }