KaMPIng 0.1.1
Flexible and (near) zero-overhead C++ bindings for MPI
|
We are writing a header-only library. Using the provided .clang-format
library is mandatory. The CI will reject non-conforming pull-requests.
kamping
(KaMPIng) namespace to avoid polluting the user's namespace with trivial names as in
, out
, or root
.internal
namespace.snake_case
, that is, separate words by an underscore (_). Write acronyms in lower case letters, e.g., partitioned_msa
and generate_mpi_failure
. This also applies to KaMPIng -> kamping
.struct
s have only trivial methods if at all, everything more complicated has to be a class
. struct
s are always forbidden to have private members or functions.std::pair
leads to hard to read code. Use named pairs (struct
s) instead._name
or _clear_cache()
.author.name()
is a getter and author.name("Turing")
the corresponding setter.is
, e.g., is_valid()
instead of valid()
length_px()
instead of length()
.public
, protected
, private
. Inside these regions: using
(typedefs) and (scoped) enum
s, struct
s and class
es, attributes, methods..cpp
and .hpp
as file endings. File names are lowercase and separate word using an underscore. For example sparse_all2all.hpp
.len
for length (of)
, num
for number (of)
, mpi
.GeneratorFunction
.using
inherit the naming rules of the type they are aliasing.For details on how to write tests see the Testing Guidelines.
TODO @Demian @Matthias: Rules for API
return
statement, even multiple return values.const
where possible.const
where possible. Use mutable
for caches to be able to keep getters const
.Communicator
using CRTP mixins: Create a new class that inherits from CRTPHelper
with protected constructor, without any member variables, and Communicator
as template parameter where you implement your functionality. Then let Communicator
inherit from your new class. See the corresponding test in tests/plugins_test.cpp
for an example.send
, recv
, and sendrecv
).static_assert
to check the signature of the function being passed as an argument.explicit
.default
, or delete
all the others: Constructor, copy constructor, move constructor, copy assignment operator, move assignment operator, destructor. If you don't need some of them and don't want to think about if they would be easy to implement, delete
them. Either way, write a comment explaining either why you think they should not be implemented, are hard to implement, or that you don't need them and didn't want to bother implementing them.#pragma once
instead of include guards, as it is available on all important compilers.include-what-you-use
to check.#include
statements will be automatically grouped and sorted by clang-format: STL headers come first, then other system headers followed by KaMPIng headers.using namespace
in header files as this would then also apply to all files including this header file.kamping/
prefix when including our own header files.const
.size_t
over std::size_t
. Do not put using size_t = std::size_t
into your code.nullptr
instead of NULL
or 0
.using
instead of typedef
.sizeof
instead of constants.asserting_cast<destType>(srcValve)
or throwing_cast<destType>(srcValue)
.//
instead of /* */
for comments, even multi-line comments.// TODO ...
. This allows grepping for TODOs.auto
.enum
s (enum class
) instead of unscoped enum
s (enum
).std::bind
, use lambda functions instead as they result in better readability and allow the compiler to inline better.C++
which compiles in gcc10
, clang10
and icc19
.KASSERT()
macro with the appropriate assertion level to validate the internal state of your code or user supplied data.THROW_IF_MPI_ERROR()
macro for MPI errors.Since we overload the &&
and ||
operators, KASSERT
cannot short circuit assertion expressions. This can lead to unexpected behaviour, for instance:
This is impossible to fix since C++ does not allow us to overload the &&
and ||
operators while preserving short-circuit evaluation. Therefore, it is not allowed to write
Instead, add an extra pair of parenthesis:
Code should compile with clang
and gcc
(not icc
) without warning with the warning flags given below. If you want to submit code which throws warnings, at least two other persons have to agree. Possible reasons for this are: False-positive warnings.
git submodule
to include dependencies. TODO: Explain in the README, how to work with git submodules.