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 /*
2 // @HEADER
3 // ***********************************************************************
4 //
5 // Tpetra: Templated Linear Algebra Services Package
6 // Copyright (2008) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // ************************************************************************
39 // @HEADER
40 */
41 // clang-format on
42 #include <algorithm> // std::transform
43 #include <array>
44 #include <cctype> // std::toupper
45 #include <cstdlib> // std::getenv
46 #include <functional>
47 #include <map>
48 #include <stdexcept>
49 #include <string>
50 #include <string_view>
51 #include <vector>
52 
53 #include "Teuchos_OrdinalTraits.hpp"
54 #include "Teuchos_TestForException.hpp"
55 #include "TpetraCore_config.h"
57 
92 // environ should be available on posix platforms
93 #if not(defined(WIN) && (_MSC_VER >= 1900))
94 // needs to be in the global namespace
95 extern char **environ;
96 #endif
97 
98 namespace Tpetra {
99 namespace Details {
100 
101 namespace BehaviorDetails {
102 
103 constexpr const std::string_view RESERVED_PREFIX = "TPETRA_";
104 constexpr const std::string_view ASSUME_GPU_AWARE_MPI =
105  "TPETRA_ASSUME_GPU_AWARE_MPI";
106 constexpr const std::string_view CUDA_LAUNCH_BLOCKING = "CUDA_LAUNCH_BLOCKING";
107 constexpr const std::string_view MM_TAFC_OptimizationCoreCount =
108  "MM_TAFC_OptimizationCoreCount";
109 constexpr const std::string_view VERBOSE_PRINT_COUNT_THRESHOLD =
110  "TPETRA_VERBOSE_PRINT_COUNT_THRESHOLD";
111 constexpr const std::string_view ROW_IMBALANCE_THRESHOLD =
112  "TPETRA_ROW_IMBALANCE_THRESHOLD";
113 constexpr const std::string_view MULTIVECTOR_USE_MERGE_PATH =
114  "TPETRA_MULTIVECTOR_USE_MERGE_PATH";
115 constexpr const std::string_view VECTOR_DEVICE_THRESHOLD =
116  "TPETRA_VECTOR_DEVICE_THRESHOLD";
117 constexpr const std::string_view HIERARCHICAL_UNPACK_BATCH_SIZE =
118  "TPETRA_HIERARCHICAL_UNPACK_BATCH_SIZE";
119 constexpr const std::string_view HIERARCHICAL_UNPACK_TEAM_SIZE =
120  "TPETRA_HIERARCHICAL_UNPACK_TEAM_SIZE";
121 constexpr const std::string_view USE_TEUCHOS_TIMERS =
122  "TPETRA_USE_TEUCHOS_TIMERS";
123 constexpr const std::string_view USE_KOKKOS_PROFILING =
124  "TPETRA_USE_KOKKOS_PROFILING";
125 constexpr const std::string_view DEBUG = "TPETRA_DEBUG";
126 constexpr const std::string_view VERBOSE = "TPETRA_VERBOSE";
127 constexpr const std::string_view TIMING = "TPETRA_TIMING";
128 constexpr const std::string_view HIERARCHICAL_UNPACK =
129  "TPETRA_HIERARCHICAL_UNPACK";
130 constexpr const std::string_view SKIP_COPY_AND_PERMUTE =
131  "TPETRA_SKIP_COPY_AND_PERMUTE";
132 constexpr const std::string_view FUSED_RESIDUAL = "TPETRA_FUSED_RESIDUAL";
133 constexpr const std::string_view OVERLAP = "TPETRA_OVERLAP";
134 constexpr const std::string_view SPACES_ID_WARN_LIMIT =
135  "TPETRA_SPACES_ID_WARN_LIMIT";
136 constexpr const std::string_view TIME_KOKKOS_DEEP_COPY =
137  "TPETRA_TIME_KOKKOS_DEEP_COPY";
138 constexpr const std::string_view TIME_KOKKOS_DEEP_COPY_VERBOSE1 =
139  "TPETRA_TIME_KOKKOS_DEEP_COPY_VERBOSE1";
140 constexpr const std::string_view TIME_KOKKOS_DEEP_COPY_VERBOSE2 =
141  "TPETRA_TIME_KOKKOS_DEEP_COPY_VERBOSE2";
142 constexpr const std::string_view TIME_KOKKOS_FENCE = "TPETRA_TIME_KOKKOS_FENCE";
143 constexpr const std::string_view TIME_KOKKOS_FUNCTIONS =
144  "TPETRA_TIME_KOKKOS_FUNCTIONS";
145 
146 // construct an std::array of string_view with any number of provided
147 // string_views
148 template <typename... Elems>
149 constexpr std::array<std::string_view, sizeof...(Elems)>
150 make_array(Elems &&... elems) {
151  return {std::forward<Elems>(elems)...};
152 }
153 
154 constexpr const auto RECOGNIZED_VARS = make_array(
155  ASSUME_GPU_AWARE_MPI, CUDA_LAUNCH_BLOCKING, MM_TAFC_OptimizationCoreCount,
156  VERBOSE_PRINT_COUNT_THRESHOLD, ROW_IMBALANCE_THRESHOLD,
157  MULTIVECTOR_USE_MERGE_PATH, VECTOR_DEVICE_THRESHOLD,
158  HIERARCHICAL_UNPACK_BATCH_SIZE, HIERARCHICAL_UNPACK_TEAM_SIZE,
159  USE_TEUCHOS_TIMERS, USE_KOKKOS_PROFILING, DEBUG, VERBOSE, TIMING,
160  HIERARCHICAL_UNPACK, SKIP_COPY_AND_PERMUTE, FUSED_RESIDUAL, OVERLAP,
161  SPACES_ID_WARN_LIMIT, TIME_KOKKOS_DEEP_COPY, TIME_KOKKOS_DEEP_COPY_VERBOSE1,
162  TIME_KOKKOS_DEEP_COPY_VERBOSE2, TIME_KOKKOS_FENCE, TIME_KOKKOS_FUNCTIONS);
163 
164 // clang-format off
165 std::map<std::string, std::map<std::string, bool> > namedVariableMap_;
166 bool verboseDisabled_ = false;
167 bool timingDisabled_ = false;
168 }
169 
170 namespace { // (anonymous)
171 
172  enum EnvironmentVariableState
173  {
174  EnvironmentVariableIsSet_ON,
175  EnvironmentVariableIsSet_OFF,
176  EnvironmentVariableIsSet,
177  EnvironmentVariableIsNotSet
178  };
179 
180  // See example here:
181  //
182  // http://en.cppreference.com/w/cpp/string/byte/toupper
183  std::string stringToUpper (std::string s)
184  {
185  std::transform (s.begin (), s.end (), s.begin (),
186  [] (unsigned char c) { return std::toupper (c); });
187  return s;
188  }
189 
190  void
191  split(const std::string_view s,
192  std::function<void(const std::string&)> f,
193  const char sep=',')
194  {
195  typedef std::string::size_type size_type;
196  size_type cur_pos, last_pos=0, length=s.length();
197  while(last_pos < length + 1)
198  {
199  cur_pos = s.find_first_of(sep, last_pos);
200  if(cur_pos == std::string::npos)
201  {
202  cur_pos = length;
203  }
204  if(cur_pos!=last_pos) {
205  auto token = std::string(s.data()+last_pos, (size_type)cur_pos-last_pos);
206  f(token);
207  }
208  last_pos = cur_pos + 1;
209  }
210  return;
211  }
212 
213  EnvironmentVariableState
214  environmentVariableState(const std::string& environmentVariableValue)
215  {
216  std::string v = stringToUpper(environmentVariableValue);
217  if (v == "1" || v == "YES" || v == "TRUE" || v == "ON")
218  // Environment variable is "ON"
219  return EnvironmentVariableIsSet_ON;
220  else if (v == "0" || v == "NO" || v == "FALSE" || v == "OFF")
221  // Environment variable is "OFF"
222  return EnvironmentVariableIsSet_OFF;
223  // Environment has some other non-boolean value
224  return EnvironmentVariableIsSet;
225  }
226 
227  void
228  setEnvironmentVariableMap (const char environmentVariableName[],
229  std::map<std::string,std::map<std::string, bool> >& valsMap,
230  const bool defaultValue)
231  {
232  using std::map;
233  using std::getenv;
234  using std::string;
235  using std::vector;
236 
237  // Set the default value for this variable
238  valsMap[environmentVariableName] = map<string,bool>{{"DEFAULT", defaultValue}};
239 
240  const char* varVal = getenv (environmentVariableName);
241  if (varVal == nullptr) {
242  // Environment variable is not set, use the default value for any named
243  // variants
244  return;
245  }
246 
247  // Variable is not empty.
248  const string varStr(varVal);
249  vector<string> names;
250  split(varStr, [&](const string& x){names.push_back(x);});
251  for (auto const& name: names) {
252  auto state = environmentVariableState(name);
253  if (state == EnvironmentVariableIsSet_ON) {
254  // Environment variable was set as ENVAR_NAME=[1,YES,TRUE,ON]
255  // Global value takes precedence
256  valsMap[environmentVariableName]["DEFAULT"] = true;
257  }
258  else if (state == EnvironmentVariableIsSet_OFF) {
259  // Environment variable was set as ENVAR_NAME=[0,NO,FALSE,OFF]
260  // Global value takes precedence
261  valsMap[environmentVariableName]["DEFAULT"] = false;
262  }
263  else {
264  // Environment variable was set as ENVAR_NAME=...:name:...
265  // So we set the mapping true for this named variant
266  valsMap[environmentVariableName][name] = true;
267  }
268  }
269  return;
270  }
271 
272  bool
273  idempotentlyGetNamedEnvironmentVariableAsBool (const char name[],
274  bool& initialized,
275  const char environmentVariableName[],
276  const bool defaultValue)
277  {
278  using BehaviorDetails::namedVariableMap_;
279  if (! initialized) {
280  setEnvironmentVariableMap (environmentVariableName,
281  namedVariableMap_,
282  defaultValue);
283  initialized = true;
284  }
285  auto thisEnvironmentVariableMap = namedVariableMap_[environmentVariableName];
286  auto thisEnvironmentVariable = thisEnvironmentVariableMap.find(name);
287  if (thisEnvironmentVariable != thisEnvironmentVariableMap.end())
288  return thisEnvironmentVariable->second;
289  return thisEnvironmentVariableMap["DEFAULT"];
290  }
291 // clang-format on
292 
293 template <typename T>
294 T getEnvironmentVariable(const std::string_view environmentVariableName,
295  const T defaultValue) {
296  const char prefix[] = "Tpetra::Details::Behavior: ";
297 
298  const char *varVal = std::getenv(environmentVariableName.data());
299  if (varVal == nullptr) {
300  return defaultValue;
301  } else {
302  std::stringstream ss(varVal);
303  T parsed;
304  ss >> parsed;
305 
306  TEUCHOS_TEST_FOR_EXCEPTION(!ss, std::out_of_range,
307  prefix << "Environment "
308  "variable \""
309  << environmentVariableName
310  << "\" has a "
311  "value "
312  << varVal
313  << " that cannot be parsed as a "
314  << typeid(T).name() << ".");
315 
316  return parsed;
317  }
318 }
319 
320 // full specialization of bool to preserve historical Tpetra parsing behavior
321 template <>
322 bool getEnvironmentVariable<bool>(
323  const std::string_view environmentVariableName, const bool defaultValue) {
324  const char *varVal = std::getenv(environmentVariableName.data());
325  bool retVal = defaultValue;
326  if (varVal != nullptr) {
327  auto state = environmentVariableState(std::string(varVal));
328  if (state == EnvironmentVariableIsSet_ON)
329  retVal = true;
330  else if (state == EnvironmentVariableIsSet_OFF)
331  retVal = false;
332  }
333  return retVal;
334 }
335 
341 template <>
342 size_t
343 getEnvironmentVariable<size_t>(const std::string_view environmentVariableName,
344  const size_t defaultValue) {
345  const char prefix[] = "Tpetra::Details::Behavior: ";
346 
347  const char *varVal = std::getenv(environmentVariableName.data());
348  if (varVal == nullptr) {
349  return defaultValue;
350  } else {
351  long long val = std::stoll(stringToUpper(varVal));
352  if (val < static_cast<long long>(0)) {
353  // If negative - user has requested threshold be lifted
354  return std::numeric_limits<size_t>::max();
355  }
356  if (sizeof(long long) > sizeof(size_t)) {
357  // It's hard to test this code, but I want to try writing it
358  // at least, in case we ever have to run on 32-bit machines or
359  // machines with sizeof(long long)=16 and sizeof(size_t)=8.
360  constexpr long long maxSizeT =
361  static_cast<long long>(std::numeric_limits<size_t>::max());
362  TEUCHOS_TEST_FOR_EXCEPTION(
363  val > maxSizeT, std::out_of_range,
364  prefix << "Environment "
365  "variable \""
366  << environmentVariableName
367  << "\" has a "
368  "value "
369  << val << " larger than the largest size_t value " << maxSizeT
370  << ".");
371  }
372  return static_cast<size_t>(val);
373  }
374 }
375 
376 template <typename T>
377 T idempotentlyGetEnvironmentVariable(
378  T &value, bool &initialized, const std::string_view environmentVariableName,
379  const T defaultValue) {
380  if (!initialized) {
381  value = getEnvironmentVariable<T>(environmentVariableName, defaultValue);
382  initialized = true;
383  }
384  return value;
385 }
386 
387 // clang-format off
388  constexpr bool debugDefault () {
389 #ifdef HAVE_TPETRA_DEBUG
390  return true;
391 #else
392  return false;
393 #endif // HAVE_TPETRA_DEBUG
394  }
395 
396  constexpr bool verboseDefault () {
397  return false;
398  }
399 
400  constexpr bool timingDefault () {
401  return false;
402  }
403 
404  constexpr bool assumeMpiIsGPUAwareDefault () {
405 #ifdef TPETRA_ASSUME_GPU_AWARE_MPI
406  return true;
407 #else
408  return false;
409 #endif // TPETRA_ASSUME_GPU_AWARE_MPI
410  }
411 
412  constexpr bool cudaLaunchBlockingDefault () {
413  return false;
414  }
415 
416  constexpr bool hierarchicalUnpackDefault () {
417  return true;
418  }
419 
420 } // namespace (anonymous)
421 // clang-format on
422 
424 
425  static bool once = false;
426 
427  if (!once) {
428  const char prefix[] = "Tpetra::Details::Behavior: ";
429  char **env;
430 #if defined(WIN) && (_MSC_VER >= 1900)
431  env = *__p__environ();
432 #else
433  env = environ; // defined at the top of this file as extern char **environ;
434 #endif
435  for (; *env; ++env) {
436 
437  std::string name;
438  std::string value;
439  const std::string_view ev(*env);
440 
441  // split name=value on the first =, everything before = is name
442  split(
443  ev,
444  [&](const std::string &s) {
445  if (name.empty()) {
446  name = s;
447  } else {
448  value = s;
449  }
450  },
451  '=');
452 
453  if (name.size() >= BehaviorDetails::RESERVED_PREFIX.size() &&
454  name.substr(0, BehaviorDetails::RESERVED_PREFIX.size()) ==
455  BehaviorDetails::RESERVED_PREFIX) {
456  const auto it = std::find(BehaviorDetails::RECOGNIZED_VARS.begin(),
457  BehaviorDetails::RECOGNIZED_VARS.end(), name);
458  TEUCHOS_TEST_FOR_EXCEPTION(
459  it == BehaviorDetails::RECOGNIZED_VARS.end(), std::out_of_range,
460  prefix << "Environment "
461  "variable \""
462  << name << "\" (prefixed with \""
463  << BehaviorDetails::RESERVED_PREFIX
464  << "\") is not a recognized Tpetra variable.");
465  }
466  }
467 
468  once = true;
469  }
470 }
471 
473  constexpr bool defaultValue = debugDefault();
474 
475  static bool value_ = defaultValue;
476  static bool initialized_ = false;
477  return idempotentlyGetEnvironmentVariable(
478  value_, initialized_, BehaviorDetails::DEBUG, defaultValue);
479 }
480 
482  if (BehaviorDetails::verboseDisabled_)
483  return false;
484 
485  constexpr bool defaultValue = verboseDefault();
486 
487  static bool value_ = defaultValue;
488  static bool initialized_ = false;
489  return idempotentlyGetEnvironmentVariable(
490  value_, initialized_, BehaviorDetails::VERBOSE, defaultValue);
491 }
492 
494  if (BehaviorDetails::timingDisabled_)
495  return false;
496 
497  constexpr bool defaultValue = timingDefault();
498 
499  static bool value_ = defaultValue;
500  static bool initialized_ = false;
501  return idempotentlyGetEnvironmentVariable(
502  value_, initialized_, BehaviorDetails::TIMING, defaultValue);
503 }
504 
506  constexpr bool defaultValue = assumeMpiIsGPUAwareDefault();
507 
508  static bool value_ = defaultValue;
509  static bool initialized_ = false;
510  return idempotentlyGetEnvironmentVariable(
511  value_, initialized_, BehaviorDetails::ASSUME_GPU_AWARE_MPI,
512  defaultValue);
513 }
514 
516  constexpr bool defaultValue = cudaLaunchBlockingDefault();
517 
518  static bool value_ = defaultValue;
519  static bool initialized_ = false;
520  return idempotentlyGetEnvironmentVariable(
521  value_, initialized_, BehaviorDetails::CUDA_LAUNCH_BLOCKING,
522  defaultValue);
523 }
524 
526  constexpr int _default = 3000;
527  static int value_ = _default;
528  static bool initialized_ = false;
529  return idempotentlyGetEnvironmentVariable(
530  value_, initialized_, BehaviorDetails::MM_TAFC_OptimizationCoreCount,
531  _default);
532 }
533 
535  constexpr size_t defaultValue(200);
536 
537  static size_t value_ = defaultValue;
538  static bool initialized_ = false;
539  return idempotentlyGetEnvironmentVariable(
540  value_, initialized_, BehaviorDetails::VERBOSE_PRINT_COUNT_THRESHOLD,
541  defaultValue);
542 }
543 
545  constexpr size_t defaultValue(256);
546 
547  static size_t value_ = defaultValue;
548  static bool initialized_ = false;
549  return idempotentlyGetEnvironmentVariable(
550  value_, initialized_, BehaviorDetails::ROW_IMBALANCE_THRESHOLD,
551  defaultValue);
552 }
553 
555  constexpr bool defaultValue = false;
556 
557  static bool value_ = defaultValue;
558  static bool initialized_ = false;
559  return idempotentlyGetEnvironmentVariable(
560  value_, initialized_, BehaviorDetails::MULTIVECTOR_USE_MERGE_PATH,
561  defaultValue);
562 }
563 
565  constexpr size_t defaultValue(22000);
566 
567  static size_t value_ = defaultValue;
568  static bool initialized_ = false;
569  return idempotentlyGetEnvironmentVariable(
570  value_, initialized_, BehaviorDetails::VECTOR_DEVICE_THRESHOLD,
571  defaultValue);
572 }
573 
575 
576 #ifdef HAVE_TPETRA_INST_CUDA
577  constexpr size_t defaultValue(16);
578 #else
579  constexpr size_t defaultValue(256);
580 #endif
581 
582  static size_t value_ = defaultValue;
583  static bool initialized_ = false;
584  return idempotentlyGetEnvironmentVariable(
585  value_, initialized_, BehaviorDetails::HIERARCHICAL_UNPACK_BATCH_SIZE,
586  defaultValue);
587 }
588 
590 #ifdef HAVE_TPETRA_INST_CUDA
591  const size_t defaultValue(16);
592 #else
593  const size_t defaultValue(Teuchos::OrdinalTraits<size_t>::invalid());
594 #endif
595 
596  static size_t value_ = defaultValue;
597  static bool initialized_ = false;
598  return idempotentlyGetEnvironmentVariable(
599  value_, initialized_, BehaviorDetails::HIERARCHICAL_UNPACK_TEAM_SIZE,
600  defaultValue);
601 }
602 
604  constexpr bool defaultValue(false);
605 
606  static bool value_ = defaultValue;
607  static bool initialized_ = false;
608  return idempotentlyGetEnvironmentVariable(
609  value_, initialized_, BehaviorDetails::USE_TEUCHOS_TIMERS, defaultValue);
610 }
611 
613  constexpr bool defaultValue(false);
614 
615  static bool value_ = defaultValue;
616  static bool initialized_ = false;
617  return idempotentlyGetEnvironmentVariable(
618  value_, initialized_, BehaviorDetails::USE_KOKKOS_PROFILING,
619  defaultValue);
620 }
621 
622 bool Behavior::debug(const char name[]) {
623  constexpr bool defaultValue = false;
624 
625  static bool initialized_ = false;
626  return idempotentlyGetNamedEnvironmentVariableAsBool(
627  name, initialized_, BehaviorDetails::DEBUG.data(), defaultValue);
628 }
629 
630 bool Behavior::verbose(const char name[]) {
631  if (BehaviorDetails::verboseDisabled_)
632  return false;
633 
634  constexpr bool defaultValue = false;
635 
636  static bool initialized_ = false;
637  return idempotentlyGetNamedEnvironmentVariableAsBool(
638  name, initialized_, BehaviorDetails::VERBOSE.data(), defaultValue);
639 }
640 
642  BehaviorDetails::verboseDisabled_ = false;
643 }
644 
646  BehaviorDetails::verboseDisabled_ = true;
647 }
648 
649 bool Behavior::timing(const char name[]) {
650  if (BehaviorDetails::timingDisabled_)
651  return false;
652 
653  constexpr bool defaultValue = false;
654 
655  static bool initialized_ = false;
656  return idempotentlyGetNamedEnvironmentVariableAsBool(
657  name, initialized_, BehaviorDetails::TIMING.data(), defaultValue);
658 }
659 
660 void Behavior::enable_timing() { BehaviorDetails::timingDisabled_ = false; }
661 
662 void Behavior::disable_timing() { BehaviorDetails::timingDisabled_ = true; }
663 
665  constexpr bool defaultValue = hierarchicalUnpackDefault();
666 
667  static bool value_ = defaultValue;
668  static bool initialized_ = false;
669  return idempotentlyGetEnvironmentVariable(
670  value_, initialized_, BehaviorDetails::HIERARCHICAL_UNPACK, defaultValue);
671 }
672 
674  constexpr bool defaultValue(false);
675 
676  static bool value_ = defaultValue;
677  static bool initialized_ = false;
678  return idempotentlyGetEnvironmentVariable(
679  value_, initialized_, BehaviorDetails::SKIP_COPY_AND_PERMUTE,
680  defaultValue);
681 }
682 
684  constexpr bool defaultValue(true);
685 
686  static bool value_ = defaultValue;
687  static bool initialized_ = false;
688  return idempotentlyGetEnvironmentVariable(
689  value_, initialized_, BehaviorDetails::FUSED_RESIDUAL, defaultValue);
690 }
691 
693  constexpr bool defaultValue(false);
694 
695  static bool value_ = defaultValue;
696  static bool initialized_ = false;
697  return idempotentlyGetEnvironmentVariable(
698  value_, initialized_, BehaviorDetails::OVERLAP, defaultValue);
699 }
700 
702  constexpr size_t defaultValue(16);
703 
704  static size_t value_ = defaultValue;
705  static bool initialized_ = false;
706  return idempotentlyGetEnvironmentVariable(
707  value_, initialized_, BehaviorDetails::SPACES_ID_WARN_LIMIT,
708  defaultValue);
709 }
710 
712  constexpr bool defaultValue(false);
713 
714  static bool value_ = defaultValue;
715  static bool initialized_ = false;
716  return idempotentlyGetEnvironmentVariable(
717  value_, initialized_, BehaviorDetails::TIME_KOKKOS_DEEP_COPY,
718  defaultValue);
719 }
720 
722  constexpr bool defaultValue(false);
723 
724  static bool value_ = defaultValue;
725  static bool initialized_ = false;
726  return idempotentlyGetEnvironmentVariable(
727  value_, initialized_, BehaviorDetails::TIME_KOKKOS_DEEP_COPY_VERBOSE1,
728  defaultValue);
729 }
730 
732  constexpr bool defaultValue(false);
733 
734  static bool value_ = defaultValue;
735  static bool initialized_ = false;
736  return idempotentlyGetEnvironmentVariable(
737  value_, initialized_, BehaviorDetails::TIME_KOKKOS_DEEP_COPY_VERBOSE2,
738  defaultValue);
739 }
740 
742  constexpr bool defaultValue(false);
743 
744  static bool value_ = defaultValue;
745  static bool initialized_ = false;
746  return idempotentlyGetEnvironmentVariable(
747  value_, initialized_, BehaviorDetails::TIME_KOKKOS_FENCE, defaultValue);
748 }
749 
751  constexpr bool defaultValue(false);
752 
753  static bool value_ = defaultValue;
754  static bool initialized_ = false;
755  return idempotentlyGetEnvironmentVariable(
756  value_, initialized_, BehaviorDetails::TIME_KOKKOS_FUNCTIONS,
757  defaultValue);
758 }
759 
760 } // namespace Details
761 } // 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.