5#include <Kokkos_Core.hpp>
16 void initialize(
int& argc,
char* argv[], MPI_Comm comm) {
17 Env = std::make_unique<mpi::Environment>(argc, argv, comm);
19 Comm = std::make_unique<mpi::Communicator>(comm);
21 Info = std::make_unique<Inform>(
"Ippl");
22 Warn = std::make_unique<Inform>(
"Warning", std::cerr);
26 std::list<std::string> notparsed;
29 while (nargs < argc) {
31 if (
Comm->rank() == 0) {
38 throw std::runtime_error(
"Missing info level value!");
40 infoLevel = detail::getNumericalOption<int>(argv[nargs]);
44 throw std::runtime_error(
"Missing timer fence enable option!");
46 if (std::strcmp(argv[nargs],
"on") == 0) {
48 }
else if (std::strcmp(argv[nargs],
"off") == 0) {
51 throw std::runtime_error(
"Invalid timer fence option");
56 std::string header(
"Compile-time options: ");
57 while (options.length() > 58) {
58 std::string line = options.substr(0, 58);
59 size_t n = line.find_last_of(
' ');
60 *
Info << header << line.substr(0, n) <<
"\n";
62 header = std::string(22,
' ');
63 options = options.substr(n + 1);
70 throw std::runtime_error(
"Missing overallocation factor value!");
72 auto factor = detail::getNumericalOption<double>(argv[nargs]);
73 Comm->setDefaultOverallocation(factor);
74 }
else if (nargs > 0 && std::strstr(argv[nargs],
"--kokkos") ==
nullptr) {
75 notparsed.push_back(argv[nargs]);
84 }
catch (
const std::exception&
e) {
85 if (
Comm->rank() == 0) {
95 Comm->deleteAllBuffers();
107 void abort(
const char* msg,
int errorcode) {
111 Comm->abort(errorcode);
115 bool checkOption(
const char* arg,
const char* lstr,
const char* sstr) {
116 return (std::strcmp(arg, lstr) == 0) || (std::strcmp(arg, sstr) == 0);
119 template <
typename T,
typename>
121 constexpr bool isInt = std::is_integral_v<T>;
122 std::string sarg = arg;
126 if constexpr (isInt) {
127 ret = std::stoll(sarg, &parsed);
129 ret = std::stold(sarg, &parsed);
131 if (parsed != sarg.length())
132 throw std::invalid_argument(
"Failed to parse");
134 }
catch (std::invalid_argument&
e) {
135 if constexpr (isInt) {
136 throw std::runtime_error(
"Expected integer argument!");
138 throw std::runtime_error(
"Expected floating point argument!");
142 throw std::runtime_error(
"Unreachable state");
Inform & endl(Inform &inf)
constexpr double e
The value of.
Implementations for FFT constructor/destructor and transforms.
void initialize(int &argc, char *argv[], MPI_Comm comm)
std::unique_ptr< Inform > Info
std::unique_ptr< Inform > Error
std::unique_ptr< Inform > Warn
std::unique_ptr< mpi::Communicator > Comm
std::unique_ptr< mpi::Environment > Env
void abort(const char *msg, int errorcode)
T getNumericalOption(const char *arg)
bool checkOption(const char *arg, const char *lstr, const char *sstr)
static void printVersion(void)
static void printHelp(char **argv)
static const char * compileOptions()