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

Experimental integrator2 #12

Merged
merged 70 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
7598997
commit with speed up integration / partially modernised caching
Mar 17, 2020
6595276
Begin vectorising the code
Apr 9, 2020
7d22858
add simd headers
Apr 9, 2020
a46c0ff
Consolidate SIMD integration / caching code with scalar version, remo…
Apr 14, 2020
e074da9
fixes for travis build
Apr 14, 2020
a04a7b2
Fix if number of events % simd_size != 0 and Chi2 calculation
Apr 14, 2020
53a3917
fixes for array / splines for avx2d
Apr 15, 2020
7ad8e91
fix for OSX
Apr 15, 2020
462ae54
Fix simd'ed integration and plotting
Apr 19, 2020
33121a5
fix travis...
Apr 19, 2020
b97eceb
fix travis...
Apr 19, 2020
f1b1591
fix travis...
Apr 19, 2020
e1f26c8
fix travis...
Apr 19, 2020
194f473
fix travis...
Apr 19, 2020
6403a29
fix travis...
Apr 19, 2020
1c7d80f
fix travis...
Apr 19, 2020
7b9816d
fix travis...
Apr 19, 2020
9c7e191
fix travis...
Apr 19, 2020
77339ca
fix travis build
Apr 20, 2020
9b38caa
fix control predicate for CompiledExpression batch
Apr 20, 2020
b18d048
remove debug_norm for src/PolarisedSum
Apr 20, 2020
5c10f20
try to fix osx ci
Apr 20, 2020
df71985
fix travis ci
Apr 20, 2020
5e3fe48
fix travis ci
Apr 20, 2020
c5d3906
fix travis ci
Apr 20, 2020
3f193e8
increase verbosity of ci
Apr 21, 2020
14e6db1
remove --quiet from conda options
Apr 21, 2020
804603f
chris's fix to build_root
Apr 22, 2020
a5a2e68
A few random fixes for clang
Apr 22, 2020
14937c4
fixes for osx
Apr 22, 2020
d34fd54
add -fma flag
Apr 22, 2020
324b896
remove std::fabs from unary expression
Apr 22, 2020
94ae640
still applying fixes for osx
Apr 22, 2020
2f14291
cleanup of AVX code, add AVX512, fixes to spline shapes
Apr 28, 2020
e8180a0
fix avx512d types, units for OSX
Apr 28, 2020
c0c7f1c
fix units for osx
Apr 28, 2020
867cf2a
Progress towards SIMD compatible generation, various fixes
May 16, 2020
fb6a9a0
Fix OpenMP predicates
May 16, 2020
958c379
Options to switch of mvec
May 17, 2020
934860e
cleanup mvec code
May 17, 2020
064296d
fix scalar build
May 17, 2020
0ddc4eb
Fixes for canonical formulation with deeper decay topologies
May 19, 2020
c3e827e
fix fitting in scalar build
May 28, 2020
87d3838
fix fitting in scalar build
May 28, 2020
07c4773
improve customised particles, improve compiler threading
Jun 7, 2020
9a16468
fix polarisedSum issue for clang
Jun 8, 2020
614a5a1
fix isPhoton flag
Jun 9, 2020
b4863e3
add some sanity checks for photons
Jun 9, 2020
d5e981b
fix cuts in DataConvertor
Jun 29, 2020
e527eb0
Fix complex logarithm for AVX, Weyl spinors for neutrinos
Jul 27, 2020
08d32d0
fix debugging of |T|^2 in PolarisedSum
Jul 29, 2020
f88f7f6
hopefully scalar builds don't accidentally include some AVX instructions
Jul 30, 2020
7374dcd
Merge branch 'experimental_integrator2' of https://github.com/GooFit/…
Jul 30, 2020
76fa62a
change the way constants are encoded into strings to allow very large…
tevans1260 Aug 5, 2020
5365228
possible fix in CompilerWrapper
tevans1260 Aug 5, 2020
e83679b
disable openmp for osx by default
tevans1260 Aug 5, 2020
559e8ea
fix openmp silliness
tevans1260 Aug 5, 2020
d39508a
disable openmp in the travis job
tevans1260 Aug 5, 2020
754298a
[Lineshapes] Add production (P-)vector approach to GenericKmatrix and…
marianstahl Aug 10, 2020
dde1671
fix custom helicity couplings + cleanup of evaluation of PDFs to arbi…
tevans1260 Aug 10, 2020
fa24e34
[example apps] add BaryonFitter and fit_hyperon_parameters.cpp
marianstahl Aug 10, 2020
d50abb1
[SumPDF] use event weight in fit
marianstahl Aug 10, 2020
8982ae8
[BaryonFitter] throw error when adding branches and using AVX; [Minim…
marianstahl Aug 10, 2020
da730a7
fix enum parser
tevans1260 Aug 11, 2020
14a8c12
fix enum
tevans1260 Aug 11, 2020
43c9096
Merge pull request #10 from marianstahl/marianstahl_additions_to_v2
tevans1260 Aug 11, 2020
d26f957
fix enum... again ... and add unit tests this time
tevans1260 Aug 12, 2020
24d7015
[Particle tables] update particle tables to be compatible with Gauss
marianstahl Aug 12, 2020
ed09fac
Merge pull request #11 from marianstahl/marianstahl_particle_tables_G…
tevans1260 Aug 12, 2020
7b5d15a
add automated testing against released models
tevans1260 Aug 13, 2020
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
20 changes: 20 additions & 0 deletions .ci/build_root.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pushd $DEPS_DIR
set -evx

os=$1
if [[ $os == "osx" ]] ; then
wget -nv http://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda_${os}.sh
elif [[ $os == "linux" ]] ; then
wget -nv http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda_${os}.sh
fi

bash miniconda_${os}.sh -b -p $DEPS_DIR/miniconda
export PATH="$DEPS_DIR/miniconda/bin:$PATH"
hash -r
conda config --add channels conda-forge
# conda config --set channel_priority strict

conda create --yes -n env_${os} root doxygen -c conda-forge

set +evx
popd
16 changes: 12 additions & 4 deletions .ci/build_root_linux.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
pushd $DEPS_DIR

wget -nv http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
if [[ $1 == "osx" ]] ; then
wget -nv http://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh
elif [[ $1 == "linux" ]] ; then
wget -nv http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
fi

bash miniconda.sh -b -p $DEPS_DIR/miniconda
export PATH="$DEPS_DIR/miniconda/bin:$PATH"
hash -r
conda config --add channels conda-forge
conda install --quiet --yes -c conda-forge/label/gcc8 root
conda config --set channel_priority strict

source "$DEPS_DIR/miniconda/bin/thisroot.sh"
export CXX="$DEPS_DIR/miniconda/bin/g++"
# conda install --quiet --yes -c conda-forge/label/gcc8 root_base doxygen
conda create --quiet --yes -n my_root_env root doxygen zstd=1.3.7 -c conda-forge
# conda init bash
# source "$DEPS_DIR/miniconda/bin/thisroot.sh"
# export CXX="$DEPS_DIR/miniconda/bin/g++"
popd
25 changes: 12 additions & 13 deletions .ci/travis_linux.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
#!/bin/bash

set -evx
# from https://stackoverflow.com/questions/55342122/conda-activate-on-travis-ci
export PATH="$DEPS_DIR/miniconda/bin:$PATH"
. $(conda info --root)/etc/profile.d/conda.sh
conda activate env_${TRAVIS_OS_NAME}

echo -en 'travis_fold:start:script.build\\r'
echo "Building..."
echo "Building under OS: $TRAVIS_OS_NAME, CXX =$CXX"
set -evx

mkdir -p build
cd build
cmake .. -DCMAKE_CXX_COMPILER=$CXX
mkdir -p build.conda
cd build.conda
cmake ..
cmake --build . -- -j2

set +evx

cd ..

./build/bin/Generator options/example_b2kstarll.opt --CompilerWrapper::Verbose --nEvents 1000


# echo -e 'travis_fold:end:script.build\\r'
# echo -en 'travis_fold:start:script.test\\r'
# echo "Testing..."
# set -evx

# ctest --output-on-failure
./build.conda/bin/Generator options/example_b2kstarll.opt --CompilerWrapper::Verbose --nEvents 10000

18 changes: 7 additions & 11 deletions .ci/travis_osx.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
#!/bin/bash

. $(conda info --root)/etc/profile.d/conda.sh
conda activate env_${TRAVIS_OS_NAME}

echo -en 'travis_fold:start:script.build\\r'
echo "Building..."
echo "Building under OS: $TRAVIS_OS_NAME"

mkdir -p build
cd build
echo "CMake-ing, CXX = $CXX"
cmake .. -DCMAKE_CXX_COMPILER=clang
cmake .. -DCMAKE_CXX_COMPILER=clang -DUSE_SIMD="" -DUSE_OPENMP=0
echo "Building ..."
cmake --build . -- -j2
cd ..
echo "Running test job ..."
./build/bin/Generator options/example_b2kstarll.opt --CompilerWrapper::Verbose --nEvents 1000


# echo -e 'travis_fold:end:script.build\\r'
# echo -en 'travis_fold:start:script.test\\r'
# echo "Testing..."
# set -evx

# ctest --output-on-failure

./build/bin/Generator options/example_b2kstarll.opt --CompilerWrapper::Verbose --nEvents 10000
26 changes: 13 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ matrix:
packages:
- libomp
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-8
- doxygen
- doxygen-doc
- doxygen-gui
- graphviz
- libtbb-dev
# addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# packages:
# - g++-8
# - doxygen
# - doxygen-doc
# - doxygen-gui
# - graphviz
# - libtbb-dev
env:
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"

Expand Down Expand Up @@ -48,8 +48,8 @@ env:

before_install:
- eval "${MATRIX_EVAL}"
- chmod +x .ci/build_root_${TRAVIS_OS_NAME}.sh
- source .ci/build_root_${TRAVIS_OS_NAME}.sh
- chmod +x .ci/build_root.sh
- source .ci/build_root.sh ${TRAVIS_OS_NAME}

# Build your code e.g. by calling make
script:
Expand Down
12 changes: 8 additions & 4 deletions AmpGen/ASTResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ namespace AmpGen {
{
auto it = m_cacheFunctions.find(name);
if( it != m_cacheFunctions.end() ) return it->second->address();
auto cacheFunction = std::make_shared<TYPE>(m_nParameters, args... );
auto cacheFunction = std::make_shared<TYPE>(m_nParameters, name, args... );
m_cacheFunctions[name] = cacheFunction;
m_nParameters += cacheFunction->size();
return m_nParameters - cacheFunction->size();
}
size_t nParams() const { return m_nParameters ; }
bool enableCuda() const { return m_enable_cuda ; }
bool enableAVX() const { return m_enable_avx; }
bool enableCompileConstants() const { return m_enable_compileTimeConstants ;}
void setEnableAVX(){ m_enable_avx = true ; }
std::map<std::string, std::shared_ptr<CacheTransfer>> cacheFunctions() const;
void addResolvedParameter(const IExpression* param, const std::string& thing);
void addResolvedParameter(const IExpression* param, const size_t& address, const size_t& arg=0);
Expand All @@ -58,10 +60,12 @@ namespace AmpGen {
std::map<std::string, unsigned> m_evtMap; /// Event specification
std::map<std::string, std::string> m_parameterMapping; /// Mapping of parameters to compile parameters
const MinuitParameterSet* m_mps; /// Set of MinuitParameters
std::map<const SubTree*, uint64_t> m_tempTrees; /// temporary store of sub-trees for performing cse reduction
std::map<const IExpression*, const SubTree*> m_tempTrees; /// temporary store of sub-trees for performing cse reduction
unsigned int m_nParameters; /// Number of parameters
bool m_enable_cuda; /// flag to generate CUDA code <<experimental>>
bool m_enable_compileTimeConstants; /// flag to enable compile time constants <<experimental>>
bool m_enable_cuda {false}; /// flag to generate CUDA code <<experimental>>
bool m_enable_compileTimeConstants {false}; /// flag to enable compile time constants <<experimental>>
bool m_enable_avx {false}; /// flag to generate code using AVX instructions <<experimental>>
bool m_check_hashes {false}; /// flag to check that hashes are unique
};

template <> void ASTResolver::resolve<Parameter>( const Parameter& obj );
Expand Down
83 changes: 51 additions & 32 deletions AmpGen/AmplitudeRules.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include "AmpGen/Event.h"
#include "AmpGen/Particle.h"
#include "AmpGen/ExpressionParser.h"
#if ENABLE_AVX
#include "AmpGen/EventListSIMD.h"
#endif

namespace AmpGen
{
Expand Down Expand Up @@ -73,7 +76,7 @@ namespace AmpGen
AmplitudeRules( const MinuitParameterSet& mps );
std::vector<Coupling> rulesForDecay(const std::string& head, const std::string& prefix="");
bool hasDecay( const std::string& head );
std::map<std::string, std::vector<Coupling>> rules();
const std::map<std::string, std::vector<Coupling>>& rules() const;
std::vector<std::pair<Particle, TotalCoupling>> getMatchingRules(
const EventType& type, const std::string& prefix="" );
std::vector<Coupling> processesThatProduce(const Particle& particle) const;
Expand All @@ -82,39 +85,48 @@ namespace AmpGen
std::map<std::string, std::vector<Coupling>> m_rules;
};

template <class RT> struct TransitionMatrix
template <class RT> struct TransitionMatrix : public CompiledExpression<RT(const real_t*, const float_v*)>
{
using amp_type = CompiledExpression<RT(const real_t*, const float_v*)>;
TransitionMatrix() = default;
TransitionMatrix(const Particle& dt,
const TotalCoupling& coupling,
const CompiledExpression<RT, const real_t*, const real_t*> & amp) :
const amp_type& amp) :
amp_type(amp),
decayTree(dt),
coupling(coupling),
amp(amp) {}
coupling(coupling) {}

TransitionMatrix(Particle& dt,
TransitionMatrix(const Particle& dt,
const TotalCoupling& coupling,
const MinuitParameterSet& mps,
const std::map<std::string, unsigned>& evtFormat,
const bool& debugThis=false) :
amp_type(Particle(dt).getExpression(debugThis ? &db : nullptr ), dt.decayDescriptor(), evtFormat, db, &mps ),
decayTree(dt),
coupling(coupling),
amp(decayTree.getExpression(debugThis ? &db : nullptr ), decayTree.decayDescriptor(), evtFormat, db, &mps ) {}
coupling(coupling) {}

const RT operator()(const Event& event) const { return amp(event.address() ); }
const RT operator()(const Event& event, const size_t& cacheOffset) const { return amp(event.address() + cacheOffset); }
#if ENABLE_AVX
const RT operator()(const Event& event) const { return amp_type::operator()(EventListSIMD::makeEvent(event).data()); }
void debug( const Event& event ) const { amp_type::debug(EventListSIMD::makeEvent(event).data() ) ; }

#else
const RT operator()(const Event& event) const { return amp_type::operator()(event.address()) ; }
void debug( const Event& event ) const { amp_type::debug(event.address()) ; }
#endif
template <class... arg_types> auto operator()(arg_types... args ) const { return amp_type::operator()(args...) ; }

const RT operator()(const float_v* t) const { return amp_type::operator()(t) ; }
void debug( const float_v* t ) const { amp_type::debug(t) ; }
const std::string decayDescriptor() const { return decayTree.decayDescriptor() ; }

Particle decayTree;
TotalCoupling coupling;
complex_t coefficient;
DebugSymbols db;
CompiledExpression<RT,const real_t*,const real_t*> amp;
size_t addressData = {999};
bool workToDo = {false};
};

template <class RT>
std::vector<size_t> processIndex(const std::vector<TransitionMatrix<RT>>& tm, const std::string& label)
template <class RT> std::vector<size_t> processIndex(const std::vector<TransitionMatrix<RT>>& tm, const std::string& label)
{
std::vector<size_t> indices;
for ( size_t i = 0; i < tm.size(); ++i ) {
Expand All @@ -123,8 +135,7 @@ namespace AmpGen
return indices;
}

template <class RT>
size_t findIndex(const std::vector<TransitionMatrix<RT>>& tm, const std::string& decayDescriptor)
template <class RT> size_t findIndex(const std::vector<TransitionMatrix<RT>>& tm, const std::string& decayDescriptor)
{
for ( size_t i = 0; i < tm.size(); ++i ) {
if ( tm[i].decayDescriptor() == decayDescriptor ) return i;
Expand All @@ -143,43 +154,51 @@ namespace AmpGen
return rt;
}

template <> struct TransitionMatrix<void>
template <> struct TransitionMatrix<void> : public CompiledExpression<void(complex_v*, const size_t&, const real_t*, const float_v*)>
{
using amp_type = CompiledExpression<void(complex_v*, const size_t&, const real_t*, const float_v*)>;
TransitionMatrix() = default;
TransitionMatrix(const Particle& dt,
const TotalCoupling& coupling,
const CompiledExpression<void, complex_t*, const real_t*, const real_t*> & amp) :
const amp_type& amp) :
amp_type(amp),
decayTree(dt),
coupling(coupling),
amp(amp) {}
coupling(coupling) {}

TransitionMatrix(const Particle& dt,
const TotalCoupling& coupling,
const MinuitParameterSet& mps,
const std::map<std::string, unsigned>& evtFormat,
const bool& debugThis=false) :
amp_type(Particle(dt).getExpression(debugThis ? &db : nullptr ), dt.decayDescriptor(), evtFormat, db, &mps ),
decayTree(dt),
coupling(coupling),
amp(decayTree.getExpression(debugThis ? &db : nullptr ), decayTree.decayDescriptor(), evtFormat, db, &mps ) { amp.use_rto();}
coupling(coupling)
{ use_rto();}

const std::vector<complex_t> operator()(const Event& event) const {
std::vector<complex_t> rt;
amp(rt.data(), amp.externBuffer().data(), event.address() );
return rt;
}
const std::vector<complex_t> operator()(const Event& event, const size_t& cacheOffset) const {
std::vector<complex_t> rt;
amp(rt.data(), amp.externBuffer().data(), event.address() + cacheOffset);
const std::vector<complex_v> operator()(const Event& event) const
{
std::vector<complex_v> rt(size);
#if ENABLE_AVX
amp_type::operator()(rt.data(), 1, externBuffer().data(), EventListSIMD::makeEvent(event).data());
#else
amp_type::operator()(rt.data(), 1, externBuffer().data(), event.address());
#endif
return rt;
}
template <class... arg_types> auto operator()(arg_types... args ) const { return amp_type::operator()(args...) ; }
#if ENABLE_AVX
void debug( const Event& event ) const { amp_type::debug(EventListSIMD::makeEvent(event).data() ) ; }
#else
void debug( const Event& event ) const { amp_type::debug(event.address()) ; }
#endif
const std::string decayDescriptor() const { return decayTree.decayDescriptor() ; }

Particle decayTree;
TotalCoupling coupling;
complex_t coefficient;
DebugSymbols db;
CompiledExpression<void, complex_t*, const real_t*, const real_t*> amp;
size_t addressData = {999};
bool workToDo = {false};
unsigned size = {0};
};

} // namespace AmpGen
Expand Down
20 changes: 13 additions & 7 deletions AmpGen/ArgumentPack.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace AmpGen
#define DECLARE_ARGUMENT(X, Y) \
struct X : public AmpGen::Argument<Y> { \
template<class Z> \
explicit X(Z val) : AmpGen::Argument<Y>(val){} \
explicit X(Z val = Z()) : AmpGen::Argument<Y>(val){} \
X() : AmpGen::Argument<Y>(){} \
}
/** @class IArgument
Expand Down Expand Up @@ -76,14 +76,20 @@ namespace AmpGen
std::tuple<ARGS...> argTuple( args... );
for_each(argTuple, [this](const auto& f){ this->addArgument(f) ; } );
}
template <typename ARG, typename DEFAULT_TYPE=ARG>
ARG getArg( const DEFAULT_TYPE& default_argument = DEFAULT_TYPE() ) const
template <typename arg_type> arg_type* get() const
{
for ( auto param : m_parameters ) {
auto ptr = dynamic_cast<ARG*>( param.get() );
if ( ptr != nullptr ) return *ptr;
for( const auto& param : m_parameters )
{
auto ptr = dynamic_cast<arg_type*>(param.get());
if( ptr != nullptr ) return ptr;
}
return ARG(default_argument);
return nullptr;
}
template <typename arg_type, typename default_arg_type=arg_type>
arg_type getArg( const default_arg_type& default_argument = default_arg_type() ) const
{
auto p = get<arg_type>();
return p == nullptr ? arg_type(default_argument) : *p;
}
private:
std::vector<std::shared_ptr<IArgument>> m_parameters;
Expand Down
4 changes: 2 additions & 2 deletions AmpGen/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ namespace AmpGen
complex_t operator()() const override;
Expression operator[]( const Expression& address ) const;
Expression top() const { return m_top ; }

unsigned size() const { return m_size; }
private:
Expression m_top;
Expression m_address;
size_t m_size;
unsigned m_size;
};
} // namespace AmpGen

Expand Down
Loading