54 std::vector<EspressoGpuDevice> devices_local;
56 std::vector<EspressoGpuDevice> devices_global;
63 char proc_name[MPI_MAX_PROCESSOR_NAME];
64 MPI_Get_processor_name(proc_name, &proc_name_len);
68 for (
int i = 0; i < n_devices; ++i) {
70 std::strncpy(device.proc_name, proc_name, 64);
71 device.proc_name[63] =
'\0';
73 devices_local.emplace_back(device);
77 auto const n_gpus =
static_cast<int>(devices_local.size());
81 std::set<EspressoGpuDevice, CompareDevices> device_set;
82 int *n_gpu_array =
new int[
static_cast<unsigned int>(n_nodes)];
83 MPI_Gather(&n_gpus, 1, MPI_INT, n_gpu_array, 1, MPI_INT, 0, MPI_COMM_WORLD);
86 std::copy(devices_local.begin(), devices_local.end(),
87 std::inserter(device_set, device_set.begin()));
92 for (
int i = 1; i < n_nodes; ++i) {
93 for (
int j = 0; j < n_gpu_array[i]; ++j) {
96 device_set.insert(device);
100 std::copy(device_set.begin(), device_set.end(),
101 std::inserter(devices_global, devices_global.begin()));
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;