From d8384bdc4aa7fa1ccc24aec296fac83f1d43a2b4 Mon Sep 17 00:00:00 2001 From: KunoiSayami Date: Thu, 1 Jun 2023 16:09:13 +0800 Subject: feat: Optimize read_helper library Signed-off-by: KunoiSayami --- expt_0525.cu | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'expt_0525.cu') diff --git a/expt_0525.cu b/expt_0525.cu index c2ee041..8867cee 100644 --- a/expt_0525.cu +++ b/expt_0525.cu @@ -76,7 +76,6 @@ typedef unsigned long long LL; // #define MEASURE_TIME // #define MEASURE_ACCESS -#define READ_NO_OUTPUT #include "read_helper.h" #if (defined(MEASURE_ACCESS) && defined(MEASURE_TIME)) @@ -108,12 +107,6 @@ constexpr size_t FACTOR = 1; typedef LL key_type; -#ifdef RANDOM_TARGET -constexpr const char *TARGET_STRING = "RANDOM"; -#else -// constexpr const char *TARGET_STRING = "PERFECT"; -#endif - #define CUDA_ERROR_CHECK #define CudaSafeCall(err) __cudaSafeCall(err, __FILE__, __LINE__) @@ -153,7 +146,13 @@ inline void __cudaCheckError(const char *file, const int line) { // Definition of generic node class -class __attribute__((aligned(16))) Node { +class +#ifndef _MSC_VER + __attribute__((aligned(16))) +#else + __declspec(align(16)) +#endif + Node { public: int topLevel; // Level of the node LL key; // Key value @@ -636,7 +635,7 @@ inline double calcSliceSize(size_t insertion_size) { return 1.0 / (double)insertion_size; } -inline size_t calcBlocks(size_t input) { +inline auto calcBlocks(size_t input) { return (input % (NUM_THREADS * FACTOR) == 0) ? input / (NUM_THREADS * FACTOR) : (input / (NUM_THREADS * FACTOR)) + 1; @@ -660,8 +659,8 @@ int main(int argc, char **argv) { insertion_length, search_length); ReadHelper readHelper("normal_distribution.txt", sample_length, - insertion_length); - readHelper.readFile(nullptr); + insertion_length, 0); + readHelper.readFile(); std::vector _sample, _population; readHelper.split_into(_sample, _population); /*printf("%lu, Create search vector: %ld\n", _population.size(), -- cgit v1.3.1