Major updates integration from all upstreams

This commit is contained in:
miketout
2018-09-18 14:33:53 -07:00
396 changed files with 25517 additions and 6854 deletions

View File

@@ -15,6 +15,7 @@
#include <cassert>
#include <stdexcept>
#include <chrono>
#include <cinttypes>
#include <cstdio>
#include <list>
#include <vector>
@@ -41,7 +42,7 @@ int64_t get_nsec_time()
return std::chrono::duration_cast<std::chrono::nanoseconds>(timepoint.time_since_epoch()).count();
}
/* Return total CPU time consumsed by all threads of the process, in nanoseconds. */
/* Return total CPU time consumed by all threads of the process, in nanoseconds. */
int64_t get_nsec_cpu_time()
{
::timespec ts;
@@ -62,8 +63,10 @@ int64_t get_nsec_cpu_time()
return ts.tv_sec * 1000000000ll + ts.tv_nsec;
}
int64_t start_time, last_time;
int64_t start_cpu_time, last_cpu_time;
static int64_t start_time;
static int64_t last_time;
static int64_t start_cpu_time;
static int64_t last_cpu_time;
void start_profiling()
{
@@ -74,20 +77,20 @@ void start_profiling()
}
std::map<std::string, size_t> invocation_counts;
std::map<std::string, int64_t> enter_times;
static std::map<std::string, int64_t> enter_times;
std::map<std::string, int64_t> last_times;
std::map<std::string, int64_t> cumulative_times;
//TODO: Instead of analogous maps for time and cpu_time, use a single struct-valued map
std::map<std::string, int64_t> enter_cpu_times;
std::map<std::string, int64_t> last_cpu_times;
std::map<std::pair<std::string, std::string>, int64_t> op_counts;
std::map<std::pair<std::string, std::string>, int64_t> cumulative_op_counts; // ((msg, data_point), value)
static std::map<std::string, int64_t> enter_cpu_times;
static std::map<std::string, int64_t> last_cpu_times;
static std::map<std::pair<std::string, std::string>, int64_t> op_counts;
static std::map<std::pair<std::string, std::string>, int64_t> cumulative_op_counts; // ((msg, data_point), value)
// TODO: Convert op_counts and cumulative_op_counts from pair to structs
size_t indentation = 0;
static size_t indentation = 0;
std::vector<std::string> block_names;
static std::vector<std::string> block_names;
std::list<std::pair<std::string, int64_t*> > op_data_points = {
static std::list<std::pair<std::string, int64_t*> > op_data_points = {
#ifdef PROFILE_OP_COUNTS
std::make_pair("Fradd", &Fr<default_ec_pp>::add_cnt),
std::make_pair("Frsub", &Fr<default_ec_pp>::sub_cnt),
@@ -104,7 +107,7 @@ std::list<std::pair<std::string, int64_t*> > op_data_points = {
#endif
};
bool inhibit_profiling_info = false;
bool inhibit_profiling_info = true;
bool inhibit_profiling_counters = false;
void clear_profiling_counters()
@@ -120,7 +123,7 @@ void print_cumulative_time_entry(const std::string &key, const int64_t factor)
const double total_ms = (cumulative_times.at(key) * 1e-6);
const size_t cnt = invocation_counts.at(key);
const double avg_ms = total_ms / cnt;
printf(" %-45s: %12.5fms = %lld * %0.5fms (%zu invocations, %0.5fms = %lld * %0.5fms per invocation)\n", key.c_str(), total_ms, factor, total_ms/factor, cnt, avg_ms, factor, avg_ms/factor);
printf(" %-45s: %12.5fms = %" PRId64 " * %0.5fms (%zu invocations, %0.5fms = %" PRId64 " * %0.5fms per invocation)\n", key.c_str(), total_ms, factor, total_ms/factor, cnt, avg_ms, factor, avg_ms/factor);
}
void print_cumulative_times(const int64_t factor)

View File

@@ -15,8 +15,8 @@
namespace libsnark {
uint64_t log2(uint64_t n)
/* returns ceil(log2(n)), so 1ul<<log2(n) is the smallest power of 2,
size_t log2(size_t n)
/* returns ceil(log2(n)), so UINT64_C(1)<<log2(n) is the smallest power of 2,
that is not less than n. */
{
uint64_t r = ((n & (n-1)) == 0 ? 0 : 1); // add 1 if n is not power of 2

View File

@@ -20,13 +20,13 @@ namespace libsnark {
typedef std::vector<bool> bit_vector;
/// returns ceil(log2(n)), so 1ul<<log2(n) is the smallest power of 2, that is not less than n
uint64_t log2(uint64_t n);
/// returns ceil(log2(n)), so UINT64_C(1)<<log2(n) is the smallest power of 2, that is not less than n
size_t log2(size_t n);
inline uint64_t exp2(uint64_t k) { return 1ull << k; }
inline size_t exp2(size_t k) { return UINT64_C(1) << k; }
uint64_t bitreverse(uint64_t n, const uint64_t l);
bit_vector int_list_to_bits(const std::initializer_list<uint64_t> &l, const uint64_t wordsize);
size_t bitreverse(size_t n, const size_t l);
bit_vector int_list_to_bits(const std::initializer_list<uint64_t> &l, const size_t wordsize);
int64_t div_ceil(int64_t x, int64_t y);
bool is_little_endian();