コード例 #1
0
ファイル: CL10.cs プロジェクト: forki/FSCL.Runtime
 public extern static CLContextHandle CreateContext(
     [MarshalAs(UnmanagedType.LPArray)] IntPtr[] properties,
     Int32 num_devices,
     [MarshalAs(UnmanagedType.LPArray)] CLDeviceHandle[] devices,
     OpenCLContextNotifier pfn_notify,
     IntPtr user_data,
     out OpenCLErrorCode errcode_ret);
コード例 #2
0
        /// <summary>
        /// Creates a new <see cref="OpenCLContext"/> on all the <see cref="OpenCLDevice"/>s that match the specified <see cref="OpenCLDeviceTypes"/>.
        /// </summary>
        /// <param name="deviceType"> A bit-field that identifies the type of <see cref="OpenCLDevice"/> to associate with the <see cref="OpenCLContext"/>. </param>
        /// <param name="properties"> A <see cref="OpenCLContextPropertyList"/> of the <see cref="OpenCLContext"/>. </param>
        /// <param name="notify"> A delegate instance that refers to a notification routine. This routine is a callback function that will be used by the OpenCL implementation to report information on errors that occur in the <see cref="OpenCLContext"/>. The callback function may be called asynchronously by the OpenCL implementation. It is the application's responsibility to ensure that the callback function is thread-safe and that the delegate instance doesn't get collected by the Garbage Collector until <see cref="OpenCLContext"/> is disposed. If <paramref name="notify"/> is <c>null</c>, no callback function is registered. </param>
        /// <param name="userDataPtr"> Optional user data that will be passed to <paramref name="notify"/>. </param>
        public OpenCLContext(OpenCLDeviceType deviceType, OpenCLContextPropertyList properties, OpenCLContextNotifier notify, IntPtr userDataPtr)
        {
            IntPtr[] propertyArray = (properties != null) ? properties.ToIntPtrArray() : null;
            callback = notify;

            OpenCLErrorCode error = OpenCLErrorCode.Success;

            Handle = CL10.CreateContextFromType(propertyArray, deviceType, notify, userDataPtr, out error);
            OpenCLException.ThrowOnError(error);

            SetID(Handle.Value);

            this.properties = properties;
            OpenCLContextProperty platformProperty = properties.GetByName(OpenCLContextProperties.Platform);

            this.platform = OpenCLPlatform.GetByHandle(platformProperty.Value);
            this.devices  = GetDevices();

            //Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }
コード例 #3
0
        /// <summary>
        /// Creates a new <see cref="OpenCLContext"/> on a collection of <see cref="OpenCLDevice"/>s.
        /// </summary>
        /// <param name="devices"> A collection of <see cref="OpenCLDevice"/>s to associate with the <see cref="OpenCLContext"/>. </param>
        /// <param name="properties"> A <see cref="OpenCLContextPropertyList"/> of the <see cref="OpenCLContext"/>. </param>
        /// <param name="notify"> A delegate instance that refers to a notification routine. This routine is a callback function that will be used by the OpenCL implementation to report information on errors that occur in the <see cref="OpenCLContext"/>. The callback function may be called asynchronously by the OpenCL implementation. It is the application's responsibility to ensure that the callback function is thread-safe and that the delegate instance doesn't get collected by the Garbage Collector until <see cref="OpenCLContext"/> is disposed. If <paramref name="notify"/> is <c>null</c>, no callback function is registered. </param>
        /// <param name="notifyDataPtr"> Optional user data that will be passed to <paramref name="notify"/>. </param>
        public OpenCLContext(List <OpenCLDevice> devices, OpenCLContextPropertyList properties, OpenCLContextNotifier notify, IntPtr notifyDataPtr)
        {
            int handleCount;

            CLDeviceHandle[] deviceHandles = OpenCLTools.ExtractHandles(devices, out handleCount);
            IntPtr[]         propertyArray = (properties != null) ? properties.ToIntPtrArray() : null;
            callback = notify;

            OpenCLErrorCode error = OpenCLErrorCode.Success;

            Handle = CL10.CreateContext(propertyArray, handleCount, deviceHandles, notify, notifyDataPtr, out error);
            OpenCLException.ThrowOnError(error);

            SetID(Handle.Value);

            this.properties = properties;
            OpenCLContextProperty platformProperty = properties.GetByName(OpenCLContextProperties.Platform);

            this.platform = OpenCLPlatform.GetByHandle(platformProperty.Value);
            this.devices  = GetDevices();

            //Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }
コード例 #4
0
ファイル: CL10.cs プロジェクト: cloudRoutine/FSCL.Runtime
 public extern static CLContextHandle CreateContext(
     [MarshalAs(UnmanagedType.LPArray)] IntPtr[] properties,
     Int32 num_devices,
     [MarshalAs(UnmanagedType.LPArray)] CLDeviceHandle[] devices,
     OpenCLContextNotifier pfn_notify,
     IntPtr user_data,
     out OpenCLErrorCode errcode_ret);
コード例 #5
0
ファイル: CL10.cs プロジェクト: cloudRoutine/FSCL.Runtime
 public extern static CLContextHandle CreateContextFromType(
     [MarshalAs(UnmanagedType.LPArray)] IntPtr[] properties,
     OpenCLDeviceType device_type,
     OpenCLContextNotifier pfn_notify,
     IntPtr user_data,
     out OpenCLErrorCode errcode_ret);
コード例 #6
0
        /// <summary>
        /// Creates a new <see cref="OpenCLContext"/> on all the <see cref="OpenCLDevice"/>s that match the specified <see cref="OpenCLDeviceTypes"/>.
        /// </summary>
        /// <param name="deviceType"> A bit-field that identifies the type of <see cref="OpenCLDevice"/> to associate with the <see cref="OpenCLContext"/>. </param>
        /// <param name="properties"> A <see cref="OpenCLContextPropertyList"/> of the <see cref="OpenCLContext"/>. </param>
        /// <param name="notify"> A delegate instance that refers to a notification routine. This routine is a callback function that will be used by the OpenCL implementation to report information on errors that occur in the <see cref="OpenCLContext"/>. The callback function may be called asynchronously by the OpenCL implementation. It is the application's responsibility to ensure that the callback function is thread-safe and that the delegate instance doesn't get collected by the Garbage Collector until <see cref="OpenCLContext"/> is disposed. If <paramref name="notify"/> is <c>null</c>, no callback function is registered. </param>
        /// <param name="userDataPtr"> Optional user data that will be passed to <paramref name="notify"/>. </param>
        public OpenCLContext(OpenCLDeviceType deviceType, OpenCLContextPropertyList properties, OpenCLContextNotifier notify, IntPtr userDataPtr)
        {
            IntPtr[] propertyArray = (properties != null) ? properties.ToIntPtrArray() : null;
            callback = notify;

            OpenCLErrorCode error = OpenCLErrorCode.Success;
            Handle = CL10.CreateContextFromType(propertyArray, deviceType, notify, userDataPtr, out error);
            OpenCLException.ThrowOnError(error);

            SetID(Handle.Value);

            this.properties = properties;
            OpenCLContextProperty platformProperty = properties.GetByName(OpenCLContextProperties.Platform);
            this.platform = OpenCLPlatform.GetByHandle(platformProperty.Value);
            this.devices = GetDevices();

            //Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }
コード例 #7
0
        /// <summary>
        /// Creates a new <see cref="OpenCLContext"/> on a collection of <see cref="OpenCLDevice"/>s.
        /// </summary>
        /// <param name="devices"> A collection of <see cref="OpenCLDevice"/>s to associate with the <see cref="OpenCLContext"/>. </param>
        /// <param name="properties"> A <see cref="OpenCLContextPropertyList"/> of the <see cref="OpenCLContext"/>. </param>
        /// <param name="notify"> A delegate instance that refers to a notification routine. This routine is a callback function that will be used by the OpenCL implementation to report information on errors that occur in the <see cref="OpenCLContext"/>. The callback function may be called asynchronously by the OpenCL implementation. It is the application's responsibility to ensure that the callback function is thread-safe and that the delegate instance doesn't get collected by the Garbage Collector until <see cref="OpenCLContext"/> is disposed. If <paramref name="notify"/> is <c>null</c>, no callback function is registered. </param>
        /// <param name="notifyDataPtr"> Optional user data that will be passed to <paramref name="notify"/>. </param>
        public OpenCLContext(List<OpenCLDevice> devices, OpenCLContextPropertyList properties, OpenCLContextNotifier notify, IntPtr notifyDataPtr)
        {
            int handleCount;
            CLDeviceHandle[] deviceHandles = OpenCLTools.ExtractHandles(devices, out handleCount);
            IntPtr[] propertyArray = (properties != null) ? properties.ToIntPtrArray() : null;
            callback = notify;

            OpenCLErrorCode error = OpenCLErrorCode.Success;
            Handle = CL10.CreateContext(propertyArray, handleCount, deviceHandles, notify, notifyDataPtr, out error);
            OpenCLException.ThrowOnError(error);
            
            SetID(Handle.Value);
            
            this.properties = properties;
            OpenCLContextProperty platformProperty = properties.GetByName(OpenCLContextProperties.Platform);
            this.platform = OpenCLPlatform.GetByHandle(platformProperty.Value);
            this.devices = GetDevices();

            //Trace.WriteLine("Create " + this + " in Thread(" + Thread.CurrentThread.ManagedThreadId + ").", "Information");
        }
コード例 #8
0
ファイル: CL10.cs プロジェクト: forki/FSCL.Runtime
 public extern static CLContextHandle CreateContextFromType(
     [MarshalAs(UnmanagedType.LPArray)] IntPtr[] properties,
     OpenCLDeviceType device_type,
     OpenCLContextNotifier pfn_notify,
     IntPtr user_data,
     out OpenCLErrorCode errcode_ret);