Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9b11a2c
Update README.md to reflect correct repository links and images
sortA0329 Apr 17, 2026
754a008
Move copilot-instructions.md to AGENTS.md
sortA0329 Apr 17, 2026
6215992
Update copyright and repository links to reflect correct name
sortA0329 Apr 17, 2026
4e19e3a
Refactor benchmark summary output to include overall averages and det…
sortA0329 Apr 17, 2026
d932b85
Refactor benchmark summary
sortA0329 Apr 17, 2026
50c7ec1
Update dependencies and improve benchmark output formatting
sortA0329 Jun 21, 2026
2b084f7
Refactor benchmark output handling
sortA0329 Jun 21, 2026
1abd969
Streamline benchmark processes for development
sortA0329 Jun 21, 2026
f6c1238
Accelerate image generation processing for benchmarks
sortA0329 Jun 21, 2026
d3225b7
Update AGENTS.md to correct task file reference and streamline instru…
sortA0329 Jun 21, 2026
9d92ed2
Fix errors in CONTRIBUTING.md
sortA0329 Jun 21, 2026
cf481d2
Fixed a bug in the benchmark for MSVC
sortA0329 Jun 22, 2026
7c6627d
Add bundling task and script for public headers
sortA0329 Jun 22, 2026
32b02ce
Add inline lambda attribute for optimization
sortA0329 Jun 22, 2026
92f798a
Performance optimization
sortA0329 Jun 22, 2026
b0e4ee7
Separate macro definitions into Environment.hpp
sortA0329 Jun 26, 2026
8371ef5
Improve the quality of the code generated by the bundle command
sortA0329 Jun 26, 2026
4adf030
Update LICENSE to include algorithm attribution
sortA0329 Jun 26, 2026
7ade60e
Add inline attribute for optimization
sortA0329 Jun 26, 2026
bb7a3d1
Adjusting the code style
sortA0329 Jun 26, 2026
fd80ca7
Optimization of mint.neg(one)
sortA0329 Jun 26, 2026
d81f7e5
Remove [[likely]] attribute
sortA0329 Jun 26, 2026
37af21a
Update GitHub Actions workflows to use latest action versions
sortA0329 Jun 26, 2026
f06d656
Remove the inline attribute from the lambda function within
sortA0329 Jun 26, 2026
d21a926
Improve performance
sortA0329 Jun 27, 2026
91148ba
Improve performance on gcc
sortA0329 Jun 27, 2026
831da9d
Improve performance on msvc
sortA0329 Jun 27, 2026
834445d
Fix behavior in clang-cl
sortA0329 Jun 27, 2026
c0e0255
Updated the Python version for document generation to 3.14
sortA0329 Jun 28, 2026
bbbfda8
Delete tasks.json
sortA0329 Jun 28, 2026
a3eb7a1
Create settings.json for Zed
sortA0329 Jun 28, 2026
7b65d84
Add a changelog to README.md
sortA0329 Jun 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,28 @@ jobs:
- compiler: clang
build_dir: build-clang
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Install build dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build ccache clang

- name: Install Task
uses: go-task/setup-task@v1
uses: go-task/setup-task@v2
with:
version: 3.x

- name: Setup uv
uses: astral-sh/setup-uv@v4
uses: astral-sh/setup-uv@v8.2.0
with:
enable-cache: true
cache-dependency-glob: |
pyproject.toml
uv.lock

- name: Cache deps
uses: actions/cache@v4
uses: actions/cache@v6
with:
path: ${{ matrix.build_dir }}/_deps
key: ${{ runner.os }}-${{ matrix.compiler }}-deps-${{ hashFiles('CMakeLists.txt', '**/CMakeLists.txt', '**/*.cmake') }}
Expand All @@ -63,7 +63,7 @@ jobs:
run: task bench-heavy:${{ matrix.compiler }}

- name: Upload benchmark artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: benchmark-${{ runner.os }}-${{ matrix.compiler }}
if-no-files-found: warn
Expand All @@ -85,7 +85,7 @@ jobs:
- compiler: clang-cl
build_dir: build-clang-cl
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Install LLVM + Ninja (clang-cl)
if: matrix.compiler == 'clang-cl'
Expand All @@ -94,20 +94,20 @@ jobs:
choco install llvm ninja -y --no-progress

- name: Install Task
uses: go-task/setup-task@v1
uses: go-task/setup-task@v2
with:
version: 3.x

- name: Setup uv
uses: astral-sh/setup-uv@v4
uses: astral-sh/setup-uv@v8.2.0
with:
enable-cache: true
cache-dependency-glob: |
pyproject.toml
uv.lock

- name: Cache deps
uses: actions/cache@v4
uses: actions/cache@v6
with:
path: ${{ matrix.build_dir }}/_deps
key: ${{ runner.os }}-${{ matrix.compiler }}-deps-${{ hashFiles('CMakeLists.txt', '**/CMakeLists.txt', '**/*.cmake') }}
Expand All @@ -118,7 +118,7 @@ jobs:
run: task bench-heavy:${{ matrix.compiler }}

- name: Upload benchmark artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: benchmark-${{ runner.os }}-${{ matrix.compiler }}
if-no-files-found: warn
Expand All @@ -136,10 +136,10 @@ jobs:
group: gh-pages-deploy
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Download benchmark artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
path: artifacts
pattern: benchmark-*
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
group: gh-pages-deploy
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
with:
fetch-depth: 0

Expand All @@ -35,17 +35,17 @@ jobs:
sudo apt-get install -y pngquant

- name: Install Task
uses: go-task/setup-task@v1
uses: go-task/setup-task@v2
with:
version: 3.x

