// ---------------------------------------------------------------------
#include <deal.II/base/kokkos.h>
+#include <deal.II/base/multithread_info.h>
#include <deal.II/lac/la_parallel_vector.h>
#include <deal.II/lac/vector_memory.h>
// only execute once
static bool dummy = [] {
dealii_initialized_kokkos = true;
- Kokkos::initialize();
+ const auto settings =
+ Kokkos::InitializationSettings().set_num_threads(
+ MultithreadInfo::n_threads());
+ Kokkos::initialize(settings);
std::atexit(Kokkos::finalize);
return true;
}();
#endif
// Initialize Kokkos
- Kokkos::initialize(argc, argv);
+ {
+ std::vector<char *> argv_new;
+ for (int i = 0; i < argc; ++i)
+ argv_new.push_back(argv[i]);
+ std::stringstream threads_flag;
+ threads_flag << "--kokkos-threads=" << MultithreadInfo::n_threads();
+ argv_new.push_back(const_cast<char *>(threads_flag.str().c_str()));
+ argv_new.push_back(nullptr);
+ int argc_new = argc + 1;
+ Kokkos::initialize(argc_new, argv_new.data());
+ }
// we are allowed to call MPI_Init ourselves and PETScInitialize will
// detect this. This allows us to use MPI_Init_thread instead.