Esempio n. 1
0
        static OpenCLPlatform()
        {
            try
            {
                if (platforms != null)
                {
                    return;
                }
                CLPlatformHandle[] handles;
                int             handlesLength;
                OpenCLErrorCode error = CL10.GetPlatformIDs(0, null, out handlesLength);
                OpenCLException.ThrowOnError(error);
                handles = new CLPlatformHandle[handlesLength];

                error = CL10.GetPlatformIDs(handlesLength, handles, out handlesLength);
                OpenCLException.ThrowOnError(error);

                List <OpenCLPlatform> platformList = new List <OpenCLPlatform>(handlesLength);
                foreach (CLPlatformHandle handle in handles)
                {
                    platformList.Add(new OpenCLPlatform(handle));
                }

                platforms = platformList.AsReadOnly();
            }
            catch (DllNotFoundException)
            {
                platforms = new List <OpenCLPlatform>().AsReadOnly();
            }
        }
Esempio n. 2
0
        static ComputePlatform()
        {
            lock (typeof(ComputePlatform))
            {
                try
                {
                    if (platforms != null)
                    {
                        return;
                    }

                    ComputeErrorCode error = CL12.GetPlatformIDs(0, null, out var handlesLength);
                    ComputeException.ThrowOnError(error);
                    var handles = new CLPlatformHandle[handlesLength];

                    error = CL12.GetPlatformIDs(handlesLength, handles, out handlesLength);
                    ComputeException.ThrowOnError(error);

                    List <ComputePlatform> platformList = new List <ComputePlatform>(handlesLength);
                    foreach (CLPlatformHandle handle in handles)
                    {
                        platformList.Add(new ComputePlatform(handle));
                    }

                    platforms = platformList.AsReadOnly();
                }
                catch (DllNotFoundException)
                {
                    platforms = new List <ComputePlatform>().AsReadOnly();
                }
            }
        }
Esempio n. 3
0
        private ComputePlatform(CLPlatformHandle handle)
        {
            Handle = handle;
            SetID(Handle.Value);

            string extensionString = GetStringInfo<CLPlatformHandle, ComputePlatformInfo>(Handle, ComputePlatformInfo.Extensions, CL12.GetPlatformInfo);
            extensions = new ReadOnlyCollection<string>(extensionString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));

            name = GetStringInfo<CLPlatformHandle, ComputePlatformInfo>(Handle, ComputePlatformInfo.Name, CL12.GetPlatformInfo);
            profile = GetStringInfo<CLPlatformHandle, ComputePlatformInfo>(Handle, ComputePlatformInfo.Profile, CL12.GetPlatformInfo);
            vendor = GetStringInfo<CLPlatformHandle, ComputePlatformInfo>(Handle, ComputePlatformInfo.Vendor, CL12.GetPlatformInfo);
            version = GetStringInfo<CLPlatformHandle, ComputePlatformInfo>(Handle, ComputePlatformInfo.Version, CL12.GetPlatformInfo);
            QueryDevices();
        }
Esempio n. 4
0
        static ComputePlatform()
        {
            lock (typeof(ComputePlatform))
            {
                try
                {
                    if (platforms != null)
                    {
                        return;
                    }

                    CLPlatformHandle[] handles;
                    int handlesLength;
                    ComputeErrorCode error = CLInterface.CL12.GetPlatformIDs(0, null, out handlesLength);
                    ComputeException.ThrowOnError(error);
                    handles = new CLPlatformHandle[handlesLength];

                    error = CLInterface.CL12.GetPlatformIDs(handlesLength, handles, out handlesLength);
                    ComputeException.ThrowOnError(error);

                    List <ComputePlatform> platformList = new List <ComputePlatform>(handlesLength);
                    foreach (CLPlatformHandle handle in handles)
                    {
                        platformList.Add(new ComputePlatform(handle));
                    }

                    platforms      = platformList;
                    platformsArray = new ComputePlatform[platforms.Count];
                    platforms.CopyTo(platformsArray);
                }
                catch (DllNotFoundException)
                {
                    platforms      = new List <ComputePlatform>();
                    platformsArray = new ComputePlatform[platforms.Count];
                    platforms.CopyTo(platformsArray);
                }
            }
        }
        private OpenCLPlatform(CLPlatformHandle handle)
        {
            Handle = handle;
            SetID(Handle.Value);

            string extensionString = GetStringInfo<CLPlatformHandle, OpenCLPlatformInfo>(Handle, OpenCLPlatformInfo.Extensions, CL10.GetPlatformInfo);
            extensions = new ReadOnlyCollection<string>(extensionString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));

            name = GetStringInfo<CLPlatformHandle, OpenCLPlatformInfo>(Handle, OpenCLPlatformInfo.Name, CL10.GetPlatformInfo);
            profile = GetStringInfo<CLPlatformHandle, OpenCLPlatformInfo>(Handle, OpenCLPlatformInfo.Profile, CL10.GetPlatformInfo);
            vendor = GetStringInfo<CLPlatformHandle, OpenCLPlatformInfo>(Handle, OpenCLPlatformInfo.Vendor, CL10.GetPlatformInfo);
            version = GetStringInfo<CLPlatformHandle, OpenCLPlatformInfo>(Handle, OpenCLPlatformInfo.Version, CL10.GetPlatformInfo);
            QueryDevices();
        }
        static OpenCLPlatform()
        {
            try
            {
                if (platforms != null)
                    return;
                CLPlatformHandle[] handles;
                int handlesLength;
                OpenCLErrorCode error = CL10.GetPlatformIDs(0, null, out handlesLength);
                OpenCLException.ThrowOnError(error);
                handles = new CLPlatformHandle[handlesLength];

                error = CL10.GetPlatformIDs(handlesLength, handles, out handlesLength);
                OpenCLException.ThrowOnError(error);

                List<OpenCLPlatform> platformList = new List<OpenCLPlatform>(handlesLength);
                foreach (CLPlatformHandle handle in handles)
                    platformList.Add(new OpenCLPlatform(handle));

                platforms = platformList.AsReadOnly();
            }
            catch (DllNotFoundException)
            {
                platforms = new List<OpenCLPlatform>().AsReadOnly();
            }
        }
Esempio n. 7
0
 public extern static OpenCLErrorCode GetDeviceIDs(
     CLPlatformHandle platform,
     OpenCLDeviceType device_type,
     Int32 num_entries,
     [Out, MarshalAs(UnmanagedType.LPArray)] CLDeviceHandle[] devices,
     out Int32 num_devices);
Esempio n. 8
0
 public extern static OpenCLErrorCode GetPlatformInfo(
     CLPlatformHandle platform,
     OpenCLPlatformInfo param_name,
     IntPtr param_value_size,
     IntPtr param_value,
     out IntPtr param_value_size_ret);