예제 #1
0
파일: CLAPI.cs 프로젝트: karayakar/ILGPU
 /// <summary>
 /// Resolves the number of available platforms.
 /// </summary>
 /// <returns>The error code.</returns>
 public static CLError GetNumDevices(IntPtr platform, CLDeviceType deviceType, out int numDevices) =>
 NativeMethods.GetDeviceIDs(
     platform,
     deviceType,
     short.MaxValue,
     null,
     out numDevices);
예제 #2
0
파일: CLAPI.cs 프로젝트: karayakar/ILGPU
 public static CLError GetDevices(
     IntPtr platform,
     CLDeviceType deviceType,
     IntPtr *devices,
     ref int numDevices) =>
 NativeMethods.GetDeviceIDs(
     platform,
     deviceType,
     numDevices,
     devices,
     out numDevices);
예제 #3
0
        public static IntPtr CreateContextFromType(CLDeviceType deviceType, ref int error)
        {
            uint   numPlatforms;
            IntPtr platform = IntPtr.Zero;

            IntPtr[] platforms = null;

            int ciErrNum = CL.GetPlatformIDs(0, ref platforms, out numPlatforms);

            if (ciErrNum != 0)
            {
                error = ciErrNum;
                return(IntPtr.Zero);
            }

            if (CLStuff.deviceType == CLDeviceType.Cpu)
            {
                platformVendor = "MiniCL, SCEA";
            }

            if (numPlatforms > 0)
            {
                platforms = new IntPtr[numPlatforms];
                ciErrNum  = CL.GetPlatformIDs(numPlatforms, ref platforms, out numPlatforms);
                if (ciErrNum != 0)
                {
                    error = ciErrNum;
                    return(IntPtr.Zero);
                }

                for (int i = 0; i < numPlatforms; ++i)
                {
                    string vendor;
                    ciErrNum = CL.GetPlatformInfo(platforms[i], CLPlatform.Vendor, out vendor);
                    if (ciErrNum != 0)
                    {
                        error = ciErrNum;
                        return(IntPtr.Zero);
                    }

                    platform = platforms[i];
                    if (vendor == platformVendor)
                    {
                        break;
                    }
                }
            }

            List <KeyValuePair <CLContext, IntPtr> > properties = new List <KeyValuePair <CLContext, IntPtr> >();

            properties.Add(new KeyValuePair <CLContext, IntPtr>(CLContext.Platform, platform));
            return(CL.CreateContextFromType(properties, deviceType, out error));
        }
예제 #4
0
파일: CLAPI.cs 프로젝트: karayakar/ILGPU
 /// <summary>
 /// Resolves the number of available devices.
 /// </summary>
 /// <param name="platform">The target platform.</param>
 /// <param name="deviceType">The device type.</param>
 /// <param name="devices">The device ids to fill.</param>
 /// <param name="numDevices">The number of devices.</param>
 /// <returns>The error code.</returns>
 public static CLError GetDevices(
     IntPtr platform,
     CLDeviceType deviceType,
     IntPtr[] devices,
     out int numDevices)
 {
     Debug.Assert(devices != null, "Invalid devices");
     fixed(IntPtr *ptr = &devices[0])
     {
         numDevices = devices.Length;
         return(GetDevices(platform, deviceType, ptr, ref numDevices));
     }
 }
예제 #5
0
        public static Devices Create(CLDeviceType deviceType, Platform platform)
        {
            Int32 deviceCount = 0;

            CLPlatformID pfm = platform == null ? new CLPlatformID() : platform.CLPlatformID;

            OpenCLError.Validate(OpenCLDriver.clGetDeviceIDs(pfm, (ManOCL.Internal.OpenCL.CLDeviceType)deviceType, 0, null, ref deviceCount));

            CLDeviceID[] deviceIds = new CLDeviceID[deviceCount];

            OpenCLError.Validate(OpenCLDriver.clGetDeviceIDs(pfm, (ManOCL.Internal.OpenCL.CLDeviceType)deviceType, deviceCount, deviceIds, ref deviceCount));

            return(new Devices(deviceIds));
        }
