From 4bc6a8eb66ef32fc17d2bfd190c8ebcd1da6785c Mon Sep 17 00:00:00 2001 From: syedshazli Date: Tue, 2 Dec 2025 17:14:47 -0500 Subject: [PATCH 1/2] Initial commit, removed comments Signed-off-by: syedshazli --- _posts/2025-08-11-cuda-debugging.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/_posts/2025-08-11-cuda-debugging.md b/_posts/2025-08-11-cuda-debugging.md index 02ef393..08cbf0f 100644 --- a/_posts/2025-08-11-cuda-debugging.md +++ b/_posts/2025-08-11-cuda-debugging.md @@ -96,14 +96,13 @@ __global__ void illegalMemoryAccessKernel(int* data, int size) { } } -// Kernel with illegal memory access - accesses memory beyond allocated bounds +// Simple kernel with no errors __global__ void normalKernel(int* data, int size) { int idx = blockIdx.x * blockDim.x + threadIdx.x; - // This will cause illegal memory access - accessing beyond allocated memory - // We allocate 'size' elements but access up to size * 2 - if (idx < size) { // Access twice the allocated size - data[idx] = idx; // + + if (idx < size) { + data[idx] = idx; } } From 09c4303e044c4fe15c037f753d0668495d2a7e66 Mon Sep 17 00:00:00 2001 From: syedshazli Date: Tue, 2 Dec 2025 17:15:50 -0500 Subject: [PATCH 2/2] Changed wording of blog Signed-off-by: syedshazli --- _posts/2025-08-11-cuda-debugging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/2025-08-11-cuda-debugging.md b/_posts/2025-08-11-cuda-debugging.md index 08cbf0f..784a633 100644 --- a/_posts/2025-08-11-cuda-debugging.md +++ b/_posts/2025-08-11-cuda-debugging.md @@ -151,7 +151,7 @@ int main() { } ``` -This code launches two kernels consecutively (`illegalMemoryAccessKernel` and `normalKernel`). During normal execution, you would encounter an error message: `CUDA Error at test.cu:62 - cudaMemcpy(h_data, d_data, size * sizeof(int), cudaMemcpyDeviceToHost): an illegal memory access was encountered`, and the error would only be detected in the return value of `cudaMemcpy`. Even with `CUDA_LAUNCH_BLOCKING=1`, it is still impossible to identify the specific kernel that caused the error. +This code launches two kernels consecutively (`illegalMemoryAccessKernel` and `normalKernel`). During execution, you would encounter an error message: `CUDA Error at test.cu:62 - cudaMemcpy(h_data, d_data, size * sizeof(int), cudaMemcpyDeviceToHost): an illegal memory access was encountered`, and the error would only be detected in the return value of `cudaMemcpy`. Even with `CUDA_LAUNCH_BLOCKING=1`, it is still impossible to identify the specific kernel that caused the error. By adding the CUDA core dump-related environment variables, we can observe: