Skip to content

r.param.scale: parallelize using RAM preload with private thread buffers#7442

Draft
krcoder123 wants to merge 1 commit into
OSGeo:mainfrom
krcoder123:gsoc-rparamscale-private-buffer
Draft

r.param.scale: parallelize using RAM preload with private thread buffers#7442
krcoder123 wants to merge 1 commit into
OSGeo:mainfrom
krcoder123:gsoc-rparamscale-private-buffer

Conversation

@krcoder123

Copy link
Copy Markdown

What this PR does

This is a draft PR that parallelizes r.param.scale using a RAM preload with a private buffer per thread. The full input map is loaded into RAM once before the parallel region. Then each thread copies its own strip of rows plus halo rows out of the shared map into its own private buffer, and does all its window math reading only from that private buffer.

The original serial version of param.scale uses a single sliding window buffer that gets shuffled down one row at a time. This creates a sequential dependency between rows that makes it hard to parallelize. This PR removes that completely by giving each thread its own chunk of output rows and its own private strip buffer to compute from.

Changes

  • Makefile: added OpenMP wiring (EXTRA_CFLAGS, EXTRA_LIBS, EXTRA_INC)
  • main.c, param.h, interface.c: added nprocs parameter using G_OPT_M_NPROCS
  • process.c: rewrote to load the full map into RAM, give each thread its own private strip buffer with halo, indexed output slots, and a serial in-order write at the end

Correctness

Output matched the serial version across every configuration I tested (sizes 5, 15, 31, 51 × threads 1, 2, 4, 8 = 16 runs total, all with r.univar diff: min=0, max=0).

Status

Draft PR for GSoC 2026 coding period task.

@github-actions github-actions Bot added raster Related to raster data processing C Related code is in C module labels May 29, 2026
@krcoder123 krcoder123 changed the title GSoC 2026: r.param.scale parallelization with RAM preload and private buffers r.param.scale: parallelize using RAM preload with private thread buffers May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C Related code is in C module raster Related to raster data processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant