1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
/*
* Normaliz
* Copyright (C) 2007-2022 W. Bruns, B. Ichim, Ch. Soeger, U. v. d. Ohe
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* As an exception, when this program is distributed through (i) the App Store
* by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or (iii) Google Play
* by Google Inc., then that store may impose any digital rights management,
* device limits and/or redistribution restrictions that are required by its
* terms of service.
*/
#include <cstdlib>
#include <csignal>
#include <sys/time.h>
#include "libnormaliz/general.h"
namespace libnormaliz {
bool verbose = false;
volatile sig_atomic_t nmz_interrupted = 0;
const int default_thread_limit = 8;
int thread_limit = default_thread_limit;
bool parallelization_set = false;
// bool test_arithmetic_overflow = false;
// long overflow_test_modulus = 15401;
size_t GMP_mat = 0;
size_t GMP_hyp = 0;
size_t GMP_scal_prod = 0;
size_t TotDet = 0;
long cone_recursion_level = 0;
long full_cone_recursion_level = 0;
bool int_max_value_dual_long_computed = false;
bool int_max_value_dual_long_long_computed = false;
bool int_max_value_primary_long_computed = false;
bool int_max_value_primary_long_long_computed = false;
vector<vector<vector<long> > > CollectedAutoms(default_thread_limit); // for use in nmz_nauty.cpp
#ifdef NMZ_EXTENDED_TESTS
bool test_arith_overflow_full_cone = false;
bool test_arith_overflow_dual_mode = false;
bool test_arith_overflow_descent = false;
bool test_arith_overflow_proj_and_lift = false;
bool test_simplex_parallel = false;
bool test_small_pyramids = false;
bool test_large_pyramids = false;
bool test_linear_algebra_GMP = false;
#endif
#ifdef NMZ_NAUTY
void kill_nauty();
#endif
void interrupt_signal_handler(int signal) {
nmz_interrupted = 1;
#ifdef NMZ_NAUTY
kill_nauty();
#endif
}
namespace {
std::ostream* verbose_ostream_ptr = &std::cout;
std::ostream* error_ostream_ptr = &std::cerr;
} // namespace
bool setVerboseDefault(bool v) {
// we want to return the old value
bool old = verbose;
verbose = v;
return old;
}
int set_thread_limit(int t) {
int old = thread_limit;
parallelization_set = true;
thread_limit = t;
CollectedAutoms.resize(t);
return old;
}
void setVerboseOutput(std::ostream& v_out) {
verbose_ostream_ptr = &v_out;
}
void setErrorOutput(std::ostream& e_out) {
error_ostream_ptr = &e_out;
}
std::ostream& verboseOutput() {
return *verbose_ostream_ptr;
}
std::ostream& errorOutput() {
return *error_ostream_ptr;
}
struct timeval TIME_global_begin, TIME_global_end;
void StartGlobalTime() {
gettimeofday(&TIME_global_begin, 0);
}
void MeasureGlobalTime(bool verbose) {
gettimeofday(&TIME_global_end, 0);
long seconds = TIME_global_end.tv_sec - TIME_global_begin.tv_sec;
long microseconds = TIME_global_end.tv_usec - TIME_global_begin.tv_usec;
double elapsed = seconds + microseconds * 1e-6;
if (verbose)
verboseOutput() << "Normaliz elapsed wall clock time: " << elapsed << " sec" << endl;
TIME_global_begin = TIME_global_end;
}
#ifdef NMZ_DEVELOP
struct timeval TIME_begin, TIME_end;
void StartTime() {
gettimeofday(&TIME_begin, 0);
}
void MeasureTime(bool verbose, const std::string& step) {
gettimeofday(&TIME_end, 0);
long seconds = TIME_end.tv_sec - TIME_begin.tv_sec;
long microseconds = TIME_end.tv_usec - TIME_begin.tv_usec;
double elapsed = seconds + microseconds * 1e-6;
if (verbose)
verboseOutput() << step << ": " << elapsed << " sec" << endl;
TIME_begin = TIME_end;
}
#else
void StartTime() {
return;
}
void MeasureTime(bool verbose, const std::string& step) {
return;
}
#endif
unsigned int getVersion()
{
#ifdef NMZ_MAKEFILE_CLASSIC
#ifdef NMZ_DEVELOP
#define NMZ_RELEASE 9999999
#endif
#endif
return NMZ_RELEASE;
}
} /* end namespace libnormaliz */
|