Tidy unused #ifdefs, unbuilt sources and a few dead headers

Open
#287 2 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 3 days

@skilledwolf is already working on this.

Since Nov 2, 2026.

Assessment

This issue has not been assessed yet.

Description

area:build-sdk enhancement

A full configure (apps, all tests, legacy API, MPI, OpenMP) shows several macros, files and headers that no build uses. The first four sections remove nothing that is compiled today, except the five fitter sources noted below. The last two are judgement calls.

Every claim here was re-checked against master: each macro's definitions were grepped across sources, CMake, config.h.in and the Python build; the scheduler-using translation units were preprocessed to read ALPS_WRITE_ALL_XML; the two tests were rebuilt with their guards removed; and the dead headers were compiled on their own with the build's flags.

Macros that nothing defines

  • ALPS_WITHOUT_XML (13 files in lattice, model, legacy parameters and alps/xml.h) and ALPS_WITHOUT_OSIRIS (5 ALEA files). These are build modes without XML or osiris, which ALPS no longer supports. Keep the code under #ifndef and drop the guards.
  • ALPS_ONE_CHECKPOINT_FILE_ONLY in scheduler/montecarlo.C and task.C. This is an unfinished one-file checkpoint layout: the RNG state save is still a //TODO.
  • USE_MPI in apps/dmft/qmc/green_function.h. It guards an <mpi.h> include and a broadcast() member that nothing calls.
  • ALPS_HAVE_SHARED_ALLOCATOR in gf/.../tensors/tensor_base.hpp. It would alias a shared_storage type that doesn't exist.
  • ALPS_HDF5_1_8 in accumulators/tests/save_load2.cpp. It hides the long double cases with the note "fail with HDF5 1.10+", but they pass with HDF5 1.10.10 and 1.14.6 (96 tests). Drop the guards and keep the cases; it is the file's last #ifdef.
  • HAVE_PARAPACK_13 in looper (loop.C, path_integral.C, sse.C, looper/evaluator.h).
  • ALPS_MPI_HAS_MPI_CXX_BOOL, ALPS_MPI_HAS_MPI_CXX_FLOAT_COMPLEX and ALPS_MPI_HAS_MPI_CXX_DOUBLE_COMPLEX in utilities/mpi.hpp and utilities/tests/mpi_utils_reduce.cpp. Keep the #ifndef side (the hand-written bool overloads).
  • USE_LATTICE_CONSTANT_2D in graph/is_embeddable.hpp. It includes alps/graph/lattice_constant_2d.hpp, which doesn't exist.
  • Vendor BLAS switches: VECLIB, ACML and MKL in numeric/matrix/vector.hpp, ACML in dmft/qmc/interaction_expansion/operator.hpp and interaction_expansion2/operator.hpp, and UBLAS and USE_MATRIX_DISPATCH (with its #undef __APPLE_CC__) in the deprecated numeric headers. Keep the plain-loop side.
  • FOURPOINT in dmft/qmc/hirschfyesim.C.

Macros that are always defined

For these, keep the #ifdef side and drop the #else side.

  • ALPS_ONLY_HDF5 in scheduler/task.h, types.h and montecarlo.C. config.h.in defines it unconditionally. Note that task.h tests it before anything includes config.h, so in ten translation units (scheduler/{abstract_task,factory,task,workertask}.C, fulldiag/{factory,fulldiag}.C, sparsediag/{factory,sparsediag}.C, dmrg/{dmrg,factory}.C) the ALPS_WRITE_ALL_XML default is currently true instead of false. Nothing there uses the default; the two callers that do (dmft/qmc/hirschfyesim.C and interaction_expansion/measurements.cpp) already see false. So making it an unconditional false changes no behaviour.
  • ALPS_HAVE_HDF5: 21 guards in the scheduler sources and apps/dmrg/dmrg/dmrg.h. Three have an #else (options.C, master_scheduler.C).
  • HAVE_LAPACK in apps/maxent/src/eigen_lapack.hpp and maxent_params.cpp, defined by target_compile_definitions in apps/maxent/CMakeLists.txt and apps/maxent/tests/CMakeLists.txt. Drop both definitions with the guards.
  • BOOST_HAS_LONG_LONG: 20 guards in osiris and parser/xmlstream.h. Every C++17 compiler has long long.

Workarounds for compilers and libraries below the minimum

The build requires C++17 and Boost 1.76. None of these conditions can hold, so keep the modern side.

  • BOOST_NO_EXCEPTIONS (79 sites, mostly try/catch around app mains). ALPS can't build with exceptions off.
  • BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP (21 sites, all using declarations).
  • BOOST_NO_SFINAE (expression/evaluate_helper.h, expression.h, model/half_integer.h, looper power.h).
  • BOOST_NO_OPERATORS_IN_NAMESPACE (parapack integer_range.h).
  • BOOST_NO_STRINGSTREAM (utilities/vectorio.hpp).
  • BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS (params/dict_value.hpp).
  • __GXX_EXPERIMENTAL_CXX0X__ in ietl/jd.h. On a non-GCC compiler it selects the pre-C++11 eigensystem signature without the defaulted solver.
  • GCC 3.x checks: legacy utility/bitops.hpp (3) and containers/tests/test_main.h.
  • The Apple GCC 4.2 OpenMP workaround in parapack/parapack.C.
  • The Boost 1.58 + C++14 workaround in params/src/dict_value.cpp.
  • The Intel-on-macOS guard in accumulators/tests/mean_err_count.cpp. It is inverted: the EXPECT_ANY_THROW checks run only on the platform where they were said to fail. They pass on GCC (276 tests), so make them unconditional.
  • Old Fujitsu compiler (__FCC_VERSION) in alea/simplebinning.h and lattice/latticelibrary.C. On that compiler make_all_graphs() throws "not implemented".
  • PGI (__PGI) in gf/flagcheck.hpp. It only silences two #warnings.
  • cray in legacy utility/bitops.hpp.

Sources that no build compiles

  • parapack/tests/clone_mpi.C and worker_mpi.C, with their .ip-4/.op-4 files. They include parapack headers that no longer exist. The registered *_mpi tests cover parapack's MPI code.
  • graph/tests/embedding_test.cpp and its .output, and alea/tests/binned_data.C. They test removed headers (graph/embedding.hpp, alea/binned_data.h).
  • containers/tests/timing_{stack,queue,vector}.C. These are micro-benchmarks with no assertions, and they use boost::timer.
  • tutorials/examples/scheduler/evaluate.C and evaluate2.C. The CMakeLists there builds only ising1-ising3. They are also the only users of ALPS_HAVE_VALARRAY.
  • apps/mc/spins/fit.C. No build has ever compiled it. The fitter sources it uses (abstract_fitter.C, base_incr_fitter.C, dummy_fitter.C, est_grad_fitter.C, fitting_scheduler.C/.h, fitter.h) are compiled, into spinmc_impl in apps/mc/spins/CMakeLists.txt, but nothing in spinmc or spinmc_evaluate references a fitter. Remove them from that library with fit.C.
  • osiris/src/osiris/xdrcore.C. This is an older copy of the XDR code, now built from third_party/xdr/src. It is also the only user of ALPS_HAVE_RPC_XDR_H, USE_IN_LIBIO and vax.
  • apps/mc/simple/vtk.h. It is empty apart from its include guard.
  • tests/cmake/preserved_public_headers.json. Nothing reads it since the installed-header check replaced it.

Switches that nothing defines (judgement call)

Removing these keeps today's behaviour:

  • ALPS_NGS_SINGLE_THREAD (commented out in ngs/config.hpp, ngs/mutex.hpp, thread_exceptions.hpp, hdf5/archive.*, cli/mcoptions.cpp, cli_contract.cpp). This is a build without mutexes and without --threaded. Best done after the Boost.Thread removal.
  • ALPS_HDF5_CLOSE_GREEDY and ALPS_HDF5_READ_GREEDY in hdf5/src/archive.cpp, with their commented-out lines in ngs/config.hpp.
  • ALPS_NO_DELETE in alea/src/alea/observableset.C.
  • USEPATTERN in src/tools/archive/. It guards a --pattern-file mode of the archive tool; drop that option with it.
  • ALPS_DEBUG in osiris/src/osiris/mpdump.C. These are three "message not initialized" checks, and they could become plain asserts instead (absent in Release builds, as today).

Installed headers that don't compile (judgement call)

Nothing in the repo includes these, and they fail on their own. Removing them is a small public-API change, so it belongs in the release notes. Each is listed in its component's header set in CMakeLists.txt, which must be edited with it.

  • ietl/interface/mtl.h. Its body is #error The MTL-2 interface is not yet implemented.
  • ietl/interface/blitz.h. It needs Blitz++, which the build doesn't support.
  • ietl/krylov_wrapper.h. It needs the old ITL (itl/krylov/cg.h).
  • alps/numeric/matrix/matrix_concept_archetype.hpp. It includes boost/concept_archetypes.hpp, which doesn't exist.
  • alps/ngs/scheduler/tcpserver.hpp and alps/ngs/detail/tcpsession.hpp. An unused prototype; it lacks the <map> and <boost/function.hpp> includes it needs.
  • alps/graph/lattice_constant_debug.hpp. It uses a detail::has_coloring that no longer exists. It is also the only user of USE_COMPRESSED_EMBEDDING{,2} and CHECK_COMPRESSED_EMBEDDING.
  • alps/random/mersenne_twister.hpp. It compiles, but nothing includes it: everything uses boost/random/mersenne_twister.hpp directly. Its #else branch is a bundled copy of Boost's header for the Boost 1.47 bug, and the only user of BOOST_NO_INT64_T, BOOST_NO_INTEGRAL_INT64_T and BOOST_NO_INCLASS_MEMBER_INITIALIZATION. Delete the file and its line in random/CMakeLists.txt.

Sequencing

hdf5/src/archive.cpp, parapack/parapack.C and the scheduler sources are also changed by #281, #282, #284 and #288. The BOOST_NO_EXCEPTIONS, ALPS_HAVE_HDF5 and ALPS_ONLY_HDF5 edits in particular overlap with #282, so do this cleanup after those merge.

Not included here: apps/qmc/sse, sse2 and apps/diag/fulldiagfqhe (to be decided separately), and app-specific debug switches in dmtk, looper, worms and sse4.

Related: #213

Dominant language
C++
Stars
32
Forks
10
Avg merge
4d 6h
Merged PRs (30d)
51

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ALPSim/ALPS

All issues in ALPSim/ALPS

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.