Skip to content

Commit

Permalink
add Ubuntu 22.04 image with updated dependencies and C++20 (#83)
Browse files Browse the repository at this point in the history
* add Ubuntu 22.04 image with updated dependencies and C++20

* remove patch file that's not needed

* fix patch directive

---------

Co-authored-by: Paul Gessinger-Befurt <[email protected]>
  • Loading branch information
paulgessinger and Paul Gessinger-Befurt authored Mar 28, 2023
1 parent 9746e87 commit 1c1bd3d
Show file tree
Hide file tree
Showing 3 changed files with 327 additions and 0 deletions.
183 changes: 183 additions & 0 deletions ubuntu2204_cpp20/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
FROM ubuntu:22.04

LABEL description="Ubuntu 22.04 with Acts dependencies"
LABEL maintainer="Paul Gessinger <[email protected]>"
# increase whenever any of the RUN commands change
LABEL version="1"

# DEBIAN_FRONTEND ensures non-blocking operation (tzdata is a problem)
ENV DEBIAN_FRONTEND noninteractive

# install dependencies from the package manager.
#
# see also https://root.cern.ch/build-prerequisites
RUN apt-get update -y \
&& apt-get install -y \
build-essential \
cmake \
curl \
git \
freeglut3-dev \
libboost-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-test-dev \
libeigen3-dev \
libexpat-dev \
libftgl-dev \
libgl2ps-dev \
libglew-dev \
libgsl-dev \
liblz4-dev \
liblzma-dev \
libpcre3-dev \
libtbb-dev \
libx11-dev \
libxext-dev \
libxft-dev \
libxpm-dev \
libxerces-c-dev \
libxxhash-dev \
libzstd-dev \
ninja-build \
python3 \
python3-dev \
python3-pip \
rsync \
zlib1g-dev \
ccache \
&& apt-get clean -y

# manual builds for hep-specific packages
ENV GET curl --location --silent --create-dirs
ENV UNPACK_TO_SRC tar -xz --strip-components=1 --directory src
ENV PREFIX /usr/local

# Geant4
RUN mkdir src \
&& ${GET} https://gitlab.cern.ch/geant4/geant4/-/archive/v11.1.1/geant4-v11.1.1.tar.gz \
| ${UNPACK_TO_SRC} \
&& cmake -B build -S src -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DCMAKE_CXX_STANDARD=20 \
-DGEANT4_BUILD_TLS_MODEL=global-dynamic \
-DGEANT4_INSTALL_DATA=OFF \
-DGEANT4_USE_GDML=ON \
-DGEANT4_USE_SYSTEM_EXPAT=ON \
-DGEANT4_USE_SYSTEM_ZLIB=ON \
&& cmake --build build -- install \
&& rm -rf build src

# HepMC3
RUN mkdir src \
&& ${GET} https://hepmc.web.cern.ch/hepmc/releases/HepMC3-3.2.5.tar.gz \
| ${UNPACK_TO_SRC} \
&& cmake -B build -S src -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DHEPMC3_BUILD_STATIC_LIBS=OFF \
-DHEPMC3_ENABLE_PYTHON=OFF \
-DHEPMC3_ENABLE_ROOTIO=OFF \
-DHEPMC3_ENABLE_SEARCH=OFF \
&& cmake --build build -- install \
&& rm -rf build src

# Pythia8
# requires rsync; installation uses `rsync` instead of `install`
ADD pythia8307_cpp20.patch .
RUN mkdir src \
&& ${GET} https://pythia.org/download/pythia83/pythia8309.tgz\
| ${UNPACK_TO_SRC} \
&& cd src \
&& git apply ../pythia8307_cpp20.patch \
&& ./configure --enable-shared --prefix=${PREFIX} \
&& make -j$(nproc) install \
&& cd .. \
&& rm -rf src

# nlohmann's JSON
RUN mkdir src \
&& ${GET} https://github.com/nlohmann/json/archive/refs/tags/v3.11.2.tar.gz \
| ${UNPACK_TO_SRC} \
&& cmake -B build -S src -GNinja -DJSON_BuildTests=OFF \
&& cmake --build build -- install \
&& rm -rf build src

# ROOT
RUN mkdir src \
&& ${GET} https://root.cern/download/root_v6.28.02.source.tar.gz \
| ${UNPACK_TO_SRC} \
&& cmake -B build -S src -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=20 \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-Dfail-on-missing=ON \
-Dgminimal=ON \
-Dgdml=ON \
-Dopengl=ON \
-Dpyroot=ON \
-Ddataframe=ON \
&& cmake --build build -- install \
&& rm -rf build src

# environment variables needed to find ROOT libraries
ENV LD_LIBRARY_PATH /usr/local/lib
ENV PYTHON_PATH /usr/local/lib

ADD podio_cpp20.patch .
# podio
RUN mkdir src \
&& ${GET} https://github.com/AIDASoft/podio/archive/refs/tags/v00-16-03.tar.gz \
| ${UNPACK_TO_SRC} \
&& cd src && git apply ../podio_cpp20.patch && cd .. \
&& cmake -B build -S src -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DBUILD_TESTING=OFF \
-USE_EXTERNAL_CATCH2=OFF \
&& cmake --build build -- install \
&& rm -rf build src

# EDM4hep
RUN pip3 install jinja2 pyyaml \
&& mkdir src \
&& ${GET} https://github.com/key4hep/EDM4hep/archive/refs/tags/v00-07-02.tar.gz \
| ${UNPACK_TO_SRC} \
&& cmake -B build -S src -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DBUILD_TESTING=OFF \
-DUSE_EXTERNAL_CATCH2=OFF \
&& cmake --build build -- install \
&& rm -rf build src

# DD4hep
# requires Geant4 and ROOT and must come last
RUN mkdir src \
&& ${GET} https://github.com/AIDASoft/DD4hep/archive/v01-25-01.tar.gz \
| ${UNPACK_TO_SRC} \
&& cmake -B build -S src -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=20 \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DCMAKE_PREFIX_PATH=${PREFIX} \
-DBUILD_TESTING=OFF \
-DDD4HEP_BUILD_PACKAGES="DDG4 DDDetectors DDRec UtilityApps" \
-DDD4HEP_USE_GEANT4=ON \
-DDD4HEP_USE_XERCESC=ON \
-DDD4HEP_USE_EDM4HEP=ON \
&& cmake --build build -- install \
&& rm -rf build src

# Onnx (download of tar.gz does not work out of the box, since the build.sh script requires a git repository)
RUN git clone https://github.com/microsoft/onnxruntime src \
&& (cd src && git checkout v1.13.1) \
&& ./src/build.sh \
--config MinSizeRel \
--build_shared_lib \
--build_dir build \
--parallel $(nproc) \
--skip_tests \
&& cmake --build build/MinSizeRel -- install \
&& rm -rf build src
15 changes: 15 additions & 0 deletions ubuntu2204_cpp20/podio_cpp20.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e8a943b..c4f3a96 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,8 +77,8 @@ find_package(ROOT REQUIRED COMPONENTS RIO Tree)

# Check that root is compiled with a modern enough c++ standard
get_target_property(ROOT_COMPILE_FEATURES ROOT::Core INTERFACE_COMPILE_FEATURES)
-if (NOT "cxx_std_17" IN_LIST ROOT_COMPILE_FEATURES)
- message(FATAL_ERROR "You are trying to build podio against a version of ROOT that has not been built with a sufficient c++ standard. podio requires c++17")
+if (NOT "cxx_std_17" IN_LIST ROOT_COMPILE_FEATURES AND NOT "cxx_std_20" IN_LIST ROOT_COMPILE_FEATURES)
+ message(FATAL_ERROR "You are trying to build podio against a version of ROOT that has not been built with a sufficient c++ standard. podio requires c++17 or higher")
endif()
#Check if Python version detected matches the version used to build ROOT
SET(Python_FIND_FRAMEWORK LAST)
129 changes: 129 additions & 0 deletions ubuntu2204_cpp20/pythia8307_cpp20.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
From 09ef584f1ca797d84c1c0af18ec06b33d6c0d2d0 Mon Sep 17 00:00:00 2001
From: Paul Gessinger <[email protected]>
Date: Thu, 24 Mar 2022 16:08:26 +0100
Subject: [PATCH] fixes for C++20 build

---
include/Pythia8/SusyLesHouches.h | 6 +++---
src/HadronWidths.cc | 8 ++++----
src/NucleonExcitations.cc | 8 ++++----
src/PythiaParallel.cc | 2 +-
4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/include/Pythia8/SusyLesHouches.h b/include/Pythia8/SusyLesHouches.h
index 2f1d9fd..5090c00 100644
--- a/include/Pythia8/SusyLesHouches.h
+++ b/include/Pythia8/SusyLesHouches.h
@@ -28,7 +28,7 @@ namespace Pythia8 {
public:

//Constructor.
- LHblock<T>() : idnow(0), qDRbar(), i(), val() {} ;
+ LHblock() : idnow(0), qDRbar(), i(), val() {} ;

//Does block exist?
bool exists() { return int(entry.size()) == 0 ? false : true ; };
@@ -129,7 +129,7 @@ namespace Pythia8 {
template <int size> class LHmatrixBlock {
public:
//Constructor. Set uninitialized and explicitly zero.
- LHmatrixBlock<size>() : entry(), qDRbar(), val() {
+ LHmatrixBlock() : entry(), qDRbar(), val() {
initialized=false;
for (i=1;i<=size;i++) {
for (j=1;j<=size;j++) {
@@ -208,7 +208,7 @@ namespace Pythia8 {
template <int size> class LHtensor3Block {
public:
//Constructor. Set uninitialized and explicitly zero.
- LHtensor3Block<size>() : entry(), qDRbar(), val() {
+ LHtensor3Block() : entry(), qDRbar(), val() {
initialized=false;
for (i=1;i<=size;i++) {
for (j=1;j<=size;j++) {
diff --git a/src/HadronWidths.cc b/src/HadronWidths.cc
index ccc5c72..95a5cb1 100644
--- a/src/HadronWidths.cc
+++ b/src/HadronWidths.cc
@@ -867,7 +867,7 @@ double HadronWidths::psSize(double eCM, ParticleDataEntryPtr prodA,
return 0.;

// Integrate mass of A.
- auto f = [=](double mA) {
+ auto f = [=,this](double mA) {
return pow(pCMS(eCM, mA, m0B), lType) * mDistr(idA, mA); };
if (!integrateGauss(result, f, mMinA, min(mMaxA, eCM - m0B)))
success = false;
@@ -879,7 +879,7 @@ double HadronWidths::psSize(double eCM, ParticleDataEntryPtr prodA,
return 0.;

// Integrate mass of B.
- auto f = [=](double mB) {
+ auto f = [=,this](double mB) {
return pow(pCMS(eCM, m0A, mB), lType) * mDistr(idB, mB); };
if (!integrateGauss(result, f, mMinB, min(mMaxB, eCM - m0A)))
success = false;
@@ -891,10 +891,10 @@ double HadronWidths::psSize(double eCM, ParticleDataEntryPtr prodA,
return 0.;

// Define integrand of outer integral.
- auto I = [=, &success](double mA) {
+ auto I = [=, &success, this](double mA) {

// Define integrand of inner integral.
- auto f = [=](double mB) {
+ auto f = [=,this](double mB) {
return pow(pCMS(eCM, mA, mB), lType)
* mDistr(idA, mA) * mDistr(idB, mB); };
double res;
diff --git a/src/NucleonExcitations.cc b/src/NucleonExcitations.cc
index b5eef8f..a82383a 100644
--- a/src/NucleonExcitations.cc
+++ b/src/NucleonExcitations.cc
@@ -502,7 +502,7 @@ double NucleonExcitations::psSize(double eCM, ParticleDataEntry& prodA,
return 0.;

// Integrate mass of A.
- auto f = [=](double mA) {
+ auto f = [=, this](double mA) {
return pCMS(eCM, mA, m0B) * hadronWidthsPtr->mDistr(idA, mA); };
if (!integrateGauss(result, f, mMinA, min(mMaxA, eCM - m0B)))
success = false;
@@ -514,7 +514,7 @@ double NucleonExcitations::psSize(double eCM, ParticleDataEntry& prodA,
return 0.;

// Integrate mass of B.
- auto f = [=](double mB) {
+ auto f = [=,this](double mB) {
return pCMS(eCM, m0A, mB) * hadronWidthsPtr->mDistr(idB, mB); };
if (!integrateGauss(result, f, mMinB, min(mMaxB, eCM - m0A)))
success = false;
@@ -526,10 +526,10 @@ double NucleonExcitations::psSize(double eCM, ParticleDataEntry& prodA,
return 0.;

// Define integrand of outer integral.
- auto I = [=, &success](double mA) {
+ auto I = [=, &success, this](double mA) {

// Define integrand of inner integral.
- auto f = [=](double mB) {
+ auto f = [=,this](double mB) {
return pCMS(eCM, mA, mB)
* hadronWidthsPtr->mDistr(idA, mA)
* hadronWidthsPtr->mDistr(idB, mB); };
diff --git a/src/PythiaParallel.cc b/src/PythiaParallel.cc
index 81450e2..7ec3a92 100644
--- a/src/PythiaParallel.cc
+++ b/src/PythiaParallel.cc
@@ -106,7 +106,7 @@ bool PythiaParallel::init(function<bool(Pythia&)> customInit) {
bool initSuccess = true;

for (int iPythia = 0; iPythia < numThreads; iPythia += 1) {
- initThreads.emplace_back([=, &seeds, &initSuccess]() {
+ initThreads.emplace_back([=, &seeds, &initSuccess, this]() {
Pythia* pythiaPtr = new Pythia(settings, particleData, false);
pythiaObjects[iPythia] = unique_ptr<Pythia>(pythiaPtr);
pythiaObjects[iPythia]->settings.flag("Print:quiet", true);
--
2.31.1

0 comments on commit 1c1bd3d

Please sign in to comment.