Compadre  1.5.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Compadre_KokkosParser.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Compadre: COMpatible PArticle Discretization and REmap Toolkit
4 //
5 // Copyright 2018 NTESS and the Compadre contributors.
6 // SPDX-License-Identifier: BSD-2-Clause
7 // *****************************************************************************
8 // @HEADER
10 
11 using namespace Compadre;
12 
13 // for InitArguments, pass them directly in to Kokkos
15  this->ksg = !Kokkos::is_initialized()
16 #ifdef COMPADRE_KOKKOS_GREATEREQUAL_3_7
17  && !Kokkos::is_finalized()
18 #endif
19  ?
20  new Kokkos::ScopeGuard(args) : nullptr;
21  if (print_status) this->status();
22 }
23 
24 // for command line arguments, pass them directly in to Kokkos
25 KokkosParser::KokkosParser(int narg, char* args[], bool print_status) {
26  this->ksg = !Kokkos::is_initialized()
27 #ifdef COMPADRE_KOKKOS_GREATEREQUAL_3_7
28  && !Kokkos::is_finalized()
29 #endif
30  ?
31  new Kokkos::ScopeGuard(narg, args) : nullptr;
32  if (print_status) this->status();
33 }
34 
35 KokkosParser::KokkosParser(std::vector<std::string> stdvec_args, bool print_status) {
36  std::vector<char*> char_args;
37  for (const auto& arg : stdvec_args) {
38  char_args.push_back((char*)arg.data());
39  }
40  char_args.push_back(nullptr);
41  int narg = (int)stdvec_args.size();
42 
43  this->ksg = !Kokkos::is_initialized()
44 #ifdef COMPADRE_KOKKOS_GREATEREQUAL_3_7
45  && !Kokkos::is_finalized()
46 #endif
47  ?
48  new Kokkos::ScopeGuard(narg, char_args.data()) : nullptr;
49  if (print_status) this->status();
50 }
51 
52 KokkosParser::KokkosParser(bool print_status) : KokkosParser(KokkosInitArguments(), print_status) {}
53 
54 std::string KokkosParser::status() {
55  std::stringstream stream;
56  Kokkos::print_configuration(stream, true);
57  std::string status = stream.str();
58  return status;
59 }
Class handling Kokkos command line arguments and returning parameters.
Kokkos::InitArguments KokkosInitArguments
static std::string status()