summaryrefslogtreecommitdiff
path: root/expt_0510.cu
diff options
context:
space:
mode:
authorKunoiSayami <[email protected]>2023-06-01 16:09:13 +0800
committerKunoiSayami <[email protected]>2023-06-01 16:09:13 +0800
commitd8384bdc4aa7fa1ccc24aec296fac83f1d43a2b4 (patch)
tree31f2dfd29c191596bf6d7275b82826de745943f0 /expt_0510.cu
parent5d373e5db4d1626f085c5f19ab8481f8a0b14226 (diff)
feat: Optimize read_helper library
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'expt_0510.cu')
-rw-r--r--expt_0510.cu36
1 files changed, 6 insertions, 30 deletions
diff --git a/expt_0510.cu b/expt_0510.cu
index 82f2624..eca1b92 100644
--- a/expt_0510.cu
+++ b/expt_0510.cu
@@ -1,6 +1,7 @@
// Experimental content: Test branch performance (optimized memory)
#include "sortlib.cuh"
+#include "read_helper.h"
#include <algorithm>
#include <cassert>
#include <cstdio>
@@ -167,34 +168,6 @@ unsigned long randomRow(unsigned long max_value_) {
return dst(mt19937);
}
-void readFile(char const *filename, long sample_length,
- unsigned long &total_row,
- unsigned long max_number = TEST_LENGTH) {
- auto read_number = 0UL;
- FILE *file = fopen(filename, "r");
- assert(file);
- for (long long i;
- read_number < max_number && fscanf(file, "%lld ", &i) != EOF;
- store_into_vector(i))
- read_number++;
-
- if (total_row > 0) {
- read_number = randomRow(total_row - sample_length - max_number - 256);
- total_row = read_number;
- // fprintf(stderr, "Skip %lu\n", read_number);
- for (long long i; read_number > 0 && fscanf(file, "%lld ", &i) != EOF;)
- read_number--;
- }
-
- read_number = 0;
-
- auto remain = sample_length + 256;
- for (long long i; read_number < remain && fscanf(file, "%lld ", &i) != EOF;
- store_into_vector(i))
- read_number++;
- fclose(file);
-}
-
long pow_for_sample(long n) {
auto x = 2;
for (int i = 0; i < n; i++) {
@@ -225,10 +198,13 @@ int main(int argc, char const *argv[]) {
// CustomSort::testSelf(sample_length);
- readFile("normal_distribution.txt", sample_length, total_row, test_size);
+ ReadHelper readHelper("normal_distribution.txt", sample_length, test_size,
+ total_row);
+ readHelper.readFile();
printf("population: %zu, skip: %lu, test size: %zu, sample length: %zu | ",
- population_vector.size(), total_row, test_size, sample_length);
+ population_vector.size(), readHelper.random_number, test_size,
+ sample_length);
sample_vector = std::vector<key_type>(
population_vector.begin(), population_vector.begin() + sample_length - 2);