Skip to content

Commit 2b9f907

Browse files
committed
DEBUG_TIME fix
1 parent 0b88019 commit 2b9f907

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

hashtable/CUDA/src/main.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
// #define DEBUG_TIME
2323
#define CPP_MODULE "MAIN"
24+
#define ITERATIONS 10
2425

2526
#define TIMER_START() time_start = std::chrono::steady_clock::now();
2627
#define TIMER_END() \
@@ -170,7 +171,11 @@ START_TIMER();
170171
#ifdef DEBUG_TIME
171172
STOP_TIMER();
172173
PRINT_TIMER("init ");
174+
#endif
173175

176+
std::vector<KeyValue> kvs;
177+
for (int iter = 0; iter < ITERATIONS; iter++){
178+
#ifdef DEBUG_TIME
174179
START_TIMER();
175180
#endif
176181
// Allocates device memory for the hashtable and
@@ -231,7 +236,7 @@ PRINT_TIMER("delete_hashtable ");
231236
START_TIMER();
232237
#endif
233238
// Get all the key-values from the hash table
234-
std::vector<KeyValue> kvs = iterate_hashtable(pHashTable);
239+
kvs = iterate_hashtable(pHashTable);
235240
#ifdef DEBUG_TIME
236241
STOP_TIMER();
237242
PRINT_TIMER("iterate_hashtable ");
@@ -244,9 +249,10 @@ PRINT_TIMER("iterate_hashtable ");
244249

245250
destroy_hashtable(pHashTable);
246251

252+
}
247253
TIMER_END()
248254
TIMER_PRINT("hashtable - total time for whole calculation")
249-
printf("%f million keys/second\n", kNumKeyValues / (time_total / 1000.0f) / 1000000.0f);
255+
printf("%f million keys/second\n", kNumKeyValues / (time_total / ITERATIONS / 1000.0f) / 1000000.0f);
250256

251257
bool verify = true;
252258
if (argc > 1 && strcmp(argv[1], "--no-verify") == 0) {

hashtable/HIP/src/main.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
// #define DEBUG_TIME
2323
#define CPP_MODULE "MAIN"
24+
#define ITERATIONS 10
2425

2526
#define TIMER_START() time_start = std::chrono::steady_clock::now();
2627
#define TIMER_END() \
@@ -170,7 +171,11 @@ START_TIMER();
170171
#ifdef DEBUG_TIME
171172
STOP_TIMER();
172173
PRINT_TIMER("init ");
174+
#endif
173175

176+
std::vector<KeyValue> kvs;
177+
for (int iter = 0; iter < ITERATIONS; iter++){
178+
#ifdef DEBUG_TIME
174179
START_TIMER();
175180
#endif
176181
// Allocates device memory for the hashtable and
@@ -231,7 +236,7 @@ PRINT_TIMER("delete_hashtable ");
231236
START_TIMER();
232237
#endif
233238
// Get all the key-values from the hash table
234-
std::vector<KeyValue> kvs = iterate_hashtable(pHashTable);
239+
kvs = iterate_hashtable(pHashTable);
235240
#ifdef DEBUG_TIME
236241
STOP_TIMER();
237242
PRINT_TIMER("iterate_hashtable ");
@@ -243,10 +248,10 @@ PRINT_TIMER("iterate_hashtable ");
243248
// seconds = milliseconds / 1000.0f;
244249

245250
destroy_hashtable(pHashTable);
246-
251+
}
247252
TIMER_END()
248253
TIMER_PRINT("hashtable - total time for whole calculation")
249-
printf("%f million keys/second\n", kNumKeyValues / (time_total / 1000.0f) / 1000000.0f);
254+
printf("%f million keys/second\n", kNumKeyValues / (time_total / ITERATIONS / 1000.0f) / 1000000.0f);
250255

251256
bool verify = true;
252257
if (argc > 1 && strcmp(argv[1], "--no-verify") == 0) {

hashtable/SYCL/src/main.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
// #define DEBUG_TIME
2323
#define CPP_MODULE "MAIN"
24+
#define ITERATIONS 10
2425

2526
#define TIMER_START() time_start = std::chrono::steady_clock::now();
2627
#define TIMER_END() \
@@ -169,7 +170,11 @@ START_TIMER();
169170
#ifdef DEBUG_TIME
170171
STOP_TIMER();
171172
PRINT_TIMER("init ");
173+
#endif
172174

175+
std::vector<KeyValue> kvs;
176+
for (int iter = 0; iter < ITERATIONS; iter++) {
177+
#ifdef DEBUG_TIME
173178
START_TIMER();
174179
#endif
175180
// Allocates device memory for the hashtable and
@@ -233,7 +238,7 @@ PRINT_TIMER("delete_hashtable ");
233238
START_TIMER();
234239
#endif
235240
// Get all the key-values from the hash table
236-
std::vector<KeyValue> kvs = iterate_hashtable(pHashTable, qht);
241+
kvs = iterate_hashtable(pHashTable, qht);
237242
#ifdef DEBUG_TIME
238243
STOP_TIMER();
239244
PRINT_TIMER("iterate_hashtable ");
@@ -246,9 +251,10 @@ PRINT_TIMER("iterate_hashtable ");
246251

247252
destroy_hashtable(pHashTable, qht);
248253

254+
}
249255
TIMER_END()
250256
TIMER_PRINT("hashtable - total time for whole calculation")
251-
printf("%f million keys/second\n", kNumKeyValues / (time_total / 1000.0f) / 1000000.0f);
257+
printf("%f million keys/second\n", kNumKeyValues / (time_total / ITERATIONS / 1000.0f) / 1000000.0f);
252258

253259
bool verify = true;
254260
if (argc > 1 && strcmp(argv[1], "--no-verify") == 0) {

0 commit comments

Comments
 (0)