Port Multiply.cuh to spla
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
Piste de recherche
Start with GALATIC/source/device/Multiply.cuh and the private OpenCL mxm wrappers named in the plan, then inspect the existing OpenCL test patterns and registry in src/opencl/cl_algo_registry.cpp. The plan divides the work into buffer/config helpers, the orchestration loop, and public algorithm registration, with focused tests at each stage. Done means the public OpenCL mxm matches the CPU semiring result, stores no additive-identity entries, and the specified verification gates pass.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Detailed plan: port Multiply.cuh to spla (task #290)
Integration branch: mxm-opencl (stacked mode). Feature branch: feature/290-multiply-cuh, created from mxm-opencl.
Task #290 wires the already ported private OpenCL mxm modules into an end-to-end generic sparse matrix product and registers it for public mxm. The GALATIC orchestrator is GALATIC/source/device/Multiply.cuh; the current whitelisted template tuple is THREADS=128, BLOCKS_PER_MP=1, NNZ_PER_THREAD=2, INPUT_ELEMENTS_PER_THREAD=2, RETAIN_ELEMENTS_PER_THREAD=1, MAX_CHUNKS_TO_MERGE=16, MAX_CHUNKS_GENERALIZED_MERGE=256, MERGE_PATH_OPTIONS=8. User guidance is to preserve GALATIC's two independent restart caps of 128; Algorithm Semantics' "3 times" note does not replace that explicit decision.
S1: Add private multiply configuration and buffer-state helpers [pending]
Code: add src/opencl/cl_mxm_pipeline.hpp in namespace spla::cl_mxm with the fixed GALATIC constants, typed semiring configuration builders for ComputeSpgemmPartConfig, merge configs, ChunksToCsrConfig, an owned typed buffer bundle for all intermediate CSR/chunk/merge/restart arrays, and small host helpers to allocate zeroed buffers, read scalar flags/counters, write/compute starting_ids and per-block nnz, and grow pool/pointer storage without losing published chunks. Reuse the existing fixed 32-bit chunk index layout, WorkSplitConfig::nnz_per_block(), csp_cut_off(), compute_spgemm_part_sort_type_mode(), assign_combine_blocks() case thresholds, and cl_csr_resize(); do not introduce a parallel copy of any sizing or status rule. Add the new header to CMakeLists.txt as a source entry only if the project lists private headers there.
Tests: add host-only validation tests in a new tests/test_opencl_mxm_pipeline.cpp with target_include_directories(... PRIVATE src svector robin_hood) for config derivation: GALATIC constants, restart caps, cut-off derivation, case offsets, and zeroed buffer sizes. Mark new gtest cases with the accelerator-independent main pattern used by other private module tests where possible.
Docs: record in the Code section that the helper layer reuses all existing private wrapper configs and only adds ownership/layout glue, so no public Doxygen or pdoc change is required. Mirror the detailed plan to issue #290.
Spec:
- No new kernel source is added; no generated source changes are required.
- Chunk index bits stay 32; compute
sort_type_moderemains-1so the existing wrapper derives GALATIC modes 0/1/2. - Flags are read as whole
uintvalues; pool bit is0x1, pointer bit is0x2. - Restart counters are independent and each fails after 128 restarts, matching GALATIC.
- Focused config tests must pass with zero failures.
Finding: the private wrappers expose all primitives needed, but no shared owner exists for their transient buffers. The orchestrator therefore needs a typed host-side bundle; duplicating kernel logic is not required.
S2: Implement the full private orchestration loop [pending]
Code: in src/opencl/cl_mxm_pipeline.hpp, add cl_mxm::multiply(queue, R, A, B, op_multiply, op_add, init). Execute the GALATIC sequence: estimate chunk pool; allocate pool and pointer table; run determine_block_starts; build compute starting_ids/nnz; reset run/state arrays; loop compute until flags are zero, growing chunk storage on bit 0x1 and pointer storage on bit 0x2 while rewinding chunk_pointer_alloc from chunk_pointer_position; when compute completes, call assign_combine_blocks once; grow and reset merge restart arrays on shared-row high-water growth; dispatch SIMPLE/MAX_CHUNKS/GENERALIZED with GALATIC restart_offset values; loop merges with the same flag handling and preserve already-published rows; compute final row offsets, determine output nnz, resize CLCsr<T> output, and run chunks_to_csr. Handle a_rows==0 or nnz_a==0 as a valid empty result. Return the first non-Ok status from any private wrapper without publishing a partial public result.
Tests: extend tests/test_opencl_mxm_pipeline.cpp with end-to-end private tests for a small dense-ish product, cancellation to additive identity, a long row that reaches the direct-chunk path, and an empty input. Compare against a CPU reference built from the public semiring functions. Use the existing OpenCL test main/finalize pattern and accelerator limit helpers.
Docs: record in the Code section that GALATIC's Either tags are represented by the existing SPLA restart-kind buffers, CUB BlockScan/BlockRadixSort map to the existing portable SPLA device modules, and no naive scan or sort is introduced. No public API change, so no Doxygen/pdoc update.
Spec:
- Completion rule: a stage attempt is complete only when its run flag is zero.
- On pointer restart, only
chunk_pointer_allocis rewound; chunk pool cursor, row heads, row counts, completion status and handled flags are preserved. - On pool restart, published chunks and pointer state are preserved; a new same-sized pool is allocated.
- Merge restart arrays are indexed by
block + restart_offset. - Final
result_offsetsis the exclusive prefix sum ofoutput_row_count; the last entry is the output nnz. - OpenCL tests must pass with zero failures and zero skipped tests on an available device.
Finding: GALATIC uses three streams for the three merge cases; SPLA's private wrappers take one command queue, so all stages are enqueued in order on the selected default queue. This preserves correctness and all restart semantics while using the existing single-queue accelerator API.
S3: Register the algorithm and add public end-to-end coverage [pending]
Code: add src/opencl/cl_mxm.hpp defining Algo_mxm_cl<T> following Algo_mxmT_masked_cl<T>: validate R writable and A/B readable in FormatMatrix::AccCsr, obtain CLCsr<T> storage, build private configs using get_ttype<T>(), op_multiply, op_add, and the additive-identity literal from init, then call cl_mxm::multiply(). Include the header in src/opencl/cl_algo_registry.cpp and register make_key_cl_0("mxm", INT/UINT/FLOAT). Leave the CPU registration and public API unchanged.
Tests: extend tests/test_mxm.cpp with an OpenCL-backed exec_mxm case that verifies matrix dimensions, sparse output entries, and absence of additive-identity entries. Keep the existing CPU tests unchanged and add an accelerator-gated expectation only where the runtime reports a usable GPU.
Docs: record in this plan that the public exec_mxm API is unchanged and the new algorithm is selected by the existing registry suffix, so no Doxygen/pdoc update is required. Mark T21 done in tasks/global_plan.md. Mirror the final plan state to issue #290.
Spec:
R = A * Bmust match the CPU semiring result for supported scalar types.- No additive-identity values are stored in the result.
- Registry must prefer the OpenCL
mxmalgorithm whenever acceleration is available and not force-disabled. - Final subtask commit message includes standalone
Closes #290andCloses #251lines.
Finding: public exec_mxm already creates ScheduleTask_mxm and dispatches by registry key; only the missing OpenCL algorithm registration prevents the private pipeline from being selected.
Design notes
- User guidance recorded verbatim: "Module + wiring (Recommended)", "Yes, full workflow", and "Preserve GALATIC 128".
- GALATIC source:
/home/dmitry-sergeev/SPLA/GALATIC/source/device/Multiply.cuhandGALATIC/include/device/MultiplyKernels.h. - CUB primitives observed in the GALATIC call graph:
BlockScan,BlockRadixSort,DeviceScan, warp reductions/ballot. SPLA already has portable analogs inblock_scan.cl,block_radix_sort.cl,cl_prefix_sum.hpp, and the private mxm wrappers; no naive replacement is introduced. - Restart semantics preserve the existing direct OOM behavior from task #289: direct pool/pointer failures set only run-flag bits.
Verification
Run focused build and focused tests after S1, S2 and S3; format all touched C/C++ files with clang-format v21 after each subtask. Final Release quality gate from DEVELOPMENT.md: build, python ./run_tests.py --build-dir=build, find include src tests examples \( -name '*.h' -o -name '*.hpp' -o -name '*.cpp' \) -print0 | xargs -0 clang-format --dry-run -Werror, doxygen Doxyfile, and SPLA_DOCS=true pdoc -o pydocs python/pyspla.
- Langage dominant
- C++
- Étoiles
- 37
- Forks
- 21
- Merge moyen
- 11 h 3 min
- PR mergées (30 j)
- 13
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de SparseLinearAlgebra/spla
-
task
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
SparseLinearAlgebra/spla#316 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
task
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
SparseLinearAlgebra/spla#249 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
task
Difficulté 4/5 3-5 jours Accessibilité débutants 52/100
SparseLinearAlgebra/spla#315 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
task
Difficulté 3/5 1-2 jours Accessibilité débutants 70/100
SparseLinearAlgebra/spla#314 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Optimize compute_spgemm_part chunk flushes, atomics, radix sort, SLM, restrict, and subgroup shuffleOuvertetask
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
SparseLinearAlgebra/spla#313 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de SparseLinearAlgebra/spla
Issues similaires
-
[Bug]: pip install -U cudaq-qec fails with a conflict that names cudaq-qec itselfPeut-être pris @fedonman l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
Les mainteneurs répondent en général sous 3 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
gofractally/psibase#2379 ·
Les mainteneurs répondent en général sous 3 jours