| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// Trilinos: An Object-Oriented Solver Framework |
| 4 |
// |
| 5 |
// Copyright 2001-2024 NTESS and the Trilinos contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#include <iostream> |
| 11 |
#include <vector> |
| 12 |
#include <Teuchos_Comm.hpp> |
| 13 |
#include <Teuchos_ParameterList.hpp> |
| 14 |
#include <Teuchos_RCP.hpp> |
| 15 |
#include <Tpetra_KokkosCompat_DefaultNode.hpp> |
| 16 |
|
| 17 |
#include "fenl.hpp" |
| 18 |
|
| 19 |
//---------------------------------------------------------------------------- |
| 20 |
//---------------------------------------------------------------------------- |
| 21 |
// Command line processing: |
| 22 |
|
| 23 |
enum clp_return_type { |
| 24 |
CLP_HELP=0, |
| 25 |
CLP_ERROR, |
| 26 |
CLP_OK |
| 27 |
}; |
| 28 |
|
| 29 |
enum GroupingType { |
| 30 |
GROUPING_NATURAL=0, |
| 31 |
GROUPING_MAX_ANISOTROPY, |
| 32 |
GROUPING_MORTAN_Z, |
| 33 |
GROUPING_TASMANIAN_SURROGATE |
| 34 |
}; |
| 35 |
|
| 36 |
enum SamplingType { |
| 37 |
SAMPLING_STOKHOS=0, |
| 38 |
SAMPLING_DAKOTA, |
| 39 |
SAMPLING_TASMANIAN, |
| 40 |
SAMPLING_FILE, |
| 41 |
SAMPLING_VPS |
| 42 |
}; |
| 43 |
|
| 44 |
struct CMD { |
| 45 |
bool USE_SERIAL; |
| 46 |
int USE_THREADS; |
| 47 |
int USE_OPENMP; |
| 48 |
int USE_NUMA; |
| 49 |
int USE_CORE_PER_NUMA; |
| 50 |
bool USE_CUDA; |
| 51 |
int USE_CUDA_DEV; |
| 52 |
int USE_NGPUS; |
| 53 |
int USE_FIXTURE_X; |
| 54 |
int USE_FIXTURE_Y; |
| 55 |
int USE_FIXTURE_Z; |
| 56 |
bool USE_FIXTURE_QUADRATIC; |
| 57 |
bool USE_ATOMIC; |
| 58 |
int USE_TRIALS; |
| 59 |
std::string USE_FENL_XML_FILE; |
| 60 |
bool USE_BELOS; |
| 61 |
bool USE_MUELU; |
| 62 |
bool USE_MEANBASED; |
| 63 |
bool USE_UQ; |
| 64 |
SamplingType USE_UQ_SAMPLING; |
| 65 |
int USE_UQ_FAKE; |
| 66 |
int USE_UQ_DIM; |
| 67 |
int USE_UQ_ORDER; |
| 68 |
int USE_UQ_INIT_LEVEL; |
| 69 |
int USE_UQ_MAX_LEVEL; |
| 70 |
int USE_UQ_MAX_SAMPLES; |
| 71 |
double USE_UQ_TOL; |
| 72 |
double USE_DIFF_COEFF_LINEAR; |
| 73 |
double USE_DIFF_COEFF_CONSTANT; |
| 74 |
double USE_MEAN; |
| 75 |
double USE_VAR; |
| 76 |
double USE_COR; |
| 77 |
bool USE_EXPONENTIAL; |
| 78 |
double USE_EXP_SHIFT; |
| 79 |
double USE_EXP_SCALE; |
| 80 |
bool USE_DISC_EXP_SCALE; |
| 81 |
bool USE_ISOTROPIC; |
| 82 |
double USE_COEFF_SRC; |
| 83 |
double USE_COEFF_ADV; |
| 84 |
bool USE_SPARSE; |
| 85 |
int USE_UQ_ENSEMBLE; |
| 86 |
GroupingType USE_GROUPING; |
| 87 |
int TAS_GROUPING_INITIAL_LEVEL; |
| 88 |
bool VTUNE; |
| 89 |
bool VERBOSE; |
| 90 |
bool PRINT; |
| 91 |
bool PRINT_ITS; |
| 92 |
bool SUMMARIZE; |
| 93 |
int ECHO; |
| 94 |
int ERROR; |
| 95 |
int COUNT; |
| 96 |
bool UNIT_TEST; |
| 97 |
double TEST_MEAN; |
| 98 |
double TEST_STD_DEV; |
| 99 |
double TEST_TOL; |
| 100 |
|
| 101 |
CMD() : USE_SERIAL(0), |
| 102 |
USE_THREADS(0), |
| 103 |
USE_OPENMP(0), |
| 104 |
USE_NUMA(0), |
| 105 |
USE_CORE_PER_NUMA(0), |
| 106 |
USE_CUDA(false), |
| 107 |
USE_CUDA_DEV(-1), |
| 108 |
USE_NGPUS(1), |
| 109 |
USE_FIXTURE_X(2), |
| 110 |
USE_FIXTURE_Y(2), |
| 111 |
USE_FIXTURE_Z(2), |
| 112 |
USE_FIXTURE_QUADRATIC(false), |
| 113 |
USE_ATOMIC(false), |
| 114 |
USE_TRIALS(1), |
| 115 |
USE_FENL_XML_FILE("fenl.xml"), |
| 116 |
USE_BELOS(false), |
| 117 |
USE_MUELU(false), |
| 118 |
USE_MEANBASED(false), |
| 119 |
USE_UQ(false), |
| 120 |
USE_UQ_SAMPLING(SAMPLING_STOKHOS), |
| 121 |
USE_UQ_FAKE(0), |
| 122 |
USE_UQ_DIM(3), |
| 123 |
USE_UQ_ORDER(2), |
| 124 |
USE_UQ_INIT_LEVEL(1), |
| 125 |
USE_UQ_MAX_LEVEL(7), |
| 126 |
USE_UQ_MAX_SAMPLES(1000), |
| 127 |
USE_UQ_TOL(1e-2), |
| 128 |
USE_DIFF_COEFF_LINEAR(0.0), |
| 129 |
USE_DIFF_COEFF_CONSTANT(1.0), |
| 130 |
USE_MEAN(1), |
| 131 |
USE_VAR(0.1), |
| 132 |
USE_COR(0.25), |
| 133 |
USE_EXPONENTIAL(false), |
| 134 |
USE_EXP_SHIFT(1.0), |
| 135 |
USE_EXP_SCALE(1.0), |
| 136 |
USE_DISC_EXP_SCALE(false), |
| 137 |
USE_ISOTROPIC(true), |
| 138 |
USE_COEFF_SRC(1.0), |
| 139 |
USE_COEFF_ADV(0.0), |
| 140 |
USE_SPARSE(false), |
| 141 |
USE_UQ_ENSEMBLE(0), |
| 142 |
USE_GROUPING(GROUPING_NATURAL), |
| 143 |
TAS_GROUPING_INITIAL_LEVEL(2), |
| 144 |
VTUNE(false), |
| 145 |
VERBOSE(false), |
| 146 |
PRINT(false), |
| 147 |
PRINT_ITS(false), |
| 148 |
SUMMARIZE(false), |
| 149 |
UNIT_TEST(false), |
| 150 |
TEST_MEAN(0.0), |
| 151 |
TEST_STD_DEV(0.0), |
| 152 |
TEST_TOL(1.0e-3) |
| 153 |
{} |
| 154 |
}; |
| 155 |
|
| 156 |
// Print command line |
| 157 |
void print_cmdline( std::ostream & s , const CMD & cmd ); |
| 158 |
|
| 159 |
//---------------------------------------------------------------------------- |
| 160 |
//---------------------------------------------------------------------------- |
| 161 |
// Display performance: |
| 162 |
|
| 163 |
// Parse command line |
| 164 |
clp_return_type parse_cmdline( int argc , char ** argv, CMD & cmdline, |
| 165 |
const Teuchos::Comm<int>& comm, |
| 166 |
const bool uq); |
| 167 |
|
| 168 |
|
| 169 |
// Print timing headers |
| 170 |
std::vector< size_t > |
| 171 |
print_headers( std::ostream & s , const CMD & cmd , const int comm_rank ); |
| 172 |
|
| 173 |
|
| 174 |
// Print times |
| 175 |
void print_perf_value( std::ostream & s , |
| 176 |
const CMD & cmd , |
| 177 |
const std::vector<size_t> & widths , |
| 178 |
const Kokkos::Example::FENL::Perf & perf ); |
| 179 |
|
| 180 |
//---------------------------------------------------------------------------- |
| 181 |
//---------------------------------------------------------------------------- |
| 182 |
// Profiling: |
| 183 |
|
| 184 |
// Connect executable to vtune for profiling |
| 185 |
void connect_vtune(const int p_rank); |
| 186 |
|
| 187 |
// Get memory usage in MB |
| 188 |
struct MemUsage { |
| 189 |
double max_mem, min_mem, tot_mem; |
| 190 |
}; |
| 191 |
MemUsage get_memory_usage(const Teuchos::Comm<int>& comm); |
| 192 |
|
| 193 |
// Print memory usage to stream |
| 194 |
void print_memory_usage(std::ostream& os, const Teuchos::Comm<int>& comm); |