Exemple #1
0
        // static factory methods

        public static Device[] GetDeviceIDs(Platform platform, DeviceType type)
        {
            ErrorCode error;
            uint      count;

            error = NativeMethods.clGetDeviceIDs((platform?.handle).GetValueOrDefault(), type, 0, null, out count);
            if (error != ErrorCode.Success)
            {
                throw new OpenClException(error);
            }

            var ids = new IntPtr[count];

            error = NativeMethods.clGetDeviceIDs((platform?.handle).GetValueOrDefault(), type, count, ids, out count);
            if (error != ErrorCode.Success)
            {
                throw new OpenClException(error);
            }

            var res = new Device[count];

            for (var i = 0; i < count; i++)
            {
                res[i] = new Device(ids[i]);
            }
            return(res);
        }