Skip to content

optimize gpu.cu which leads to a ~4% speedup#28

Open
mrzetti wants to merge 1 commit into
MinecraftAtHome:mainfrom
mrzetti:perfomance
Open

optimize gpu.cu which leads to a ~4% speedup#28
mrzetti wants to merge 1 commit into
MinecraftAtHome:mainfrom
mrzetti:perfomance

Conversation

@mrzetti

@mrzetti mrzetti commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

This is created by me trying out gpt5.6 sol xhigh.
Further testing on more gpus and cuda versions would be nice :)

Changes

  • transpose convolution tables from [256][6] to [6][256] to avoid stride-6 shared-memory bank conflicts
  • reduce Perlin convolution kernels from 16 to 12 gradients by canonicalizing duplicate hashes:
    • 12 -> 0
    • 13 -> 9
    • 14 -> 1
    • 15 -> 11
  • use uint8_t indices so modulo 256 occurs once instead of at every lookup
  • use separate input/output buffers for filter_2_01b, fixing unsafe in-place compaction

Resource impact

On sm_89, filter_gradvecs_1 shared memory drops from 17,712 to 16,560 bytes per block. This allows six resident blocks within Ada's 100 KiB shared-memory limit instead of five.

Benchmark

RTX 4070, sm_89, bounded small biomes, fixed start seed 0:

Version Throughput
Previous local baseline ~15.5 Gseeds/s
This change ~16.2 Gseeds/s

Fixed-seed stage counts remained identical during testing.

Related work

PR #24 also modifies the gradient-vector kernels, but takes a different approach by expanding and flattening the convolution buffers. This change instead reduces and transposes them, lowering filter_gradvecs_1 shared memory from approximately 30 KB in #24 to 16,560 bytes while preserving fixed-seed stage outputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant