diff options
Diffstat (limited to 'main.cu')
| -rw-r--r-- | main.cu | 33 |
1 files changed, 30 insertions, 3 deletions
@@ -69,6 +69,7 @@ Conference on Parallel and Distributed Systems, December 2012. #include <cstdio> #include <cstdlib> #include <random> +#include <set> #if __WORDSIZE == 64 typedef unsigned long long LL; @@ -601,9 +602,6 @@ LL RandomLevel(std::mt19937 &randomEngine, double p) { } std::vector<LL> storage; -#ifdef MEASURE_TIME -std::vector<int> SpendTimeVec; -#endif unsigned trailing_zeroes(size_t index) { unsigned bits = 0; @@ -648,6 +646,35 @@ __global__ void copy_function(int *spend_time) { memcpy(spend_time, l->spend_time, sizeof(int) * NUM_ITEMS); } +std::vector<double> population; +std::vector<double> sample; + +void initialize(const std::vector<double> &input_population, + const std::vector<double> &input_sample) { + population = input_population; + std::sort(population.begin(), population.end()); + sample = input_sample; + std::sort(sample.begin(), sample.end()); +} + +double sample_cdf(double x) { + auto it = lower_bound(sample.begin(), sample.end(), x); + if (it == sample.end()) { + return 1; + } + if (it == sample.begin()) { + return 0; + } + auto it_prev = it - 1; + return (double(it_prev - sample.begin()) + + double(x - *it_prev) / (*it - *it_prev)) / + double(sample.size() - 1); +} + +int infer_offset(double x) { + return int(sample_cdf(x) * double(population.size())); +} + int main(int argc, char **argv) { if (argc != 3) { printf("Need two arguments: percent add ops and percent delete ops (e.g., " |
