CUDA: split the cluster finder into algorithm, stream context and driver

ClusterFinderCUDA mixed three things: which kernel runs and what device
state it needs, the per-stream buffers, and the batching pipeline. A
second algorithm meant a second copy of all of it. The pieces are now
separate and the driver is templated on the algorithm.

  cuda::FixedWindow  (clusterfinder_algo.cuh)  the fixed-size window
      search: DeviceState pointer bundle, launch(), and the pedestal
      transforms. Stateless; every pointer is supplied by the caller,
      so external code can drive the kernel on its own memory and
      stream without touching the driver.
  StreamContext<Algo>  one stream's buffers, RAII, non-movable.
  ClusterFinderCUDA<Algo>  the pipeline, unchanged in behaviour.

no_2x2_cluster moves to Cluster.hpp so the kernel and algorithm headers
no longer drag in ClusterFinder.hpp. The Python factory gains
algorithm="fixed_window"; memory stays internal.

Kernel SASS identical to before. Positions identical against
ClusterFinderFrozen for 3x3, 5x5, 9x9 (stream and graph finders). New
Catch2 test drives FixedWindow::launch on raw cudaMalloc buffers and
requires exact agreement with the driver.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
kferjaouiandClaude Fable 5.1 committed 2026-09-10 12:08:16 +02:00
1 parent 570938e88c
commit 272b483c6c
12 files changed
+1231 -781

No files matched your search

+4 -1
View File
@@ -27,7 +27,10 @@ void define_ClusterFinderCUDA(py::module &m, const std::string &typestr) {
auto class_name = fmt::format("ClusterFinderCUDA_{}", typestr);
using ClusterType = Cluster<T, ClusterSizeX, ClusterSizeY, CoordType>;
using CF = ClusterFinderCUDA<ClusterType, uint16_t, pd_type>;
// The driver is templated on the algorithm; a second algorithm is a second
// instantiation registered under its own suffix (see ClusterFinder.py).
using Algo = aare::cuda::FixedWindow<ClusterType, uint16_t>;
using CF = ClusterFinderCUDA<Algo, pd_type>;
using ContigArr =
py::array_t<uint16_t, py::array::c_style | py::array::forcecast>;