Skip to content

Lay the source tree out in directories instead of one flat root - #67

Merged
galekseev merged 2 commits into
masterfrom
refactor/project-layout
Aug 8, 2026
Merged

Lay the source tree out in directories instead of one flat root#67
galekseev merged 2 commits into
masterfrom
refactor/project-layout

Conversation

@galekseev

Copy link
Copy Markdown

Summary

The repository root held the C++ sources, the OpenCL kernels, the Dockerfile, the build artifacts and the documentation side by side. Everything now has a directory:

src/       C++ sources of the host program
kernels/   keccak.cl and profanity.cl
bin/       what make produces: the binary and a copy of the kernels
build/     object files
docker/    the shipping image and its entrypoint
bench/     revision comparison tooling, with its recorded runs in bench/logs/
tests/     correctness tests and the mp-math microbenchmark
docs/      build guides and the vast.ai guide, with the screenshot in docs/img/

Two things needed real changes rather than a move:

Finding the kernels. profanity.cpp read them from the working directory. It now looks next to the executable first, then in kernels/ beside it, and falls back to the working directory, which is where every earlier release kept them. The compiled-kernel cache moves next to the binary for the same reason. So ./bin/profanity2.x64 works from the repository root, from inside bin/, and by absolute path from an unrelated directory.

Comparing across the move. bench/ builds arbitrary revisions out of history, and has to go on comparing a revision from before this change against one from after it. bench/Dockerfile and bench/prepare-native.sh now take the build output from whichever layout a revision uses. The second commit fixes a false positive this introduced: a git diff of SpeedSample.cpp reported the move itself as a change, so every comparison spanning the reorganization warned that the two revisions time a round differently. The timer is now compared by blob rather than by path.

Test plan

  • make from clean builds bin/profanity2.x64 with no warnings, kernels copied next to it
  • runs from the repository root, from bin/, and by absolute path from /tmp; the cache lands in bin/ in all three cases and nothing is left in the working directory
  • make -C tests builds, and test_correctness_pr49.x64 passes run both from tests/ and from the root
  • bench/prepare-native.sh 90c61e3 868be80 builds both layouts and lays them out identically; timer.state is same, as it should be for a file that only moved
  • no performance change: Dispatcher.o, Mode.o, precomp.o and SpeedSample.o are byte-identical between the two builds, only profanity.o differs. A speed comparison on the Mac this was written on was thermally saturated and could not tell the two apart from noise, which is why the object files are the evidence here
  • CI builds the image from docker/Dockerfile (no local Docker daemon to check it with)

Made with Cursor

galekseev and others added 2 commits August 8, 2026 21:28
The repository root held the C++ sources, the OpenCL kernels, the Dockerfile,
the build artifacts and the documentation side by side, so nothing about it
said which file belonged to what. Sources now live in src/, kernels in
kernels/, the shipping image in docker/, the recorded comparisons in
bench/logs/, and make writes to build/ and bin/.

The binary looks for its kernels next to itself and falls back to the working
directory, so it can be started from anywhere: ./bin/profanity2.x64 from the
repository root, from inside bin/, or by absolute path from an unrelated
directory. Its compiled-kernel cache moves next to the binary for the same
reason. make copies the kernels into bin/, which keeps that directory
self-contained and lets the container image copy it as one.

The benchmark tooling builds arbitrary revisions out of history and has to go
on comparing a revision from before this change against one from after it, so
bench/Dockerfile and bench/prepare-native.sh now take the build output from
whichever of the two layouts a revision uses, and look for SpeedSample.cpp in
both places.

Co-authored-by: Cursor <cursoragent@cursor.com>
Asking git for a diff of SpeedSample.cpp between two revisions reports the
move from the root of the tree into src/ as a change, so every comparison
spanning the reorganization ended with "SpeedSample.cpp differs between the
two revisions" and the warning that the two speeds come from different clocks.
They do not: the file only moved.

Each revision is now asked for the blob it records for the file, at either
path, and the two blobs are compared. The image build already compared the
extracted files with cmp and was never affected.

Co-authored-by: Cursor <cursoragent@cursor.com>
@galekseev
galekseev merged commit 6c897bb into master Aug 8, 2026
1 check passed
@galekseev
galekseev deleted the refactor/project-layout branch August 8, 2026 21:23
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