Skip to content
dmalhotraPublic

About

Scientific Computing Template Library

Resources

Stars

32 stars

Watchers

5 watching

Forks

Repository files navigation

SCTL: Scientific Computing Template Library

tests codecov Stable Version Latest Release DOI

SCTL is a header-only C++ library providing various functionalities for scientific computing. This documentation outlines these functionalities and provides a guide to getting started.

Requirements

The only requirement to use SCTL is a working C++17 compliant compiler with OpenMP 4.0 support. It has been tested with GCC-9 and newer.

GCC 14 and newer on AArch64 (ARM, including Apple silicon): compile with -mearly-ra=none. GCC's early register allocator for vector registers can assign one register to two values in use at the same time, which gave wrong results in Vec at -O3 with GCC 14. GCC 15 and 16 have the same bug, hidden in the cases found so far. GCC 11 to 13 reject the flag.

Getting Started

To get started, download the latest version of SCTL from the SCTL GitHub.

git clone https://github.com/dmalhotra/SCTL.git

Since SCTL is a header-only library, it does not require compilation or installation. Simply include the sctl.hpp header file in your C++ project and start using the provided classes and functions.

#include <sctl.hpp>

Ensure the compiler can locate the header file by providing the path to SCTL_ROOT/include using the flag -I ${SCTL_ROOT}/include.

The included Makefile builds the tests (make test). On Apple silicon with Homebrew: CPATH=/opt/homebrew/include LIBRARY_PATH=/opt/homebrew/lib make CXX=g++-15.

Optional Dependencies

The following libraries can be optionally used when available. If not available, SCTL uses its own implementation which may be slower.

  • BLAS: Enable by defining SCTL_HAVE_BLAS.
  • LAPACK: Enable by defining SCTL_HAVE_LAPACK.
  • libmvec: Enable by defining SCTL_HAVE_LIBMVEC.
  • Intel SVML: Enable by defining SCTL_HAVE_SVML.
  • MPI: Enable by defining SCTL_HAVE_MPI (see Comm).
  • FFTW: Enable double precision by defining SCTL_HAVE_FFTW, single precision by defining SCTL_HAVE_FFTWF, or long double precision by defining SCTL_HAVE_FFTWL (see FFT).
  • PVFMM: Enable by defining SCTL_HAVE_PVFMM (requires MPI, see ParticleFMM).
  • LIBXSMM: Enable by defining SCTL_HAVE_LIBXSMM, for small matrix products (see SmallGEMM).

To enable support for any of these libraries, define the corresponding flag during compilation. For example, to enable MPI support, use -DSCTL_HAVE_MPI.

Optional Compiler Flags

The following compiler flags can be used to enable or disable specific features in SCTL:

  • -DSCTL_MEMDEBUG: Enable memory debugging (iterator.hpp, static-array.hpp).
  • -DSCTL_GLOBAL_MEM_BUFF=<size in MB>: Use a global memory buffer for allocations.
  • -DSCTL_PROFILE=<level>: Enable profiling.
  • -DSCTL_VERBOSE: Enable verbose profiling output.
  • -DSCTL_SIG_HANDLER: Enable stack trace. On Linux with glibc < 2.34, link with -ldl (newer glibc has it merged into libc).
  • -DSCTL_QUAD_T=<type>: Enable support for quad-precision type, e.g. __float128 on x86 and with GCC on Apple silicon.
  • -DSCTL_BLAS_INT=<type>: Integer type of the BLAS and LAPACK interface, int (LP64) or int64_t (ILP64). By default it is detected from the linked BLAS on the first call; on big-endian systems it is int unless set.

Features and Capabilities

The following list outlines the primary features and capabilities provided by the library, along with references to detailed tutorials and documentation for each component:

  • Basic Data Structures: Fundamental classes for storing and manipulating data.

    • Vector: Dynamically allocated linear array.
    • Matrix, Permutation: Dynamically allocated 2D array for matrix operations.
    • Tensor: Statically allocated multi-dimensional array.
  • Numerical Solvers and Algorithms: Methods for solving equations, performing interpolations, numerical integration, and partitioning data.

  • Spectral Methods: Methods for spectral representations and transformations.

    • FFT: Wrapper for FFTW to perform fast Fourier transforms.
    • SphericalHarmonics: Computing spherical harmonics.
  • Boundary Integral Methods: Techniques for solving partial differential equations using boundary integral representations.

    • BoundaryIntegralOp: Generic class for instantiating layer-potential operators.
    • Kernel functions: Contains a variety of kernel functions for integral equations.
    • ParticleFMM: Integration with PVFMM for particle N-body calculations.
  • High Performance Computing (HPC): Tools for parallel and distributed computing.

    • Comm: Wrapper for MPI to facilitate parallel computing.
    • Vec: SIMD vectorization class for optimized computations.
    • OpenMP utilities: Parallel algorithms such as merge-sort and scan using OpenMP.
    • Profile: Tools for profiling and performance analysis.
  • Utilities: Miscellaneous utilities for data handling, debugging, and visualization.

  • Experimental: Components whose interfaces may still change.

    • GPUTree, PtTree: The Tree/PtTree interface on a thrust backend, OpenMP host or CUDA device, with CUDA-aware MPI (make gpu).
  • Legacy (Unmaintained): Older functionalities that are no longer actively maintained.

    • ChebBasis: Tensor product Chebyshev basis for general-dimension computations.

Citing SCTL

If you use SCTL, or code derived from it, please cite the software below (also listed in CITATION.cff):

BibTeX
@software{sctl,
  author    = {Malhotra, Dhairya and Li, Tianyue and Blackwell, Robert and Rahimian, Abtin and Yan, Wen and Gao, Xuanzhao},
  title     = {{SCTL}: Scientific Computing Template Library},
  url       = {https://github.com/dmalhotra/SCTL},
  doi       = {10.5281/zenodo.23511629},
  version   = {2.1.0},
  year      = {2026}
}

License

SCTL is licensed under the Apache License 2.0. The NOTICE file lists the authors and must be kept in any redistribution, including ports to other languages. It also has the authors' requests on crediting them and on AI use.

About

Scientific Computing Template Library

Resources

Stars

32 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages