11 #include "Teuchos_GlobalMPISession.hpp"
12 #include "Kokkos_Core.hpp"
13 #include "Tpetra_Details_checkLaunchBlocking.hpp"
22 void finalizeKokkosIfNeeded() {
23 if (!Kokkos::is_finalized()) {
29 if (!Kokkos::is_initialized()) {
30 std::vector<std::string> args = Teuchos::GlobalMPISession::getArgv();
31 int narg =
static_cast<int>(args.size());
33 std::vector<char*> args_c;
34 std::vector<std::unique_ptr<char[]>> args_;
35 for (
auto const& x : args) {
36 args_.emplace_back(
new char[x.size() + 1]);
37 char* ptr = args_.back().get();
38 strcpy(ptr, x.c_str());
39 args_c.push_back(ptr);
41 args_c.push_back(
nullptr);
43 Kokkos::initialize(narg, narg == 0 ?
nullptr : args_c.data());
44 checkOldCudaLaunchBlocking();
46 std::atexit(finalizeKokkosIfNeeded);
49 Tpetra::Details::AddKokkosDeepCopyToTimeMonitor();
50 Tpetra::Details::AddKokkosFenceToTimeMonitor();
51 Tpetra::Details::AddKokkosFunctionsToTimeMonitor();
Declaration functions that use Kokkos' profiling library to add deep copies between memory spaces...
Declaration of Tpetra::Details::initializeKokkos.
void initializeKokkos()
Initialize Kokkos, using command-line arguments (if any) given to Teuchos::GlobalMPISession.