Skip to content

Fix Siddon projection kernel missing return on missed rays (cone and parallel) - #791

Closed
hashimoto-koh wants to merge 1 commit into
CERN:masterfrom
hashimoto-koh:fix/siddon-missing-return-on-missed-ray
Closed

hashimoto-koh wants to merge 1 commit into
CERN:masterfrom
hashimoto-koh:fix/siddon-missing-return-on-missed-ray

Conversation

@hashimoto-koh

Copy link
Copy Markdown

Description

In Siddon_projection.cu and Siddon_projection_parallel.cu, when a ray does not intersect the bounding box of the voxel volume (am >= aM), detector[idx] is set to 0, but the kernel forgets to return.

Consequently, GPU threads for missed rays continue executing subsequent index computations, texture fetches, and loop iterations with invalid index ranges (such as imin > imax), causing unnecessary GPU instruction overhead and potential undefined behaviors.

This PR adds an early return; immediately after zeroing the detector pixel on missed rays in both cone-beam and parallel-beam Siddon projection kernels.

Changes

  • Common/CUDA/Siddon_projection.cu: early return when am >= aM
  • Common/CUDA/Siddon_projection_parallel.cu: early return when am >= aM
  • Python/tests/test_siddon_missed_rays.py: regression test for missed rays in both cone and parallel modes

…parallel)

Add early return after zeroing detector on missed rays (am >= aM) to avoid invalid index ranges and unnecessary computation in subsequent steps. Add regression test test_siddon_missed_rays.py covering cone and parallel modes.
@AnderBiguri

Copy link
Copy Markdown
Member

Ca you clarify how this PR is different to this one: #779?

@hashimoto-koh

Copy link
Copy Markdown
Author

Hi @AnderBiguri,

Apologies for the oversight — I hadn't noticed #779 when opening this PR.

You are completely right: the core fix (adding the missing return; when am >= aM in both Siddon_projection.cu and Siddon_projection_parallel.cu to prevent infinite looping / GPU hang) is essentially identical to #779.

The main differences are:

  1. No binary files: This PR does not include the PNG image asset or figure generators present in Siddon: a missed ray must RETURN, or the projector never comes back #779.
  2. Minimal & fast regression test: This PR includes a small, lightweight unit test (Python/tests/test_siddon_missed_rays.py) that runs in under a second without multiprocessing/timeouts, and passes all CI checks.

Next steps (up to your preference):

@AnderBiguri AnderBiguri closed this Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants