diff options
| author | KunoiSayami <[email protected]> | 2023-05-01 19:50:15 +0800 |
|---|---|---|
| committer | KunoiSayami <[email protected]> | 2023-05-01 19:50:15 +0800 |
| commit | 6f6359c6d9f1a05b509b0509762b77df127ebe37 (patch) | |
| tree | 8a28f56b7e0b84fdc0e8cbe7ee88e0d6364b471f /expt_0804.cu | |
| parent | 4c6a7764a97c6daf836197022ea154fdc387c015 (diff) | |
2023-05-01 19:50
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'expt_0804.cu')
| -rw-r--r-- | expt_0804.cu | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/expt_0804.cu b/expt_0804.cu index a94dd2b..66f66ec 100644 --- a/expt_0804.cu +++ b/expt_0804.cu @@ -30,7 +30,7 @@ constexpr long SAMPLE_LENGTH = 1024; constexpr long TEST_SIZE = 1024; -__device__ key_type *SampleItem, *PopulationItem; +__device__ key_type *cudaSampleItem, *cudaPopulationItem; __device__ bool *cdf_result; __device__ unsigned insert_value; #ifdef TEST_BOUNDS @@ -62,15 +62,15 @@ __device__ __host__ size_t calculate_location(size_t index) { } __device__ double sample_cdf(double x) { - auto it = cudaBinarySearch(SampleItem, x); - if (it == SampleItem + SAMPLE_LENGTH) { + auto it = cudaBinarySearch(cudaSampleItem, x); + if (it == cudaSampleItem + SAMPLE_LENGTH) { return 1; } - if (it == SampleItem) { + if (it == cudaSampleItem) { return 0; } auto it_prev = it - 1; - return (double(it_prev - SampleItem) + + return (double(it_prev - cudaSampleItem) + (x - (double)*it_prev) / (double)(*it - *it_prev)) / double(SAMPLE_LENGTH - 1); } @@ -88,11 +88,12 @@ __global__ void initStorage(unsigned scale, unsigned test_size) { } __global__ void initCuda(key_type *sample_item, key_type *population_item) { - SampleItem = sample_item; - PopulationItem = population_item; + cudaSampleItem = sample_item; + cudaPopulationItem = population_item; /*for (int i = 0; i < SAMPLE_LENGTH; i++) { }*/ - // cudaMalloc(&SampleItem, (SAMPLE_LENGTH + 2) * sizeof(unsigned long long)); + // cudaMalloc(&cudaSampleItem, (SAMPLE_LENGTH + 2) * sizeof(unsigned long + // long)); // cudaMalloc(&Storage, TEST_SIZE * sizeof(key_type)); cdf_result = nullptr; } @@ -104,7 +105,7 @@ __global__ void kernel(unsigned long step, const double slice_size, threadIdx.x + i; // printf("%d\n", tid); - auto index = (int)(sample_cdf(PopulationItem[tid]) / slice_size); + auto index = (int)(sample_cdf(cudaPopulationItem[tid]) / slice_size); if (cdf_result[index]) { while (cdf_result[++index]) { assert(index < split_size); |
