TRIQS/nda
2.0.0
Multi-dimensional array library for C++
Toggle main menu visibility
Loading...
Searching...
No Matches
utils.hpp
Go to the documentation of this file.
1
// Copyright (c) 2024--present, The Simons Foundation
2
// This file is part of TRIQS/nda and is licensed under the Apache License, Version 2.0.
3
// SPDX-License-Identifier: Apache-2.0
4
// See LICENSE in the root of this distribution for details.
5
10
11
#pragma once
12
13
#include "
../concepts.hpp
"
14
#include "
../exceptions.hpp
"
15
16
#include <mpi/mpi.hpp>
17
18
#include <string>
19
20
namespace
nda::detail {
21
22
// Check if the layout of an array/view is contiguous with positive strides, otherwise throw an exception.
23
template
<nda::Array A>
24
void
check_layout_mpi_compatible(
const
A &a,
const
std::string &func) {
25
if
(not a.is_contiguous() or not a.has_positive_strides())
26
NDA_RUNTIME_ERROR <<
"Error in function "
<< func <<
": Array is not contiguous with positive strides"
;
27
}
28
29
// Check if the ranks of arrays/views are the same on all processes.
30
template
<nda::Array A>
31
bool
have_mpi_equal_ranks(
const
A &a,
const
mpi::communicator &comm) {
32
return
mpi::all_equal(a.rank, comm);
33
}
34
35
// Check if the shape of arrays/views are the same on all processes.
36
template
<nda::Array A>
37
bool
have_mpi_equal_shapes(
const
A &a,
const
mpi::communicator &comm) {
38
return
have_mpi_equal_ranks(a, comm) && mpi::all_equal(a.shape(), comm);
39
}
40
41
}
// namespace nda::detail
concepts.hpp
Provides concepts for the nda library.
exceptions.hpp
Provides a custom runtime error class and macros to assert conditions and throw exceptions.
nda
mpi
utils.hpp
Generated by
1.17.0