Repository navigation
Extend AGENTS.md with HPX conventions and checks #8196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ CMake, has a large test suite, and follows Boost-style coding conventions. | |
|
|
||
| ## Before changing code | ||
|
|
||
| - Read `README.rst` and `CONTRIBUTING.md`. | ||
| - Read `README.rst` and `.github/CONTRIBUTING.md`. | ||
| - Do not update or rewrite `AGENT.md` unless explicitly asked. | ||
| - Do not stage, commit, amend, or push unless explicitly asked. | ||
| - Do not suggest staging, committing, amending, or pushing unless | ||
|
|
@@ -39,12 +39,77 @@ CMake, has a large test suite, and follows Boost-style coding conventions. | |
| - Add doxygen-style comments for API functions. For this, use | ||
| `///` style comments and `\` prefixed doxygen tags. | ||
| - Use the repository's `.clang-format` and `.editorconfig` as guidance. | ||
| - In the HPX libraries use `HPX_MOVE(x)` and `HPX_FORWARD(T, x)` instead of | ||
| `std::move` and `std::forward`. Tests and examples use the standard | ||
| functions. | ||
|
|
||
| ## Data layout and hot paths | ||
|
|
||
| - Use `alignas` only for data that is allocated during initialization | ||
| (for instance the scheduler's data). Types that are allocated all the | ||
| time (threads, futures, shared states, tasks) use explicit padding | ||
| instead, so that the allocator doesn't have to align them. | ||
| - Don't give bit fields default member initializers; some supported | ||
| compilers don't accept them. Initialize them in every constructor. | ||
| - Don't read clocks (`std::chrono::steady_clock::now()` and similar) inside | ||
| spin loops or other hot paths; a clock read costs far more than a spin | ||
| round. Calibrate once at startup and count rounds instead. | ||
|
|
||
| ## Modules | ||
|
|
||
| - Module dependencies must not be circular: a module must not depend, | ||
| directly or through other modules, on a module that depends on it. | ||
| This also means that `libs/core` modules must not depend on `libs/full` | ||
| modules. | ||
| - Classes and functions used outside their module need the export macro | ||
| of their library: `HPX_CORE_EXPORT` in `libs/core`, `HPX_EXPORT` in | ||
| `libs/full`. A missing export macro links on Linux and fails only on | ||
| Windows. | ||
| - List new headers and sources in the module's `CMakeLists.txt` | ||
| (`<module>_headers`, `<module>_sources`). | ||
| - Every header must compile on its own: the header tests | ||
| (`HPX_WITH_TESTS_HEADERS=ON`) compile each one alone. | ||
| - HPX can also be built as C++ modules (`HPX_WITH_CXX_MODULES=ON`), which | ||
| CI checks separately; changes to public headers can break that build | ||
| only. In that build, declarations that other modules or users need must | ||
| be exported from their C++ module: mark them with `HPX_CXX_CORE_EXPORT` | ||
| in `libs/core` and `HPX_CXX_EXPORT` in `libs/full` (they expand to | ||
| `export` in that build and to nothing otherwise). Keep the exported | ||
| interface as small as possible: export only what is needed outside the | ||
| module, and avoid exporting declarations in `detail` namespaces where | ||
| possible. These macros are separate from the library export macros | ||
| above. | ||
|
|
||
| ## Compiler-specific rules | ||
|
|
||
| CI builds with MSVC, GCC, and Clang, with warnings as errors in several | ||
| configurations. Each compiler warns about different things: | ||
|
|
||
| - MSVC: a class exported from a module (`HPX_CORE_EXPORT` and similar) | ||
| whose members have standard library types needs | ||
| `#include <hpx/config/warnings_prefix.hpp>` after the other includes and | ||
| `#include <hpx/config/warnings_suffix.hpp>` at the end of the header; | ||
| otherwise MSVC warns (C4251) in every file that includes the header. | ||
| - MSVC: implicit narrowing conversions that GCC and Clang accept produce | ||
| warnings (C4267, C4244). Use `std::size_t` for sizes and indices, and | ||
| cast explicitly where narrowing is intended. | ||
| - GCC: initialize a `std::array` with double braces (`{{...}}`); single | ||
| braces fail with `-Werror=missing-braces`. | ||
| - Compile a change with more than one of these compilers before | ||
| submitting it, at least the files it touches. | ||
|
|
||
| ## Formatting rules | ||
|
|
||
| - Keep formatting-only changes separate from functional changes. | ||
| - Do not reformat whole files unless necessary. | ||
| - Do not configure auto-format-on-save for source files. | ||
| - Format C++ files with clang-format 20, using the rules in | ||
| `.clang-format`; clang-format 20 is the version of the CI check | ||
| (`.github/workflows/check-formatting.yml`), other versions format some | ||
| constructs differently. | ||
| - Format `CMakeLists.txt` and `*.cmake` files with `cmake-format`, using | ||
| the rules in `.cmake-format.py` (see | ||
| https://github.com/cheshirekow/cmake_format); the CI checks this too. | ||
|
|
||
| ## New files | ||
|
|
||
|
|
@@ -57,6 +122,10 @@ Add the project license header: | |
| // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
| ``` | ||
|
|
||
| Every new file needs this license information, not only C++ files (the | ||
| repository follows REUSE, see `REUSE.toml`): use the comment syntax of the | ||
| file type, as the HTML comment at the top of this file does for Markdown. | ||
|
Comment on lines
+125
to
+127
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explain licensing for files without comments. JSON and binary files cannot carry the specified comment header. Adding one can invalidate the file, while omitting license metadata can fail the REUSE check. Direct contributors to use an existing
|
||
|
|
||
| ## Build and test | ||
|
|
||
| - Prefer CMake-based builds. | ||
|
|
@@ -65,9 +134,14 @@ Add the project license header: | |
| - For code changes, run targeted tests for the affected component/module. | ||
| - For build-system changes, verify at least one configuration that exercises | ||
| the changed path. | ||
| - `CMakeFiles.txt` and `*.cmake` files should be formatted using | ||
| `cmake-format` based rules defined in `.cmake-format.py` (see: | ||
| https://github.com/cheshirekow/cmake_format). | ||
| - Add a unit test to the `tests` list in the `CMakeLists.txt` of the | ||
| module's test directory; extra arguments go into | ||
| `<test>_PARAMETERS` (e.g. `THREADS_PER_LOCALITY 4`). The target is named | ||
| `<test>_test`, the CTest name is | ||
| `tests.unit.modules.<module>.<test>`, so `ctest -R <test>` runs it. | ||
|
Comment on lines
+139
to
+141
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Build the test target before running CTest. The version module creates its test executable with
|
||
| - Tests check with the `HPX_TEST*` macros from `hpx/modules/testing.hpp` | ||
| and return `hpx::util::report_errors()`; a test of the local runtime | ||
| starts it with `hpx::local::init`. | ||
|
|
||
| ## PR / contribution workflow | ||
|
|
||
|
|
@@ -79,6 +153,12 @@ Add the project license header: | |
| - Do not create large generated files. | ||
| - Make changes on a topic branch. | ||
| - Keep commits clear and scoped. | ||
| - Sign off every commit (`git commit -s`); CI checks the DCO sign-off. | ||
| - Document user-visible additions in `docs/sphinx`: configuration | ||
| settings and command-line options in | ||
| `manual/launching_and_configuring_hpx_applications.rst`, performance | ||
| counters in `manual/optimizing_hpx_applications.rst`. Add CMake options | ||
| with `hpx_option`. | ||
| - Mention relevant issue numbers in PR descriptions when applicable. | ||
| - If a change is documentation-only, say so explicitly in the PR. | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow clock reads for elapsed-time deadlines.
A calibrated round count cannot measure elapsed time if a spinning thread is preempted. When the thread resumes after its deadline, it can continue spinning instead of detecting the timeout. Allow clock checks when correctness requires an elapsed-time deadline; round counting can still be used for approximate backoff.