Repository navigation
feat(acceleration): Kernel Block-Dimension Occupancy Tuning (v1.9.0) - #4618
Merged
makr-code merged 2 commits intoApr 13, 2026
Merged
Conversation
14 tasks
…, v1.9.0) Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/6e3ed4c6-7684-4ff0-b589-5e09a43935da Co-authored-by: makr-code <[email protected]>
Copilot
AI
changed the title
[WIP] Implement kernel block-dimension occupancy tuning for v1.9.0
feat(acceleration): Kernel Block-Dimension Occupancy Tuning (v1.9.0)
Apr 13, 2026
makr-code
marked this pull request as ready for review
April 13, 2026 11:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces all hard-coded
256-thread block sizes in CUDA/HIP kernel launchers with runtime-tuned values queried viacudaOccupancyMaxPotentialBlockSize/hipOccupancyMaxPotentialBlockSizeatinitialize()time. Adds AMD GCN wavefront-64 awareness and Vulkan specialization-constant injection for the L2 compute pipeline.Description
Pattern applied across all affected kernel TUs
Each
.cu/.hipfile now exposes a module-level mutable block-size variable, a direct setter, and an internal tuner that calls the occupancy API on its own kernel pointer — avoiding the need to expose__global__symbols across TU boundaries:Files changed
CUDA kernel files
cuda/geo_kernels.cu—g_cuda_geo_block_size;tuneGeoKernelBlockSize()querieshaversineDistanceKernelcuda/graph_kernels.cu—kBFSBlockDim(now mutable);tuneGraphBFSBlockDim()queriesgraphBFSInitKernelcuda/vector_kernels.cu—g_cuda_vec_block_dimreplacesdim3(16,16);tuneVecKernelBlockSize()queriescomputeL2DistanceKernel, computes integer-sqrt 2-D blockHIP kernel files
hip/ann_kernels.hip—g_hip_topk_block_size;hipSetTopKBlockSize(int)hip/geo_kernels.hip—g_hip_geo_block_size;hipSetGeoKernelBlockSize(int)Backend initialization
hip_backend.cpp—HIPBackendImpl::occupancyTunedBlockSize; starts baseline at 64 whenwarpSize == 64(AMD GCN), then queriestopKSelectionKernel; propagates to all HIP launcher setters;batchKnnSearchWithMetricreads the stored valuecuda_backend.cpp—CUDAVectorBackend,CUDAGraphBackend,CUDAGeoBackendeach call their respectivetune*()ininitialize()Vulkan backend
vulkan_backend_full.cpp—createComputePipelines()builds aVkSpecializationInfo(constant_id 0 →LOCAL_SIZE_X, 1 →LOCAL_SIZE_Y) injected into the L2 pipeline stage; 32×16 whenmaxComputeWorkGroupInvocations ≥ 512, otherwise 16×16Benchmark
benchmarks/kernel_block_size_bench.cpp— Google Benchmark sweeping 64/128/256/512 for CUDA geo Haversine, HIP geo Haversine, and HIP top-K; reportspairs_per_sec/queries_per_secrate counterscmake/CMakeLists.txt— registerskernel_block_size_benchtargetDocumentation
src/acceleration/FUTURE_ENHANCEMENTS.md— all implementation items marked[x]Linked Issues
Closes #234
Type of Change
Breaking Change Checklist
N/A
Testing
📚 Research & Knowledge (wenn applicable)
Relevante Quellen:
Checklist
[Unreleased]