Skip to content

Clean up the spotfinder's kernel launch geometry - #163

Open
dimitrivlachos wants to merge 6 commits into
mainfrom
spotfinder-launch-geometry
Open

dimitrivlachos wants to merge 6 commits into
mainfrom
spotfinder-launch-geometry

Conversation

@dimitrivlachos

@dimitrivlachos dimitrivlachos commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Building on #159, this PR tidies up how the spotfinder launches its
thresholding kernels. The block size was a bare {32, 16}, and each
kernel worked out its own shared memory split by hand, separately from
the size the launch asked for, so changing one without the other would
have gone unnoticed. The image tile also only lined up for 32-bit
pixels because the mask tiles in front of it happened to come out a
multiple of 4 bytes.

While in there I removed the image batching path. The original
spotfinder could load several images into one buffer and launch over
all of them, with each block picking out its image by blockIdx.z,
but the host side of that was taken out in March 2023 and only the
kernel offsets were left. They still cost about 80 instructions, and
the extended second pass, written since, never offsets its dispersion
mask, so a batch would not have worked as the code stands. Bringing
batching back would need batch-sized buffers, offsets on every
per-image pointer, and a decode step that stages several images per
upload.

I also swept six block shapes to see whether 32x16 was worth keeping.
32x8 was about 6% faster on the dispersion algorithm, however, it
began producing non deterministic results which is beyond the scope
of this PR. Thus it remains at 32x16 where results appear
deterministic and an investigation of this will come next.

Changes

  • include/spotfinder/launch_geometry.hpp: new, naming both block
    shapes and holding the shared memory arithmetic in one place.
  • spotfinder/kernels/thresholding.cu: the batching offsets are gone,
    and static asserts check each kernel's shared memory split against
    the launch and the image tile's alignment.
  • spotfinder/spotfinder.cu: the erosion launch no longer asks for
    shared memory it never uses, and check_launch_geometry rejects a
    block too small for the halo or too big for the device's shared
    memory.
  • spotfinder/spotfinder.cc: --dmin and --dmax are checked, since
    a negative value was quietly ignored and a reversed range masked the
    whole image.

@dimitrivlachos dimitrivlachos self-assigned this Nov 10, 2026
@dimitrivlachos
dimitrivlachos force-pushed the spotfinder-launch-geometry branch 3 times, most recently from ce0473a to c4354fa Compare November 12, 2026 17:30
@dimitrivlachos
dimitrivlachos force-pushed the spotfinder-launch-geometry branch from c4354fa to ff1946d Compare November 12, 2026 17:57
@dimitrivlachos
dimitrivlachos marked this pull request as ready for review November 16, 2026 17:17

This branch has not been deployed

No deployments
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.

1 participant