- name: Setup Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.12"
python-version: "3.14"

- name: Setup uv
uses: astral-sh/setup-uv@v4
uses: astral-sh/setup-uv@v8.2.0
with:
enable-cache: true
cache-dependency-glob: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ jobs:
cc: clang
cxx: clang++
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build ccache
- name: Install Task
uses: go-task/setup-task@v1
uses: go-task/setup-task@v2
with:
version: 3.x
- name: Cache build dir (${{ matrix.compiler }})
uses: actions/cache@v4
uses: actions/cache@v6
with:
path: ${{ matrix.build_dir }}
key: ${{ runner.os }}-${{ matrix.compiler }}-build-${{ hashFiles('CMakeLists.txt', '**/CMakeLists.txt', '**/*.cmake') }}
Expand All @@ -70,23 +70,23 @@ jobs:
- compiler: clang-cl
build_dir: build-clang-cl
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Install LLVM + Ninja (clang-cl)
if: matrix.compiler == 'clang-cl'
shell: pwsh
run: |
choco install llvm ninja -y --no-progress

- uses: actions/cache@v4
- uses: actions/cache@v6
with:
path: ${{ matrix.build_dir }}
key: ${{ runner.os }}-${{ matrix.compiler }}-build-${{ hashFiles('CMakeLists.txt', '**/CMakeLists.txt', '**/*.cmake') }}
restore-keys: |
${{ runner.os }}-${{ matrix.compiler }}-build-

- name: Install Task
uses: go-task/setup-task@v1
uses: go-task/setup-task@v2
with:
version: 3.x

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ ENV/
CMakeUserPresets.json

/tmp
/bundled
compile_commands.json

# Documentation
Expand Down
50 changes: 0 additions & 50 deletions .vscode/tasks.json

This file was deleted.

54 changes: 54 additions & 0 deletions .zed/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"format_on_save": "on",
"formatter": "language_server",
"tab_size": 4,
"hard_tabs": false,
"ensure_final_newline_on_save": true,
"remove_trailing_whitespace_on_save": true,
"file_types": {
"YAML": [
".clang-format",
".clangd"
],
},
"file_scan_exclusions": [
"**/.git",
"**/.DS_Store",
"build-*",
".cache",
".venv"
],
"lsp": {
"clangd": {
"binary": {
"path": "clangd",
},
},
},
"languages": {
"YAML": {
"tab_size": 2,
},
"C++": {
"language_servers": [
"clangd"
],
"formatter": {
"language_server": {
"name": "clangd",
},
},
},
"Python": {
"language_servers": [
"basedpyright",
"ruff"
],
"formatter": {
"language_server": {
"name": "ruff",
},
},
},
},
}
12 changes: 1 addition & 11 deletions .github/copilot-instructions.md → AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
This is a C++ header-only library called "libcpprime", intended for fast primality testing of 64-bit integers.


The library itself and its test code should be written to work with compilers supporting C++11.
Benchmark and other temporary files may use the latest C++ features.
The library implementation should pay particular attention to compatibility with older compilers.


Supported compilers include gcc, clang, msvc, clang-cl, and the gcc and clang versions within mingw.


When you want to run tests or benchmarks, execute the tasks described in tasks.json.
For detailed benchmark results, please refer to benchmarks/bench_summary.md.
Running tests and benchmarks takes approximately 20-30 seconds.

When you want to run tests or benchmarks, execute the tasks described in Taskfile.yml.

When optimizing code, primarily use gcc or msvc for benchmarks.
However, to avoid significant speed differences between compilers, run them with clang and clang-cl once you have finished the initial implementation.

Please inform users of any breaking changes.


.txt files often contain large amounts of data. Do not read files with the .txt extension.


If you wish to generate data mechanically, please create C++ code or Python scripts within the tmp folder.


For primality testing in Python, you can use Scipy. For execution speed, please prioritize using PyPy.


All code and README.md should be written in English. However, this response uses the language currently used in our chat.

The directory structure is as follows:
Expand Down
12 changes: 2 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ if(LIBCPPRIME_BUILD_TESTS)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
GIT_TAG v1.17.0
)

set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
Expand Down Expand Up @@ -207,15 +207,7 @@ if(LIBCPPRIME_BUILD_BENCHMARKS)
add_executable(benchmark_isprime benchmarks/isprime_bench.cpp)
target_compile_features(benchmark_isprime PRIVATE cxx_std_23)

include(FetchContent)
FetchContent_Declare(
nanobench
GIT_REPOSITORY https://github.com/martinus/nanobench.git
GIT_TAG v4.3.11
)
FetchContent_MakeAvailable(nanobench)

target_link_libraries(benchmark_isprime PRIVATE libcpprime nanobench::nanobench)
target_link_libraries(benchmark_isprime PRIVATE libcpprime)

if(LIBCPPRIME_MSVC_LIKE)
target_compile_options(benchmark_isprime PRIVATE /W4 /permissive- /Zc:__cplusplus)
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Thanks for your interest in improving `libcpprime`.

### Python tooling (benchmarks/docs)

- Python >= 3.12
- Python >= 3.14
- `uv`
- pngquant

Expand Down Expand Up @@ -52,7 +52,7 @@ cd libcpprime
### 2) Install dependencies

- Install CMake, compiler(s), and Task.
- For docs/benchmark plots, install Python 3.12+ and `uv`.
- For docs/benchmark plots, install Python 3.14+ and `uv`.

### 3) Run tests

Expand All @@ -63,7 +63,7 @@ task test:msvc
task test:clang-cl
```

Typical runtime for tests is around 20-60 seconds per run.
Typical runtime for tests is around 10 seconds per run.

## Command reference

Expand Down
Loading