From b441484e6028e2662a1c9c1e37a7a31bd0e4014b Mon Sep 17 00:00:00 2001 From: Alexander Filonenko Date: Fri, 24 Mar 2017 19:25:11 +0900 Subject: [PATCH] Update atomics.cu Using a pointer prevents stack overflow error that was reported on forums. Tested using Windows 10, Visual Studio 2015, CUDA 8.0. --- Lesson Code Snippets/Lesson 2 Code Snippets/atomics.cu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lesson Code Snippets/Lesson 2 Code Snippets/atomics.cu b/Lesson Code Snippets/Lesson 2 Code Snippets/atomics.cu index 79369eac..a0f64648 100644 --- a/Lesson Code Snippets/Lesson 2 Code Snippets/atomics.cu +++ b/Lesson Code Snippets/Lesson 2 Code Snippets/atomics.cu @@ -40,7 +40,7 @@ int main(int argc,char **argv) NUM_THREADS, NUM_THREADS / BLOCK_WIDTH, ARRAY_SIZE); // declare and allocate host memory - int h_array[ARRAY_SIZE]; + int *h_array = new int[ARRAY_SIZE]; const int ARRAY_BYTES = ARRAY_SIZE * sizeof(int); // declare, allocate, and zero out GPU memory @@ -62,4 +62,4 @@ int main(int argc,char **argv) // free GPU memory allocation and exit cudaFree(d_array); return 0; -} \ No newline at end of file +}