Exemple #1
0
        /// <summary>
        /// Gets an array of all OpenCL Devices with the specified flags.
        /// </summary>
        /// <param name="deviceTypeFlags">A bitfield that identifies the type of OpenCL device.</param>
        /// <returns>An array of OpenCL devices with the specified flags.</returns>
        public Device[] GetDevices(DeviceTypeFlags deviceTypeFlags)
        {
            Device[] devices = null;
            uint     count   = 0;

            unsafe
            {
                ErrorCode errorCode = (ErrorCode)Native.GetDeviceIDs(this.Handle, deviceTypeFlags, 0, null, &count);

                if (errorCode == ErrorCode.DeviceNotFound)
                {
                    return(new Device[0]);
                }
                else if (errorCode != ErrorCode.Success)
                {
                    throw new OpenCLCallFailedException(errorCode);
                }

                IntPtr[] devHandles = new IntPtr[count];
                devices = new Device[count];

                fixed(IntPtr *p_devHandles = devHandles)
                {
                    Native.Call(Native.GetDeviceIDs(this.Handle, deviceTypeFlags, count, p_devHandles, null));
                }

                devices = Device.CreateFromHandles(devHandles);
            }
            return(devices);
        }
Exemple #2
0
        public static Context CreateFromType(Platform platform, DeviceTypeFlags deviceTypeFlags)
        {
            ContextProperties[] properties = new ContextProperties[3];
            properties[0] = ContextProperties.Platform;
            properties[1] = (ContextProperties)(platform.Handle);
            properties[2] = (ContextProperties)0;

            return(CreateFromType(properties, deviceTypeFlags));
        }
Exemple #3
0
		public static IntPtr[] GetDeviceIds(IntPtr platformId, DeviceTypeFlags deviceType)
        {
            //get numOfPlatforms
            uint num;
            CheckError(CL.GetDeviceIDs(platformId, deviceType, 0, (IntPtr*)NullPtr, &num));
            //get platforms
            IntPtr[] ids = new IntPtr[num];
            fixed (IntPtr* idsPtr = ids)
            {
                CheckError(CL.GetDeviceIDs(platformId, deviceType, num, idsPtr, (uint*)NullPtr));
            }
            return ids;
        }
Exemple #4
0
        public static IntPtr[] GetDeviceIds(IntPtr platformId, DeviceTypeFlags deviceType)
        {
            //get numOfPlatforms
            uint num;

            CheckError(CL.GetDeviceIDs(platformId, deviceType, 0, (IntPtr *)NullPtr, &num));
            //get platforms
            IntPtr[] ids = new IntPtr[num];
            fixed(IntPtr *idsPtr = ids)
            {
                CheckError(CL.GetDeviceIDs(platformId, deviceType, num, idsPtr, (uint *)NullPtr));
            }

            return(ids);
        }
Exemple #5
0
        public static Context CreateFromType(ContextProperties[] properties, DeviceTypeFlags deviceTypeFlags)
        {
            Context   result    = null;
            ErrorCode errorCode = ErrorCode.Success;
            IntPtr    ctxHandle = IntPtr.Zero;

            unsafe
            {
                fixed(ContextProperties *p_properties = properties)
                {
                    ctxHandle = Native.CreateContextFromType(p_properties, deviceTypeFlags, IntPtr.Zero, IntPtr.Zero, &errorCode);
                }
            }

            if (errorCode != ErrorCode.Success)
            {
                throw new OpenCLCallFailedException(errorCode);
            }

            result = new Context(ctxHandle);

            return(result);
        }
Exemple #6
0
 public static Device[] GetDevices(Platform platform, DeviceTypeFlags deviceTypeFlags)
 {
     return(platform.GetDevices(deviceTypeFlags));
 }
Exemple #7
0
        public static unsafe IntPtr CreateContextFromType <T4>(ref ContextProperties properties, DeviceTypeFlags device_type, IntPtr pfn_notify, ref T4 user_data, out OpenTK.Compute.CL10.ErrorCode errcode_ret)
            where T4 : struct
        {
            IntPtr properties_correct = new IntPtr((int)properties);

            return(CreateContextFromType(ref properties_correct, device_type, pfn_notify, ref user_data, out errcode_ret));
        }
Exemple #8
0
 public static unsafe IntPtr CreateContextFromType <T4>(ContextProperties[] properties, DeviceTypeFlags device_type, IntPtr pfn_notify, ref T4 user_data, OpenTK.Compute.CL10.ErrorCode[] errcode_ret)
     where T4 : struct
 {
     IntPtr[] properties_correct = properties != null ? new IntPtr[properties.Length] : null;
     for (int i = 0; i < properties_correct.Length; i++)
     {
         properties_correct[i] = new IntPtr((int)properties[i]);
     }
     return(CreateContextFromType(properties_correct, device_type, pfn_notify, ref user_data, errcode_ret));
 }
Exemple #9
0
 public static unsafe IntPtr CreateContextFromType <T4>(ContextProperties *properties, DeviceTypeFlags device_type, IntPtr pfn_notify, ref T4 user_data, OpenTK.Compute.CL10.ErrorCode *errcode_ret)
     where T4 : struct
 {
     return(CreateContextFromType((IntPtr *)properties, device_type, pfn_notify, ref user_data, errcode_ret));
 }
Exemple #10
0
 internal extern static unsafe IntPtr CreateContextFromType(ContextProperties *properties, DeviceTypeFlags device_type, IntPtr pfn_notify, IntPtr user_data, [Out] ErrorCode *errcode_ret);
Exemple #11
0
 internal extern static unsafe ErrorCode GetDeviceIDs(IntPtr platform, DeviceTypeFlags device_type, uint num_entries, IntPtr *devices, uint *num_devices);
Exemple #12
0
 internal extern static unsafe IntPtr CreateContextFromType(IntPtr *properties, DeviceTypeFlags device_type, IntPtr pfn_notify, IntPtr user_data, [OutAttribute] OpenTK.Compute.CL10.ErrorCode *errcode_ret);
Exemple #13
0
 internal extern static unsafe IntPtr CreateContextFromType(ContextProperties* properties, DeviceTypeFlags device_type, IntPtr pfn_notify, IntPtr user_data, [OutAttribute] OpenTK.Compute.CL10.ErrorCode* errcode_ret);
Exemple #14
0
 internal extern static unsafe int GetDeviceIDs(IntPtr platform, DeviceTypeFlags device_type, uint num_entries, IntPtr* devices, uint* num_devices);
Exemple #15
0
 public static unsafe IntPtr CreateContextFromType(ContextProperties *properties, DeviceTypeFlags device_type, IntPtr pfn_notify, IntPtr user_data, osuTK.Compute.CL10.ErrorCode *errcode_ret)
 {
     return(CreateContextFromType((IntPtr *)properties, device_type, pfn_notify, user_data, errcode_ret));
 }