55 std::vector<EspressoGpuDevice> devices_local;
57 std::vector<EspressoGpuDevice> devices_global;
64 char proc_name[MPI_MAX_PROCESSOR_NAME];
65 MPI_Get_processor_name(proc_name, &proc_name_len);
69 for (
int i = 0; i < n_devices; ++i) {
71 std::strncpy(device.proc_name, proc_name, 64);
72 device.proc_name[63] =
'\0';
74 devices_local.emplace_back(device);
78 auto const n_gpus =
static_cast<int>(devices_local.size());
82 std::set<EspressoGpuDevice, CompareDevices> device_set;
83 int *n_gpu_array =
new int[
static_cast<unsigned int>(n_nodes)];
84 MPI_Gather(&n_gpus, 1, MPI_INT, n_gpu_array, 1, MPI_INT, 0, MPI_COMM_WORLD);
87 std::ranges::copy(devices_local,
88 std::inserter(device_set, device_set.begin()));
93 for (
int i = 1; i < n_nodes; ++i) {
94 for (
int j = 0; j < n_gpu_array[i]; ++j) {
97 device_set.insert(device);
101 std::ranges::copy(device_set, std::back_inserter(devices_global));
102 delete[] n_gpu_array;
105 MPI_Gather(&n_gpus, 1, MPI_INT,
nullptr, 1, MPI_INT, 0, MPI_COMM_WORLD);
107 for (
auto const &device : devices_local) {
112 return devices_global;