diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/drama/src/rev-mc.c b/drama/src/rev-mc.c index 3c52ace..9564d14 100644 --- a/drama/src/rev-mc.c +++ b/drama/src/rev-mc.c @@ -11,6 +11,7 @@ #include +#include #include #include #include @@ -37,6 +38,7 @@ typedef std::vector set_t; //------------------------------------------- +bool is_in(char* val, std::set arr); bool is_in(char* val, std::vector arr); bool found_enough(std::vector sets, uint64_t set_cnt, size_t set_size); void filter_sets(std::vector& sets, size_t set_size); @@ -44,9 +46,11 @@ void print_sets(std::vector sets); void verify_sets(std::vector& sets, uint64_t threshold, size_t rounds); //------------------------------------------- +static std::vector 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& sets, std::vector 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 sets; - std::vector used_addr; + // std::vector used_addr; + std::set used_addr; std::vector 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 arr) { + return arr.find(val) != arr.end(); +} + bool is_in(char* val, std::vector arr) { for (auto v: arr) { if (val == v) {