Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new <see cref="OpenCLCommandQueue"/>.
        /// </summary>
        /// <param name="context"> A <see cref="OpenCLContext"/>. </param>
        /// <param name="device"> A <see cref="OpenCLDevice"/> associated with the <paramref name="context"/>. It can either be one of <see cref="OpenCLContext.Devices"/> or have the same <see cref="OpenCLDeviceTypes"/> as the <paramref name="device"/> specified when the <paramref name="context"/> is created. </param>
        /// <param name="properties"> The properties for the <see cref="OpenCLCommandQueue"/>. </param>
        public OpenCLCommandQueue(OpenCLContext context, OpenCLDevice device, OpenCLCommandQueueProperties properties)
        {
            OpenCLErrorCode error = OpenCLErrorCode.Success;

            Handle = CL10.CreateCommandQueue(context.Handle, device.Handle, properties, out error);
            OpenCLException.ThrowOnError(error);

            SetID(Handle.Value);

            this.device  = device;
            this.context = context;

            outOfOrderExec = ((properties & OpenCLCommandQueueProperties.OutOfOrderExecution) == OpenCLCommandQueueProperties.OutOfOrderExecution);
            profiling      = ((properties & OpenCLCommandQueueProperties.Profiling) == OpenCLCommandQueueProperties.Profiling);

            Events = new List <OpenCLEventBase>();

            //Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a read-only collection of available <see cref="OpenCLDevice"/>s on the <see cref="OpenCLPlatform"/>.
        /// </summary>
        /// <returns> A read-only collection of the available <see cref="OpenCLDevice"/>s on the <see cref="OpenCLPlatform"/>. </returns>
        /// <remarks> This method resets the <c>OpenCLPlatform.Devices</c>. This is useful if one or more of them become unavailable (<c>OpenCLDevice.Available</c> is <c>false</c>) after a <see cref="OpenCLContext"/> and <see cref="OpenCLCommandQueue"/>s that use the <see cref="OpenCLDevice"/> have been created and commands have been queued to them. Further calls will trigger an <c>OutOfResourcesOpenCLException</c> until this method is executed. You will also need to recreate any <see cref="OpenCLResource"/> that was created on the no longer available <see cref="OpenCLDevice"/>. </remarks>
        public ReadOnlyCollection <OpenCLDevice> QueryDevices()
        {
            int             handlesLength = 0;
            OpenCLErrorCode error         = CL10.GetDeviceIDs(Handle, OpenCLDeviceType.All, 0, null, out handlesLength);

            OpenCLException.ThrowOnError(error);

            CLDeviceHandle[] handles = new CLDeviceHandle[handlesLength];
            error = CL10.GetDeviceIDs(Handle, OpenCLDeviceType.All, handlesLength, handles, out handlesLength);
            OpenCLException.ThrowOnError(error);

            OpenCLDevice[] devices = new OpenCLDevice[handlesLength];
            for (int i = 0; i < handlesLength; i++)
            {
                devices[i] = new OpenCLDevice(this, handles[i]);
            }

            this.devices = new ReadOnlyCollection <OpenCLDevice>(devices);

            return(this.devices);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the maximum work-group size that can be used to execute the <see cref="OpenCLKernel"/> on a <see cref="OpenCLDevice"/>.
 /// </summary>
 /// <param name="device"> One of the <see cref="OpenCLKernel.Program.Device"/>s. </param>
 /// <returns> The maximum work-group size that can be used to execute the <see cref="OpenCLKernel"/> on <paramref name="device"/>. </returns>
 public long GetWorkGroupSize(OpenCLDevice device)
 {
     return((long)GetInfo <CLKernelHandle, CLDeviceHandle, OpenCLKernelWorkGroupInfo, IntPtr>(
                Handle, device.Handle, OpenCLKernelWorkGroupInfo.WorkGroupSize, CL10.GetKernelWorkGroupInfo));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets the minimum amount of memory, in bytes, used by each work-item in the kernel.
 /// </summary>
 /// <param name="device"> One of the <see cref="OpenCLKernel.Program.Device"/>s. </param>
 /// <returns> The minimum amount of memory, in bytes, used by each work-item in the kernel. </returns>
 /// <remarks> The returned value may include any private memory needed by an implementation to execute the kernel, including that used by the language built-ins and variable declared inside the kernel with the <c>__private</c> or <c>private</c> qualifier. </remarks>
 public long GetPrivateMemorySize(OpenCLDevice device)
 {
     return(GetInfo <CLKernelHandle, CLDeviceHandle, OpenCLKernelWorkGroupInfo, long>(
                Handle, device.Handle, OpenCLKernelWorkGroupInfo.PrivateMemorySize, CL10.GetKernelWorkGroupInfo));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Gets the preferred multiple of workgroup size for launch.
 /// </summary>
 /// <param name="device"> One of the <see cref="OpenCLKernel.Program.Device"/>s. </param>
 /// <returns> The preferred multiple of workgroup size for launch. </returns>
 /// <remarks> The returned value is a performance hint. Specifying a workgroup size that is not a multiple of the value returned by this query as the value of the local work size argument to OpenCLCommandQueue.Execute will not fail to enqueue the kernel for execution unless the work-group size specified is larger than the device maximum. </remarks>
 /// <remarks> Requires OpenCL 1.1. </remarks>
 public long GetPreferredWorkGroupSizeMultiple(OpenCLDevice device)
 {
     return((long)GetInfo <CLKernelHandle, CLDeviceHandle, OpenCLKernelWorkGroupInfo, IntPtr>(
                Handle, device.Handle, OpenCLKernelWorkGroupInfo.PreferredWorkGroupSizeMultiple, CL10.GetKernelWorkGroupInfo));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Gets the compile work-group size specified by the <c>__attribute__((reqd_work_group_size(X, Y, Z)))</c> qualifier.
 /// </summary>
 /// <param name="device"> One of the <see cref="OpenCLKernel.Program.Device"/>s. </param>
 /// <returns> The compile work-group size specified by the <c>__attribute__((reqd_work_group_size(X, Y, Z)))</c> qualifier. If no such qualifier is specified, (0, 0, 0) is returned. </returns>
 public long[] GetCompileWorkGroupSize(OpenCLDevice device)
 {
     return(OpenCLTools.ConvertArray(
                GetArrayInfo <CLKernelHandle, CLDeviceHandle, OpenCLKernelWorkGroupInfo, IntPtr>(
                    Handle, device.Handle, OpenCLKernelWorkGroupInfo.CompileWorkGroupSize, CL10.GetKernelWorkGroupInfo)));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Gets the <see cref="OpenCLProgramBuildStatus"/> of the <see cref="OpenCLProgram"/> for a specified <see cref="OpenCLDevice"/>.
 /// </summary>
 /// <param name="device"> The <see cref="OpenCLDevice"/> building the <see cref="OpenCLProgram"/>. Must be one of <see cref="OpenCLProgram.Devices"/>. </param>
 /// <returns> The <see cref="OpenCLProgramBuildStatus"/> of the <see cref="OpenCLProgram"/> for <paramref name="device"/>. </returns>
 public OpenCLProgramBuildStatus GetBuildStatus(OpenCLDevice device)
 {
     return((OpenCLProgramBuildStatus)GetInfo <CLProgramHandle, CLDeviceHandle, OpenCLProgramBuildInfo, uint>(Handle, device.Handle, OpenCLProgramBuildInfo.Status, CL10.GetProgramBuildInfo));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Gets the build log of the <see cref="OpenCLProgram"/> for a specified <see cref="OpenCLDevice"/>.
 /// </summary>
 /// <param name="device"> The <see cref="OpenCLDevice"/> building the <see cref="OpenCLProgram"/>. Must be one of <see cref="OpenCLProgram.Devices"/>. </param>
 /// <returns> The build log of the <see cref="OpenCLProgram"/> for <paramref name="device"/>. </returns>
 public string GetBuildLog(OpenCLDevice device)
 {
     return(GetStringInfo <CLProgramHandle, CLDeviceHandle, OpenCLProgramBuildInfo>(Handle, device.Handle, OpenCLProgramBuildInfo.BuildLog, CL10.GetProgramBuildInfo));
 }