예제 #6
0
        public static IntPtr CreateContextFromType(CLDeviceType deviceType, ref int error)
        {
            uint numPlatforms;
            IntPtr platform = IntPtr.Zero;
            IntPtr[] platforms = null;

            int ciErrNum = CL.GetPlatformIDs(0, ref platforms, out numPlatforms);
            if (ciErrNum != 0)
            {
                error = ciErrNum;
                return IntPtr.Zero;
            }

            if (CLStuff.deviceType == CLDeviceType.Cpu)
            {
                platformVendor = "MiniCL, SCEA";
            }

            if (numPlatforms > 0)
            {
                platforms = new IntPtr[numPlatforms];
                ciErrNum = CL.GetPlatformIDs(numPlatforms, ref platforms, out numPlatforms);
                if (ciErrNum != 0)
                {
                    error = ciErrNum;
                    return IntPtr.Zero;
                }

                for (int i = 0; i < numPlatforms; ++i)
                {
                    string vendor;
                    ciErrNum = CL.GetPlatformInfo(platforms[i], CLPlatform.Vendor, out vendor);
                    if (ciErrNum != 0)
                    {
                        error = ciErrNum;
                        return IntPtr.Zero;
                    }

                    platform = platforms[i];
                    if (vendor == platformVendor)
                        break;
                }
            }

            List<KeyValuePair<CLContext, IntPtr>> properties = new List<KeyValuePair<CLContext, IntPtr>>();
            properties.Add(new KeyValuePair<CLContext, IntPtr>(CLContext.Platform, platform));
            return CL.CreateContextFromType(properties, deviceType, out error);
        }
예제 #7
0
        public static Devices Create(CLDeviceType deviceType, Platforms platforms)
        {
            List <Device> rd = new List <Device>();

            foreach (Platform platform in platforms)
            {
                Devices devices = Devices.Create(deviceType, platform);

                foreach (Device device in devices)
                {
                    rd.Add(device);
                }
            }

            Device[]     resultingDevices       = rd.ToArray();
            CLDeviceID[] resultingOpenCLDevices = GetOpenCLDeviceArray(resultingDevices);

            return(new Devices(resultingOpenCLDevices, resultingDevices));
        }
예제 #8
0
 public static extern CLError GetDeviceIDs(
     [In] IntPtr platform,
     [In] CLDeviceType deviceType,
     [In] int maxNumDevices,
     [Out] IntPtr *devices,
     [Out] out int numDevices);
예제 #9
0
 public static extern CLError clGetDeviceIDs(
     CLPlatformID platform_id,
     CLDeviceType device_type,
     uint num_entries,
     IntPtr devices,
     ref uint num_devices);
예제 #10
0
 public static extern CLContext clCreateContextFromType(
     [In] IntPtr[] properties,
     CLDeviceType device_type,
     LoggingFunction pfn_notify,
     IntPtr user_data,
     ref CLError errcode_ret);
예제 #11
0
 internal static extern CLContext clCreateContextFromType([In] IntPtr[] properties, CLDeviceType device_type, LoggingFunction pfn_notify, IntPtr user_data, ref CLError errcode_ret);
예제 #12
0
 internal static extern CLError clGetDeviceIDs(CLPlatformID platform_id, CLDeviceType device_type, int num_entries, IntPtr devices, ref int num_devices);
예제 #13
0
파일: OpenCLDriver.cs 프로젝트: lu4/ManOCL
 internal static extern CLError clGetDeviceIDs(CLPlatformID platform_id, CLDeviceType device_type, int num_entries, [Out] CLDeviceID[] devices, ref int num_devices);
예제 #14
0
 public static Devices Create(CLDeviceType deviceType)
 {
     return(Create(deviceType, Context.Default.Platforms));
 }