-
Notifications
You must be signed in to change notification settings - Fork 213
Additional modularization of stdlib #1081
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
base: master
Are you sure you want to change the base?
Conversation
|
@jvdp1 I wonder if it would be advisable given all different options being added to include in the readme.md a table listing all possible macros/flags. I asked copilot to generate a first version that would look like this: ### Preprocessing macros / flags
`stdlib` uses two preprocessing steps:
- **fypp** for meta-programming (templating and feature selection)
- **C preprocessing** (compiler `-cpp`/`-fpp`) for conditional compilation
The table below lists all preprocessing macros/flags currently used by `stdlib`.
| Macro/flag Name | preprocessing | comments |
| --- | --- | --- |
| `MAXRANK` | fypp | Maximum array rank generated by templates. Set via CMake `-DCMAKE_MAXIMUM_RANK=<n>` (passed to fypp as `-DMAXRANK=<n>`), via `fpm.toml` `preprocess.fypp.macros=["MAXRANK=<n>"]`, or via `python config/fypp_deployment.py --maxrank <n>`. |
| `VERSION90` | fypp | Enables a more Fortran-90-friendly preprocessing mode (affects defaults such as the maximum rank generated). Can be passed directly to fypp as `-DVERSION90` (CMake sets this automatically in some configurations). |
| `WITH_CBOOL` | fypp | Enables `c_bool` logical support if available. CMake auto-detects this and passes it to fypp; can be overridden at configure time with `-DWITH_CBOOL=ON/OFF`. |
| `WITH_QP` | fypp | Enables quadruple precision code generation (`real(qp)`, `complex(qp)`). CMake: `-DWITH_QP=ON/OFF`; fypp deployment script: `--with_qp`. |
| `WITH_XDP` | fypp | Enables extended double precision code generation (`real(xdp)`, `complex(xdp)`). CMake: `-DWITH_XDP=ON/OFF`; fypp deployment script: `--with_xdp`. |
| `WITH_ILP64` | fypp | Enables generation of 64-bit integer (ILP64) linear-algebra interfaces (built in addition to the default 32-bit interface). CMake: `-DWITH_ILP64=ON/OFF`; fypp deployment script: `--with_ilp64`. |
| `PROJECT_VERSION_MAJOR` | fypp | Part of the version string passed into fypp templates. Set automatically by CMake/from `VERSION`, but can be overridden by passing `-DPROJECT_VERSION_MAJOR=<n>` (used by `config/fypp_deployment.py`). |
| `PROJECT_VERSION_MINOR` | fypp | See `PROJECT_VERSION_MAJOR`. |
| `PROJECT_VERSION_PATCH` | fypp | See `PROJECT_VERSION_MAJOR`. |
| `STDLIB_NO_BITSET` | C | Disables compilation of the bitsets component. CMake: `-DSTDLIB_NO_BITSET=ON`; or define for the compiler preprocessor (e.g., `-DSTDLIB_NO_BITSET`). This makes `STDLIB_BITSET` evaluate to 0 via `include/macros.inc`. |
| `STDLIB_BITSET` | C | Internal numeric macro (0/1) derived from `STDLIB_NO_BITSET` in `include/macros.inc`. Used in code as `#if STDLIB_BITSET == 1`. Prefer setting `STDLIB_NO_BITSET` rather than defining `STDLIB_BITSET` directly. |
| `STDLIB_NO_STATS` | C | Disables compilation of the statistics component. CMake: `-DSTDLIB_NO_STATS=ON`; or define for the compiler preprocessor (e.g., `-DSTDLIB_NO_STATS`). This makes `STDLIB_STATS` evaluate to 0 via `include/macros.inc`. |
| `STDLIB_STATS` | C | Internal numeric macro (0/1) derived from `STDLIB_NO_STATS` in `include/macros.inc`. Used in code as `#if STDLIB_STATS == 1`. Prefer setting `STDLIB_NO_STATS` rather than defining `STDLIB_STATS` directly. |
| `STDLIB_EXTERNAL_BLAS` | C | Use an external BLAS (32-bit integer interface). Usually set by CMake when external BLAS/LAPACK are found, or manually via `add_compile_definitions(STDLIB_EXTERNAL_BLAS)`. In fpm: `preprocess.cpp.macros=["STDLIB_EXTERNAL_BLAS", ...]`. |
| `STDLIB_EXTERNAL_LAPACK` | C | Use an external LAPACK (32-bit integer interface). Usually paired with `STDLIB_EXTERNAL_BLAS`. |
| `STDLIB_EXTERNAL_BLAS_I64` | C | Use an external BLAS with ILP64 (64-bit integer) interfaces. Usually paired with `STDLIB_EXTERNAL_LAPACK_I64`. |
| `STDLIB_EXTERNAL_LAPACK_I64` | C | Use an external LAPACK with ILP64 (64-bit integer) interfaces. |
|
|
sorry @jvdp1 I was writting a comment and pushed on "Close" by accident, just reopened. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1081 +/- ##
==========================================
+ Coverage 68.60% 68.64% +0.03%
==========================================
Files 394 394
Lines 12730 12730
Branches 1376 1376
==========================================
+ Hits 8734 8738 +4
+ Misses 3996 3992 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Thank you @jalvesz .I agree that such a table is needed. I will open a new PR based on your first version. |
|
@jvdp1 after the issues encountered with #1086 it makes me think that we need to find a way of enforcing a strict hierarchy of dependencies to limit build time complexities. The first level would be "a module at the root of Some modules are potentially used by all others such as constants and maybe others. There could be a subset of modules put in one |
|
I just asked chatgpt to give some advice https://chatgpt.com/share/6960afff-a10c-800f-8493-948f753047d1 I think there are some nice ideas there! One of the interesting points is about the |
I agree with you. One of the reasons we stopped supporting Makefile is that the depencies became to complex to be handle them easily. The modularization with Cmake leads to the same issues :(
I am moving towards this goal in this PR. However, it is not so simple. Some linalg modules depend on e.g., a sort module that itself depends on another linalg module. Therefore creating subfolders based on the names only (e.g., stdlib_linalg, stdlib_sorting,...) is a too naive approach.
These will be easy to identify after that all other modules are moved to subdirectories. We can already identify 4-5 candidates for such a core subfolder. However, this should be done after all other modules are moved out of the src directory.
It is actually a good idea. This will allow us to introduce a |
Update:
src(exceptstdlib_version.fypp) were moved to the follwing subfolders (a library is created within each subfolder):ansi,bitsets,core,hashmaps,io,lapack_extendedlinalg_coremathselectionspecialfunctionsstats,stringlistsystemarrayblasconstantshashintrinsicslapacklinalgloggerquadraturesortingspecialmatricesstringsandunsortedtestandexamples.coreandlinalg_corecontain modules that are required by various parts ofstdliband were created to avoid interdependencies.stdlib_version.fyppwas maintained insrcto avoid to modifycmake/stdlib.cmakein this PR. It could be moved later to the subfoldercore.stdlib_ansiand stdlib_hashmaps` will be added in a following PR.unsortedis currently called like this because I couldn't find an appropriate name. Suggestions are welcome.Depends on #1088