File indexing completed on 2025-01-18 09:12:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "Acts/Plugins/Cuda/Utilities/Info.hpp"
0011
0012 #include "ErrorCheck.cuh"
0013
0014
0015 #include <cmath>
0016 #include <iostream>
0017
0018 namespace Acts {
0019 namespace Cuda {
0020
0021 Info& Info::instance() {
0022 static Info info;
0023 return info;
0024 }
0025
0026 const std::vector<Info::Device>& Info::devices() const {
0027 return m_devices;
0028 }
0029
0030 Info::Info() {
0031
0032
0033
0034 int nDevices = 0;
0035 static_cast<void>(cudaGetDeviceCount(&nDevices));
0036
0037 for (int i = 0; i < nDevices; ++i) {
0038
0039 cudaDeviceProp properties;
0040 ACTS_CUDA_ERROR_CHECK(cudaGetDeviceProperties(&properties, i));
0041
0042
0043 m_devices.push_back({i, properties.name, properties.maxThreadsPerBlock,
0044 static_cast<bool>(properties.concurrentKernels),
0045 properties.totalGlobalMem});
0046 }
0047 }
0048
0049 std::ostream& operator<<(std::ostream& out, const Info::Device& device) {
0050 out << " /-- Device ID " << device.id << " " << std::string(31, '-') << "\\"
0051 << std::endl;
0052 out << " | Name: " << device.name
0053 << std::string(
0054 (39 > device.name.length() ? 39 - device.name.length() : 0), ' ')
0055 << "|" << std::endl;
0056 const std::size_t threadDigits =
0057 static_cast<std::size_t>(std::log10(device.maxThreadsPerBlock)) + 1;
0058 out << " | Max. threads per block: " << device.maxThreadsPerBlock
0059 << std::string((21 > threadDigits ? 21 - threadDigits : 0), ' ') << "|"
0060 << std::endl;
0061 out << " | Concurrent kernels: "
0062 << (device.concurrentKernels ? "true " : "false") << std::string(20, ' ')
0063 << "|" << std::endl;
0064 static constexpr double MEGABYTES = 1.0 / (1024 * 1024);
0065 const double totalMem = device.totalMemory * MEGABYTES;
0066 const std::size_t memDigits =
0067 static_cast<std::size_t>(std::log10(totalMem)) + 1;
0068 out << " | Total memory: " << totalMem << " MB"
0069 << std::string((25 > memDigits ? 25 - memDigits : 0), ' ') << "|"
0070 << std::endl;
0071 out << " \\" << std::string(46, '-') << "/";
0072
0073 return out;
0074 }
0075
0076 }
0077 }