NVIDIA / NVIDIA/cuda-samples

cdpQuadtree does not work correctly on a large number of points

Open
#389 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
9.6k
Forks
2.4k
Avg merge
53m
Merged PRs (30d)
1

Description

I've found that the quadtree example doesn't work correctly for a large number of points, such as 100K. It fails the "check_quadtree" test. I tried to locate the problem with compute-sanitizer, which reported illegal memory access. Without the sanitizer, the kernel doesn't raise an error; it just produces incorrect results. By default, the tree depth is 8. With a leaf that can hold 16 points, it can hold 4^8 ∗16, which is about 1M points, but the sample code doesn't work as expected. Can you help me solve this issue?

========= Invalid __global__ write of size 4 bytes
=========     at void build_quadtree_kernel<(int)128>(Quadtree_node *, Points *, Parameters)+0x2280 in /home/geng.161/cuda-samples/Samples/3_CUDA_Features/cdpQuadtree/cdpQuadtree.cu:542
=========     by thread (127,0,0) in block (0,0,0)
=========     Address 0x7fe9f6a12170 is out of bounds
=========     and is 73,585 bytes after the nearest allocation at 0x7fe9f6a00000 of size 512 bytes
=========     Saved host backtrace up to driver entry point at kernel launch time
=========     Host Frame: [0x3812c8]
=========                in /lib/x86_64-linux-gnu/libcuda.so.1
=========     Host Frame:libcudart_static_4d8b33a106dceb3c07a56e26de61f2d53bb62a68 [0x1fcde]
=========                in /home/geng.161/cuda-samples/Samples/3_CUDA_Features/cdpQuadtree/debug/./cdpQuadtree
=========     Host Frame:cudaLaunchKernel [0x8292e]
=========                in /home/geng.161/cuda-samples/Samples/3_CUDA_Features/cdpQuadtree/debug/./cdpQuadtree
=========     Host Frame:cudaError cudaLaunchKernel<char>(char const*, dim3, dim3, void**, unsigned long, CUstream_st*) in /usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:216 [0xfaaf]
=========                in /home/geng.161/cuda-samples/Samples/3_CUDA_Features/cdpQuadtree/debug/./cdpQuadtree
=========     Host Frame:__device_stub__Z21build_quadtree_kernelILi128EEvP13Quadtree_nodeP6Points10Parameters(Quadtree_node*, Points*, Parameters&) in /tmp/tmpxft_00188328_00000000-6_cdpQuadtree.compute_86.cudafe1.stub.c:23 [0xf109]
=========                in /home/geng.161/cuda-samples/Samples/3_CUDA_Features/cdpQuadtree/debug/./cdpQuadtree
=========     Host Frame:void __wrapper__device_stub_build_quadtree_kernel<128>(Quadtree_node*&, Points*&, Parameters&) in /tmp/tmpxft_00188328_00000000-6_cdpQuadtree.compute_86.cudafe1.stub.c:24 [0xf166]
=========                in /home/geng.161/cuda-samples/Samples/3_CUDA_Features/cdpQuadtree/debug/./cdpQuadtree
=========     Host Frame:void build_quadtree_kernel<128>(Quadtree_node*, Points*, Parameters) in /home/geng.161/cuda-samples/Samples/3_CUDA_Features/cdpQuadtree/cdpQuadtree.cu:545 [0x12f86]
=========                in /home/geng.161/cuda-samples/Samples/3_CUDA_Features/cdpQuadtree/debug/./cdpQuadtree
=========     Host Frame:cdpQuadtree(int) in /home/geng.161/cuda-samples/Samples/3_CUDA_Features/cdpQuadtree/cdpQuadtree.cu:680 [0xea87]
=========                in /home/geng.161/cuda-samples/Samples/3_CUDA_Features/cdpQuadtree/debug/./cdpQuadtree
=========     Host Frame:main in /home/geng.161/cuda-samples/Samples/3_CUDA_Features/cdpQuadtree/cdpQuadtree.cu:729 [0xef3a]
=========                in /home/geng.161/cuda-samples/Samples/3_CUDA_Features/cdpQuadtree/debug/./cdpQuadtree
=========     Host Frame:__libc_start_main in ../csu/libc-start.c:342 [0x24083]
=========                in /lib/x86_64-linux-gnu/libc.so.6
=========     Host Frame:_start [0xdebe]
=========                in /home/geng.161/cuda-samples/Samples/3_CUDA_Features/cdpQuadtree/debug/./cdpQuadtree
=========

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Samples/3_CUDA_Features/cdpQuadtree/cdpQuadtree.cu, especially build_quadtree_kernel around lines 542–545 and the setup and launch at lines 680 and 729. Reproduce with 100K points, run the check_quadtree test under compute-sanitizer, and trace the tree allocation and indexing. Done means the sample passes check_quadtree without illegal memory accesses or incorrect results.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
hpc
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.