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 DEFAULT_SEND_TYPE = "TPETRA_DEFAULT_SEND_TYPE";
105 constexpr const std::string_view GRANULAR_TRANSFERS = "TPETRA_GRANULAR_TRANSFERS";
106 constexpr const std::string_view SPACES_ID_WARN_LIMIT =
107  "TPETRA_SPACES_ID_WARN_LIMIT";
108 constexpr const std::string_view TIME_KOKKOS_DEEP_COPY =
109  "TPETRA_TIME_KOKKOS_DEEP_COPY";
110 constexpr const std::string_view TIME_KOKKOS_DEEP_COPY_VERBOSE1 =
111  "TPETRA_TIME_KOKKOS_DEEP_COPY_VERBOSE1";
112 constexpr const std::string_view TIME_KOKKOS_DEEP_COPY_VERBOSE2 =
113  "TPETRA_TIME_KOKKOS_DEEP_COPY_VERBOSE2";
114 constexpr const std::string_view TIME_KOKKOS_FENCE = "TPETRA_TIME_KOKKOS_FENCE";
115 constexpr const std::string_view TIME_KOKKOS_FUNCTIONS =
116  "TPETRA_TIME_KOKKOS_FUNCTIONS";
117 
118 // construct an std::array of string_view with any number of provided
119 // string_views
120 template <typename... Elems>
121 constexpr std::array<std::string_view, sizeof...(Elems)>
122 make_array(Elems &&... elems) {
123  return {std::forward<Elems>(elems)...};
124 }
125 
126 constexpr const auto RECOGNIZED_VARS = make_array(
127  ASSUME_GPU_AWARE_MPI, CUDA_LAUNCH_BLOCKING, MM_TAFC_OptimizationCoreCount,
128  VERBOSE_PRINT_COUNT_THRESHOLD, ROW_IMBALANCE_THRESHOLD,
129  MULTIVECTOR_USE_MERGE_PATH, VECTOR_DEVICE_THRESHOLD,
130  HIERARCHICAL_UNPACK_BATCH_SIZE, HIERARCHICAL_UNPACK_TEAM_SIZE,
131  USE_TEUCHOS_TIMERS, USE_KOKKOS_PROFILING, DEBUG, VERBOSE, TIMING,
132  HIERARCHICAL_UNPACK, SKIP_COPY_AND_PERMUTE, FUSED_RESIDUAL, OVERLAP,
133  DEFAULT_SEND_TYPE, GRANULAR_TRANSFERS,
134  SPACES_ID_WARN_LIMIT, TIME_KOKKOS_DEEP_COPY, TIME_KOKKOS_DEEP_COPY_VERBOSE1,
135  TIME_KOKKOS_DEEP_COPY_VERBOSE2, TIME_KOKKOS_FENCE, TIME_KOKKOS_FUNCTIONS);
136 
137 // clang-format off
138 std::map<std::string, std::map<std::string, bool> > namedVariableMap_;
139 bool verboseDisabled_ = false;
140 bool timingDisabled_ = false;
141 }
142 
143 namespace { // (anonymous)
144 
145  enum EnvironmentVariableState
146  {
147  EnvironmentVariableIsSet_ON,
148  EnvironmentVariableIsSet_OFF,
149  EnvironmentVariableIsSet,
150  EnvironmentVariableIsNotSet
151  };
152 
153  // See example here:
154  //
155  // http://en.cppreference.com/w/cpp/string/byte/toupper
156  std::string stringToUpper (std::string s)
157  {
158  std::transform (s.begin (), s.end (), s.begin (),
159  [] (unsigned char c) { return std::toupper (c); });
160  return s;
161  }
162 
163  void
164  split(const std::string_view s,
165  std::function<void(const std::string&)> f,
166  const char sep=',')
167  {
168  typedef std::string::size_type size_type;
169  size_type cur_pos, last_pos=0, length=s.length();
170  while(last_pos < length + 1)
171  {
172  cur_pos = s.find_first_of(sep, last_pos);
173  if(cur_pos == std::string::npos)
174  {
175  cur_pos = length;
176  }
177  if(cur_pos!=last_pos) {
178  auto token = std::string(s.data()+last_pos, (size_type)cur_pos-last_pos);
179  f(token);
180  }
181  last_pos = cur_pos + 1;
182  }
183  return;
184  }
185 
186  EnvironmentVariableState
187  environmentVariableState(const std::string& environmentVariableValue)
188  {
189  std::string v = stringToUpper(environmentVariableValue);
190  if (v == "1" || v == "YES" || v == "TRUE" || v == "ON")
191  // Environment variable is "ON"
192  return EnvironmentVariableIsSet_ON;
193  else if (v == "0" || v == "NO" || v == "FALSE" || v == "OFF")
194  // Environment variable is "OFF"
195  return EnvironmentVariableIsSet_OFF;
196  // Environment has some other non-boolean value
197  return EnvironmentVariableIsSet;
198  }
199 
200  void
201  setEnvironmentVariableMap (const char environmentVariableName[],
202  std::map<std::string,std::map<std::string, bool> >& valsMap,
203  const bool defaultValue)
204  {
205  using std::map;
206  using std::getenv;
207  using std::string;
208  using std::vector;
209 
210  // Set the default value for this variable
211  valsMap[environmentVariableName] = map<string,bool>{{"DEFAULT", defaultValue}};
212 
213  const char* varVal = getenv (environmentVariableName);
214  if (varVal == nullptr) {
215  // Environment variable is not set, use the default value for any named
216  // variants
217  return;
218  }
219 
220  // Variable is not empty.
221  const string varStr(varVal);
222  vector<string> names;
223  split(varStr, [&](const string& x){names.push_back(x);});
224  for (auto const& name: names) {
225  auto state = environmentVariableState(name);
226  if (state == EnvironmentVariableIsSet_ON) {
227  // Environment variable was set as ENVAR_NAME=[1,YES,TRUE,ON]
228  // Global value takes precedence
229  valsMap[environmentVariableName]["DEFAULT"] = true;
230  }
231  else if (state == EnvironmentVariableIsSet_OFF) {
232  // Environment variable was set as ENVAR_NAME=[0,NO,FALSE,OFF]
233  // Global value takes precedence
234  valsMap[environmentVariableName]["DEFAULT"] = false;
235  }
236  else {
237  // Environment variable was set as ENVAR_NAME=...:name:...
238  // So we set the mapping true for this named variant
239  valsMap[environmentVariableName][name] = true;
240  }
241  }
242  return;
243  }
244 
245  bool
246  idempotentlyGetNamedEnvironmentVariableAsBool (const char name[],
247  bool& initialized,
248  const char environmentVariableName[],
249  const bool defaultValue)
250  {
251  using BehaviorDetails::namedVariableMap_;
252  if (! initialized) {
253  setEnvironmentVariableMap (environmentVariableName,
254  namedVariableMap_,
255  defaultValue);
256  initialized = true;
257  }
258  auto thisEnvironmentVariableMap = namedVariableMap_[environmentVariableName];
259  auto thisEnvironmentVariable = thisEnvironmentVariableMap.find(name);
260  if (thisEnvironmentVariable != thisEnvironmentVariableMap.end())
261  return thisEnvironmentVariable->second;
262  return thisEnvironmentVariableMap["DEFAULT"];
263  }
264 // clang-format on
265 
266 template <typename T>
267 T getEnvironmentVariable(const std::string_view environmentVariableName,
268  const T defaultValue) {
269  const char prefix[] = "Tpetra::Details::Behavior: ";
270 
271  const char *varVal = std::getenv(environmentVariableName.data());
272  if (varVal == nullptr) {
273  return defaultValue;
274  } else {
275  std::stringstream ss(varVal);
276  T parsed;
277  ss >> parsed;
278 
279  TEUCHOS_TEST_FOR_EXCEPTION(!ss, std::out_of_range,
280  prefix << "Environment "
281  "variable \""
282  << environmentVariableName
283  << "\" has a "
284  "value "
285  << varVal
286  << " that cannot be parsed as a "
287  << typeid(T).name() << ".");
288 
289  return parsed;
290  }
291 }
292 
293 // full specialization of bool to preserve historical Tpetra parsing behavior
294 template <>
295 bool getEnvironmentVariable<bool>(
296  const std::string_view environmentVariableName, const bool defaultValue) {
297  const char *varVal = std::getenv(environmentVariableName.data());
298  bool retVal = defaultValue;
299  if (varVal != nullptr) {
300  auto state = environmentVariableState(std::string(varVal));
301  if (state == EnvironmentVariableIsSet_ON)
302  retVal = true;
303  else if (state == EnvironmentVariableIsSet_OFF)
304  retVal = false;
305  }
306  return retVal;
307 }
308 
314 template <>
315 size_t
316 getEnvironmentVariable<size_t>(const std::string_view environmentVariableName,
317  const size_t defaultValue) {
318  const char prefix[] = "Tpetra::Details::Behavior: ";
319 
320  const char *varVal = std::getenv(environmentVariableName.data());
321  if (varVal == nullptr) {
322  return defaultValue;
323  } else {
324  long long val = std::stoll(stringToUpper(varVal));
325  if (val < static_cast<long long>(0)) {
326  // If negative - user has requested threshold be lifted
327  return std::numeric_limits<size_t>::max();
328  }
329  if (sizeof(long long) > sizeof(size_t)) {
330  // It's hard to test this code, but I want to try writing it
331  // at least, in case we ever have to run on 32-bit machines or
332  // machines with sizeof(long long)=16 and sizeof(size_t)=8.
333  constexpr long long maxSizeT =
334  static_cast<long long>(std::numeric_limits<size_t>::max());
335  TEUCHOS_TEST_FOR_EXCEPTION(
336  val > maxSizeT, std::out_of_range,
337  prefix << "Environment "
338  "variable \""
339  << environmentVariableName
340  << "\" has a "
341  "value "
342  << val << " larger than the largest size_t value " << maxSizeT
343  << ".");
344  }
345  return static_cast<size_t>(val);
346  }
347 }
348 
349 template <typename T>
350 T idempotentlyGetEnvironmentVariable(
351  T &value, bool &initialized, const std::string_view environmentVariableName,
352  const T defaultValue) {
353  if (!initialized) {
354  value = getEnvironmentVariable<T>(environmentVariableName, defaultValue);
355  initialized = true;
356  }
357  return value;
358 }
359 
360 // clang-format off
361  constexpr bool debugDefault () {
362 #ifdef HAVE_TPETRA_DEBUG
363  return true;
364 #else
365  return false;
366 #endif // HAVE_TPETRA_DEBUG
367  }
368 
369  constexpr bool verboseDefault () {
370  return false;
371  }
372 
373  constexpr bool timingDefault () {
374  return false;
375  }
376 
377  constexpr bool assumeMpiIsGPUAwareDefault () {
378 #ifdef TPETRA_ASSUME_GPU_AWARE_MPI
379  return true;
380 #else
381  return false;
382 #endif // TPETRA_ASSUME_GPU_AWARE_MPI
383  }
384 
385  constexpr bool cudaLaunchBlockingDefault () {
386  return false;
387  }
388 
389  constexpr bool hierarchicalUnpackDefault () {
390  return true;
391  }
392 
393 } // namespace (anonymous)
394 // clang-format on
395 
397 
398  static bool once = false;
399 
400  if (!once) {
401  const char prefix[] = "Tpetra::Details::Behavior: ";
402  char **env;
403 #if defined(WIN) && (_MSC_VER >= 1900)
404  env = *__p__environ();
405 #else
406  env = environ; // defined at the top of this file as extern char **environ;
407 #endif
408  for (; *env; ++env) {
409 
410  std::string name;
411  std::string value;
412  const std::string_view ev(*env);
413 
414  // split name=value on the first =, everything before = is name
415  split(
416  ev,
417  [&](const std::string &s) {
418  if (name.empty()) {
419  name = s;
420  } else {
421  value = s;
422  }
423  },
424  '=');
425 
426  if (name.size() >= BehaviorDetails::RESERVED_PREFIX.size() &&
427  name.substr(0, BehaviorDetails::RESERVED_PREFIX.size()) ==
428  BehaviorDetails::RESERVED_PREFIX) {
429  const auto it = std::find(BehaviorDetails::RECOGNIZED_VARS.begin(),
430  BehaviorDetails::RECOGNIZED_VARS.end(), name);
431  TEUCHOS_TEST_FOR_EXCEPTION(
432  it == BehaviorDetails::RECOGNIZED_VARS.end(), std::out_of_range,
433  prefix << "Environment "
434  "variable \""
435  << name << "\" (prefixed with \""
436  << BehaviorDetails::RESERVED_PREFIX
437  << "\") is not a recognized Tpetra variable.");
438  }
439  }
440 
441  once = true;
442  }
443 }
444 
446  constexpr bool defaultValue = debugDefault();
447 
448  static bool value_ = defaultValue;
449  static bool initialized_ = false;
450  return idempotentlyGetEnvironmentVariable(
451  value_, initialized_, BehaviorDetails::DEBUG, defaultValue);
452 }
453 
455  if (BehaviorDetails::verboseDisabled_)
456  return false;
457 
458  constexpr bool defaultValue = verboseDefault();
459 
460  static bool value_ = defaultValue;
461  static bool initialized_ = false;
462  return idempotentlyGetEnvironmentVariable(
463  value_, initialized_, BehaviorDetails::VERBOSE, defaultValue);
464 }
465 
467  if (BehaviorDetails::timingDisabled_)
468  return false;
469 
470  constexpr bool defaultValue = timingDefault();
471 
472  static bool value_ = defaultValue;
473  static bool initialized_ = false;
474  return idempotentlyGetEnvironmentVariable(
475  value_, initialized_, BehaviorDetails::TIMING, defaultValue);
476 }
477 
479  constexpr bool defaultValue = assumeMpiIsGPUAwareDefault();
480 
481  static bool value_ = defaultValue;
482  static bool initialized_ = false;
483  return idempotentlyGetEnvironmentVariable(
484  value_, initialized_, BehaviorDetails::ASSUME_GPU_AWARE_MPI,
485  defaultValue);
486 }
487 
489  constexpr bool defaultValue = cudaLaunchBlockingDefault();
490 
491  static bool value_ = defaultValue;
492  static bool initialized_ = false;
493  return idempotentlyGetEnvironmentVariable(
494  value_, initialized_, BehaviorDetails::CUDA_LAUNCH_BLOCKING,
495  defaultValue);
496 }
497 
499  constexpr int _default = 3000;
500  static int value_ = _default;
501  static bool initialized_ = false;
502  return idempotentlyGetEnvironmentVariable(
503  value_, initialized_, BehaviorDetails::MM_TAFC_OptimizationCoreCount,
504  _default);
505 }
506 
508  constexpr size_t defaultValue(200);
509 
510  static size_t value_ = defaultValue;
511  static bool initialized_ = false;
512  return idempotentlyGetEnvironmentVariable(
513  value_, initialized_, BehaviorDetails::VERBOSE_PRINT_COUNT_THRESHOLD,
514  defaultValue);
515 }
516 
518  constexpr size_t defaultValue(256);
519 
520  static size_t value_ = defaultValue;
521  static bool initialized_ = false;
522  return idempotentlyGetEnvironmentVariable(
523  value_, initialized_, BehaviorDetails::ROW_IMBALANCE_THRESHOLD,
524  defaultValue);
525 }
526 
528  constexpr bool defaultValue = false;
529 
530  static bool value_ = defaultValue;
531  static bool initialized_ = false;
532  return idempotentlyGetEnvironmentVariable(
533  value_, initialized_, BehaviorDetails::MULTIVECTOR_USE_MERGE_PATH,
534  defaultValue);
535 }
536 
538  constexpr size_t defaultValue(22000);
539 
540  static size_t value_ = defaultValue;
541  static bool initialized_ = false;
542  return idempotentlyGetEnvironmentVariable(
543  value_, initialized_, BehaviorDetails::VECTOR_DEVICE_THRESHOLD,
544  defaultValue);
545 }
546 
548 
549 #ifdef HAVE_TPETRA_INST_CUDA
550  constexpr size_t defaultValue(16);
551 #else
552  constexpr size_t defaultValue(256);
553 #endif
554 
555  static size_t value_ = defaultValue;
556  static bool initialized_ = false;
557  return idempotentlyGetEnvironmentVariable(
558  value_, initialized_, BehaviorDetails::HIERARCHICAL_UNPACK_BATCH_SIZE,
559  defaultValue);
560 }
561 
563 #ifdef HAVE_TPETRA_INST_CUDA
564  const size_t defaultValue(16);
565 #else
566  const size_t defaultValue(Teuchos::OrdinalTraits<size_t>::invalid());
567 #endif
568 
569  static size_t value_ = defaultValue;
570  static bool initialized_ = false;
571  return idempotentlyGetEnvironmentVariable(
572  value_, initialized_, BehaviorDetails::HIERARCHICAL_UNPACK_TEAM_SIZE,
573  defaultValue);
574 }
575 
577  constexpr bool defaultValue(false);
578 
579  static bool value_ = defaultValue;
580  static bool initialized_ = false;
581  return idempotentlyGetEnvironmentVariable(
582  value_, initialized_, BehaviorDetails::USE_TEUCHOS_TIMERS, defaultValue);
583 }
584 
586  constexpr bool defaultValue(false);
587 
588  static bool value_ = defaultValue;
589  static bool initialized_ = false;
590  return idempotentlyGetEnvironmentVariable(
591  value_, initialized_, BehaviorDetails::USE_KOKKOS_PROFILING,
592  defaultValue);
593 }
594 
595 bool Behavior::debug(const char name[]) {
596  constexpr bool defaultValue = false;
597 
598  static bool initialized_ = false;
599  return idempotentlyGetNamedEnvironmentVariableAsBool(
600  name, initialized_, BehaviorDetails::DEBUG.data(), defaultValue);
601 }
602 
603 bool Behavior::verbose(const char name[]) {
604  if (BehaviorDetails::verboseDisabled_)
605  return false;
606 
607  constexpr bool defaultValue = false;
608 
609  static bool initialized_ = false;
610  return idempotentlyGetNamedEnvironmentVariableAsBool(
611  name, initialized_, BehaviorDetails::VERBOSE.data(), defaultValue);
612 }
613 
615  BehaviorDetails::verboseDisabled_ = false;
616 }
617 
619  BehaviorDetails::verboseDisabled_ = true;
620 }
621 
622 bool Behavior::timing(const char name[]) {
623  if (BehaviorDetails::timingDisabled_)
624  return false;
625 
626  constexpr bool defaultValue = false;
627 
628  static bool initialized_ = false;
629  return idempotentlyGetNamedEnvironmentVariableAsBool(
630  name, initialized_, BehaviorDetails::TIMING.data(), defaultValue);
631 }
632 
633 void Behavior::enable_timing() { BehaviorDetails::timingDisabled_ = false; }
634 
635 void Behavior::disable_timing() { BehaviorDetails::timingDisabled_ = true; }
636 
638  constexpr bool defaultValue = hierarchicalUnpackDefault();
639 
640  static bool value_ = defaultValue;
641  static bool initialized_ = false;
642  return idempotentlyGetEnvironmentVariable(
643  value_, initialized_, BehaviorDetails::HIERARCHICAL_UNPACK, defaultValue);
644 }
645 
647  constexpr bool defaultValue(false);
648 
649  static bool value_ = defaultValue;
650  static bool initialized_ = false;
651  return idempotentlyGetEnvironmentVariable(
652  value_, initialized_, BehaviorDetails::SKIP_COPY_AND_PERMUTE,
653  defaultValue);
654 }
655 
657 #if defined(KOKKOSKERNELS_ENABLE_TPL_CUSPARSE) || \
658  defined(KOKKOSKERNELS_ENABLE_TPL_ROCSPARSE) || \
659  defined(KOKKOSKERNELS_ENABLE_TPL_MKL)
660  constexpr bool defaultValue(false);
661 #else
662  constexpr bool defaultValue(true);
663 #endif
664 
665  static bool value_ = defaultValue;
666  static bool initialized_ = false;
667  return idempotentlyGetEnvironmentVariable(
668  value_, initialized_, BehaviorDetails::FUSED_RESIDUAL, defaultValue);
669 }
670 
672  constexpr bool defaultValue(false);
673 
674  static bool value_ = defaultValue;
675  static bool initialized_ = false;
676  return idempotentlyGetEnvironmentVariable(
677  value_, initialized_, BehaviorDetails::OVERLAP, defaultValue);
678 }
679 
681  const std::string defaultValue("Send");
682 
683  static std::string value_ = defaultValue;
684  static bool initialized_ = false;
685  return idempotentlyGetEnvironmentVariable(
686  value_, initialized_, BehaviorDetails::DEFAULT_SEND_TYPE, defaultValue);
687 }
688 
690  constexpr bool defaultValue(false);
691 
692  static bool value_ = defaultValue;
693  static bool initialized_ = false;
694  return idempotentlyGetEnvironmentVariable(
695  value_, initialized_, BehaviorDetails::GRANULAR_TRANSFERS, defaultValue);
696 }
697 
699  constexpr size_t defaultValue(16);
700 
701  static size_t value_ = defaultValue;
702  static bool initialized_ = false;
703  return idempotentlyGetEnvironmentVariable(
704  value_, initialized_, BehaviorDetails::SPACES_ID_WARN_LIMIT,
705  defaultValue);
706 }
707 
709  constexpr bool defaultValue(false);
710 
711  static bool value_ = defaultValue;
712  static bool initialized_ = false;
713  return idempotentlyGetEnvironmentVariable(
714  value_, initialized_, BehaviorDetails::TIME_KOKKOS_DEEP_COPY,
715  defaultValue);
716 }
717 
719  constexpr bool defaultValue(false);
720 
721  static bool value_ = defaultValue;
722  static bool initialized_ = false;
723  return idempotentlyGetEnvironmentVariable(
724  value_, initialized_, BehaviorDetails::TIME_KOKKOS_DEEP_COPY_VERBOSE1,
725  defaultValue);
726 }
727 
729  constexpr bool defaultValue(false);
730 
731  static bool value_ = defaultValue;
732  static bool initialized_ = false;
733  return idempotentlyGetEnvironmentVariable(
734  value_, initialized_, BehaviorDetails::TIME_KOKKOS_DEEP_COPY_VERBOSE2,
735  defaultValue);
736 }
737 
739  constexpr bool defaultValue(false);
740 
741  static bool value_ = defaultValue;
742  static bool initialized_ = false;
743  return idempotentlyGetEnvironmentVariable(
744  value_, initialized_, BehaviorDetails::TIME_KOKKOS_FENCE, defaultValue);
745 }
746 
748  constexpr bool defaultValue(false);
749 
750  static bool value_ = defaultValue;
751  static bool initialized_ = false;
752  return idempotentlyGetEnvironmentVariable(
753  value_, initialized_, BehaviorDetails::TIME_KOKKOS_FUNCTIONS,
754  defaultValue);
755 }
756 
757 } // namespace Details
758 } // 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 std::string defaultSendType()
Default send type.
static bool profilingRegionUseKokkosProfiling()
Use Kokkos::Profiling in Tpetra::ProfilingRegion.
static bool enableGranularTransfers()
Speed up transfers by overlapping computation and communication.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra&#39;s behavior.