-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathmpi_create.cpp
More file actions
31 lines (26 loc) · 1.08 KB
/
mpi_create.cpp
File metadata and controls
31 lines (26 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2019 Lawrence Livermore National Security, LLC and other Metall
// Project Developers. See the top-level COPYRIGHT file for details.
//
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
#include <metall/utility/metall_mpi_adaptor.hpp>
#include <metall/utility/filesystem.hpp>
int main(int argc, char **argv) {
::MPI_Init(&argc, &argv);
{
// This over-write mode fails if the existing file/directory is not Metall
// datastore or the existing datastore was created by a different number of
// MPI ranks.
// To forcibly remove the existing datastore, one can use the following
// code.
// metall::utility::filesystem::remove("/tmp/metall_mpi");
// ::MPI_Barrier(MPI_COMM_WORLD);
bool overwrite = true;
metall::utility::metall_mpi_adaptor mpi_adaptor(
metall::create_only, "/tmp/metall_mpi", MPI_COMM_WORLD, overwrite);
auto &metall_manager = mpi_adaptor.get_local_manager();
auto rank = metall_manager.construct<int>("my-rank")();
::MPI_Comm_rank(MPI_COMM_WORLD, rank); // Stores my rank
}
::MPI_Finalize();
return 0;
}