Loading...
Searching...
No Matches
ParametersMpi.h
Go to the documentation of this file.
1/*
2** This file is part of eOn.
3**
4** SPDX-License-Identifier: BSD-3-Clause
5**
6** Copyright (c) 2010--present, eOn Development Team
7** All rights reserved.
8**
9** Repo:
10** https://github.com/TheochemUI/eOn
11*/
12#pragma once
13
16
17#include "eon/Parameters.h"
18#include <cstring>
19
20#ifdef EONMPI
21#include "mpi.h"
22
23namespace eonc {
24
25inline void setMpiClientComm(Parameters &p, MPI_Comm comm) {
26 static_assert(sizeof(MPI_Comm) <= sizeof(std::uintptr_t),
27 "MPI_Comm does not fit in uintptr_t");
28 std::uintptr_t raw = 0;
29 std::memcpy(&raw, &comm, sizeof(comm));
30 p.set_mpi_client_comm(raw);
31}
32
33inline MPI_Comm getMpiClientComm(const Parameters &p) {
34 MPI_Comm comm{};
35 std::uintptr_t raw = p.mpi_client_comm();
36 std::memcpy(&comm, &raw, sizeof(comm));
37 return comm;
38}
39
40} // namespace eonc
41#endif
RAII resource manager for the ARTn C library with global synchronization.