Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_Details_Behavior.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Tpetra: Templated Linear Algebra Services Package
4 //
5 // Copyright 2008 NTESS and the Tpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 // clang-format on
11 #include <algorithm> // std::transform
12 #include <array>
13 #include <cctype> // std::toupper
14 #include <cstdlib> // std::getenv
15 #include <functional>
16 #include <map>
17 #include <stdexcept>
18 #include <string>
19 #include <string_view>
20 #include <vector>
21 
22 #include "Teuchos_OrdinalTraits.hpp"
23 #include "Teuchos_TestForException.hpp"
24 #include "TpetraCore_config.h"
26 #include "KokkosKernels_config.h" // for TPL enable macros
27 
62 // environ should be available on posix platforms
63 #if not(defined(WIN) && (_MSC_VER >= 1900))
64 // needs to be in the global namespace
65 extern char **environ;
66 #endif
67 
68 namespace Tpetra {
69 namespace Details {
70 
71 namespace BehaviorDetails {
72 
73 constexpr const std::string_view RESERVED_PREFIX = "TPETRA_";
74 constexpr const std::string_view ASSUME_GPU_AWARE_MPI =
75  "TPETRA_ASSUME_GPU_AWARE_MPI";
76 constexpr const std::string_view CUDA_LAUNCH_BLOCKING = "CUDA_LAUNCH_BLOCKING";
77 constexpr const std::string_view MM_TAFC_OptimizationCoreCount =
78  "MM_TAFC_OptimizationCoreCount";
79 constexpr const std::string_view VERBOSE_PRINT_COUNT_THRESHOLD =
80  "TPETRA_VERBOSE_PRINT_COUNT_THRESHOLD";
81 constexpr const std::string_view ROW_IMBALANCE_THRESHOLD =
82  "TPETRA_ROW_IMBALANCE_THRESHOLD";
83 constexpr const std::string_view MULTIVECTOR_USE_MERGE_PATH =
84  "TPETRA_MULTIVECTOR_USE_MERGE_PATH";
85 constexpr const std::string_view VECTOR_DEVICE_THRESHOLD =
86  "TPETRA_VECTOR_DEVICE_THRESHOLD";
87 constexpr const std::string_view HIERARCHICAL_UNPACK_BATCH_SIZE =
88  "TPETRA_HIERARCHICAL_UNPACK_BATCH_SIZE";
89 constexpr const std::string_view HIERARCHICAL_UNPACK_TEAM_SIZE =
90  "TPETRA_HIERARCHICAL_UNPACK_TEAM_SIZE";
91 constexpr const std::string_view USE_TEUCHOS_TIMERS =
92  "TPETRA_USE_TEUCHOS_TIMERS";
93 constexpr const std::string_view USE_KOKKOS_PROFILING =
94  "TPETRA_USE_KOKKOS_PROFILING";
95 constexpr const std::string_view DEBUG = "TPETRA_DEBUG";
96 constexpr const std::string_view VERBOSE = "TPETRA_VERBOSE";
97 constexpr const std::string_view TIMING = "TPETRA_TIMING";
98 constexpr const std::string_view HIERARCHICAL_UNPACK =
99  "TPETRA_HIERARCHICAL_UNPACK";
100 constexpr const std::string_view SKIP_COPY_AND_PERMUTE =
101  "TPETRA_SKIP_COPY_AND_PERMUTE";
102 constexpr const std::string_view FUSED_RESIDUAL = "TPETRA_FUSED_RESIDUAL";
103 constexpr const std::string_view OVERLAP = "TPETRA_OVERLAP";
104 constexpr const std::string_view SPACES_ID_WARN_LIMIT =
105  "TPETRA_SPACES_ID_WARN_LIMIT";
106 constexpr const std::string_view TIME_KOKKOS_DEEP_COPY =
107  "TPETRA_TIME_KOKKOS_DEEP_COPY";
108 constexpr const std::string_view TIME_KOKKOS_DEEP_COPY_VERBOSE1 =
109  "TPETRA_TIME_KOKKOS_DEEP_COPY_VERBOSE1";
110 constexpr const std::string_view TIME_KOKKOS_DEEP_COPY_VERBOSE2 =
111  "TPETRA_TIME_KOKKOS_DEEP_COPY_VERBOSE2";
112 constexpr const std::string_view TIME_KOKKOS_FENCE = "TPETRA_TIME_KOKKOS_FENCE";
113 constexpr const std::string_view TIME_KOKKOS_FUNCTIONS =
114  "TPETRA_TIME_KOKKOS_FUNCTIONS";
115 
116 // construct an std::array of string_view with any number of provided
117 // string_views
118 template <typename... Elems>
119 constexpr std::array<std::string_view, sizeof...(Elems)>
120 make_array(Elems &&... elems) {
121  return {std::forward<Elems>(elems)...};
122 }
123 
124 constexpr const auto RECOGNIZED_VARS = make_array(
125  ASSUME_GPU_AWARE_MPI, CUDA_LAUNCH_BLOCKING, MM_TAFC_OptimizationCoreCount,
126  VERBOSE_PRINT_COUNT_THRESHOLD, ROW_IMBALANCE_THRESHOLD,
127  MULTIVECTOR_USE_MERGE_PATH, VECTOR_DEVICE_THRESHOLD,
128  HIERARCHICAL_UNPACK_BATCH_SIZE, HIERARCHICAL_UNPACK_TEAM_SIZE,
129  USE_TEUCHOS_TIMERS, USE_KOKKOS_PROFILING, DEBUG, VERBOSE, TIMING,
130  HIERARCHICAL_UNPACK, SKIP_COPY_AND_PERMUTE, FUSED_RESIDUAL, OVERLAP,
131  SPACES_ID_WARN_LIMIT, TIME_KOKKOS_DEEP_COPY, TIME_KOKKOS_DEEP_COPY_VERBOSE1,
132  TIME_KOKKOS_DEEP_COPY_VERBOSE2, TIME_KOKKOS_FENCE, TIME_KOKKOS_FUNCTIONS);
133 
134 // clang-format off
135 std::map<std::string, std::map<std::string, bool> > namedVariableMap_;
136 bool verboseDisabled_ = false;
137 bool timingDisabled_ = false;
138 }
139 
140 namespace { // (anonymous)
141 
142  enum EnvironmentVariableState
143  {
144  EnvironmentVariableIsSet_ON,
145  EnvironmentVariableIsSet_OFF,
146  EnvironmentVariableIsSet,
147  EnvironmentVariableIsNotSet
148  };
149 
150  // See example here:
151  //
152  // http://en.cppreference.com/w/cpp/string/byte/toupper
153  std::string stringToUpper (std::string s)
154  {
155  std::transform (s.begin (), s.end (), s.begin (),
156  [] (unsigned char c) { return std::toupper (c); });
157  return s;
158  }
159 
160  void
161  split(const std::string_view s,
162  std::function<void(const std::string&)> f,
163  const char sep=',')
164  {
165  typedef std::string::size_type size_type;
166  size_type cur_pos, last_pos=0, length=s.length();
167  while(last_pos < length + 1)
168  {
169  cur_pos = s.find_first_of(sep, last_pos);
170  if(cur_pos == std::string::npos)
171  {
172  cur_pos = length;
173  }
174  if(cur_pos!=last_pos) {
175  auto token = std::string(s.data()+last_pos, (size_type)cur_pos-last_pos);
176  f(token);
177  }
178  last_pos = cur_pos + 1;
179  }
180  return;
181  }
182 
183  EnvironmentVariableState
184  environmentVariableState(const std::string& environmentVariableValue)
185  {
186  std::string v = stringToUpper(environmentVariableValue);
187  if (v == "1" || v == "YES" || v == "TRUE" || v == "ON")
188  // Environment variable is "ON"
189  return EnvironmentVariableIsSet_ON;
190  else if (v == "0" || v == "NO" || v == "FALSE" || v == "OFF")
191  // Environment variable is "OFF"
192  return EnvironmentVariableIsSet_OFF;
193  // Environment has some other non-boolean value
194  return EnvironmentVariableIsSet;
195  }
196 
197  void
198  setEnvironmentVariableMap (const char environmentVariableName[],
199  std::map<std::string,std::map<std::string, bool> >& valsMap,
200  const bool defaultValue)
201  {
202  using std::map;
203  using std::getenv;
204  using std::string;
205  using std::vector;
206 
207  // Set the default value for this variable
208  valsMap[environmentVariableName] = map<string,bool>{{"DEFAULT", defaultValue}};
209 
210  const char* varVal = getenv (environmentVariableName);
211  if (varVal == nullptr) {
212  // Environment variable is not set, use the default value for any named
213  // variants
214  return;
215  }
216 
217  // Variable is not empty.
218  const string varStr(varVal);
219  vector<string> names;
220  split(varStr, [&](const string& x){names.push_back(x);});
221  for (auto const& name: names) {
222  auto state = environmentVariableState(name);
223  if (state == EnvironmentVariableIsSet_ON) {
224  // Environment variable was set as ENVAR_NAME=[1,YES,TRUE,ON]
225  // Global value takes precedence
226  valsMap[environmentVariableName]["DEFAULT"] = true;
227  }
228  else if (state == EnvironmentVariableIsSet_OFF) {
229  // Environment variable was set as ENVAR_NAME=[0,NO,FALSE,OFF]
230  // Global value takes precedence
231  valsMap[environmentVariableName]["DEFAULT"] = false;
232  }
233  else {
234  // Environment variable was set as ENVAR_NAME=...:name:...
235  // So we set the mapping true for this named variant
236  valsMap[environmentVariableName][name] = true;
237  }
238  }
239  return;
240  }
241 
242  bool
243  idempotentlyGetNamedEnvironmentVariableAsBool (const char name[],
244  bool& initialized,
245  const char environmentVariableName[],
246  const bool defaultValue)
247  {
248  using BehaviorDetails::namedVariableMap_;
249  if (! initialized) {
250  setEnvironmentVariableMap (environmentVariableName,
251  namedVariableMap_,
252  defaultValue);
253  initialized = true;
254  }
255  auto thisEnvironmentVariableMap = namedVariableMap_[environmentVariableName];
256  auto thisEnvironmentVariable = thisEnvironmentVariableMap.find(name);
257  if (thisEnvironmentVariable != thisEnvironmentVariableMap.end())
258  return thisEnvironmentVariable->second;
259  return thisEnvironmentVariableMap["DEFAULT"];
260  }
261 // clang-format on
262 
263 template <typename T>
264 T getEnvironmentVariable(const std::string_view environmentVariableName,
265  const T defaultValue) {
266  const char prefix[] = "Tpetra::Details::Behavior: ";
267 
268  const char *varVal = std::getenv(environmentVariableName.data());
269  if (varVal == nullptr) {
270  return defaultValue;
271  } else {
272  std::stringstream ss(varVal);
273  T parsed;
274  ss >> parsed;
275 
276  TEUCHOS_TEST_FOR_EXCEPTION(!ss, std::out_of_range,
277  prefix << "Environment "
278  "variable \""
279  << environmentVariableName
280  << "\" has a "
281  "value "
282  << varVal
283  << " that cannot be parsed as a "
284  << typeid(T).name() << ".");
285 
286  return parsed;
287  }
288 }
289 
290 // full specialization of bool to preserve historical Tpetra parsing behavior
291 template <>
292 bool getEnvironmentVariable<bool>(
293  const std::string_view environmentVariableName, const bool defaultValue) {
294  const char *varVal = std::getenv(environmentVariableName.data());
295  bool retVal = defaultValue;
296  if (varVal != nullptr) {
297  auto state = environmentVariableState(std::string(varVal));
298  if (state == EnvironmentVariableIsSet_ON)
299  retVal = true;
300  else if (state == EnvironmentVariableIsSet_OFF)
301  retVal = false;
302  }
303  return retVal;
304 }
305 
311 template <>
312 size_t
313 getEnvironmentVariable<size_t>(const std::string_view environmentVariableName,
314  const size_t defaultValue) {
315  const char prefix[] = "Tpetra::Details::Behavior: ";
316 
317  const char *varVal = std::getenv(environmentVariableName.data());
318  if (varVal == nullptr) {
319  return defaultValue;
320  } else {
321  long long val = std::stoll(stringToUpper(varVal));
322  if (val < static_cast<long long>(0)) {
323  // If negative - user has requested threshold be lifted
324  return std::numeric_limits<size_t>::max();
325  }
326  if (sizeof(long long) > sizeof(size_t)) {
327  // It's hard to test this code, but I want to try writing it
328  // at least, in case we ever have to run on 32-bit machines or
329  // machines with sizeof(long long)=16 and sizeof(size_t)=8.
330  constexpr long long maxSizeT =
331  static_cast<long long>(std::numeric_limits<size_t>::max());
332  TEUCHOS_TEST_FOR_EXCEPTION(
333  val > maxSizeT, std::out_of_range,
334  prefix << "Environment "
335  "variable \""
336  << environmentVariableName
337  << "\" has a "
338  "value "
339  << val << " larger than the largest size_t value " << maxSizeT
340  << ".");
341  }
342  return static_cast<size_t>(val);
343  }
344 }
345 
346 template <typename T>
347 T idempotentlyGetEnvironmentVariable(
348  T &value, bool &initialized, const std::string_view environmentVariableName,
349  const T defaultValue) {
350  if (!initialized) {
351  value = getEnvironmentVariable<T>(environmentVariableName, defaultValue);
352  initialized = true;
353  }
354  return value;
355 }
356 
357 // clang-format off
358  constexpr bool debugDefault () {
359 #ifdef HAVE_TPETRA_DEBUG
360  return true;
361 #else
362  return false;
363 #endif // HAVE_TPETRA_DEBUG
364  }
365 
366  constexpr bool verboseDefault () {
367  return false;
368  }
369 
370  constexpr bool timingDefault () {
371  return false;
372  }
373 
374  constexpr bool assumeMpiIsGPUAwareDefault () {
375 #ifdef TPETRA_ASSUME_GPU_AWARE_MPI
376  return true;
377 #else
378  return false;
379 #endif // TPETRA_ASSUME_GPU_AWARE_MPI
380  }
381 
382  constexpr bool cudaLaunchBlockingDefault () {
383  return false;
384  }
385 
386  constexpr bool hierarchicalUnpackDefault () {
387  return true;
388  }
389 
390 } // namespace (anonymous)
391 // clang-format on
392 
394 
395  static bool once = false;
396 
397  if (!once) {
398  const char prefix[] = "Tpetra::Details::Behavior: ";
399  char **env;
400 #if defined(WIN) && (_MSC_VER >= 1900)
401  env = *__p__environ();
402 #else
403  env = environ; // defined at the top of this file as extern char **environ;
404 #endif
405  for (; *env; ++env) {
406 
407  std::string name;
408  std::string value;
409  const std::string_view ev(*env);
410 
411  // split name=value on the first =, everything before = is name
412  split(
413  ev,
414  [&](const std::string &s) {
415  if (name.empty()) {
416  name = s;
417  } else {
418  value = s;
419  }
420  },
421  '=');
422 
423  if (name.size() >= BehaviorDetails::RESERVED_PREFIX.size() &&
424  name.substr(0, BehaviorDetails::RESERVED_PREFIX.size()) ==
425  BehaviorDetails::RESERVED_PREFIX) {
426  const auto it = std::find(BehaviorDetails::RECOGNIZED_VARS.begin(),
427  BehaviorDetails::RECOGNIZED_VARS.end(), name);
428  TEUCHOS_TEST_FOR_EXCEPTION(
429  it == BehaviorDetails::RECOGNIZED_VARS.end(), std::out_of_range,
430  prefix << "Environment "
431  "variable \""
432  << name << "\" (prefixed with \""
433  << BehaviorDetails::RESERVED_PREFIX
434  << "\") is not a recognized Tpetra variable.");
435  }
436  }
437 
438  once = true;
439  }
440 }
441 
443  constexpr bool defaultValue = debugDefault();
444 
445  static bool value_ = defaultValue;
446  static bool initialized_ = false;
447  return idempotentlyGetEnvironmentVariable(
448  value_, initialized_, BehaviorDetails::DEBUG, defaultValue);
449 }
450 
452  if (BehaviorDetails::verboseDisabled_)
453  return false;
454 
455  constexpr bool defaultValue = verboseDefault();
456 
457  static bool value_ = defaultValue;
458  static bool initialized_ = false;
459  return idempotentlyGetEnvironmentVariable(
460  value_, initialized_, BehaviorDetails::VERBOSE, defaultValue);
461 }
462 
464  if (BehaviorDetails::timingDisabled_)
465  return false;
466 
467  constexpr bool defaultValue = timingDefault();
468 
469  static bool value_ = defaultValue;
470  static bool initialized_ = false;
471  return idempotentlyGetEnvironmentVariable(
472  value_, initialized_, BehaviorDetails::TIMING, defaultValue);
473 }
474 
476  constexpr bool defaultValue = assumeMpiIsGPUAwareDefault();
477 
478  static bool value_ = defaultValue;
479  static bool initialized_ = false;
480  return idempotentlyGetEnvironmentVariable(
481  value_, initialized_, BehaviorDetails::ASSUME_GPU_AWARE_MPI,
482  defaultValue);
483 }
484 
486  constexpr bool defaultValue = cudaLaunchBlockingDefault();
487 
488  static bool value_ = defaultValue;
489  static bool initialized_ = false;
490  return idempotentlyGetEnvironmentVariable(
491  value_, initialized_, BehaviorDetails::CUDA_LAUNCH_BLOCKING,
492  defaultValue);
493 }
494 
496  constexpr int _default = 3000;
497  static int value_ = _default;
498  static bool initialized_ = false;
499  return idempotentlyGetEnvironmentVariable(
500  value_, initialized_, BehaviorDetails::MM_TAFC_OptimizationCoreCount,
501  _default);
502 }
503 
505  constexpr size_t defaultValue(200);
506 
507  static size_t value_ = defaultValue;
508  static bool initialized_ = false;
509  return idempotentlyGetEnvironmentVariable(
510  value_, initialized_, BehaviorDetails::VERBOSE_PRINT_COUNT_THRESHOLD,
511  defaultValue);
512 }
513 
515  constexpr size_t defaultValue(256);
516 
517  static size_t value_ = defaultValue;
518  static bool initialized_ = false;
519  return idempotentlyGetEnvironmentVariable(
520  value_, initialized_, BehaviorDetails::ROW_IMBALANCE_THRESHOLD,
521  defaultValue);
522 }
523 
525  constexpr bool defaultValue = false;
526 
527  static bool value_ = defaultValue;
528  static bool initialized_ = false;
529  return idempotentlyGetEnvironmentVariable(
530  value_, initialized_, BehaviorDetails::MULTIVECTOR_USE_MERGE_PATH,
531  defaultValue);
532 }
533 
535  constexpr size_t defaultValue(22000);
536 
537  static size_t value_ = defaultValue;
538  static bool initialized_ = false;
539  return idempotentlyGetEnvironmentVariable(
540  value_, initialized_, BehaviorDetails::VECTOR_DEVICE_THRESHOLD,
541  defaultValue);
542 }
543 
545 
546 #ifdef HAVE_TPETRA_INST_CUDA
547  constexpr size_t defaultValue(16);
548 #else
549  constexpr size_t defaultValue(256);
550 #endif
551 
552  static size_t value_ = defaultValue;
553  static bool initialized_ = false;
554  return idempotentlyGetEnvironmentVariable(
555  value_, initialized_, BehaviorDetails::HIERARCHICAL_UNPACK_BATCH_SIZE,
556  defaultValue);
557 }
558 
560 #ifdef HAVE_TPETRA_INST_CUDA
561  const size_t defaultValue(16);
562 #else
563  const size_t defaultValue(Teuchos::OrdinalTraits<size_t>::invalid());
564 #endif
565 
566  static size_t value_ = defaultValue;
567  static bool initialized_ = false;
568  return idempotentlyGetEnvironmentVariable(
569  value_, initialized_, BehaviorDetails::HIERARCHICAL_UNPACK_TEAM_SIZE,
570  defaultValue);
571 }
572 
574  constexpr bool defaultValue(false);
575 
576  static bool value_ = defaultValue;
577  static bool initialized_ = false;
578  return idempotentlyGetEnvironmentVariable(
579  value_, initialized_, BehaviorDetails::USE_TEUCHOS_TIMERS, defaultValue);
580 }
581 
583  constexpr bool defaultValue(false);
584 
585  static bool value_ = defaultValue;
586  static bool initialized_ = false;
587  return idempotentlyGetEnvironmentVariable(
588  value_, initialized_, BehaviorDetails::USE_KOKKOS_PROFILING,
589  defaultValue);
590 }
591 
592 bool Behavior::debug(const char name[]) {
593  constexpr bool defaultValue = false;
594 
595  static bool initialized_ = false;
596  return idempotentlyGetNamedEnvironmentVariableAsBool(
597  name, initialized_, BehaviorDetails::DEBUG.data(), defaultValue);
598 }
599 
600 bool Behavior::verbose(const char name[]) {
601  if (BehaviorDetails::verboseDisabled_)
602  return false;
603 
604  constexpr bool defaultValue = false;
605 
606  static bool initialized_ = false;
607  return idempotentlyGetNamedEnvironmentVariableAsBool(
608  name, initialized_, BehaviorDetails::VERBOSE.data(), defaultValue);
609 }
610 
612  BehaviorDetails::verboseDisabled_ = false;
613 }
614 
616  BehaviorDetails::verboseDisabled_ = true;
617 }
618 
619 bool Behavior::timing(const char name[]) {
620  if (BehaviorDetails::timingDisabled_)
621  return false;
622 
623  constexpr bool defaultValue = false;
624 
625  static bool initialized_ = false;
626  return idempotentlyGetNamedEnvironmentVariableAsBool(
627  name, initialized_, BehaviorDetails::TIMING.data(), defaultValue);
628 }
629 
630 void Behavior::enable_timing() { BehaviorDetails::timingDisabled_ = false; }
631 
632 void Behavior::disable_timing() { BehaviorDetails::timingDisabled_ = true; }
633 
635  constexpr bool defaultValue = hierarchicalUnpackDefault();
636 
637  static bool value_ = defaultValue;
638  static bool initialized_ = false;
639  return idempotentlyGetEnvironmentVariable(
640  value_, initialized_, BehaviorDetails::HIERARCHICAL_UNPACK, defaultValue);
641 }
642 
644  constexpr bool defaultValue(false);
645 
646  static bool value_ = defaultValue;
647  static bool initialized_ = false;
648  return idempotentlyGetEnvironmentVariable(
649  value_, initialized_, BehaviorDetails::SKIP_COPY_AND_PERMUTE,
650  defaultValue);
651 }
652 
654 #if defined(KOKKOSKERNELS_ENABLE_TPL_CUSPARSE) || \
655  defined(KOKKOSKERNELS_ENABLE_TPL_ROCSPARSE) || \
656  defined(KOKKOSKERNELS_ENABLE_TPL_MKL)
657  constexpr bool defaultValue(false);
658 #else
659  constexpr bool defaultValue(true);
660 #endif
661 
662  static bool value_ = defaultValue;
663  static bool initialized_ = false;
664  return idempotentlyGetEnvironmentVariable(
665  value_, initialized_, BehaviorDetails::FUSED_RESIDUAL, defaultValue);
666 }
667 
669  constexpr bool defaultValue(false);
670 
671  static bool value_ = defaultValue;
672  static bool initialized_ = false;
673  return idempotentlyGetEnvironmentVariable(
674  value_, initialized_, BehaviorDetails::OVERLAP, defaultValue);
675 }
676 
678  constexpr size_t defaultValue(16);
679 
680  static size_t value_ = defaultValue;
681  static bool initialized_ = false;
682  return idempotentlyGetEnvironmentVariable(
683  value_, initialized_, BehaviorDetails::SPACES_ID_WARN_LIMIT,
684  defaultValue);
685 }
686 
688  constexpr bool defaultValue(false);
689 
690  static bool value_ = defaultValue;
691  static bool initialized_ = false;
692  return idempotentlyGetEnvironmentVariable(
693  value_, initialized_, BehaviorDetails::TIME_KOKKOS_DEEP_COPY,
694  defaultValue);
695 }
696 
698  constexpr bool defaultValue(false);
699 
700  static bool value_ = defaultValue;
701  static bool initialized_ = false;
702  return idempotentlyGetEnvironmentVariable(
703  value_, initialized_, BehaviorDetails::TIME_KOKKOS_DEEP_COPY_VERBOSE1,
704  defaultValue);
705 }
706 
708  constexpr bool defaultValue(false);
709 
710  static bool value_ = defaultValue;
711  static bool initialized_ = false;
712  return idempotentlyGetEnvironmentVariable(
713  value_, initialized_, BehaviorDetails::TIME_KOKKOS_DEEP_COPY_VERBOSE2,
714  defaultValue);
715 }
716 
718  constexpr bool defaultValue(false);
719 
720  static bool value_ = defaultValue;
721  static bool initialized_ = false;
722  return idempotentlyGetEnvironmentVariable(
723  value_, initialized_, BehaviorDetails::TIME_KOKKOS_FENCE, defaultValue);
724 }
725 
727  constexpr bool defaultValue(false);
728 
729  static bool value_ = defaultValue;
730  static bool initialized_ = false;
731  return idempotentlyGetEnvironmentVariable(
732  value_, initialized_, BehaviorDetails::TIME_KOKKOS_FUNCTIONS,
733  defaultValue);
734 }
735 
736 } // namespace Details
737 } // namespace Tpetra
static bool useMergePathMultiVector()
Whether to use the cuSPARSE merge path algorithm to perform sparse matrix-multivector products...
static int TAFC_OptimizationCoreCount()
MPI process count above which Tpetra::CrsMatrix::transferAndFillComplete will attempt to do advanced ...
static bool overlapCommunicationAndComputation()
Overlap communication and computation.
static bool timing()
Whether Tpetra is in timing mode.
static void disable_verbose_behavior()
Disable verbose mode, programatically.
static size_t multivectorKernelLocationThreshold()
the threshold for transitioning from device to host
static bool assumeMpiIsGPUAware()
Whether to assume that MPI is CUDA aware.
static size_t spacesIdWarnLimit()
Warn if more than this many Kokkos spaces are accessed.
static bool debug()
Whether Tpetra is in debug mode.
static size_t hierarchicalUnpackTeamSize()
Size of team for hierarchical unpacking.
static void reject_unrecognized_env_vars()
Search the environment for TPETRA_ variables and reject unrecognized ones.
static bool timeKokkosFunctions()
Add Teuchos timers for all host calls to Kokkos::parallel_for(), Kokkos::parallel_reduce() and Kokkos...
static bool fusedResidual()
Fusing SpMV and update in residual instead of using 2 kernel launches. Fusing kernels implies that no...
static bool profilingRegionUseTeuchosTimers()
Use Teuchos::Timer in Tpetra::ProfilingRegion.
static void disable_timing()
Disable timing, programatically.
static bool hierarchicalUnpack()
Unpack rows of a matrix using hierarchical unpacking.
static void enable_timing()
Enable timing, programatically.
static bool verbose()
Whether Tpetra is in verbose mode.
static size_t rowImbalanceThreshold()
Threshold for deciding if a local matrix is &quot;imbalanced&quot; in the number of entries per row...
static size_t hierarchicalUnpackBatchSize()
Size of batch for hierarchical unpacking.
static bool timeKokkosDeepCopyVerbose2()
Adds verbose output to Kokkos deep_copy timers by appending source, destination, and size...
static bool timeKokkosDeepCopyVerbose1()
Adds verbose output to Kokkos deep_copy timers by appending source and destination. This is especially useful for identifying host/device data transfers.
static bool skipCopyAndPermuteIfPossible()
Skip copyAndPermute if possible.
static void enable_verbose_behavior()
Enable verbose mode, programatically.
static size_t verbosePrintCountThreshold()
Number of entries below which arrays, lists, etc. will be printed in debug mode.
static bool timeKokkosFence()
Add Teuchos timers for all host calls to Kokkos::fence().
static bool cudaLaunchBlocking()
Whether the CUDA_LAUNCH_BLOCKING environment variable has been set.
static bool timeKokkosDeepCopy()
Add Teuchos timers for all host calls to Kokkos::deep_copy(). This is especially useful for identifyi...
static bool profilingRegionUseKokkosProfiling()
Use Kokkos::Profiling in Tpetra::ProfilingRegion.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra&#39;s behavior.