示例#1
0
        public Devices()
        {
            Cpus = new List <CpuDevice>((int)KokkosLibrary.GetNumaCount());

            OperatingSystem os = Environment.OSVersion;

            for (int i = 0; i < (int)KokkosLibrary.GetNumaCount(); ++i)
            {
                Cpus.Add(new CpuDevice(i,
                                       $"{os.Platform:G}",
                                       (int)KokkosLibrary.GetCoresPerNuma(),
                                       (int)KokkosLibrary.GetCoresPerNuma() * (int)KokkosLibrary.GetThreadsPerCore(),
                                       new DeviceArch(RuntimeInformation.ProcessArchitecture == Architecture.X64 ? "x64" : "x86")));
            }

            Gpus = new List <GpuDevice>((int)KokkosLibrary.GetDeviceCount());

            uint gpuId = 0;

            foreach (PhysicalGPU physicalGpu in PhysicalGPU.GetPhysicalGPUs())
            {
                uint gpuVersion = KokkosLibrary.GetComputeCapability(gpuId);

                Gpus.Add(new CudaGpuDevice((int)gpuId,
                                           "Cuda",
                                           physicalGpu.ArchitectInformation.NumberOfCores,
                                           physicalGpu.ArchitectInformation.NumberOfCores,
                                           new DeviceArch(GetCudaDeviceName(gpuVersion), (int)gpuVersion),
                                           physicalGpu.UsageInformation));

                ++gpuId;
            }
        }