#pragma once
#include <stdbool.h>
#include <stdint.h>
#if defined(_MSC_VER)
#pragma warning(disable : 4127)
#if _MSC_VER > 1800
#pragma warning(disable : 4464)
#endif
#endif
#include "../t1ha.h"
typedef uint64_t timestamp_t;
enum mera_flags {
timestamp_clock_have = 1u << 0,
timestamp_clock_cheap = 1u << 1,
timestamp_ticks = 1u << 2,
timestamp_cycles = 1u << 3,
timestamp_clock_stable = 1u << 4,
};
typedef struct {
unsigned (*start)(timestamp_t *);
unsigned (*finish)(timestamp_t *);
double (*convert)(timestamp_t);
const char *units;
const char *source;
unsigned flags;
int cpunum;
} mera_t;
extern mera_t mera;
bool mera_init(void);
typedef struct {
unsigned retry_count, restart_count;
unsigned overhead_loops_max, overhead_best_count, overhead_accounted_loops,
overhead_worthless_loops;
uint64_t overhead_best, overhead_gate;
unsigned target_loops, tail_loops_max, target_best_count,
target_accounted_loops, target_worthless_loops, spent_seconds;
uint64_t target_best, target_gate;
} mera_bci_t ;
extern mera_bci_t mera_bci;
typedef uint64_t (*mera_bench_target_t)(const void *data, size_t bytes,
uint64_t seed);
#define MERA_BENCH_TARGET mera_bench_target_t
#define MERA_BENCH_SELF_ARGS const void *data, size_t bytes, uint64_t seed
#define MERA_BENCH_TARGET_ARGS data, bytes, seed
#define MERA_PERROR_PREFIX " - "
double mera_bench(MERA_BENCH_TARGET target, MERA_BENCH_SELF_ARGS);
#if defined(__ia32__)
typedef struct _ia32_cpu_features {
struct {
uint32_t ebx;
uint32_t ecx;
uint32_t edx;
} basic
,
extended_7
;
struct {
uint32_t ecx;
uint32_t edx;
} extended_80000001
;
struct {
uint32_t ecx;
uint32_t edx;
} extended_80000007 ;
} ia32_cpu_features_t;
extern ia32_cpu_features_t ia32_cpu_features;
void ia32_fetch_cpu_features(void);
#endif