From 4e799df906e3e23a977b7f867e466306e58b6268 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 20 Aug 2026 11:23:12 +0000 Subject: [PATCH 1/2] refactor: one include-guard convention for every header The tree carried four conventions across 117 headers -- 94 with an #ifndef guard only, 12 with `#pragma once` only, 5 with both, and 6 umbrella headers in impl/kernels/ with neither. The split is by provenance: each of the six absorbed repositories had drifted its own way, and consolidation put them side by side without picking one. The convention is now: every header is bracketed by an #ifndef/#define/#endif guard, opened before any other directive and closed as the last directive in the file, and no header uses `#pragma once`. WHY GUARDS Both mechanisms work, and the historical objection to `#pragma once` here -- that every cross-repo dependency was a symlink, so "the same file" had several identities -- really is gone: main has no .gitmodules, no gitlinks and no symlinks. Portability does not decide it either; clang, g++, nvcc and MSVC all support the pragma. What decides it is what include/fastfields/ is: the public *installed* interface, copied to an install prefix and consumed from there by fastfields-dlpack. `#pragma once` keys on file identity, so the build-tree copy reached through -I include and the installed copy reached through the prefix are two files: in one translation unit that sees both, the pragma includes both and the second redefines everything the first defined. A macro guard keys on a name, so the two copies collapse into one inclusion. That is not an invented worry. It is exactly why core/dlpack.h must keep its upstream DLPACK_DLPACK_H_ guard -- so our vendored copy interoperates with a system DLPack header. The property the vendored file needs is the property an installed header needs, and it would be odd for the public surface to hold itself to a weaker rule than the one file everybody already agrees must be guarded. Guards are also the only choice under which dlpack.h conforms as it stands rather than being a carve-out: the convention costs this tree zero exemptions. "Both" was in use in five headers and is defensible, but it buys nothing over the guard alone -- in every case where the two disagree it is the guard that does the work -- at the cost of a second thing to keep in sync in 117 files. WHAT CHANGED * 12 pragma-only headers (all impl/cuda/) and the 6 unguarded umbrella headers gain a guard; * 5 "both" headers lose the redundant pragma, keeping their guard name; * impl/kernels/pushpull/nd.h closed with `#endif FF_PUSHPULL_ND` -- extra tokens after #endif, which is ill-formed and diagnosed under -pedantic; * impl/cpu/distance_mesh.h closed with a comment naming a different macro (FF_DISTANCE_MESH) than its guard (FF_CPU_DISTANCE_MESH). The six unguarded headers were harmless in that they contain nothing but #include lines, so double inclusion was a no-op -- but one added definition away from not being. GUARD NAMES A guard this pass *adds* is derived from the file's path under include/fastfields/: impl/cuda/utils.h -> FF_IMPL_CUDA_UTILS_H. Derivation makes the name unique by construction and gives new headers a rule to follow rather than a precedent to guess at. The 99 existing guards keep their names. They are already unique and already FF_-prefixed, so renaming them buys a reader nothing, invalidates the literal guard text quoted in the frozen tools/consolidate.sh, and multiplies the conflict surface against the long-running teeny branch. What had actually drifted is the *shape* of the guard, and that is what is normalised; --check enforces the properties that matter (present, whole-file, FF_-prefixed, unique) rather than a spelling. REPRODUCIBILITY tools/normalise-header-guards.py is committed, as tools/rename-macros.py and tools/dedup-dispatch-helpers.py were, so the rewrite can be replayed instead of read: git checkout HEAD~1 -- include && python3 tools/normalise-header-guards.py git diff # empty `--check` verifies the convention and exits non-zero on any violation, so a rebase does not need a 117-file hand audit. It is idempotent and it leaves core/dlpack.h untouched. The rule is recorded in CLAUDE.md beside the FF_-prefix rule. --- CLAUDE.md | 21 +- include/fastfields/api/cuda/stream.h | 1 - include/fastfields/core/autocast.h | 1 - include/fastfields/core/cuda_switch.h | 1 - include/fastfields/core/defines.h | 1 - include/fastfields/core/dispatch.h | 1 - include/fastfields/impl/cpu/distance_mesh.h | 2 +- .../fastfields/impl/cuda/distance_euclidean.h | 4 +- include/fastfields/impl/cuda/distance_l1.h | 4 +- include/fastfields/impl/cuda/distance_mesh.h | 4 +- .../fastfields/impl/cuda/distance_spline.h | 4 +- include/fastfields/impl/cuda/posdef.h | 4 +- include/fastfields/impl/cuda/pushpull.h | 4 +- include/fastfields/impl/cuda/reg_field.h | 4 +- include/fastfields/impl/cuda/reg_flow.h | 4 +- include/fastfields/impl/cuda/resize.h | 4 +- include/fastfields/impl/cuda/restrict.h | 4 +- include/fastfields/impl/cuda/splinc.h | 4 +- include/fastfields/impl/cuda/utils.h | 4 +- include/fastfields/impl/kernels/distance.h | 5 +- include/fastfields/impl/kernels/posdef.h | 3 + .../impl/kernels/posdef/estatics.inl | 2 +- include/fastfields/impl/kernels/pushpull.h | 3 + include/fastfields/impl/kernels/pushpull/nd.h | 2 +- .../fastfields/impl/kernels/regularisers.h | 3 + .../impl/kernels/regularisers/field.h | 3 + .../impl/kernels/regularisers/flow.h | 3 + tools/normalise-header-guards.py | 319 ++++++++++++++++++ 28 files changed, 397 insertions(+), 22 deletions(-) create mode 100644 tools/normalise-header-guards.py diff --git a/CLAUDE.md b/CLAUDE.md index 2da0ea4..88c7166 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -182,8 +182,27 @@ pushpull's fully-static order×bound compile is nightly library, so those *are* `` there) and the non-nvcc `__device__` / `__host__` fallbacks. Prefer an `inline` function to a macro where one will do — a function in `ff::` is collision-safe without any prefix. +- **Every header is bracketed by an `#ifndef` include guard; none uses + `#pragma once`.** The guard opens before any other directive, closes as the + last directive in the file, and is spelled `#endif // FF_NAME`. Its name is + `FF_`-prefixed (it is a macro on the installed surface like any other) and + unique tree-wide; a *new* header derives it from its path under + `include/fastfields/` — `impl/cuda/utils.h` → `FF_IMPL_CUDA_UTILS_H`. + Existing guards keep their (pre-consolidation, unique) names. + `include/fastfields/` is the public **installed** interface, so a single + translation unit can reach one logical header as two files — the build-tree + copy through `-I include` and the installed copy through the prefix. + `#pragma once` keys on file identity and would include both; a macro guard + keys on a name and collapses them. That is the same property that obliges + vendored `core/dlpack.h` to keep its upstream `DLPACK_DLPACK_H_` guard, and + choosing guards is what lets that file conform as it stands instead of being + an exemption. Enforced by `tools/normalise-header-guards.py --check`, which + also applies the convention. - `include/fastfields/core/dlpack.h` is vendored upstream code: do not edit it, - and it is skipped by `codespell` (see `.codespellrc`). + and it is skipped by `codespell` (see `.codespellrc`). It is the only + verbatim third-party file — `impl/kernels/threadpool.h` carries an upstream + copyright but has been adapted to this project's namespace and guard + conventions, so it is treated as project code. ## Pointers diff --git a/include/fastfields/api/cuda/stream.h b/include/fastfields/api/cuda/stream.h index a37975a..a59e3dd 100644 --- a/include/fastfields/api/cuda/stream.h +++ b/include/fastfields/api/cuda/stream.h @@ -1,4 +1,3 @@ -#pragma once #ifndef FF_CUDA_STREAM #define FF_CUDA_STREAM diff --git a/include/fastfields/core/autocast.h b/include/fastfields/core/autocast.h index 88c6c7b..f678cbd 100644 --- a/include/fastfields/core/autocast.h +++ b/include/fastfields/core/autocast.h @@ -1,4 +1,3 @@ -#pragma once #ifndef FF_AUTOCAST #define FF_AUTOCAST #include diff --git a/include/fastfields/core/cuda_switch.h b/include/fastfields/core/cuda_switch.h index d85669b..4d5b1ac 100755 --- a/include/fastfields/core/cuda_switch.h +++ b/include/fastfields/core/cuda_switch.h @@ -1,4 +1,3 @@ -#pragma once #ifndef FF_CUDA_SWITCH #define FF_CUDA_SWITCH diff --git a/include/fastfields/core/defines.h b/include/fastfields/core/defines.h index 3bc5819..dbd44de 100644 --- a/include/fastfields/core/defines.h +++ b/include/fastfields/core/defines.h @@ -1,4 +1,3 @@ -#pragma once #ifndef FF_DEFINES #define FF_DEFINES diff --git a/include/fastfields/core/dispatch.h b/include/fastfields/core/dispatch.h index c164876..1bf76dc 100644 --- a/include/fastfields/core/dispatch.h +++ b/include/fastfields/core/dispatch.h @@ -1,4 +1,3 @@ -#pragma once #ifndef FF_CORE_DISPATCH #define FF_CORE_DISPATCH diff --git a/include/fastfields/impl/cpu/distance_mesh.h b/include/fastfields/impl/cpu/distance_mesh.h index 452396a..478386d 100755 --- a/include/fastfields/impl/cpu/distance_mesh.h +++ b/include/fastfields/impl/cpu/distance_mesh.h @@ -716,4 +716,4 @@ FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) -#endif // FF_DISTANCE_MESH +#endif // FF_CPU_DISTANCE_MESH diff --git a/include/fastfields/impl/cuda/distance_euclidean.h b/include/fastfields/impl/cuda/distance_euclidean.h index 3708f88..2f61336 100755 --- a/include/fastfields/impl/cuda/distance_euclidean.h +++ b/include/fastfields/impl/cuda/distance_euclidean.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FF_IMPL_CUDA_DISTANCE_EUCLIDEAN_H +#define FF_IMPL_CUDA_DISTANCE_EUCLIDEAN_H #include "fastfields/core/cuda_switch.h" #include "fastfields/impl/kernels/distance.h" #include "fastfields/impl/kernels/batch.h" @@ -91,3 +92,4 @@ FF_CUHOST void dt( FF_NAMESPACE_END(distance_e) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) +#endif // FF_IMPL_CUDA_DISTANCE_EUCLIDEAN_H diff --git a/include/fastfields/impl/cuda/distance_l1.h b/include/fastfields/impl/cuda/distance_l1.h index 6f7e86c..85aa184 100755 --- a/include/fastfields/impl/cuda/distance_l1.h +++ b/include/fastfields/impl/cuda/distance_l1.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FF_IMPL_CUDA_DISTANCE_L1_H +#define FF_IMPL_CUDA_DISTANCE_L1_H #include "fastfields/core/cuda_switch.h" #include "fastfields/impl/kernels/distance.h" #include "fastfields/impl/kernels/batch.h" @@ -70,3 +71,4 @@ FF_CUHOST void dt( FF_NAMESPACE_END(distance_l1) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) +#endif // FF_IMPL_CUDA_DISTANCE_L1_H diff --git a/include/fastfields/impl/cuda/distance_mesh.h b/include/fastfields/impl/cuda/distance_mesh.h index 7775e5e..39aab17 100755 --- a/include/fastfields/impl/cuda/distance_mesh.h +++ b/include/fastfields/impl/cuda/distance_mesh.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FF_IMPL_CUDA_DISTANCE_MESH_H +#define FF_IMPL_CUDA_DISTANCE_MESH_H #include "fastfields/core/cuda_switch.h" #include "fastfields/impl/kernels/distance.h" #include "fastfields/impl/kernels/batch.h" @@ -1597,3 +1598,4 @@ dt( FF_NAMESPACE_END(distance_mesh) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) +#endif // FF_IMPL_CUDA_DISTANCE_MESH_H diff --git a/include/fastfields/impl/cuda/distance_spline.h b/include/fastfields/impl/cuda/distance_spline.h index 0a91431..727e699 100755 --- a/include/fastfields/impl/cuda/distance_spline.h +++ b/include/fastfields/impl/cuda/distance_spline.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FF_IMPL_CUDA_DISTANCE_SPLINE_H +#define FF_IMPL_CUDA_DISTANCE_SPLINE_H #include #include "fastfields/core/cuda_switch.h" #include "fastfields/impl/kernels/distance.h" @@ -240,3 +241,4 @@ mindist_gaussnewton( FF_NAMESPACE_END(distance_spline) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) +#endif // FF_IMPL_CUDA_DISTANCE_SPLINE_H diff --git a/include/fastfields/impl/cuda/posdef.h b/include/fastfields/impl/cuda/posdef.h index 9061096..b521e95 100755 --- a/include/fastfields/impl/cuda/posdef.h +++ b/include/fastfields/impl/cuda/posdef.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FF_IMPL_CUDA_POSDEF_H +#define FF_IMPL_CUDA_POSDEF_H #include "fastfields/core/cuda_switch.h" #include "fastfields/impl/kernels/posdef.h" #include "fastfields/impl/kernels/batch.h" @@ -565,3 +566,4 @@ void sym_invert_( FF_NAMESPACE_END(posdef) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) +#endif // FF_IMPL_CUDA_POSDEF_H diff --git a/include/fastfields/impl/cuda/pushpull.h b/include/fastfields/impl/cuda/pushpull.h index bdf79a7..f9f77b7 100755 --- a/include/fastfields/impl/cuda/pushpull.h +++ b/include/fastfields/impl/cuda/pushpull.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FF_IMPL_CUDA_PUSHPULL_H +#define FF_IMPL_CUDA_PUSHPULL_H #include "fastfields/core/cuda_switch.h" #include "fastfields/impl/kernels/spline.h" #include "fastfields/impl/kernels/bounds.h" @@ -1167,3 +1168,4 @@ FF_CUHOST void grad_backward( FF_NAMESPACE_END(pushpull) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) +#endif // FF_IMPL_CUDA_PUSHPULL_H diff --git a/include/fastfields/impl/cuda/reg_field.h b/include/fastfields/impl/cuda/reg_field.h index 51f817d..e2fde0b 100755 --- a/include/fastfields/impl/cuda/reg_field.h +++ b/include/fastfields/impl/cuda/reg_field.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FF_IMPL_CUDA_REG_FIELD_H +#define FF_IMPL_CUDA_REG_FIELD_H #include "fastfields/core/cuda_switch.h" #include "fastfields/impl/kernels/bounds.h" #include "fastfields/impl/kernels/utils.h" @@ -2982,3 +2983,4 @@ FF_CUHOST void relax_bending_jrls_( FF_NAMESPACE_END(reg_field) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) +#endif // FF_IMPL_CUDA_REG_FIELD_H diff --git a/include/fastfields/impl/cuda/reg_flow.h b/include/fastfields/impl/cuda/reg_flow.h index fd58a60..f8dd74f 100755 --- a/include/fastfields/impl/cuda/reg_flow.h +++ b/include/fastfields/impl/cuda/reg_flow.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FF_IMPL_CUDA_REG_FLOW_H +#define FF_IMPL_CUDA_REG_FLOW_H #include "fastfields/core/cuda_switch.h" #include "fastfields/impl/kernels/bounds.h" #include "fastfields/impl/kernels/utils.h" @@ -2280,3 +2281,4 @@ FF_CUHOST void relax_lame_jrls_( FF_NAMESPACE_END(reg_flow) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) +#endif // FF_IMPL_CUDA_REG_FLOW_H diff --git a/include/fastfields/impl/cuda/resize.h b/include/fastfields/impl/cuda/resize.h index 4214b26..fab9de1 100755 --- a/include/fastfields/impl/cuda/resize.h +++ b/include/fastfields/impl/cuda/resize.h @@ -1,9 +1,10 @@ -#pragma once /* TODO * - check if using an inner loop across batch elements is more efficient * (we currently use an outer loop, so we recompute indices many times) */ +#ifndef FF_IMPL_CUDA_RESIZE_H +#define FF_IMPL_CUDA_RESIZE_H #include "fastfields/core/cuda_switch.h" #include "fastfields/impl/kernels/spline.h" #include "fastfields/impl/kernels/bounds.h" @@ -187,3 +188,4 @@ void loop( FF_NAMESPACE_END(resize) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) +#endif // FF_IMPL_CUDA_RESIZE_H diff --git a/include/fastfields/impl/cuda/restrict.h b/include/fastfields/impl/cuda/restrict.h index 0d58f38..cf93943 100755 --- a/include/fastfields/impl/cuda/restrict.h +++ b/include/fastfields/impl/cuda/restrict.h @@ -1,10 +1,11 @@ -#pragma once /* TODO * - implement special case (order=1 + scale=2) for dim 2 and 3 * - check if using an inner loop across batch elements is more efficient * (we currently use an outer loop, so we recompute indices many times) */ +#ifndef FF_IMPL_CUDA_RESTRICT_H +#define FF_IMPL_CUDA_RESTRICT_H #include "fastfields/core/cuda_switch.h" #include "fastfields/impl/kernels/spline.h" #include "fastfields/impl/kernels/bounds.h" @@ -262,3 +263,4 @@ void loop( FF_NAMESPACE_END(restrict) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) +#endif // FF_IMPL_CUDA_RESTRICT_H diff --git a/include/fastfields/impl/cuda/splinc.h b/include/fastfields/impl/cuda/splinc.h index 07cc934..26ab4d7 100755 --- a/include/fastfields/impl/cuda/splinc.h +++ b/include/fastfields/impl/cuda/splinc.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FF_IMPL_CUDA_SPLINC_H +#define FF_IMPL_CUDA_SPLINC_H #include "fastfields/core/cuda_switch.h" #include "fastfields/impl/kernels/splinc.h" #include "fastfields/impl/kernels/bounds.h" @@ -106,3 +107,4 @@ void loop( FF_NAMESPACE_END(splinc) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) +#endif // FF_IMPL_CUDA_SPLINC_H diff --git a/include/fastfields/impl/cuda/utils.h b/include/fastfields/impl/cuda/utils.h index 54d2901..76cede9 100644 --- a/include/fastfields/impl/cuda/utils.h +++ b/include/fastfields/impl/cuda/utils.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef FF_IMPL_CUDA_UTILS_H +#define FF_IMPL_CUDA_UTILS_H #include "fastfields/core/cuda_switch.h" #include // int64_t #include // std::bad_alloc @@ -324,3 +325,4 @@ FF_CUHOST inline I * copyToHost(const I * inp, S size, I * out = nullptr) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) +#endif // FF_IMPL_CUDA_UTILS_H diff --git a/include/fastfields/impl/kernels/distance.h b/include/fastfields/impl/kernels/distance.h index 1ff4939..921a4f7 100755 --- a/include/fastfields/impl/kernels/distance.h +++ b/include/fastfields/impl/kernels/distance.h @@ -1,4 +1,7 @@ +#ifndef FF_IMPL_KERNELS_DISTANCE_H +#define FF_IMPL_KERNELS_DISTANCE_H #include "distance/euclidean.h" #include "distance/l1.h" #include "distance/spline.h" -#include "distance/mesh.h" \ No newline at end of file +#include "distance/mesh.h" +#endif // FF_IMPL_KERNELS_DISTANCE_H diff --git a/include/fastfields/impl/kernels/posdef.h b/include/fastfields/impl/kernels/posdef.h index ece49aa..23b33b9 100755 --- a/include/fastfields/impl/kernels/posdef.h +++ b/include/fastfields/impl/kernels/posdef.h @@ -1 +1,4 @@ +#ifndef FF_IMPL_KERNELS_POSDEF_H +#define FF_IMPL_KERNELS_POSDEF_H #include "posdef/posdef.h" +#endif // FF_IMPL_KERNELS_POSDEF_H diff --git a/include/fastfields/impl/kernels/posdef/estatics.inl b/include/fastfields/impl/kernels/posdef/estatics.inl index 36496ee..f72d489 100755 --- a/include/fastfields/impl/kernels/posdef/estatics.inl +++ b/include/fastfields/impl/kernels/posdef/estatics.inl @@ -205,4 +205,4 @@ struct utils: public common_estatics } }; -#endif // FF_POSDEF_ESTATICS +#endif // FF_POSDEF_ESTATICS diff --git a/include/fastfields/impl/kernels/pushpull.h b/include/fastfields/impl/kernels/pushpull.h index 4f16a5a..b0c95fe 100755 --- a/include/fastfields/impl/kernels/pushpull.h +++ b/include/fastfields/impl/kernels/pushpull.h @@ -1,3 +1,6 @@ +#ifndef FF_IMPL_KERNELS_PUSHPULL_H +#define FF_IMPL_KERNELS_PUSHPULL_H #include "pushpull/1d.h" #include "pushpull/2d.h" #include "pushpull/3d.h" +#endif // FF_IMPL_KERNELS_PUSHPULL_H diff --git a/include/fastfields/impl/kernels/pushpull/nd.h b/include/fastfields/impl/kernels/pushpull/nd.h index 9776580..75851ef 100755 --- a/include/fastfields/impl/kernels/pushpull/nd.h +++ b/include/fastfields/impl/kernels/pushpull/nd.h @@ -486,4 +486,4 @@ FF_NAMESPACE_END(pushpull) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) -#endif FF_PUSHPULL_ND +#endif // FF_PUSHPULL_ND diff --git a/include/fastfields/impl/kernels/regularisers.h b/include/fastfields/impl/kernels/regularisers.h index 29562ff..3c57907 100755 --- a/include/fastfields/impl/kernels/regularisers.h +++ b/include/fastfields/impl/kernels/regularisers.h @@ -1,2 +1,5 @@ +#ifndef FF_IMPL_KERNELS_REGULARISERS_H +#define FF_IMPL_KERNELS_REGULARISERS_H #include "regularisers/flow.h" #include "regularisers/field.h" +#endif // FF_IMPL_KERNELS_REGULARISERS_H diff --git a/include/fastfields/impl/kernels/regularisers/field.h b/include/fastfields/impl/kernels/regularisers/field.h index 6185513..24a7825 100755 --- a/include/fastfields/impl/kernels/regularisers/field.h +++ b/include/fastfields/impl/kernels/regularisers/field.h @@ -1,4 +1,7 @@ +#ifndef FF_IMPL_KERNELS_REGULARISERS_FIELD_H +#define FF_IMPL_KERNELS_REGULARISERS_FIELD_H #include "field/1d.h" #include "field/2d.h" #include "field/3d.h" #include "field/utils.h" +#endif // FF_IMPL_KERNELS_REGULARISERS_FIELD_H diff --git a/include/fastfields/impl/kernels/regularisers/flow.h b/include/fastfields/impl/kernels/regularisers/flow.h index d38918c..e355ec7 100755 --- a/include/fastfields/impl/kernels/regularisers/flow.h +++ b/include/fastfields/impl/kernels/regularisers/flow.h @@ -1,4 +1,7 @@ +#ifndef FF_IMPL_KERNELS_REGULARISERS_FLOW_H +#define FF_IMPL_KERNELS_REGULARISERS_FLOW_H #include "flow/1d.h" #include "flow/2d.h" #include "flow/3d.h" #include "flow/utils.h" +#endif // FF_IMPL_KERNELS_REGULARISERS_FLOW_H diff --git a/tools/normalise-header-guards.py b/tools/normalise-header-guards.py new file mode 100644 index 0000000..61a4414 --- /dev/null +++ b/tools/normalise-header-guards.py @@ -0,0 +1,319 @@ +#!/usr/bin/env python3 +""" +normalise-header-guards.py -- one include-guard convention for every header. + +THE RULE THIS APPLIES +-------------------------------------------------------------------------- +Every header in this repository is bracketed by an `#ifndef`/`#define`/ +`#endif` include guard, and no header uses `#pragma once`. + + #ifndef FF_SOMETHING_H + #define FF_SOMETHING_H + ... + #endif // FF_SOMETHING_H + +The guard must open before any other preprocessor directive and close as the +last directive in the file -- a guard that does not span the whole file is not +a guard. Its name must be `FF_`-prefixed (the rule the public-macro pass +established: a guard is a macro on the installed surface like any other) and +unique across the tree. + +WHY GUARDS AND NOT `#pragma once` +-------------------------------------------------------------------------- +Both work; the tree had drifted into four conventions at once (guard-only, +pragma-only, both, and six headers with neither), split by which of the six +pre-consolidation repositories a file came from rather than by any decision. +The deciding argument is what `include/fastfields/` *is*: the public installed +interface, copied to an install prefix and consumed from there by +`fastfields-dlpack`. + +`#pragma once` keys on file identity. Two *copies* of the same logical header +-- the build-tree one reached through `-I include` and the installed one +reached through the prefix, in a single translation unit -- are two files, so +`#pragma once` includes both and the second one redefines everything the first +defined. A macro guard is the mechanism that makes those two copies collapse +into one inclusion, because it keys on a name rather than on an inode. + +That is not a hypothetical worry we invented for this sweep: it is exactly the +reason `core/dlpack.h` must keep its upstream `DLPACK_DLPACK_H_` guard -- so +that our vendored copy and a system DLPack header interoperate. The property +the vendored header needs is the property an installed header needs, and there +is no reason for the public surface to hold itself to a weaker rule than the +one file everybody already agrees must be guarded. Choosing guards is also the +only choice under which `dlpack.h` is *conformant as it stands* rather than a +carve-out: the convention costs this tree zero exemptions. + +(The historical objection to `#pragma once` here -- that every cross-repo +dependency was a symlink, so "the same file" had several identities -- is +indeed gone: `main` has no `.gitmodules`, no gitlinks and no symlinks. It is +just not the argument that decides it. Nor is portability: clang, g++, nvcc +and MSVC all support the pragma. Belt-and-braces "both" is defensible too, and +was in use in five headers, but it buys nothing over the guard alone -- the +guard is what does the work in every case where the two differ -- at the cost +of a second thing to keep in sync in 117 files.) + +GUARD NAMES +-------------------------------------------------------------------------- +A guard this script *adds* is derived from the file's path under +`include/fastfields/`, uppercased, with every non-alphanumeric character +(including the extension dot) turned into `_`: + + include/fastfields/impl/cuda/utils.h -> FF_IMPL_CUDA_UTILS_H + +Derivation makes the name unique by construction and gives new headers a rule +to follow instead of a precedent to guess at. + +Guards that already exist keep their names. They are unique and already +`FF_`-prefixed, so renaming 99 working macros would be churn: it buys nothing +a reader can use, it invalidates the literal guard text quoted in the frozen +`tools/consolidate.sh`, and it multiplies the conflict surface against the +long-running `teeny` branch. The convention this script enforces is the +*shape* of the guard, which is what had actually drifted; `--check` enforces +the properties that matter (present, whole-file, prefixed, unique), not a +spelling. + +VENDORED FILES +-------------------------------------------------------------------------- +`include/fastfields/core/dlpack.h` is verbatim upstream code. It is never +rewritten, and `--check` exempts it from the `FF_` prefix requirement only -- +it must still carry a whole-file guard and must still not use `#pragma once`, +both of which are already true of it today. + +It is the only vendored file. `impl/kernels/threadpool.h` carries a +third-party copyright (wstpool, MIT) but is adapted rather than verbatim -- it +already uses this project's namespace macros and an `FF_`-prefixed guard -- so +it is treated as project code. + +USAGE +-------------------------------------------------------------------------- + python3 tools/normalise-header-guards.py # apply + python3 tools/normalise-header-guards.py --check # verify, change nothing + +Idempotent and deterministic: re-running over an already-normalised tree +rewrites nothing, and running over the pre-sweep tree reproduces the sweep +exactly. + +If this lands on a base that has moved, do NOT resolve conflicts by hand: +reset, re-run the script on the new base, and commit that. +""" + +import os +import re +import sys + +ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +SOURCE_DIRS = ("include", "src", "tests") +HEADER_EXTS = (".h", ".hpp", ".inl", ".cuh") + +# Verbatim third-party code: never rewritten, and exempt from the FF_ prefix +# requirement (only from that -- see the module docstring). +VENDORED = {"include/fastfields/core/dlpack.h"} + +PUBLIC_ROOT = os.path.join("include", "fastfields") + + +def headers(): + for d in SOURCE_DIRS: + for dirpath, _, filenames in os.walk(os.path.join(ROOT, d)): + for name in sorted(filenames): + if name.endswith(HEADER_EXTS): + yield os.path.relpath(os.path.join(dirpath, name), ROOT) + + +def derived_guard(rel): + """FF_ + the path under include/fastfields/, uppercased, non-alnum -> _.""" + stem = rel[len(PUBLIC_ROOT) + 1:] if rel.startswith(PUBLIC_ROOT + os.sep) else rel + return "FF_" + re.sub(r"[^A-Za-z0-9]", "_", stem).upper() + + +def strip_comments(text): + """Blank out block/line comments so directive scanning cannot be fooled by + a `#endif` inside a comment. Newlines are preserved, so line numbers and + line count are unchanged.""" + out = [] + i, n = 0, len(text) + while i < n: + if text.startswith("/*", i): + j = text.find("*/", i + 2) + j = n if j < 0 else j + 2 + out.append("".join(c if c == "\n" else " " for c in text[i:j])) + i = j + elif text.startswith("//", i): + j = text.find("\n", i) + j = n if j < 0 else j + out.append(" " * (j - i)) + i = j + else: + out.append(text[i]) + i += 1 + return "".join(out) + + +def directives(text): + """(line index, directive, rest) for every preprocessor directive, with + line continuations respected and comments already blanked.""" + lines = strip_comments(text).split("\n") + out = [] + i = 0 + while i < len(lines): + m = re.match(r"\s*#\s*(\w+)\s*(.*)$", lines[i]) + start = i + while lines[i].rstrip().endswith("\\") and i + 1 < len(lines): + i += 1 + if m: + out.append((start, m.group(1), m.group(2).strip())) + i += 1 + return out + + +def find_guard(text): + """The whole-file guard name, or None. + + Requires: the first directive is `#ifndef N`, the second is `#define N` + with an empty replacement list, and the conditional nesting introduced by + that `#ifndef` closes only at the file's last directive. + + A leading `#pragma once` is stepped over rather than rejected, so that a + "both styles" header is recognised as guarded and keeps its guard name + when the pragma is dropped.""" + ds = [d for d in directives(text) if d[1] != "pragma"] + if len(ds) < 3: + return None + if ds[0][1] != "ifndef": + return None + name = ds[0][2] + if not re.fullmatch(r"\w+", name or ""): + return None + if ds[1][1] != "define" or ds[1][2] != name: + return None + depth = 0 + for k, (_, d, _rest) in enumerate(ds): + if d in ("if", "ifdef", "ifndef"): + depth += 1 + elif d == "endif": + depth -= 1 + if depth == 0: + return name if k == len(ds) - 1 else None + return None + + +def prologue_end(lines): + """Index of the first line that is neither blank nor part of the leading + comment block -- i.e. where the guard goes.""" + i, n = 0, len(lines) + while i < n: + s = lines[i].strip() + if not s: + i += 1 + continue + if s.startswith("//"): + i += 1 + continue + if s.startswith("/*"): + while i < n and "*/" not in lines[i]: + i += 1 + i += 1 + continue + break + return i + + +def normalise(rel, text): + name = find_guard(text) or derived_guard(rel) + + lines = text.split("\n") + trailing_newline = lines and lines[-1] == "" + if trailing_newline: + lines.pop() + + had_guard = find_guard(text) is not None + + # 1. drop every `#pragma once`, and the blank line it may leave behind at + # the very top of the file. + kept = [l for l in lines if not re.match(r"\s*#\s*pragma\s+once\s*$", l)] + if len(kept) != len(lines): + lines = kept + while lines and not lines[0].strip(): + lines.pop(0) + + # 2. open the guard if the file has none. + if not had_guard: + at = prologue_end(lines) + lines[at:at] = ["#ifndef %s" % name, "#define %s" % name] + + # 3. close it, and normalise the closing comment. `#endif FF_X` (no `//`) + # is ill-formed -- extra tokens after #endif -- and was in the tree. + if had_guard: + for i in range(len(lines) - 1, -1, -1): + if lines[i].strip(): + lines[i] = "#endif // %s" % name + break + else: + lines.append("#endif // %s" % name) + + return "\n".join(lines) + ("\n" if trailing_newline or not had_guard else "") + + +def apply(check_only=False): + changed = 0 + for rel in headers(): + if rel in VENDORED: + continue + path = os.path.join(ROOT, rel) + with open(path, encoding="utf-8") as fh: + original = fh.read() + text = normalise(rel, original) + if text != original: + changed += 1 + if check_only: + print("would rewrite %s" % rel) + else: + with open(path, "w", encoding="utf-8") as fh: + fh.write(text) + print("%d header(s)%s" % (changed, " would change" if check_only else " rewritten")) + return changed + + +def violations(): + """Every header that does not satisfy the convention. Must be empty.""" + hits = [] + seen = {} + for rel in headers(): + with open(os.path.join(ROOT, rel), encoding="utf-8") as fh: + text = fh.read() + + for n, line in enumerate(text.split("\n"), 1): + if re.match(r"\s*#\s*pragma\s+once\s*$", line): + hits.append("%s:%d: #pragma once" % (rel, n)) + + name = find_guard(text) + if name is None: + hits.append("%s: no whole-file include guard" % rel) + continue + if rel not in VENDORED and not name.startswith("FF_"): + hits.append("%s: guard %s is not FF_-prefixed" % (rel, name)) + if name in seen: + hits.append("%s: guard %s collides with %s" % (rel, name, seen[name])) + seen[name] = rel + + last = [l for l in text.split("\n") if l.strip()][-1].strip() + if rel not in VENDORED and last != "#endif // %s" % name: + hits.append("%s: closes with %r, want '#endif // %s'" % (rel, last, name)) + return hits + + +if __name__ == "__main__": + check = "--check" in sys.argv + apply(check_only=check) + left = violations() + if left: + print("\nHEADERS NOT MATCHING THE CONVENTION:") + for h in left: + print(" " + h) + else: + print( + "\nevery header carries a whole-file, FF_-prefixed, unique include " + "guard and no #pragma once." + ) + sys.exit(1 if left else 0) From ba8ae344c4bd4c8fde3df39363b1cddd7ce737aa Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 20 Aug 2026 12:09:16 +0000 Subject: [PATCH 2/2] refactor: #pragma once in every header The tree carried four conventions across 117 headers -- 94 with an #ifndef guard only, 12 with `#pragma once` only, 5 with both, and 6 umbrella headers in impl/kernels/ with neither. The split was by provenance: each of the six absorbed repositories had drifted its own way, and consolidation put them side by side without picking one. The convention is now `#pragma once`, on line 1 of every header, with no `#ifndef` include guards. Line 1 with no exception for a licence or provenance comment: "is line 1 `#pragma once`" needs no judgement to apply and none to check, and it is what the twelve headers already using the pragma did. Attribution comments keep their text and sit one line lower. `#pragma once` is not ISO C++, but clang, g++, nvcc and MSVC all support it, so it costs nothing against the stated Windows goal. The historical hazard -- that it keys on file identity, which was ambiguous when every cross-repo dependency was a symlink -- is gone: main has no .gitmodules, no gitlinks and no symlinks. THE ONE EXCEPTION: core/dlpack.h Vendored verbatim, and it keeps its upstream `DLPACK_DLPACK_H_` guard. That macro is what lets our copy and a *system* DLPack header carrying the same guard collapse into a single inclusion -- something `#pragma once` cannot do, because those are two distinct files. The script never touches it; --check treats it as exempt but still verifies it kept the guard, and fails loudly if the path disappears rather than silently dropping the exemption. Seven other headers carry third-party provenance: impl/kernels/atomic.h "CUDA portion copied from PyTorch/ATen" impl/kernels/parallel.h "adapted from PyTorch/ATen ParallelNative" impl/kernels/parallel_impl.h ditto impl/kernels/threadpool.h YasserAsmi/wstpool (MIT) impl/kernels/threadpool.inl "some of this is copied from pytorch/aten" impl/cuda/utils.h two helpers "(Copied from PyTorch)" impl/kernels/distance/mesh.h .../TriangleMeshDistance All seven get the pragma, because all seven are adaptations rather than drop-in vendored copies. The test that settles it is not how much text came from upstream but whether the file carries an upstream *guard macro* to interoperate with, and none does: each is guarded by a name this project invented (FF_ATOMIC, FF_PARALLEL_H, FF_THREADPOOL_H, ...) or -- impl/cuda/ utils.h -- by nothing at all, having already used the pragma. They are also re-namespaced into ff:: via FF_NAMESPACE_BEGIN, use this project's FF_CUHOST /FF_CUDEV qualifiers and include project headers, so no upstream copy could substitute for them and none is on any include path. Copyright notices are untouched either way; this is include mechanics, not attribution. REMOVING A GUARD IS NOT AUTOMATICALLY INERT A guard macro can be *tested* from outside the header that defines it, and then deleting its `#define` silently changes what compiles -- the one way a sweep like this breaks something with no diagnostic. So the script greps the whole repository for every guard macro before removing any, and refuses to run if one is mentioned in a compiled source outside its own header. --check runs the same audit, so a future header that starts testing a guard name turns it red. The audit is clean on this base: all 99 guard macros are referenced exactly once, by their own `#ifndef`, with no `#ifdef` on a guard name anywhere in include/, src/ or tests/. The only mentions elsewhere are inert text -- tools/consolidate.sh quoting header text it generated, one prose line in MIGRATION-PROVENANCE.md, and the script's own docstring -- and those are reported rather than blocking. WHAT IS NOT A HEADER GUARD, AND SURVIVES Only a guard bracketing the whole file is removed. Partial-file `#ifndef` blocks stay, and two families matter: * FF_LIB_BOUND_SPLINE_T -- eight api/*.h headers wrap the shared bound_t/ spline_t declarations in it so they can be co-included. That is precisely the job `#pragma once` cannot do (one macro, eight files), and it is depended on downstream: fastfields-dlpack/src/ext.cpp includes all eight and says so in a comment. * FF_POSDEF_MAX_NBATCH, FF_PP_MAX_NBATCH, FF_RESIZE_MAX_NBATCH, FF_RESTRICT_MAX_NBATCH, FF_SPLINC_MAX_NBATCH, FF_AUTOCAST_PINNED_HOST -- `#ifndef X / #define X ` overridable build knobs. The guard finder only accepts an `#ifndef` that is the file's first directive, whose `#define` has an empty replacement list, and whose `#endif` is the file's last directive, so none of those can be mistaken for a guard. ALSO FIXED, BECAUSE THE SWEEP DELETED THE LINES * impl/kernels/pushpull/nd.h closed with `#endif FF_PUSHPULL_ND` -- extra tokens after #endif, which is ill-formed and diagnosed under -pedantic; * impl/cpu/distance_mesh.h closed with a comment naming a macro (FF_DISTANCE_MESH) that was not its guard (FF_CPU_DISTANCE_MESH); * impl/kernels/distance.h had no trailing newline. REPRODUCIBILITY tools/normalise-header-guards.py is committed, as tools/rename-macros.py and tools/normalise-include-delimiters.py were, so the rewrite is replayed rather than read: git checkout HEAD~1 -- include && python3 tools/normalise-header-guards.py git diff # empty --check verifies the convention and exits non-zero on any violation, so a rebase does not need a 117-file hand audit. It is idempotent, and everything it checks is per-file content rather than path, so it keeps working if headers move between directories. The rule is recorded in CLAUDE.md beside the FF_-prefix rule, dlpack exception and reason included. --- CLAUDE.md | 22 ++++++++++++++++++- include/fastfields/api/checks.h | 5 +---- include/fastfields/api/cpu/distance.h | 5 +---- include/fastfields/api/cpu/posdef.h | 5 +---- include/fastfields/api/cpu/pushpull.h | 5 +---- .../fastfields/api/cpu/pushpull_dispatch.h | 5 +---- include/fastfields/api/cpu/reg_field.h | 5 +---- include/fastfields/api/cpu/reg_flow.h | 5 +---- include/fastfields/api/cpu/resize.h | 5 +---- include/fastfields/api/cpu/restrict.h | 5 +---- include/fastfields/api/cpu/solve_field.h | 5 +---- include/fastfields/api/cpu/splinc.h | 5 +---- include/fastfields/api/cuda/distance.h | 5 +---- include/fastfields/api/cuda/posdef.h | 5 +---- include/fastfields/api/cuda/pushpull.h | 5 +---- .../fastfields/api/cuda/pushpull_dispatch.h | 5 +---- include/fastfields/api/cuda/reg_field.h | 5 +---- include/fastfields/api/cuda/reg_flow.h | 5 +---- include/fastfields/api/cuda/resize.h | 5 +---- include/fastfields/api/cuda/restrict.h | 5 +---- include/fastfields/api/cuda/splinc.h | 5 +---- include/fastfields/api/cuda/stream.h | 5 ----- include/fastfields/api/distance.h | 5 +---- include/fastfields/api/posdef.h | 5 +---- include/fastfields/api/pushpull.h | 5 +---- include/fastfields/api/reg_field.h | 5 +---- include/fastfields/api/reg_flow.h | 5 +---- include/fastfields/api/resize.h | 5 +---- include/fastfields/api/restrict.h | 5 +---- include/fastfields/api/solve_field.h | 5 +---- include/fastfields/api/splinc.h | 5 +---- include/fastfields/core/autocast.h | 4 ---- include/fastfields/core/cuda_switch.h | 6 ----- include/fastfields/core/defines.h | 5 ----- include/fastfields/core/dispatch.h | 5 ----- .../fastfields/impl/cpu/distance_euclidean.h | 5 +---- include/fastfields/impl/cpu/distance_l1.h | 5 +---- include/fastfields/impl/cpu/distance_mesh.h | 6 +---- include/fastfields/impl/cpu/distance_spline.h | 5 +---- include/fastfields/impl/cpu/posdef.h | 5 +---- include/fastfields/impl/cpu/pushpull.h | 5 +---- include/fastfields/impl/cpu/reg_field.h | 5 +---- include/fastfields/impl/cpu/reg_flow.h | 6 +---- include/fastfields/impl/cpu/resize.h | 5 +---- include/fastfields/impl/cpu/restrict.h | 5 +---- include/fastfields/impl/cpu/solve_field.h | 5 +---- include/fastfields/impl/cpu/splinc.h | 5 +---- include/fastfields/impl/cpu/tetrahedron.h | 7 +----- include/fastfields/impl/kernels/atomic.h | 5 +---- include/fastfields/impl/kernels/batch.h | 5 +---- include/fastfields/impl/kernels/bounds.h | 5 +---- include/fastfields/impl/kernels/distance.h | 3 ++- .../impl/kernels/distance/euclidean.h | 5 +---- include/fastfields/impl/kernels/distance/l1.h | 4 +--- .../fastfields/impl/kernels/distance/mesh.h | 5 +---- .../impl/kernels/distance/mesh_utils.h | 5 +---- .../fastfields/impl/kernels/distance/spline.h | 5 +---- include/fastfields/impl/kernels/meta.h | 6 +---- include/fastfields/impl/kernels/parallel.h | 5 +---- .../fastfields/impl/kernels/parallel_impl.h | 5 +---- include/fastfields/impl/kernels/posdef.h | 1 + .../fastfields/impl/kernels/posdef/cholesky.h | 5 +---- .../fastfields/impl/kernels/posdef/diag.inl | 7 +----- .../impl/kernels/posdef/estatics.inl | 6 +---- .../fastfields/impl/kernels/posdef/eye.inl | 6 +---- .../fastfields/impl/kernels/posdef/full.inl | 6 +---- .../fastfields/impl/kernels/posdef/posdef.h | 5 +---- .../fastfields/impl/kernels/posdef/sym.inl | 6 +---- .../fastfields/impl/kernels/posdef/utils.h | 5 +---- include/fastfields/impl/kernels/pushpull.h | 1 + include/fastfields/impl/kernels/pushpull/1d.h | 5 +---- include/fastfields/impl/kernels/pushpull/2d.h | 5 +---- include/fastfields/impl/kernels/pushpull/3d.h | 5 +---- include/fastfields/impl/kernels/pushpull/nd.h | 5 +---- .../fastfields/impl/kernels/pushpull/utils.h | 5 +---- .../fastfields/impl/kernels/regularisers.h | 1 + .../impl/kernels/regularisers/field.h | 1 + .../impl/kernels/regularisers/field/1d.h | 5 +---- .../impl/kernels/regularisers/field/2d.h | 6 +---- .../impl/kernels/regularisers/field/3d.h | 5 +---- .../impl/kernels/regularisers/field/utils.h | 5 +---- .../impl/kernels/regularisers/flow.h | 1 + .../impl/kernels/regularisers/flow/1d.h | 5 +---- .../impl/kernels/regularisers/flow/2d.h | 5 +---- .../impl/kernels/regularisers/flow/3d.h | 5 +---- .../impl/kernels/regularisers/flow/utils.h | 5 +---- include/fastfields/impl/kernels/resize.h | 5 +---- include/fastfields/impl/kernels/restrict.h | 5 +---- include/fastfields/impl/kernels/splinc.h | 5 +---- include/fastfields/impl/kernels/spline.h | 5 +---- include/fastfields/impl/kernels/tetrahedron.h | 6 +---- include/fastfields/impl/kernels/threadpool.h | 5 +---- .../fastfields/impl/kernels/threadpool.inl | 4 +--- include/fastfields/impl/kernels/utils.h | 5 +---- .../impl/kernels/vector/abstract_ptr.h | 5 +---- .../impl/kernels/vector/abstract_sized.h | 5 +---- .../impl/kernels/vector/abstract_vector.h | 7 +----- .../impl/kernels/vector/concrete_vector.h | 5 +---- .../fastfields/impl/kernels/vector/forward.h | 5 +---- .../fastfields/impl/kernels/vector/stream.h | 5 +---- .../fastfields/impl/kernels/vector/traits.h | 6 +---- .../fastfields/impl/kernels/vector/vector.h | 6 +---- .../fastfields/impl/kernels/vector/weak_ref.h | 5 +---- .../impl/kernels/vector/weak_sized.h | 5 +---- .../impl/kernels/vector/weak_vector.h | 5 +---- 105 files changed, 121 insertions(+), 414 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index b90f102..843d61d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -205,8 +205,28 @@ pushpull's fully-static order×bound compile is nightly which category a dependency is in, not about lookup. `tools/normalise-include-delimiters.py --check` enforces it, and also checks the converse: every quoted include must resolve beside its includer. +- **`#pragma once` on line 1 of every header — no `#ifndef` include guards.** + Line 1 with no exception, licence and provenance comments included; they keep + their text and sit one line lower. **`include/fastfields/core/dlpack.h` is + the one exception and must keep its upstream `DLPACK_DLPACK_H_` guard** — it + is a verbatim vendored copy, and that macro is what lets it and a *system* + DLPack header carrying the same guard collapse into one inclusion, which + `#pragma once` cannot do for two distinct files. Do not "finish the job" on + it. The seven other headers with third-party provenance (`impl/kernels/`'s + `atomic.h`, `parallel{,_impl}.h`, `threadpool.{h,inl}`, `distance/mesh.h`, + and `impl/cuda/utils.h`) are adaptations, not drop-in copies: each is + re-namespaced into `ff::` and none carries an upstream guard macro, so there + is nothing for a guard to interoperate with and the pragma applies to them. + A partial-file `#ifndef` is *not* a header guard and this rule leaves it + alone — `FF_LIB_BOUND_SPLINE_T` (eight `api/*.h` headers share it so they + co-include; `fastfields-dlpack`'s `ext.cpp` depends on that and says so) and + the `FF_*_MAX_NBATCH` / `FF_AUTOCAST_PINNED_HOST` build knobs all stay. + Enforced by `tools/normalise-header-guards.py --check`, which also applies + the convention and audits that no guard macro is tested from another file — + the one way deleting a `#define` could change what compiles. - `include/fastfields/core/dlpack.h` is vendored upstream code: do not edit it, - and it is skipped by `codespell` (see `.codespellrc`). + and it is skipped by `codespell` (see `.codespellrc`). It is the only + verbatim third-party file in the tree. ## Pointers diff --git a/include/fastfields/api/checks.h b/include/fastfields/api/checks.h index 6b41d68..f4f417a 100644 --- a/include/fastfields/api/checks.h +++ b/include/fastfields/api/checks.h @@ -1,5 +1,4 @@ -#ifndef FF_LIB_CHECKS -#define FF_LIB_CHECKS +#pragma once #include #include #include @@ -56,5 +55,3 @@ inline void require_same_device(const DLTensor & ref, const DLTensor & t, const } FF_NAMESPACE_END(FF_NS) - -#endif // FF_LIB_CHECKS diff --git a/include/fastfields/api/cpu/distance.h b/include/fastfields/api/cpu/distance.h index 9382753..ff9da0c 100644 --- a/include/fastfields/api/cpu/distance.h +++ b/include/fastfields/api/cpu/distance.h @@ -1,5 +1,4 @@ -#ifndef FF_CPU_DISTANCE -#define FF_CPU_DISTANCE +#pragma once #include #include @@ -62,5 +61,3 @@ void dt_mesh( } // namespace cpu } // namespace ff - -#endif // FF_CPU_DISTANCE diff --git a/include/fastfields/api/cpu/posdef.h b/include/fastfields/api/cpu/posdef.h index 74452e5..8f95b1e 100644 --- a/include/fastfields/api/cpu/posdef.h +++ b/include/fastfields/api/cpu/posdef.h @@ -1,5 +1,4 @@ -#ifndef FF_CPU_POSDEF -#define FF_CPU_POSDEF +#pragma once #include #include @@ -80,5 +79,3 @@ void sym_invert_( } // namespace cpu } // namespace ff - -#endif // FF_CPU_POSDEF diff --git a/include/fastfields/api/cpu/pushpull.h b/include/fastfields/api/cpu/pushpull.h index 6a33df3..7141233 100644 --- a/include/fastfields/api/cpu/pushpull.h +++ b/include/fastfields/api/cpu/pushpull.h @@ -1,5 +1,4 @@ -#ifndef FF_CPU_PUSHPULL -#define FF_CPU_PUSHPULL +#pragma once #include #include @@ -199,5 +198,3 @@ void grad_backward( } // namespace cpu } // namespace ff - -#endif // FF_CPU_PUSHPULL diff --git a/include/fastfields/api/cpu/pushpull_dispatch.h b/include/fastfields/api/cpu/pushpull_dispatch.h index a05e64c..a6383b4 100644 --- a/include/fastfields/api/cpu/pushpull_dispatch.h +++ b/include/fastfields/api/cpu/pushpull_dispatch.h @@ -1,5 +1,4 @@ -#ifndef FF_CPU_PUSHPULL_DISPATCH -#define FF_CPU_PUSHPULL_DISPATCH +#pragma once /** * Private (not installed) header: the argument-marshalling helpers, the * argument checks and the ndim x order x bound x dtype dispatch matrix @@ -103,5 +102,3 @@ typedef double reduce_t; FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_CPU_PUSHPULL_DISPATCH diff --git a/include/fastfields/api/cpu/reg_field.h b/include/fastfields/api/cpu/reg_field.h index ed3abb5..6d5e005 100644 --- a/include/fastfields/api/cpu/reg_field.h +++ b/include/fastfields/api/cpu/reg_field.h @@ -1,5 +1,4 @@ -#ifndef FF_CPU_REG_FIELD -#define FF_CPU_REG_FIELD +#pragma once #include #include @@ -368,5 +367,3 @@ void field_relax_rls( } // namespace cpu } // namespace ff - -#endif // FF_CPU_REG_FIELD diff --git a/include/fastfields/api/cpu/reg_flow.h b/include/fastfields/api/cpu/reg_flow.h index e19c798..cbf300c 100644 --- a/include/fastfields/api/cpu/reg_flow.h +++ b/include/fastfields/api/cpu/reg_flow.h @@ -1,5 +1,4 @@ -#ifndef FF_CPU_REG_FLOW -#define FF_CPU_REG_FLOW +#pragma once #include #include @@ -404,5 +403,3 @@ void flow_relax_rls( } // namespace cpu } // namespace ff - -#endif // FF_CPU_REG_FLOW diff --git a/include/fastfields/api/cpu/resize.h b/include/fastfields/api/cpu/resize.h index e67ef75..8734d0e 100644 --- a/include/fastfields/api/cpu/resize.h +++ b/include/fastfields/api/cpu/resize.h @@ -1,5 +1,4 @@ -#ifndef FF_CPU_RESIZE -#define FF_CPU_RESIZE +#pragma once #include #include @@ -38,5 +37,3 @@ void resample( } // namespace cpu } // namespace ff - -#endif // FF_CPU_RESIZE diff --git a/include/fastfields/api/cpu/restrict.h b/include/fastfields/api/cpu/restrict.h index a1c0c95..cab6c1d 100644 --- a/include/fastfields/api/cpu/restrict.h +++ b/include/fastfields/api/cpu/restrict.h @@ -1,5 +1,4 @@ -#ifndef FF_CPU_RESTRICT -#define FF_CPU_RESTRICT +#pragma once #include #include @@ -40,5 +39,3 @@ void restriction( } // namespace cpu } // namespace ff - -#endif // FF_CPU_RESTRICT diff --git a/include/fastfields/api/cpu/solve_field.h b/include/fastfields/api/cpu/solve_field.h index 31d4ec3..3e7367e 100644 --- a/include/fastfields/api/cpu/solve_field.h +++ b/include/fastfields/api/cpu/solve_field.h @@ -1,5 +1,4 @@ -#ifndef FF_CPU_SOLVE_FIELD -#define FF_CPU_SOLVE_FIELD +#pragma once #include #include @@ -66,5 +65,3 @@ void field_cg( } // namespace cpu } // namespace ff - -#endif // FF_CPU_SOLVE_FIELD diff --git a/include/fastfields/api/cpu/splinc.h b/include/fastfields/api/cpu/splinc.h index f2acc00..751a369 100644 --- a/include/fastfields/api/cpu/splinc.h +++ b/include/fastfields/api/cpu/splinc.h @@ -1,5 +1,4 @@ -#ifndef FF_CPU_SPLINC -#define FF_CPU_SPLINC +#pragma once #include #include @@ -28,5 +27,3 @@ void spline_coeff( } // namespace cpu } // namespace ff - -#endif // FF_CPU_SPLINC diff --git a/include/fastfields/api/cuda/distance.h b/include/fastfields/api/cuda/distance.h index 70b8350..42aa97e 100644 --- a/include/fastfields/api/cuda/distance.h +++ b/include/fastfields/api/cuda/distance.h @@ -1,5 +1,4 @@ -#ifndef FF_CUDA_DISTANCE -#define FF_CUDA_DISTANCE +#pragma once #include #include @@ -62,5 +61,3 @@ void dt_mesh( } // namespace cuda } // namespace ff - -#endif // FF_CUDA_DISTANCE diff --git a/include/fastfields/api/cuda/posdef.h b/include/fastfields/api/cuda/posdef.h index 7f3cab6..339f8fc 100644 --- a/include/fastfields/api/cuda/posdef.h +++ b/include/fastfields/api/cuda/posdef.h @@ -1,5 +1,4 @@ -#ifndef FF_CUDA_POSDEF -#define FF_CUDA_POSDEF +#pragma once #include #include @@ -80,5 +79,3 @@ void sym_invert_( } // namespace cuda } // namespace ff - -#endif // FF_CUDA_POSDEF diff --git a/include/fastfields/api/cuda/pushpull.h b/include/fastfields/api/cuda/pushpull.h index 4f64e26..732c16f 100644 --- a/include/fastfields/api/cuda/pushpull.h +++ b/include/fastfields/api/cuda/pushpull.h @@ -1,5 +1,4 @@ -#ifndef FF_CUDA_PUSHPULL -#define FF_CUDA_PUSHPULL +#pragma once #include #include @@ -199,5 +198,3 @@ void grad_backward( } // namespace cuda } // namespace ff - -#endif // FF_CUDA_PUSHPULL diff --git a/include/fastfields/api/cuda/pushpull_dispatch.h b/include/fastfields/api/cuda/pushpull_dispatch.h index 23c048c..34c9749 100644 --- a/include/fastfields/api/cuda/pushpull_dispatch.h +++ b/include/fastfields/api/cuda/pushpull_dispatch.h @@ -1,5 +1,4 @@ -#ifndef FF_CUDA_PUSHPULL_DISPATCH -#define FF_CUDA_PUSHPULL_DISPATCH +#pragma once /** * Private (not installed) header: the argument-marshalling helpers, the * argument checks and the ndim x order x bound x dtype dispatch matrix @@ -92,5 +91,3 @@ typedef double reduce_t; FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_CUDA_PUSHPULL_DISPATCH diff --git a/include/fastfields/api/cuda/reg_field.h b/include/fastfields/api/cuda/reg_field.h index f797a9b..330351b 100644 --- a/include/fastfields/api/cuda/reg_field.h +++ b/include/fastfields/api/cuda/reg_field.h @@ -1,5 +1,4 @@ -#ifndef FF_CUDA_REG_FIELD -#define FF_CUDA_REG_FIELD +#pragma once #include #include @@ -332,5 +331,3 @@ void field_relax_rls( } // namespace cuda } // namespace ff - -#endif // FF_CUDA_REG_FIELD diff --git a/include/fastfields/api/cuda/reg_flow.h b/include/fastfields/api/cuda/reg_flow.h index 8c7d78f..7d703c6 100644 --- a/include/fastfields/api/cuda/reg_flow.h +++ b/include/fastfields/api/cuda/reg_flow.h @@ -1,5 +1,4 @@ -#ifndef FF_CUDA_REG_FLOW -#define FF_CUDA_REG_FLOW +#pragma once #include #include @@ -359,5 +358,3 @@ void flow_relax_rls( } // namespace cuda } // namespace ff - -#endif // FF_CUDA_REG_FLOW diff --git a/include/fastfields/api/cuda/resize.h b/include/fastfields/api/cuda/resize.h index 119f3bf..90df298 100644 --- a/include/fastfields/api/cuda/resize.h +++ b/include/fastfields/api/cuda/resize.h @@ -1,5 +1,4 @@ -#ifndef FF_CUDA_RESIZE -#define FF_CUDA_RESIZE +#pragma once #include #include @@ -38,5 +37,3 @@ void resample( } // namespace cuda } // namespace ff - -#endif // FF_CUDA_RESIZE diff --git a/include/fastfields/api/cuda/restrict.h b/include/fastfields/api/cuda/restrict.h index d75a99b..ac7c4c3 100644 --- a/include/fastfields/api/cuda/restrict.h +++ b/include/fastfields/api/cuda/restrict.h @@ -1,5 +1,4 @@ -#ifndef FF_CUDA_RESTRICT -#define FF_CUDA_RESTRICT +#pragma once #include #include @@ -40,5 +39,3 @@ void restriction( } // namespace cuda } // namespace ff - -#endif // FF_CUDA_RESTRICT diff --git a/include/fastfields/api/cuda/splinc.h b/include/fastfields/api/cuda/splinc.h index 5cc7c12..f174c9b 100644 --- a/include/fastfields/api/cuda/splinc.h +++ b/include/fastfields/api/cuda/splinc.h @@ -1,5 +1,4 @@ -#ifndef FF_CUDA_SPLINC -#define FF_CUDA_SPLINC +#pragma once #include #include @@ -28,5 +27,3 @@ void spline_coeff( } // namespace cuda } // namespace ff - -#endif // FF_CUDA_SPLINC diff --git a/include/fastfields/api/cuda/stream.h b/include/fastfields/api/cuda/stream.h index 07a6ead..b5745e5 100644 --- a/include/fastfields/api/cuda/stream.h +++ b/include/fastfields/api/cuda/stream.h @@ -1,7 +1,4 @@ #pragma once -#ifndef FF_CUDA_STREAM -#define FF_CUDA_STREAM - /** * The public ABI carries a CUDA stream as an `intptr_t` (no CUDA types leak * into the exported signatures); the cuda-impl launchers take a real @@ -29,5 +26,3 @@ static inline cudaStream_t _reg_stream(intptr_t stream) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_CUDA_STREAM diff --git a/include/fastfields/api/distance.h b/include/fastfields/api/distance.h index 1d9a2db..9c5374e 100644 --- a/include/fastfields/api/distance.h +++ b/include/fastfields/api/distance.h @@ -1,5 +1,4 @@ -#ifndef FF_LIB_DISTANCE -#define FF_LIB_DISTANCE +#pragma once #include #include #include @@ -176,5 +175,3 @@ void dt_mesh( ); FF_NAMESPACE_END(FF_NS) - -#endif // FF_LIB_DISTANCE diff --git a/include/fastfields/api/posdef.h b/include/fastfields/api/posdef.h index 666454a..35d1582 100644 --- a/include/fastfields/api/posdef.h +++ b/include/fastfields/api/posdef.h @@ -1,5 +1,4 @@ -#ifndef FF_LIB_POSDEF -#define FF_LIB_POSDEF +#pragma once #include #include #include @@ -80,5 +79,3 @@ void sym_invert_( ); FF_NAMESPACE_END(FF_NS) - -#endif // FF_LIB_POSDEF diff --git a/include/fastfields/api/pushpull.h b/include/fastfields/api/pushpull.h index f71ebb2..19883b7 100644 --- a/include/fastfields/api/pushpull.h +++ b/include/fastfields/api/pushpull.h @@ -1,5 +1,4 @@ -#ifndef FF_LIB_PUSHPULL -#define FF_LIB_PUSHPULL +#pragma once #include #include #include @@ -228,5 +227,3 @@ void grad_backward( ); FF_NAMESPACE_END(FF_NS) - -#endif // FF_LIB_PUSHPULL diff --git a/include/fastfields/api/reg_field.h b/include/fastfields/api/reg_field.h index 3b43c1b..c8d39f8 100644 --- a/include/fastfields/api/reg_field.h +++ b/include/fastfields/api/reg_field.h @@ -1,5 +1,4 @@ -#ifndef FF_LIB_REG_FIELD -#define FF_LIB_REG_FIELD +#pragma once #include #include #include @@ -376,5 +375,3 @@ void field_relax_rls( ); FF_NAMESPACE_END(FF_NS) - -#endif // FF_LIB_REG_FIELD diff --git a/include/fastfields/api/reg_flow.h b/include/fastfields/api/reg_flow.h index 5b42602..7d185f3 100644 --- a/include/fastfields/api/reg_flow.h +++ b/include/fastfields/api/reg_flow.h @@ -1,5 +1,4 @@ -#ifndef FF_LIB_REG_FLOW -#define FF_LIB_REG_FLOW +#pragma once #include #include #include @@ -397,5 +396,3 @@ void flow_relax_rls( ); FF_NAMESPACE_END(FF_NS) - -#endif // FF_LIB_REG_FLOW diff --git a/include/fastfields/api/resize.h b/include/fastfields/api/resize.h index c8de089..fe75ccd 100644 --- a/include/fastfields/api/resize.h +++ b/include/fastfields/api/resize.h @@ -1,5 +1,4 @@ -#ifndef FF_LIB_RESIZE -#define FF_LIB_RESIZE +#pragma once #include #include #include @@ -68,5 +67,3 @@ void resample( ); FF_NAMESPACE_END(FF_NS) - -#endif // FF_LIB_RESIZE diff --git a/include/fastfields/api/restrict.h b/include/fastfields/api/restrict.h index 7461f71..19d731d 100644 --- a/include/fastfields/api/restrict.h +++ b/include/fastfields/api/restrict.h @@ -1,5 +1,4 @@ -#ifndef FF_LIB_RESTRICT -#define FF_LIB_RESTRICT +#pragma once #include #include #include @@ -67,5 +66,3 @@ void restriction( ); FF_NAMESPACE_END(FF_NS) - -#endif // FF_LIB_RESTRICT diff --git a/include/fastfields/api/solve_field.h b/include/fastfields/api/solve_field.h index 6bc8c21..8b7652c 100644 --- a/include/fastfields/api/solve_field.h +++ b/include/fastfields/api/solve_field.h @@ -1,5 +1,4 @@ -#ifndef FF_LIB_SOLVE_FIELD -#define FF_LIB_SOLVE_FIELD +#pragma once #include #include @@ -93,5 +92,3 @@ void field_cg( ); FF_NAMESPACE_END(FF_NS) - -#endif // FF_LIB_SOLVE_FIELD diff --git a/include/fastfields/api/splinc.h b/include/fastfields/api/splinc.h index 07f32fa..ba00472 100644 --- a/include/fastfields/api/splinc.h +++ b/include/fastfields/api/splinc.h @@ -1,5 +1,4 @@ -#ifndef FF_LIB_SPLINC -#define FF_LIB_SPLINC +#pragma once #include #include #include @@ -114,5 +113,3 @@ void spline_coeff( ); FF_NAMESPACE_END(FF_NS) - -#endif // FF_LIB_SPLINC diff --git a/include/fastfields/core/autocast.h b/include/fastfields/core/autocast.h index e730a66..6886480 100644 --- a/include/fastfields/core/autocast.h +++ b/include/fastfields/core/autocast.h @@ -1,6 +1,4 @@ #pragma once -#ifndef FF_AUTOCAST -#define FF_AUTOCAST #include #include #include @@ -199,5 +197,3 @@ inline void free_if_needed(OutPointer ptr) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_AUTOCAST diff --git a/include/fastfields/core/cuda_switch.h b/include/fastfields/core/cuda_switch.h index e302a00..23ea881 100755 --- a/include/fastfields/core/cuda_switch.h +++ b/include/fastfields/core/cuda_switch.h @@ -1,8 +1,4 @@ #pragma once -#ifndef FF_CUDA_SWITCH -#define FF_CUDA_SWITCH - - #ifndef __CUDACC__ // replace __device__ with empty symbol @@ -50,5 +46,3 @@ #endif #include - -#endif // FF_CUDA_SWITCH diff --git a/include/fastfields/core/defines.h b/include/fastfields/core/defines.h index 3bc5819..d567ce2 100644 --- a/include/fastfields/core/defines.h +++ b/include/fastfields/core/defines.h @@ -1,7 +1,4 @@ #pragma once -#ifndef FF_DEFINES -#define FF_DEFINES - // Merged from fastfields-kernels/defines.h and fastfields-lib/defines.h during // the six-repo consolidation. The first three macros were token-identical in // both; the namespace-device pair came from kernels and the FF_CPU/FF_CUDA pair @@ -34,5 +31,3 @@ #else # define FF_CUDA cuda #endif - -#endif // FF_DEFINES diff --git a/include/fastfields/core/dispatch.h b/include/fastfields/core/dispatch.h index 5862aed..1a0073b 100644 --- a/include/fastfields/core/dispatch.h +++ b/include/fastfields/core/dispatch.h @@ -1,7 +1,4 @@ #pragma once -#ifndef FF_CORE_DISPATCH -#define FF_CORE_DISPATCH - /** * The helpers shared by both dtype-dispatch layers (`src/lib-cpu` and * `src/lib-cuda`): unpack the public pointer ABI's arguments into what the @@ -228,5 +225,3 @@ inline std::vector as_weights(const double * w, int64_t nc) } FF_NAMESPACE_END(FF_NS) - -#endif // FF_CORE_DISPATCH diff --git a/include/fastfields/impl/cpu/distance_euclidean.h b/include/fastfields/impl/cpu/distance_euclidean.h index c55f9f2..e9cf7b5 100755 --- a/include/fastfields/impl/cpu/distance_euclidean.h +++ b/include/fastfields/impl/cpu/distance_euclidean.h @@ -1,5 +1,4 @@ -#ifndef FF_CPU_DISTANCE_EUCLIDEAN -#define FF_CPU_DISTANCE_EUCLIDEAN +#pragma once #include #include #include @@ -56,5 +55,3 @@ dt( FF_NAMESPACE_END(distance_e) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_CPU_DISTANCE_EUCLIDEAN diff --git a/include/fastfields/impl/cpu/distance_l1.h b/include/fastfields/impl/cpu/distance_l1.h index 3a5a5b2..ea8b0af 100755 --- a/include/fastfields/impl/cpu/distance_l1.h +++ b/include/fastfields/impl/cpu/distance_l1.h @@ -1,5 +1,4 @@ -#ifndef FF_CPU_DISTANCE_L1 -#define FF_CPU_DISTANCE_L1 +#pragma once #include #include #include @@ -35,5 +34,3 @@ dt( FF_NAMESPACE_END(distance_l1) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_CPU_DISTANCE_L1 diff --git a/include/fastfields/impl/cpu/distance_mesh.h b/include/fastfields/impl/cpu/distance_mesh.h index 7484800..53eaf89 100755 --- a/include/fastfields/impl/cpu/distance_mesh.h +++ b/include/fastfields/impl/cpu/distance_mesh.h @@ -1,5 +1,4 @@ -#ifndef FF_CPU_DISTANCE_MESH -#define FF_CPU_DISTANCE_MESH +#pragma once #include #include #include @@ -714,6 +713,3 @@ dt( FF_NAMESPACE_END(distance_mesh) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - - -#endif // FF_DISTANCE_MESH diff --git a/include/fastfields/impl/cpu/distance_spline.h b/include/fastfields/impl/cpu/distance_spline.h index a04e340..6d3799a 100755 --- a/include/fastfields/impl/cpu/distance_spline.h +++ b/include/fastfields/impl/cpu/distance_spline.h @@ -1,5 +1,4 @@ -#ifndef FF_CPU_DISTANCE_SPLINE -#define FF_CPU_DISTANCE_SPLINE +#pragma once #include #include #include @@ -182,5 +181,3 @@ mindist_gaussnewton( FF_NAMESPACE_END(distance_spline) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_CPU_DISTANCE_SPLINE diff --git a/include/fastfields/impl/cpu/posdef.h b/include/fastfields/impl/cpu/posdef.h index a467164..9a55849 100755 --- a/include/fastfields/impl/cpu/posdef.h +++ b/include/fastfields/impl/cpu/posdef.h @@ -1,5 +1,4 @@ -#ifndef FF_POSDEF_CPU -#define FF_POSDEF_CPU +#pragma once #include #include #include @@ -466,5 +465,3 @@ void sym_invert_( FF_NAMESPACE_END(posdef) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_POSDEF_CPU diff --git a/include/fastfields/impl/cpu/pushpull.h b/include/fastfields/impl/cpu/pushpull.h index 89bd380..fff4ccb 100755 --- a/include/fastfields/impl/cpu/pushpull.h +++ b/include/fastfields/impl/cpu/pushpull.h @@ -1,5 +1,4 @@ -#ifndef FF_PUSHPULL_CPU -#define FF_PUSHPULL_CPU +#pragma once #include #include #include @@ -772,5 +771,3 @@ void grad_backward( FF_NAMESPACE_END(pushpull) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_PUSHPULL_CPU diff --git a/include/fastfields/impl/cpu/reg_field.h b/include/fastfields/impl/cpu/reg_field.h index 5990f6e..9f838f0 100755 --- a/include/fastfields/impl/cpu/reg_field.h +++ b/include/fastfields/impl/cpu/reg_field.h @@ -1,5 +1,4 @@ -#ifndef FF_REGULARISERS_FIELD_CPU -#define FF_REGULARISERS_FIELD_CPU +#pragma once #include #include #include @@ -1837,5 +1836,3 @@ void relax_bending_jrls_( FF_NAMESPACE_END(reg_field) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_REGULARISERS_FIELD_CPU diff --git a/include/fastfields/impl/cpu/reg_flow.h b/include/fastfields/impl/cpu/reg_flow.h index f29ec0e..a1a71ce 100755 --- a/include/fastfields/impl/cpu/reg_flow.h +++ b/include/fastfields/impl/cpu/reg_flow.h @@ -1,5 +1,4 @@ -#ifndef FF_REGULARISERS_FLOW_CPU -#define FF_REGULARISERS_FLOW_CPU +#pragma once #include #include #include @@ -1495,6 +1494,3 @@ void relax_lame_jrls_( FF_NAMESPACE_END(reg_flow) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - - -#endif // FF_REGULARISERS_FLOW_CPU diff --git a/include/fastfields/impl/cpu/resize.h b/include/fastfields/impl/cpu/resize.h index 4973fc1..d90be66 100755 --- a/include/fastfields/impl/cpu/resize.h +++ b/include/fastfields/impl/cpu/resize.h @@ -1,5 +1,4 @@ -#ifndef FF_RESIZE_LOOP -#define FF_RESIZE_LOOP +#pragma once #include #include #include @@ -96,5 +95,3 @@ void loopnd( FF_NAMESPACE_END(resize) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_RESIZE_LOOP diff --git a/include/fastfields/impl/cpu/restrict.h b/include/fastfields/impl/cpu/restrict.h index a3e9798..9b5b848 100755 --- a/include/fastfields/impl/cpu/restrict.h +++ b/include/fastfields/impl/cpu/restrict.h @@ -1,5 +1,4 @@ -#ifndef FF_RESTRICT_LOOP -#define FF_RESTRICT_LOOP +#pragma once #include #include #include @@ -269,5 +268,3 @@ void loopnd( FF_NAMESPACE_END(restrict) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_RESTRICT_LOOP diff --git a/include/fastfields/impl/cpu/solve_field.h b/include/fastfields/impl/cpu/solve_field.h index 2b06aa0..7c156f8 100644 --- a/include/fastfields/impl/cpu/solve_field.h +++ b/include/fastfields/impl/cpu/solve_field.h @@ -1,5 +1,4 @@ -#ifndef FF_SOLVE_FIELD_CPU -#define FF_SOLVE_FIELD_CPU +#pragma once #include #include #include @@ -144,5 +143,3 @@ void axpby_( FF_NAMESPACE_END(solve_field) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_SOLVE_FIELD_CPU diff --git a/include/fastfields/impl/cpu/splinc.h b/include/fastfields/impl/cpu/splinc.h index 759d525..e9aa227 100755 --- a/include/fastfields/impl/cpu/splinc.h +++ b/include/fastfields/impl/cpu/splinc.h @@ -1,5 +1,4 @@ -#ifndef FF_SPLINC_LOOP -#define FF_SPLINC_LOOP +#pragma once #include #include #include @@ -41,5 +40,3 @@ void loop( FF_NAMESPACE_END(splinc) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_SPLINC_LOOP diff --git a/include/fastfields/impl/cpu/tetrahedron.h b/include/fastfields/impl/cpu/tetrahedron.h index 0454118..d5a7fdf 100755 --- a/include/fastfields/impl/cpu/tetrahedron.h +++ b/include/fastfields/impl/cpu/tetrahedron.h @@ -1,7 +1,4 @@ -#ifndef FF_TETRAHEDRON_LOOP -#define FF_TETRAHEDRON_LOOP - - +#pragma once namespace ff { namespace tetra { @@ -80,5 +77,3 @@ void pull( } // namespace tetra } // namespace ff - -#endif // FF_TETRAHEDRON_LOOP diff --git a/include/fastfields/impl/kernels/atomic.h b/include/fastfields/impl/kernels/atomic.h index 4f9df1e..e184806 100755 --- a/include/fastfields/impl/kernels/atomic.h +++ b/include/fastfields/impl/kernels/atomic.h @@ -1,10 +1,9 @@ +#pragma once /*********************************************************************** * CUDA portion copied from PyTorch/ATen * https://github.com/pytorch/pytorch/blob/master/LICENSE **********************************************************************/ -#ifndef FF_ATOMIC -#define FF_ATOMIC #include /*********************************************************************** @@ -362,5 +361,3 @@ static inline FF_CUDEV void anyAtomicAddNoReturn(T *address, T val) { } // namespace ff #endif // __CUDA__ - -#endif // FF_ATOMIC diff --git a/include/fastfields/impl/kernels/batch.h b/include/fastfields/impl/kernels/batch.h index 8cdceea..0f8523b 100755 --- a/include/fastfields/impl/kernels/batch.h +++ b/include/fastfields/impl/kernels/batch.h @@ -1,3 +1,4 @@ +#pragma once /* Utilities to convert contiguous linear indices to * - sub-indices, and/or * - strided linear indices @@ -19,8 +20,6 @@ * - a dynamically sized version, where `ndim` is a function argument * - a statically sized version, where `ndim` is a template parameter */ -#ifndef FF_BATCH -#define FF_BATCH #include #include "utils.h" @@ -269,5 +268,3 @@ void index2sub( } FF_NAMESPACE_END(FF_NS) - -#endif // FF_BATCH diff --git a/include/fastfields/impl/kernels/bounds.h b/include/fastfields/impl/kernels/bounds.h index 199f285..555685f 100755 --- a/include/fastfields/impl/kernels/bounds.h +++ b/include/fastfields/impl/kernels/bounds.h @@ -1,5 +1,4 @@ -#ifndef FF_BOUNDS -#define FF_BOUNDS +#pragma once #include #include "atomic.h" #include "utils.h" @@ -796,5 +795,3 @@ sign(type bound_type, offset_t coord, size_t size) { FF_NAMESPACE_END(bound) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_BOUNDS diff --git a/include/fastfields/impl/kernels/distance.h b/include/fastfields/impl/kernels/distance.h index 1ff4939..f40a817 100755 --- a/include/fastfields/impl/kernels/distance.h +++ b/include/fastfields/impl/kernels/distance.h @@ -1,4 +1,5 @@ +#pragma once #include "distance/euclidean.h" #include "distance/l1.h" #include "distance/spline.h" -#include "distance/mesh.h" \ No newline at end of file +#include "distance/mesh.h" diff --git a/include/fastfields/impl/kernels/distance/euclidean.h b/include/fastfields/impl/kernels/distance/euclidean.h index b5a6127..8a01135 100755 --- a/include/fastfields/impl/kernels/distance/euclidean.h +++ b/include/fastfields/impl/kernels/distance/euclidean.h @@ -1,3 +1,4 @@ +#pragma once // "Distance Transforms of Sampled Functions" // Pedro F. Felzenszwalb & Daniel P. Huttenlocher // Theory of Computing (2012) @@ -5,8 +6,6 @@ // // This algorithm works by upper-bounding the Euclidean distance with // the lower envelope of a series of parabolas. -#ifndef FF_DISTANCE_E -#define FF_DISTANCE_E #include #include "../utils.h" @@ -120,5 +119,3 @@ void kernel(scalar_t * f, offset_t * v, scalar_t * z, scalar_t * d, scalar_t w2, FF_NAMESPACE_END(distance_e) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_DISTANCE_E diff --git a/include/fastfields/impl/kernels/distance/l1.h b/include/fastfields/impl/kernels/distance/l1.h index f80459d..cfb9529 100755 --- a/include/fastfields/impl/kernels/distance/l1.h +++ b/include/fastfields/impl/kernels/distance/l1.h @@ -1,9 +1,8 @@ +#pragma once // "Distance Transforms of Sampled Functions" // Pedro F. Felzenszwalb & Daniel P. Huttenlocher // Theory of Computing (2012) // https://www.theoryofcomputing.org/articles/v008a019/v008a019.pdf -#ifndef FF_DISTANCE_L1 -#define FF_DISTANCE_L1 #include #include "../utils.h" @@ -45,4 +44,3 @@ void kernel(scalar_t * f, offset_t size, offset_t stride, scalar_t w) FF_NAMESPACE_END(distance_l1) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) -#endif // FF_DISTANCE_L1 diff --git a/include/fastfields/impl/kernels/distance/mesh.h b/include/fastfields/impl/kernels/distance/mesh.h index 0737766..5c771e2 100755 --- a/include/fastfields/impl/kernels/distance/mesh.h +++ b/include/fastfields/impl/kernels/distance/mesh.h @@ -1,9 +1,8 @@ +#pragma once /* * Adapted from * https://github.com/InteractiveComputerGraphics/TriangleMeshDistance */ -#ifndef FF_DISTANCE_MESH_H -#define FF_DISTANCE_MESH_H #include #include "../utils.h" #include "mesh_utils.h" @@ -1477,5 +1476,3 @@ struct MeshDist { FF_NAMESPACE_END(distance_mesh) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_DISTANCE_MESH_H diff --git a/include/fastfields/impl/kernels/distance/mesh_utils.h b/include/fastfields/impl/kernels/distance/mesh_utils.h index c67aaa3..c5735a6 100755 --- a/include/fastfields/impl/kernels/distance/mesh_utils.h +++ b/include/fastfields/impl/kernels/distance/mesh_utils.h @@ -1,5 +1,4 @@ -#ifndef FF_DISTANCE_MESH_UTILS_H -#define FF_DISTANCE_MESH_UTILS_H +#pragma once #include #include "../utils.h" @@ -1154,5 +1153,3 @@ struct ConstStridedPointArray { FF_NAMESPACE_END(distance_mesh) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_DISTANCE_MESH_UTILS_H diff --git a/include/fastfields/impl/kernels/distance/spline.h b/include/fastfields/impl/kernels/distance/spline.h index df9b174..31593a8 100755 --- a/include/fastfields/impl/kernels/distance/spline.h +++ b/include/fastfields/impl/kernels/distance/spline.h @@ -1,5 +1,4 @@ -#ifndef FF_DISTANCE_SPLINE_H -#define FF_DISTANCE_SPLINE_H +#pragma once #include #include "../spline.h" #include "../bounds.h" @@ -469,5 +468,3 @@ class Kernels { FF_NAMESPACE_END(distance_spline) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_DISTANCE_SPLINE_H diff --git a/include/fastfields/impl/kernels/meta.h b/include/fastfields/impl/kernels/meta.h index dcb2705..5ff8741 100644 --- a/include/fastfields/impl/kernels/meta.h +++ b/include/fastfields/impl/kernels/meta.h @@ -1,5 +1,4 @@ -#ifndef FF_META -#define FF_META +#pragma once #include FF_NAMESPACE_BEGIN(FF_NS) @@ -42,6 +41,3 @@ template using Int = Tuple; FF_NAMESPACE_END(meta) FF_NAMESPACE_END(FF_NS) - - -#endif // FF_META diff --git a/include/fastfields/impl/kernels/parallel.h b/include/fastfields/impl/kernels/parallel.h index e91a405..8bf6160 100755 --- a/include/fastfields/impl/kernels/parallel.h +++ b/include/fastfields/impl/kernels/parallel.h @@ -1,9 +1,8 @@ +#pragma once /* LICENSE: * Most of the functions are adapted from PyTorch/ATen's ParallelNative * https://github.com/pytorch/pytorch/blob/master/LICENSE */ -#ifndef FF_PARALLEL_H -#define FF_PARALLEL_H #include #include #include "parallel_impl.h" @@ -51,5 +50,3 @@ inline void parallel_for(int64_t begin, int64_t end, int64_t grain_size, const F } FF_NAMESPACE_END(FF_NS) - -#endif // FF_PARALLEL_H diff --git a/include/fastfields/impl/kernels/parallel_impl.h b/include/fastfields/impl/kernels/parallel_impl.h index 2fcdb78..7b1ef12 100755 --- a/include/fastfields/impl/kernels/parallel_impl.h +++ b/include/fastfields/impl/kernels/parallel_impl.h @@ -1,9 +1,8 @@ +#pragma once /* LICENSE: * Most of the functions are adapted from PyTorch/ATen's ParallelNative * https://github.com/pytorch/pytorch/blob/master/LICENSE */ -#ifndef FF_PARALLEL_IMPL_H -#define FF_PARALLEL_IMPL_H #include #include #include @@ -231,5 +230,3 @@ FF_NAMESPACE_BEGIN(internal) FF_NAMESPACE_END(internal) FF_NAMESPACE_END(FF_NS) - -#endif // FF_PARALLEL_IMPL_H diff --git a/include/fastfields/impl/kernels/posdef.h b/include/fastfields/impl/kernels/posdef.h index ece49aa..d11f9ae 100755 --- a/include/fastfields/impl/kernels/posdef.h +++ b/include/fastfields/impl/kernels/posdef.h @@ -1 +1,2 @@ +#pragma once #include "posdef/posdef.h" diff --git a/include/fastfields/impl/kernels/posdef/cholesky.h b/include/fastfields/impl/kernels/posdef/cholesky.h index f3a7eff..311cedb 100755 --- a/include/fastfields/impl/kernels/posdef/cholesky.h +++ b/include/fastfields/impl/kernels/posdef/cholesky.h @@ -1,5 +1,4 @@ -#ifndef FF_POSDEF_CHOLESKY -#define FF_POSDEF_CHOLESKY +#pragma once #include #include "../utils.h" #include "utils.h" @@ -138,5 +137,3 @@ struct cholesky { FF_NAMESPACE_END(posdef) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_POSDEF_CHOLESKY diff --git a/include/fastfields/impl/kernels/posdef/diag.inl b/include/fastfields/impl/kernels/posdef/diag.inl index 2be755a..797046e 100755 --- a/include/fastfields/impl/kernels/posdef/diag.inl +++ b/include/fastfields/impl/kernels/posdef/diag.inl @@ -1,7 +1,4 @@ -#ifndef FF_POSDEF_DIAG -#define FF_POSDEF_DIAG - - +#pragma once template struct utils: public common_diag { @@ -221,5 +218,3 @@ struct utils: public common_diag internal::div(o[c], 1., h[c]); } }; - -#endif // FF_POSDEF_DIAG diff --git a/include/fastfields/impl/kernels/posdef/estatics.inl b/include/fastfields/impl/kernels/posdef/estatics.inl index 36496ee..64c1ea4 100755 --- a/include/fastfields/impl/kernels/posdef/estatics.inl +++ b/include/fastfields/impl/kernels/posdef/estatics.inl @@ -1,6 +1,4 @@ -#ifndef FF_POSDEF_ESTATICS -#define FF_POSDEF_ESTATICS - +#pragma once template struct utils: public common_estatics { @@ -204,5 +202,3 @@ struct utils: public common_estatics } } }; - -#endif // FF_POSDEF_ESTATICS diff --git a/include/fastfields/impl/kernels/posdef/eye.inl b/include/fastfields/impl/kernels/posdef/eye.inl index 385932a..0710202 100755 --- a/include/fastfields/impl/kernels/posdef/eye.inl +++ b/include/fastfields/impl/kernels/posdef/eye.inl @@ -1,6 +1,4 @@ -#ifndef FF_POSDEF_EYE -#define FF_POSDEF_EYE - +#pragma once template struct utils: public common_eye { @@ -120,5 +118,3 @@ struct utils: public common_eye internal::div(*o, 1., *h); } }; - -#endif // FF_POSDEF_EYE diff --git a/include/fastfields/impl/kernels/posdef/full.inl b/include/fastfields/impl/kernels/posdef/full.inl index fd6f31a..f9df8dd 100755 --- a/include/fastfields/impl/kernels/posdef/full.inl +++ b/include/fastfields/impl/kernels/posdef/full.inl @@ -1,6 +1,4 @@ -#ifndef FF_POSDEF_FULL -#define FF_POSDEF_FULL - +#pragma once template struct utils: public common_sym { @@ -130,5 +128,3 @@ struct utils: public common_sym cholesky::solve_(C, b, v, static_cast(0)); // solve linear system inplace } }; - -#endif // FF_POSDEF_FULL diff --git a/include/fastfields/impl/kernels/posdef/posdef.h b/include/fastfields/impl/kernels/posdef/posdef.h index 62e0dfa..aebde8c 100755 --- a/include/fastfields/impl/kernels/posdef/posdef.h +++ b/include/fastfields/impl/kernels/posdef/posdef.h @@ -1,5 +1,4 @@ -#ifndef FF_POSDEF -#define FF_POSDEF +#pragma once #include #include "../utils.h" #include "utils.h" @@ -1009,5 +1008,3 @@ struct utils: public common_none FF_NAMESPACE_END(posdef) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_POSDEF diff --git a/include/fastfields/impl/kernels/posdef/sym.inl b/include/fastfields/impl/kernels/posdef/sym.inl index f59c02c..13e2c08 100755 --- a/include/fastfields/impl/kernels/posdef/sym.inl +++ b/include/fastfields/impl/kernels/posdef/sym.inl @@ -1,6 +1,4 @@ -#ifndef FF_POSDEF_SYM -#define FF_POSDEF_SYM - +#pragma once // --------------------------------------- // Generic implementation with static size // --------------------------------------- @@ -1089,5 +1087,3 @@ struct utils: public common_sym internal::set(o[0], i[0]); } }; - -#endif // FF_POSDEF_SYM diff --git a/include/fastfields/impl/kernels/posdef/utils.h b/include/fastfields/impl/kernels/posdef/utils.h index 0788372..f0a2a9a 100755 --- a/include/fastfields/impl/kernels/posdef/utils.h +++ b/include/fastfields/impl/kernels/posdef/utils.h @@ -1,5 +1,4 @@ -#ifndef FF_POSDEF_UTILS -#define FF_POSDEF_UTILS +#pragma once #include #include "../utils.h" @@ -445,5 +444,3 @@ FF_NAMESPACE_END(internal) FF_NAMESPACE_END(posdef) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_POSDEF_UTILS diff --git a/include/fastfields/impl/kernels/pushpull.h b/include/fastfields/impl/kernels/pushpull.h index 4f16a5a..9a50422 100755 --- a/include/fastfields/impl/kernels/pushpull.h +++ b/include/fastfields/impl/kernels/pushpull.h @@ -1,3 +1,4 @@ +#pragma once #include "pushpull/1d.h" #include "pushpull/2d.h" #include "pushpull/3d.h" diff --git a/include/fastfields/impl/kernels/pushpull/1d.h b/include/fastfields/impl/kernels/pushpull/1d.h index e4d7e6f..f81b677 100755 --- a/include/fastfields/impl/kernels/pushpull/1d.h +++ b/include/fastfields/impl/kernels/pushpull/1d.h @@ -1,10 +1,9 @@ +#pragma once /*********************************************************************** * * 1D * **********************************************************************/ -#ifndef FF_PUSHPULL_1D -#define FF_PUSHPULL_1D #include #include "../spline.h" #include "../bounds.h" @@ -1578,5 +1577,3 @@ struct Kernels, Bound, ABS>> { FF_NAMESPACE_END(pushpull) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_PUSHPULL_1D diff --git a/include/fastfields/impl/kernels/pushpull/2d.h b/include/fastfields/impl/kernels/pushpull/2d.h index a9e81a7..8310391 100755 --- a/include/fastfields/impl/kernels/pushpull/2d.h +++ b/include/fastfields/impl/kernels/pushpull/2d.h @@ -1,10 +1,9 @@ +#pragma once /*********************************************************************** * * 2D * **********************************************************************/ -#ifndef FF_PUSHPULL_2D -#define FF_PUSHPULL_2D #include #include "../spline.h" #include "../bounds.h" @@ -1252,5 +1251,3 @@ struct Kernels, Bound, ABS>> { FF_NAMESPACE_END(pushpull) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_PUSHPULL_2D diff --git a/include/fastfields/impl/kernels/pushpull/3d.h b/include/fastfields/impl/kernels/pushpull/3d.h index 9b01dfe..9c2624c 100755 --- a/include/fastfields/impl/kernels/pushpull/3d.h +++ b/include/fastfields/impl/kernels/pushpull/3d.h @@ -1,10 +1,9 @@ +#pragma once /*********************************************************************** * * 3D * **********************************************************************/ -#ifndef FF_PUSHPULL_3D -#define FF_PUSHPULL_3D #include #include "../spline.h" #include "../bounds.h" @@ -1848,5 +1847,3 @@ struct Kernels, Bound, ABS>> { FF_NAMESPACE_END(pushpull) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_PUSHPULL_3D diff --git a/include/fastfields/impl/kernels/pushpull/nd.h b/include/fastfields/impl/kernels/pushpull/nd.h index 03df18a..12c2d27 100755 --- a/include/fastfields/impl/kernels/pushpull/nd.h +++ b/include/fastfields/impl/kernels/pushpull/nd.h @@ -1,10 +1,9 @@ +#pragma once /*********************************************************************** * * ND * **********************************************************************/ -#ifndef FF_PUSHPULL_ND -#define FF_PUSHPULL_ND #include #include "../spline.h" #include "../bounds.h" @@ -485,5 +484,3 @@ struct Kernels,Bound<>,ABS>> { FF_NAMESPACE_END(pushpull) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif FF_PUSHPULL_ND diff --git a/include/fastfields/impl/kernels/pushpull/utils.h b/include/fastfields/impl/kernels/pushpull/utils.h index 6d3e67c..94b62a5 100755 --- a/include/fastfields/impl/kernels/pushpull/utils.h +++ b/include/fastfields/impl/kernels/pushpull/utils.h @@ -1,5 +1,4 @@ -#ifndef FF_PUSHPULL_UTILS -#define FF_PUSHPULL_UTILS +#pragma once #include #include "../spline.h" #include "../bounds.h" @@ -1026,5 +1025,3 @@ struct PushPullUtils { FF_NAMESPACE_END(pushpull) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_PUSHPULL_UTILS diff --git a/include/fastfields/impl/kernels/regularisers.h b/include/fastfields/impl/kernels/regularisers.h index 29562ff..9cf2450 100755 --- a/include/fastfields/impl/kernels/regularisers.h +++ b/include/fastfields/impl/kernels/regularisers.h @@ -1,2 +1,3 @@ +#pragma once #include "regularisers/flow.h" #include "regularisers/field.h" diff --git a/include/fastfields/impl/kernels/regularisers/field.h b/include/fastfields/impl/kernels/regularisers/field.h index 6185513..b2a3a42 100755 --- a/include/fastfields/impl/kernels/regularisers/field.h +++ b/include/fastfields/impl/kernels/regularisers/field.h @@ -1,3 +1,4 @@ +#pragma once #include "field/1d.h" #include "field/2d.h" #include "field/3d.h" diff --git a/include/fastfields/impl/kernels/regularisers/field/1d.h b/include/fastfields/impl/kernels/regularisers/field/1d.h index 625e419..2992037 100755 --- a/include/fastfields/impl/kernels/regularisers/field/1d.h +++ b/include/fastfields/impl/kernels/regularisers/field/1d.h @@ -1,5 +1,4 @@ -#ifndef FF_REGULARISERS_FIELD_1D -#define FF_REGULARISERS_FIELD_1D +#pragma once #include #include "../../bounds.h" #include "../../utils.h" @@ -1129,5 +1128,3 @@ struct Kernels> FF_NAMESPACE_END(reg_field) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_REGULARISERS_FIELD_1D diff --git a/include/fastfields/impl/kernels/regularisers/field/2d.h b/include/fastfields/impl/kernels/regularisers/field/2d.h index 1f307ea..060e0b9 100755 --- a/include/fastfields/impl/kernels/regularisers/field/2d.h +++ b/include/fastfields/impl/kernels/regularisers/field/2d.h @@ -1,5 +1,4 @@ -#ifndef FF_REGULARISERS_FIELD_2D -#define FF_REGULARISERS_FIELD_2D +#pragma once #include #include "../../bounds.h" #include "../../utils.h" @@ -1425,6 +1424,3 @@ struct Kernels> FF_NAMESPACE_END(reg_field) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - - -#endif // FF_REGULARISERS_FIELD_2D diff --git a/include/fastfields/impl/kernels/regularisers/field/3d.h b/include/fastfields/impl/kernels/regularisers/field/3d.h index 083a44d..05bf443 100755 --- a/include/fastfields/impl/kernels/regularisers/field/3d.h +++ b/include/fastfields/impl/kernels/regularisers/field/3d.h @@ -1,5 +1,4 @@ -#ifndef FF_REGULARISERS_FIELD_3D -#define FF_REGULARISERS_FIELD_3D +#pragma once #include #include "../../bounds.h" #include "../../utils.h" @@ -1753,5 +1752,3 @@ struct Kernels> FF_NAMESPACE_END(reg_field) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_REGULARISERS_FIELD_3D diff --git a/include/fastfields/impl/kernels/regularisers/field/utils.h b/include/fastfields/impl/kernels/regularisers/field/utils.h index 14e7c2a..f129ec3 100755 --- a/include/fastfields/impl/kernels/regularisers/field/utils.h +++ b/include/fastfields/impl/kernels/regularisers/field/utils.h @@ -1,5 +1,4 @@ -#ifndef FF_REGULARISERS_UTILS -#define FF_REGULARISERS_UTILS +#pragma once #include #include "../../bounds.h" #include "../../utils.h" @@ -156,5 +155,3 @@ bool patch3(const offset_t loc[N], offset_t n) FF_NAMESPACE_END(reg_field) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_REGULARISERS_UTILS diff --git a/include/fastfields/impl/kernels/regularisers/flow.h b/include/fastfields/impl/kernels/regularisers/flow.h index d38918c..e8d0c85 100755 --- a/include/fastfields/impl/kernels/regularisers/flow.h +++ b/include/fastfields/impl/kernels/regularisers/flow.h @@ -1,3 +1,4 @@ +#pragma once #include "flow/1d.h" #include "flow/2d.h" #include "flow/3d.h" diff --git a/include/fastfields/impl/kernels/regularisers/flow/1d.h b/include/fastfields/impl/kernels/regularisers/flow/1d.h index 388b988..bf7db4d 100755 --- a/include/fastfields/impl/kernels/regularisers/flow/1d.h +++ b/include/fastfields/impl/kernels/regularisers/flow/1d.h @@ -1,5 +1,4 @@ -#ifndef FF_REGULARISERS_FLOW_1D -#define FF_REGULARISERS_FLOW_1D +#pragma once #include #include "../../bounds.h" #include "../../utils.h" @@ -847,5 +846,3 @@ struct RegFlow { FF_NAMESPACE_END(reg_flow) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_REGULARISERS_FLOW_1D diff --git a/include/fastfields/impl/kernels/regularisers/flow/2d.h b/include/fastfields/impl/kernels/regularisers/flow/2d.h index 1af7a05..f83e886 100755 --- a/include/fastfields/impl/kernels/regularisers/flow/2d.h +++ b/include/fastfields/impl/kernels/regularisers/flow/2d.h @@ -1,5 +1,4 @@ -#ifndef FF_REGULARISERS_FLOW_2D -#define FF_REGULARISERS_FLOW_2D +#pragma once #include #include "../../bounds.h" #include "../../utils.h" @@ -1647,5 +1646,3 @@ struct RegFlow { FF_NAMESPACE_END(reg_flow) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_REGULARISERS_FLOW_2D diff --git a/include/fastfields/impl/kernels/regularisers/flow/3d.h b/include/fastfields/impl/kernels/regularisers/flow/3d.h index 9fc6159..350d52c 100755 --- a/include/fastfields/impl/kernels/regularisers/flow/3d.h +++ b/include/fastfields/impl/kernels/regularisers/flow/3d.h @@ -1,5 +1,4 @@ -#ifndef FF_REGULARISERS_FLOW_3D -#define FF_REGULARISERS_FLOW_3D +#pragma once #include #include "../../bounds.h" #include "../../utils.h" @@ -2100,5 +2099,3 @@ struct RegFlow { FF_NAMESPACE_END(reg_flow) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_REGULARISERS_FLOW_3D diff --git a/include/fastfields/impl/kernels/regularisers/flow/utils.h b/include/fastfields/impl/kernels/regularisers/flow/utils.h index 394b858..d6fdcaa 100755 --- a/include/fastfields/impl/kernels/regularisers/flow/utils.h +++ b/include/fastfields/impl/kernels/regularisers/flow/utils.h @@ -1,5 +1,4 @@ -#ifndef FF_REGULARISERS_FLOW_UTILS -#define FF_REGULARISERS_FLOW_UTILS +#pragma once #include #include "../../bounds.h" #include "../../utils.h" @@ -126,5 +125,3 @@ bool patch3(const offset_t loc[N], offset_t n) FF_NAMESPACE_END(reg_flow) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_REGULARISERS_FLOW_UTILS diff --git a/include/fastfields/impl/kernels/resize.h b/include/fastfields/impl/kernels/resize.h index 6162df7..6369dc7 100755 --- a/include/fastfields/impl/kernels/resize.h +++ b/include/fastfields/impl/kernels/resize.h @@ -1,5 +1,4 @@ -#ifndef FF_RESIZE -#define FF_RESIZE +#pragma once #include #include "spline.h" #include "bounds.h" @@ -973,5 +972,3 @@ struct Multiscale { FF_NAMESPACE_END(resize) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_RESIZE diff --git a/include/fastfields/impl/kernels/restrict.h b/include/fastfields/impl/kernels/restrict.h index 10d6c49..b743c12 100755 --- a/include/fastfields/impl/kernels/restrict.h +++ b/include/fastfields/impl/kernels/restrict.h @@ -1,5 +1,4 @@ -#ifndef FF_RESTRICT -#define FF_RESTRICT +#pragma once #include #include "spline.h" #include "bounds.h" @@ -452,5 +451,3 @@ struct Multiscale { FF_NAMESPACE_END(restrict) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_RESTRICT diff --git a/include/fastfields/impl/kernels/splinc.h b/include/fastfields/impl/kernels/splinc.h index b65e901..e9c9990 100755 --- a/include/fastfields/impl/kernels/splinc.h +++ b/include/fastfields/impl/kernels/splinc.h @@ -1,3 +1,4 @@ +#pragma once // Compute spline interpolating coefficients // // These functions are ported from the C routines in SPM's bsplines.c @@ -24,8 +25,6 @@ // "Splines: A Perfect Fit for Signal and Image Processing," // IEEE Signal Processing Magazine 16(6):22-38 (1999). -#ifndef FF_SPLINC -#define FF_SPLINC #include #include "spline.h" #include "bounds.h" @@ -335,5 +334,3 @@ inline FF_CUDEV void filter(scalar_t * inp, offset_t size, offset_t stride, FF_NAMESPACE_END(splinc) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_SPLINC diff --git a/include/fastfields/impl/kernels/spline.h b/include/fastfields/impl/kernels/spline.h index 89d7364..6bb0241 100755 --- a/include/fastfields/impl/kernels/spline.h +++ b/include/fastfields/impl/kernels/spline.h @@ -1,3 +1,4 @@ +#pragma once // This file contains static functions for handling (0-7 order) // spline weights. // It also defines an enumerated types that encodes each boundary type. @@ -23,8 +24,6 @@ // TODO? other types of basis functions (gauss, sinc) -#ifndef FF_SPLINE -#define FF_SPLINE #include #include "meta.h" @@ -1443,5 +1442,3 @@ template <> struct dyn FF_NAMESPACE_END(spline) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_SPLINE diff --git a/include/fastfields/impl/kernels/tetrahedron.h b/include/fastfields/impl/kernels/tetrahedron.h index ffd8f12..38375f2 100755 --- a/include/fastfields/impl/kernels/tetrahedron.h +++ b/include/fastfields/impl/kernels/tetrahedron.h @@ -1,5 +1,4 @@ -#ifndef FF_TETRAHEDRON -#define FF_TETRAHEDRON +#pragma once #include #include "utils.h" @@ -238,6 +237,3 @@ void pull1(scalar_t * output, FF_NAMESPACE_END(tetra) FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - - -#endif // FF_TETRAHEDRON diff --git a/include/fastfields/impl/kernels/threadpool.h b/include/fastfields/impl/kernels/threadpool.h index 4948eeb..833b168 100755 --- a/include/fastfields/impl/kernels/threadpool.h +++ b/include/fastfields/impl/kernels/threadpool.h @@ -1,9 +1,8 @@ +#pragma once // Copyright (c) Yasser Asmi // Released under the MIT License (http://opensource.org/licenses/MIT) // https://github.com/YasserAsmi/wstpool -#ifndef FF_THREADPOOL_H -#define FF_THREADPOOL_H #include #include @@ -256,5 +255,3 @@ class ThreadPool FF_NAMESPACE_END(FF_NS) #include "threadpool.inl" - -#endif // FF_THREADPOOL_H diff --git a/include/fastfields/impl/kernels/threadpool.inl b/include/fastfields/impl/kernels/threadpool.inl index 3f3bc4a..8fbf945 100755 --- a/include/fastfields/impl/kernels/threadpool.inl +++ b/include/fastfields/impl/kernels/threadpool.inl @@ -1,5 +1,4 @@ -#ifndef FF_THREADPOOL_INL -#define FF_THREADPOOL_INL +#pragma once #include #include #include @@ -75,4 +74,3 @@ inline std::shared_ptr get_global_pool() { } FF_NAMESPACE_END(FF_NS) -#endif // FF_THREADPOOL_INL diff --git a/include/fastfields/impl/kernels/utils.h b/include/fastfields/impl/kernels/utils.h index ab0cf7c..37394ce 100755 --- a/include/fastfields/impl/kernels/utils.h +++ b/include/fastfields/impl/kernels/utils.h @@ -1,5 +1,4 @@ -#ifndef FF_UTILS -#define FF_UTILS +#pragma once #include #include @@ -697,5 +696,3 @@ FF_CUHOST inline bool canUse32BitIndexMath( FF_NAMESPACE_END(FF_DEVICE) FF_NAMESPACE_END(FF_NS) - -#endif // FF_UTILS diff --git a/include/fastfields/impl/kernels/vector/abstract_ptr.h b/include/fastfields/impl/kernels/vector/abstract_ptr.h index 0fcf3a9..a4c9ce9 100755 --- a/include/fastfields/impl/kernels/vector/abstract_ptr.h +++ b/include/fastfields/impl/kernels/vector/abstract_ptr.h @@ -1,5 +1,4 @@ -#ifndef FF_VECTOR_ABSTRACTPTR_H -#define FF_VECTOR_ABSTRACTPTR_H +#pragma once #include #include "forward.h" #include "traits.h" @@ -438,5 +437,3 @@ using AbstractDynamicPointer = AbstractPointer; } // namespace ff - -#endif // FF_VECTOR_ABSTRACTPTR_H diff --git a/include/fastfields/impl/kernels/vector/abstract_sized.h b/include/fastfields/impl/kernels/vector/abstract_sized.h index e59d08b..2a88cf5 100755 --- a/include/fastfields/impl/kernels/vector/abstract_sized.h +++ b/include/fastfields/impl/kernels/vector/abstract_sized.h @@ -1,5 +1,4 @@ -#ifndef FF_VECTOR_ABSTRACTSIZED_H -#define FF_VECTOR_ABSTRACTSIZED_H +#pragma once #include #include "forward.h" #include "abstract_ptr.h" @@ -257,5 +256,3 @@ using AbstractDynamicSizedPointer = AbstractSizedPointer; } // namespace ff - -#endif // FF_VECTOR_ABSTRACTSIZED_H diff --git a/include/fastfields/impl/kernels/vector/abstract_vector.h b/include/fastfields/impl/kernels/vector/abstract_vector.h index 9e386b4..69b4c72 100755 --- a/include/fastfields/impl/kernels/vector/abstract_vector.h +++ b/include/fastfields/impl/kernels/vector/abstract_vector.h @@ -1,5 +1,4 @@ -#ifndef FF_VECTOR_ABTRACTVECTOR_H -#define FF_VECTOR_ABTRACTVECTOR_H +#pragma once #include "forward.h" #include "traits.h" #include "weak_sized.h" @@ -700,7 +699,3 @@ struct std::tuple_element< I, ff::AbstractVector > { using type = T; }; - - - -#endif // FF_VECTOR_ABTRACTVECTOR_H diff --git a/include/fastfields/impl/kernels/vector/concrete_vector.h b/include/fastfields/impl/kernels/vector/concrete_vector.h index e20824c..0fc8dc7 100755 --- a/include/fastfields/impl/kernels/vector/concrete_vector.h +++ b/include/fastfields/impl/kernels/vector/concrete_vector.h @@ -1,5 +1,4 @@ -#ifndef FF_VECTOR_CONCRETEVECTOR_H -#define FF_VECTOR_CONCRETEVECTOR_H +#pragma once #include #include "forward.h" #include "traits.h" @@ -224,5 +223,3 @@ struct std::tuple_element< I, ff::Vector > { using type = T; }; - -#endif // FF_VECTOR_CONCRETEVECTOR_H diff --git a/include/fastfields/impl/kernels/vector/forward.h b/include/fastfields/impl/kernels/vector/forward.h index 84e5cb4..497883a 100755 --- a/include/fastfields/impl/kernels/vector/forward.h +++ b/include/fastfields/impl/kernels/vector/forward.h @@ -1,5 +1,4 @@ -#ifndef FF_VECTOR_FORWARD_H -#define FF_VECTOR_FORWARD_H +#pragma once #include namespace ff { @@ -29,5 +28,3 @@ template class Vector; } - -#endif // FF_VECTOR_FORWARD_H diff --git a/include/fastfields/impl/kernels/vector/stream.h b/include/fastfields/impl/kernels/vector/stream.h index 5fb185e..f825d10 100755 --- a/include/fastfields/impl/kernels/vector/stream.h +++ b/include/fastfields/impl/kernels/vector/stream.h @@ -1,5 +1,4 @@ -#ifndef FF_VECTOR_STREAM_H -#define FF_VECTOR_STREAM_H +#pragma once #include #include "abstract_ptr.h" #include "abstract_sized.h" @@ -134,5 +133,3 @@ std::ostream& operator <<( { return Vector_print(stream, ptr); } - -#endif // FF_VECTOR_STREAM_H diff --git a/include/fastfields/impl/kernels/vector/traits.h b/include/fastfields/impl/kernels/vector/traits.h index a75d96c..f24f098 100755 --- a/include/fastfields/impl/kernels/vector/traits.h +++ b/include/fastfields/impl/kernels/vector/traits.h @@ -1,6 +1,4 @@ -#ifndef FF_VECTOR_TRAITS_H -#define FF_VECTOR_TRAITS_H - +#pragma once namespace ff { namespace internal { @@ -62,5 +60,3 @@ struct guess_iterator { } // internal } // jf - -#endif // FF_VECTOR_TRAITS_H diff --git a/include/fastfields/impl/kernels/vector/vector.h b/include/fastfields/impl/kernels/vector/vector.h index 211c449..db1591d 100755 --- a/include/fastfields/impl/kernels/vector/vector.h +++ b/include/fastfields/impl/kernels/vector/vector.h @@ -1,6 +1,4 @@ -#ifndef FF_VECTOR_VECTOR_H -#define FF_VECTOR_VECTOR_H - +#pragma once #include "weak_ref.h" #include "weak_sized.h" #include "weak_vector.h" @@ -134,5 +132,3 @@ class Vector: AbstractVector begin(), cbegin(), rbegin(), crbegin(), end(), cend(), rend(), crend() }; */ - -#endif // FF_VECTOR_VECTOR_H diff --git a/include/fastfields/impl/kernels/vector/weak_ref.h b/include/fastfields/impl/kernels/vector/weak_ref.h index 3e2eac4..28d04b6 100755 --- a/include/fastfields/impl/kernels/vector/weak_ref.h +++ b/include/fastfields/impl/kernels/vector/weak_ref.h @@ -1,5 +1,4 @@ -#ifndef FF_VECTOR_WEAKREF_H -#define FF_VECTOR_WEAKREF_H +#pragma once #include "forward.h" #include "traits.h" #include "abstract_ptr.h" @@ -92,5 +91,3 @@ WeakRef weak_ref(const AbstractPointer & ptr) } // namespace ff - -#endif // FF_VECTOR_WEAKREF_H diff --git a/include/fastfields/impl/kernels/vector/weak_sized.h b/include/fastfields/impl/kernels/vector/weak_sized.h index 226c87d..ed3df92 100755 --- a/include/fastfields/impl/kernels/vector/weak_sized.h +++ b/include/fastfields/impl/kernels/vector/weak_sized.h @@ -1,5 +1,4 @@ -#ifndef FF_VECTOR_WEAKSIZEDREF_H -#define FF_VECTOR_WEAKSIZEDREF_H +#pragma once #include "forward.h" #include "abstract_sized.h" #include @@ -135,5 +134,3 @@ WeakSizedRef weak_ref(const AbstractSizedPointer & ptr) } // namespace ff - -#endif // FF_VECTOR_WEAKSIZEDREF_H diff --git a/include/fastfields/impl/kernels/vector/weak_vector.h b/include/fastfields/impl/kernels/vector/weak_vector.h index c8d754b..a55a23a 100755 --- a/include/fastfields/impl/kernels/vector/weak_vector.h +++ b/include/fastfields/impl/kernels/vector/weak_vector.h @@ -1,5 +1,4 @@ -#ifndef FF_VECTOR_WEAKVECTOR_H -#define FF_VECTOR_WEAKVECTOR_H +#pragma once #include "forward.h" #include "traits.h" #include "abstract_vector.h" @@ -138,5 +137,3 @@ struct std::tuple_element< I, ff::WeakVector > { using type = T; }; - -#endif // FF_VECTOR_WEAKVECTOR_H