Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ImpactX_UNITY_BUILD #861

Merged
merged 3 commits into from
Feb 24, 2025
Merged
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 .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DImpactX_FFT=ON \
-DImpactX_PYTHON=ON \
-DImpactX_UNITY_BUILD=ON \
-DMPIEXEC_POSTFLAGS="--use-hwthread-cpus"
cmake --build build -j 4

Expand Down
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ option(ImpactX_PYTHON_IPO
${_ImpactX_PYTHON_IPO_DEFAULT}
)

# Unity builds combine all .cpp files into a single one (a single translation
# unit, TU).
option(ImpactX_UNITY_BUILD "ImpactX library as unity build" OFF)

if(ImpactX_FFT)
set(ABLASTR_FFT ON CACHE STRING "FFT-based solvers" FORCE)
endif()
Expand Down Expand Up @@ -165,6 +169,16 @@ set_target_properties(lib PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS ON
)

# Optional: build only a single TU
if(ImpactX_UNITY_BUILD)
set_target_properties(lib PROPERTIES
UNITY_BUILD ON
UNITY_BUILD_MODE BATCH
# Number must be more than the number of .cpp files in ImpactX
UNITY_BUILD_BATCH_SIZE 10000
)
endif()

# executable application
# note: we currently avoid a dependency on a core library
# for simpler usage, but could make this an option
Expand Down
3 changes: 3 additions & 0 deletions cmake/ImpactXFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,9 @@ function(impactx_print_summary)
else()
set(LIB_TYPE "static")
endif()
if(ImpactX_UNITY_BUILD)
set(LIB_TYPE "${LIB_TYPE} (unity build)")
endif()
#message(" Testing: ${BUILD_TESTING}")
message(" Build options:")
message(" APP: ${ImpactX_APP}")
Expand Down
1 change: 1 addition & 0 deletions docs/source/install/cmake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ CMake Option Default & Values Des
============================= ============================================== ===========================================================
``BUILD_SHARED_LIBS`` ON/**OFF** Build shared libraries for dependencies
``ImpactX_CCACHE`` **ON**/OFF Search and use CCache to speed up rebuilds.
``ImpactX_UNITY_BUILD`` ON/**OFF** ImpactX library as unity build (single TU)
``ImpactX_ablastr_src`` *None* Path to ABLASTR source directory (preferred if set)
``ImpactX_ablastr_repo`` ``https://github.com/ECP-WarpX/WarpX.git`` Repository URI to pull and build ABLASTR from
``ImpactX_ablastr_branch`` *we set and maintain a compatible commit* Repository branch for ``ImpactX_ablastr_repo``
Expand Down
3 changes: 2 additions & 1 deletion src/initialization/InitElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@ namespace detail
pp_element.queryAddWithParser("cn", cn);
}

m_lattice.emplace_back(diagnostics::BeamMonitor(openpmd_name, openpmd_backend, openpmd_encoding, period_sample_intervals));
using impactx::elements::diagnostics::BeamMonitor;
m_lattice.emplace_back(BeamMonitor(openpmd_name, openpmd_backend, openpmd_encoding, period_sample_intervals));
} else if (element_type == "source")
{
std::string distribution, openpmd_path;
Expand Down
Loading