Skip to content

Commit 8b1412f

Browse files
PatchMatch: Remove shared current-cost cache (refactor)
## Summary - Read sampled current costs from the existing cost map in the ordered fold. Remove the CUDA-only shared array, producer store and source-ID dispatch. - Scope: one CUDA file, 1 insertion and 25 deletions (net 24 fewer source lines). This removes a shared-array declaration of up to 512 bytes per cooperative block without adding an option or persistent state. RNG and addition order stay unchanged. - The ordered fold now has one cost-read expression instead of a CUDA-only cache/fallback split. Its value can be checked at the use site without tracing an earlier producer write. ## Validation - Incremental CUDA 13.2 build: four Ninja actions; the focused mvs/patch_match_cuda_test passed (1/1). - RTX 3080 Ti, 12 workers, default 15 samples, checkpoint HMM on and rotation-buffer reuse off. Five-reference Fountain GEO N3 wall medians were 5.57/5.24 s at 1536 and 17.37/17.73 s at 3072. Ranges overlapped and 3072 controls drifted faster with run order; all paired maps were exact. - Full 11-reference PHOTO/GEO N1 wall was 20.31/20.35 s at 1536 and 76.85/78.82 s at 3072, control/candidate. CPU user/system was 17.94/2.19 vs 18.03/2.02 s and 66.31/7.28 vs 66.09/7.26 s. Peak RSS was 1202.2/1105.8 MiB and 2664.4/2610.8 MiB. All 44 depth/normal maps matched at each size. The RSS gaps cannot be attributed to removal of a 512-byte shared array; these runs do not establish a speed gain. - clang-format-19 and git diff --check passed. Other GPUs, HIP and wider source-count fallback remain untested. AI disclosure: totally vibe coded.
1 parent 3e5fa70 commit 8b1412f

1 file changed

Lines changed: 1 addition & 25 deletions

File tree

‎src/colmap/mvs/patch_match_cuda.cu‎

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,14 +1118,6 @@ __global__ void SweepFromTopToBottom(
11181118
cooperative_geometric_costs[kSampleWindowSize]
11191119
[kCooperative && kGeomConsistencyTerm ? 3 : 1]
11201120
[kBlockWidth];
1121-
#ifndef COLMAP_HIP_ENABLED
1122-
// The probability pass already loads current cost for each source. The
1123-
// default CUDA tile can reuse that exact float during the ordered draw fold.
1124-
__shared__ float
1125-
source_current_cost[kCooperative && kBlockWidth == 8 ? kSampleWindowSize
1126-
: 1]
1127-
[kCooperative && kBlockWidth == 8 ? kBlockWidth : 1];
1128-
#endif
11291121

11301122
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ == 610 && !defined(__HIPCC__)
11311123
// Checkpoint construction bounds both orientations by INT_MAX. Keep
@@ -1375,13 +1367,6 @@ __global__ void SweepFromTopToBottom(
13751367
for (int image_idx = first_source; image_idx < cost_map.GetDepth();
13761368
image_idx += source_step) {
13771369
const float cost = cost_map.Get(row, col, image_idx);
1378-
#ifndef COLMAP_HIP_ENABLED
1379-
if constexpr (kCooperative && kBlockWidth == 8) {
1380-
if (image_idx < kSampleWindowSize) {
1381-
source_current_cost[image_idx][threadIdx.x] = cost;
1382-
}
1383-
}
1384-
#endif
13851370
const float alpha = likelihood_computer.ComputeForwardMessage(
13861371
cost, forward_message[image_idx * source_stride]);
13871372
const float beta =
@@ -1633,16 +1618,7 @@ __global__ void SweepFromTopToBottom(
16331618
if (source < 0) continue;
16341619
// Reuse identical evaluations, but retain every original sample
16351620
// add.
1636-
#ifndef COLMAP_HIP_ENABLED
1637-
if constexpr (kBlockWidth == 8) {
1638-
costs[0] += source < kSampleWindowSize
1639-
? source_current_cost[source][threadIdx.x]
1640-
: cost_map.Get(row, col, source);
1641-
} else
1642-
#endif
1643-
{
1644-
costs[0] += cost_map.Get(row, col, source);
1645-
}
1621+
costs[0] += cost_map.Get(row, col, source);
16461622
if constexpr (kGeomConsistencyTerm) {
16471623
for (int i = 0; i < 3; ++i) {
16481624
geometric_costs[i] =

0 commit comments

Comments
 (0)