Ejemplo n.º 1
0
        /// <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 = CL10.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 });

            //Console.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new <see cref="OpenCLProgram"/> from an array of source code strings.
        /// </summary>
        /// <param name="context"> A <see cref="OpenCLContext"/>. </param>
        /// <param name="source"> The source code lines for the <see cref="OpenCLProgram"/>. </param>
        /// <remarks> The created <see cref="OpenCLProgram"/> is associated with the <see cref="OpenCLContext.Devices"/>. </remarks>
        public OpenCLProgram(OpenCLContext context, string[] source)
        {
            OpenCLErrorCode error = OpenCLErrorCode.Success;

            Handle = CL10.CreateProgramWithSource(
                context.Handle,
                source.Length,
                source,
                null,
                out error);
            OpenCLException.ThrowOnError(error);

            this.context = context;
            this.devices = context.Devices;
            this.source  = new ReadOnlyCollection <string>(source);

            //Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }