Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ option(INTEGRATORXX_HEADER_ONLY "Force header-only build" OFF)
if(INTEGRATORXX_HEADER_ONLY)
add_library( integratorxx INTERFACE )
set(INTEGRATORXX_TARGET_TYPE INTERFACE)
target_compile_definitions( integratorxx INTERFACE INTEGRATORXX_HEADER_ONLY )
else()
add_subdirectory(src)
set(INTEGRATORXX_TARGET_TYPE PUBLIC)
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,16 @@ avoid excessive build times in complex projects with aggressive compiler
optimization. **N.B. it is highly recommend that users maintain this default
behavior to avoid excessive compilation sizes and build times**.

IntegratorXX also allows for header-only use of the runtime generator by
setting `INTEGRATORXX_HEADER_ONLY=ON`.
This feature also allows for circumvention of
the CMake build system by simply including the requisite implementation
header.

To use the runtime generator header-only, one needs to include
`<integratorxx/generators/impl/impl.hpp>` **exactly once** per project,
otherwise duplicate / incompatible symbols will occur.
IntegratorXX also allows for header-only use of the runtime generator by
setting `INTEGRATORXX_HEADER_ONLY=ON`, which defines the
`INTEGRATORXX_HEADER_ONLY` macro on the interface target. The public
generator headers then carry their own implementations, so no additional
include is required.

To circumvent the CMake build system entirely, define
`INTEGRATORXX_HEADER_ONLY` yourself and include the generator headers as
usual. The implementations have inline linkage in this mode and may be
included from any number of translation units.

## Contributing and Bug Reports

Expand Down
2 changes: 2 additions & 0 deletions include/integratorxx/generators/impl/impl.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#include <integratorxx/generators/impl/unpruned_grid.hpp>
#include <integratorxx/generators/impl/pruned_grid.hpp>
#include <integratorxx/generators/impl/radial_factory.hpp>
Expand Down
18 changes: 18 additions & 0 deletions include/integratorxx/generators/impl/linkage.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

/**
* @brief Linkage of the runtime grid generator.
*
* By default the runtime generator is compiled once into libintegratorxx
* and consumers see only the declarations in generators/*.hpp. This keeps
* the large angular grid dispatch out of every translation unit.
*
* When INTEGRATORXX_HEADER_ONLY is defined the same definitions are emitted
* inline in each translation unit that uses them, and the public generator
* headers pull in their own implementations.
*/
#ifdef INTEGRATORXX_HEADER_ONLY
#define INTEGRATORXX_GENERATOR_LINKAGE inline
#else
#define INTEGRATORXX_GENERATOR_LINKAGE
#endif
5 changes: 3 additions & 2 deletions include/integratorxx/generators/impl/pruned_grid.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <integratorxx/generators/impl/linkage.hpp>
#include <integratorxx/generators/spherical_factory.hpp>

#include <integratorxx/generators/impl/radial_types.hpp>
Expand Down Expand Up @@ -58,7 +59,7 @@ auto make_pruned_grid(const RadialQuadType& rq,

} // Implementation Details

SphericalGridFactory::spherical_grid_ptr
INTEGRATORXX_GENERATOR_LINKAGE SphericalGridFactory::spherical_grid_ptr
SphericalGridFactory::generate_pruned_grid( RadialQuad rq,
const RadialTraits& traits,
const std::vector<PruningRegion>& pruning_regions) {
Expand All @@ -83,7 +84,7 @@ SphericalGridFactory::spherical_grid_ptr
}


PrunedSphericalGridSpecification create_pruned_spec(
INTEGRATORXX_GENERATOR_LINKAGE PrunedSphericalGridSpecification create_pruned_spec(
PruningScheme scheme, UnprunedSphericalGridSpecification unp
) {

Expand Down
5 changes: 3 additions & 2 deletions include/integratorxx/generators/impl/radial_factory.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <integratorxx/generators/impl/linkage.hpp>
#include <integratorxx/generators/radial_factory.hpp>

#include <integratorxx/generators/impl/radial_types.hpp>
Expand All @@ -7,7 +8,7 @@

namespace IntegratorXX {

RadialQuad radial_from_string(std::string name) {
INTEGRATORXX_GENERATOR_LINKAGE RadialQuad radial_from_string(std::string name) {
std::transform(name.begin(), name.end(), name.begin(),
[](unsigned char c){ return static_cast<char>(std::toupper(c)); });
if(name == "BECKE") return RadialQuad::Becke;
Expand All @@ -21,7 +22,7 @@ RadialQuad radial_from_string(std::string name) {
throw std::runtime_error("Unrecognized Radial Quadrature");
}

RadialFactory::radial_grid_ptr RadialFactory::generate(RadialQuad rq, const RadialTraits& traits) {
INTEGRATORXX_GENERATOR_LINKAGE RadialFactory::radial_grid_ptr RadialFactory::generate(RadialQuad rq, const RadialTraits& traits) {

switch(rq) {
case RadialQuad::Becke:
Expand Down
5 changes: 3 additions & 2 deletions include/integratorxx/generators/impl/robust_pruning.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <integratorxx/generators/impl/linkage.hpp>
#include <integratorxx/generators/spherical_factory.hpp>

#include <integratorxx/generators/impl/s2_types.hpp>
Expand All @@ -24,7 +25,7 @@ auto get_robust_low_med_sizes(AngularSize asz) {
}


PrunedSphericalGridSpecification robust_psi4_pruning_scheme_impl(
INTEGRATORXX_GENERATOR_LINKAGE PrunedSphericalGridSpecification robust_psi4_pruning_scheme_impl(
size_t low_sz, size_t med_sz, AngularQuad angular_quad,
UnprunedSphericalGridSpecification unp ) {

Expand All @@ -46,7 +47,7 @@ PrunedSphericalGridSpecification robust_psi4_pruning_scheme_impl(
} // Implementation Details


PrunedSphericalGridSpecification robust_psi4_pruning_scheme(
INTEGRATORXX_GENERATOR_LINKAGE PrunedSphericalGridSpecification robust_psi4_pruning_scheme(
UnprunedSphericalGridSpecification unp ) {

size_t low_sz, med_sz;
Expand Down
5 changes: 3 additions & 2 deletions include/integratorxx/generators/impl/s2_factory.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <integratorxx/generators/impl/linkage.hpp>
#include <integratorxx/generators/s2_factory.hpp>

#include <integratorxx/generators/impl/s2_types.hpp>
Expand All @@ -7,7 +8,7 @@

namespace IntegratorXX {

AngularQuad angular_from_string(std::string name) {
INTEGRATORXX_GENERATOR_LINKAGE AngularQuad angular_from_string(std::string name) {
std::transform(name.begin(), name.end(), name.begin(),
[](unsigned char c){ return static_cast<char>(std::toupper(c)); });
if(name == "AHRENSBEYLKIN") return AngularQuad::AhrensBeylkin;
Expand All @@ -21,7 +22,7 @@ AngularQuad angular_from_string(std::string name) {
throw std::runtime_error("Unrecognized Angular Quadrature");
}

S2Factory::s2_grid_ptr S2Factory::generate(AngularQuad aq, size_t npts) {
INTEGRATORXX_GENERATOR_LINKAGE S2Factory::s2_grid_ptr S2Factory::generate(AngularQuad aq, size_t npts) {

switch(aq) {
case AngularQuad::AhrensBeylkin:
Expand Down
5 changes: 3 additions & 2 deletions include/integratorxx/generators/impl/treutler_pruning.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <integratorxx/generators/impl/linkage.hpp>
#include <integratorxx/generators/spherical_factory.hpp>

#include <integratorxx/generators/impl/s2_types.hpp>
Expand All @@ -16,7 +17,7 @@ auto get_treutler_low_med_sizes() {
return std::make_pair(low_sz, med_sz);
}

PrunedSphericalGridSpecification treutler_pruning_scheme_impl(
INTEGRATORXX_GENERATOR_LINKAGE PrunedSphericalGridSpecification treutler_pruning_scheme_impl(
size_t low_sz, size_t med_sz, AngularQuad angular_quad,
UnprunedSphericalGridSpecification unp ) {

Expand All @@ -39,7 +40,7 @@ PrunedSphericalGridSpecification treutler_pruning_scheme_impl(



PrunedSphericalGridSpecification treutler_pruning_scheme(
INTEGRATORXX_GENERATOR_LINKAGE PrunedSphericalGridSpecification treutler_pruning_scheme(
UnprunedSphericalGridSpecification unp ) {

size_t low_sz, med_sz;
Expand Down
3 changes: 2 additions & 1 deletion include/integratorxx/generators/impl/unpruned_grid.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <integratorxx/generators/impl/linkage.hpp>
#include <integratorxx/generators/spherical_factory.hpp>

#include <integratorxx/generators/impl/radial_types.hpp>
Expand Down Expand Up @@ -37,7 +38,7 @@ auto generate_unpruned_grid_impl(RadialQuad rq, const RadialTraits& traits,

} // Implementation details

SphericalGridFactory::spherical_grid_ptr
INTEGRATORXX_GENERATOR_LINKAGE SphericalGridFactory::spherical_grid_ptr
SphericalGridFactory::generate_unpruned_grid( RadialQuad rq,
const RadialTraits& traits, AngularQuad aq, AngularSize nang) {

Expand Down
7 changes: 7 additions & 0 deletions include/integratorxx/generators/radial_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,10 @@ struct RadialFactory {
};

}

// Header-only builds carry the implementation with the declarations. This is
// included last so that the declarations above are already visible; the impl
// headers include this one back, which #pragma once makes a no-op.
#ifdef INTEGRATORXX_HEADER_ONLY
#include <integratorxx/generators/impl/radial_factory.hpp>
#endif
7 changes: 7 additions & 0 deletions include/integratorxx/generators/s2_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ struct S2Factory {
};

}

// Header-only builds carry the implementation with the declarations. This is
// included last so that the declarations above are already visible; the impl
// headers include this one back, which #pragma once makes a no-op.
#ifdef INTEGRATORXX_HEADER_ONLY
#include <integratorxx/generators/impl/s2_factory.hpp>
#endif
8 changes: 8 additions & 0 deletions include/integratorxx/generators/spherical_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,11 @@ struct SphericalGridFactory {
};

}

// Header-only builds carry the implementation with the declarations. This is
// included last so that the declarations above are already visible; the impl
// headers include this one back, which #pragma once makes a no-op.
#ifdef INTEGRATORXX_HEADER_ONLY
#include <integratorxx/generators/impl/unpruned_grid.hpp>
#include <integratorxx/generators/impl/pruned_grid.hpp>
#endif
3 changes: 0 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ else()
endif()

add_library(integratorxx_common_ut quad_matcher.cxx)
if(INTEGRATORXX_HEADER_ONLY)
target_sources(integratorxx_common_ut PRIVATE lib_impl.cxx)
endif()
target_link_libraries( integratorxx_common_ut PUBLIC Catch2::Catch2WithMain integratorxx )

add_executable( quadrature_manipulation quadrature_manipulation.cxx )
Expand Down
2 changes: 0 additions & 2 deletions test/lib_impl.cxx

This file was deleted.

Loading