From 167ab83b42809d59388c739390193cc6e7e3cbe0 Mon Sep 17 00:00:00 2001 From: KunoiSayami Date: Wed, 22 Jun 2022 13:15:16 +0800 Subject: fix: Fix spend time item not initialized Signed-off-by: KunoiSayami --- main.cu | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'main.cu') diff --git a/main.cu b/main.cu index c34add0..c33a236 100644 --- a/main.cu +++ b/main.cu @@ -309,7 +309,7 @@ public: __device__ void increaseRoundCount(unsigned count = 1) { atomicAdd(&this->round, count); } - int spend_time[NUM_ITEMS]; + int spend_time[NUM_ITEMS]{0}; unsigned long long total_time = 0; __device__ unsigned getRoundCount() const { return this->round; } #endif @@ -578,7 +578,7 @@ __global__ void kernel(LL *items, LL *op, LL *result) { #ifdef MEASURE_TIME unsigned long long end_time = clock64() - start_time; if (l->spend_time[tid]) { - printf("%d\n", tid); + printf("conflict: %d\n", tid); } l->spend_time[tid] = (int)end_time; #endif @@ -645,7 +645,7 @@ __global__ void print_function() { } __global__ void copy_function(int *spend_time) { - memcpy(spend_time, l->spend_time, sizeof(int) * NUM_THREADS); + memcpy(spend_time, l->spend_time, sizeof(int) * NUM_ITEMS); } int main(int argc, char **argv) { -- cgit v1.3.1