fix: error
This commit is contained in:
parent
7ea523a414
commit
fc97358971
0
.gitignore
vendored
Normal file
0
.gitignore
vendored
Normal file
@ -11,6 +11,7 @@
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
#include <bitset>
|
||||
@ -37,6 +38,7 @@
|
||||
typedef std::vector<addr_tuple> set_t;
|
||||
|
||||
//-------------------------------------------
|
||||
bool is_in(char* val, std::set<char*> arr);
|
||||
bool is_in(char* val, std::vector<char*> arr);
|
||||
bool found_enough(std::vector<set_t> sets, uint64_t set_cnt, size_t set_size);
|
||||
void filter_sets(std::vector<set_t>& sets, size_t set_size);
|
||||
@ -44,9 +46,11 @@ void print_sets(std::vector<set_t> sets);
|
||||
void verify_sets(std::vector<set_t>& sets, uint64_t threshold, size_t rounds);
|
||||
|
||||
//-------------------------------------------
|
||||
static std::vector<uint64_t> time_vals;
|
||||
uint64_t time_tuple(volatile char* a1, volatile char* a2, size_t rounds) {
|
||||
|
||||
uint64_t* time_vals = (uint64_t*) calloc(rounds, sizeof(uint64_t));
|
||||
// uint64_t* time_vals = (uint64_t*) calloc(rounds, sizeof(uint64_t));
|
||||
time_vals.resize(rounds);
|
||||
uint64_t t0;
|
||||
sched_yield();
|
||||
for (size_t i = 0; i < rounds; i++) {
|
||||
@ -61,8 +65,8 @@ uint64_t time_tuple(volatile char* a1, volatile char* a2, size_t rounds) {
|
||||
|
||||
}
|
||||
|
||||
uint64_t mdn = median(time_vals, rounds);
|
||||
free(time_vals);
|
||||
uint64_t mdn = median(time_vals.data(), rounds);
|
||||
// free(time_vals);
|
||||
return mdn;
|
||||
}
|
||||
|
||||
@ -318,6 +322,7 @@ uint64_t find_row_mask(std::vector<set_t>& sets, std::vector<uint64_t> fn_masks,
|
||||
next_mask:
|
||||
row_mask = next_bit_permutation(row_mask);
|
||||
}
|
||||
return row_mask;
|
||||
|
||||
// super hackish way to recover the real row mask
|
||||
for (auto m:fn_masks) {
|
||||
@ -340,7 +345,8 @@ void rev_mc(size_t sets_cnt, size_t threshold, size_t rounds, size_t m_size, cha
|
||||
int o_fd = 0;
|
||||
int huge_fd = 0;
|
||||
std::vector<set_t> sets;
|
||||
std::vector<char*> used_addr;
|
||||
// std::vector<char*> used_addr;
|
||||
std::set<char*> used_addr;
|
||||
std::vector<uint64_t> fn_masks;
|
||||
|
||||
srand((unsigned) time(&t));
|
||||
@ -371,7 +377,8 @@ void rev_mc(size_t sets_cnt, size_t threshold, size_t rounds, size_t m_size, cha
|
||||
if (is_in(rnd_addr, used_addr))
|
||||
continue;
|
||||
|
||||
used_addr.push_back(rnd_addr);
|
||||
// used_addr.push_back(rnd_addr);
|
||||
used_addr.insert(rnd_addr);
|
||||
|
||||
addr_tuple tp = gen_addr_tuple(rnd_addr);
|
||||
bool found_set = false;
|
||||
@ -421,6 +428,10 @@ void rev_mc(size_t sets_cnt, size_t threshold, size_t rounds, size_t m_size, cha
|
||||
//----------------------------------------------------------
|
||||
// Helpers
|
||||
|
||||
bool is_in(char* val, std::set<char*> arr) {
|
||||
return arr.find(val) != arr.end();
|
||||
}
|
||||
|
||||
bool is_in(char* val, std::vector<char*> arr) {
|
||||
for (auto v: arr) {
|
||||
if (val == v) {
|
||||
|
Loading…
Reference in New Issue
Block a user