From cfcd6e22bb2081fa9f730c4ee0e07d04b1c8fe55 Mon Sep 17 00:00:00 2001 From: Jxtopher <39927513+Jxtopher@users.noreply.github.com> Date: Fri, 28 Mar 2025 22:30:30 +0100 Subject: [PATCH 1/9] Ccache setup The goal is to speed up recompilation using ccache. Ccache is a tool that speeds up recompilation of C/C++ code. It does this by caching the results of previous compilations. When you recompile code, ccache checks if it has already compiled the same code with the same compiler flags. If so, it uses the cached result instead of recompiling. --- .github/workflows/build_ubuntu_debug.yml | 9 ++++++++- CMakeLists.txt | 11 +++++++++++ README.md | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_ubuntu_debug.yml b/.github/workflows/build_ubuntu_debug.yml index b68744cb2..58aac6a42 100644 --- a/.github/workflows/build_ubuntu_debug.yml +++ b/.github/workflows/build_ubuntu_debug.yml @@ -16,8 +16,15 @@ jobs: compiler: [g++-10, g++-9, g++-8, g++-7, clang-6, clang-7, clang-8, clang-9, clang-10, clang-11, clang-12] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - name: Caching objects + id: cache-objects + uses: actions/cache@v4 + with: + path: ~/.cache/ccache + key: ${{ runner.os }}-${{env.BUILD_TYPE}}-${{ matrix.compiler }}-objects + - name: Install Dependencies shell: bash run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bec9ae43..1b364f35f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,17 @@ project("ParadisEO" ## Language set(CMAKE_CXX_STANDARD 17) +## ccache +find_program(CCACHE_PROGRAM ccache) + +if (CCACHE_PROGRAM) + message(NOTICE "-- ccache is enabled (found here: ${CCACHE_PROGRAM})") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "\"${CCACHE_PROGRAM}\"") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "\"${CCACHE_PROGRAM}\"") +else () + message(NOTICE "-- ccache has not been found") +endif () + ###################################################################################### ### 2) Check dependencies diff --git a/README.md b/README.md index 686b08334..ff158606d 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,7 @@ If you `ENABLE_CMAKE_EXAMPLE`, it will also build the examples. If may want to make build scripts more verbose (especially when building the doc) by enabling `CMAKE_VERBOSE_MAKEFILE`. +If `ccache` installed in your environment, library recompilation times can be significantly reduced. To clear all cached objects, execute `ccache -C`. ## Licenses From 22275e434b078bfb5bc480c77f74685aecb4395b Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Mon, 7 Apr 2025 14:16:37 +0200 Subject: [PATCH 2/9] fix several warnings Probably fixes a bug in es/CMA, which has been deprecated for a long time in favor of the EDO module anyway. --- eo/src/eoEasyPSO.h | 16 ++++++------- eo/src/eoSyncEasyPSO.h | 30 ++++++++++++------------- eo/src/es/CMAParams.cpp | 3 +++ eo/src/gp/parse_tree.h | 7 ++++++ eo/src/mpi/implMpi.cpp | 2 +- eo/src/utils/pipecom.cpp | 6 ++--- eo/src/utils/pipecom.h | 4 ++-- moeo/src/do/make_checkpoint_moeo.h | 2 +- moeo/src/do/make_ea_moeo.h | 2 +- moeo/src/metric/moeoHyperVolumeMetric.h | 4 ++-- moeo/tutorial/Lesson1/Sch1.cpp | 4 ++-- smp/src/PPExpander.h | 2 +- smp/src/island.cpp | 4 ++++ smp/src/island.h | 3 ++- smp/tutorial/Lesson1/QAPGA.h | 2 ++ 15 files changed, 53 insertions(+), 38 deletions(-) diff --git a/eo/src/eoEasyPSO.h b/eo/src/eoEasyPSO.h index 87c27cad3..25f030595 100644 --- a/eo/src/eoEasyPSO.h +++ b/eo/src/eoEasyPSO.h @@ -174,18 +174,18 @@ protected: // if the flight does not need to be used, use the dummy flight instance class eoDummyFlight:public eoFlight < POT > { - public: - eoDummyFlight () {} - void operator () (POT &) {} - }dummyFlight; + public: + eoDummyFlight () {} + void operator() (POT &) override {} + } dummyFlight; // if the initializer does not need to be used, use the dummy one instead class eoDummyInitializer:public eoInitializerBase < POT > { - public: - eoDummyInitializer () {} - void operator () (POT &) {} - }dummyInit; + public: + eoDummyInitializer () {} + void operator() () override {} + } dummyInit; }; /** diff --git a/eo/src/eoSyncEasyPSO.h b/eo/src/eoSyncEasyPSO.h index 11640af53..183148896 100644 --- a/eo/src/eoSyncEasyPSO.h +++ b/eo/src/eoSyncEasyPSO.h @@ -230,27 +230,25 @@ protected: // if the eval does not need to be used, use the dummy eval instance class eoDummyEval : public eoEvalFunc - { - public: - void operator()(POT &) - {} - } - dummyEval; - - class eoDummyFlight:public eoFlight < POT > { - public: - eoDummyFlight () {} - void operator () (POT &) {} - }dummyFlight; + public: + void operator()(POT &) override {} + } dummyEval; + + class eoDummyFlight:public eoFlight < POT > + { + public: + eoDummyFlight () {} + void operator() (POT &) override {} + } dummyFlight; // if the initializer does not need to be used, use the dummy one instead class eoDummyInitializer:public eoInitializerBase < POT > { - public: - eoDummyInitializer () {} - void operator () (POT &) {} - }dummyInit; + public: + eoDummyInitializer () {} + void operator() () override {} + } dummyInit; }; /** @example t-eoSyncEasyPSO.cpp diff --git a/eo/src/es/CMAParams.cpp b/eo/src/es/CMAParams.cpp index 2862cdd1a..d27204f97 100644 --- a/eo/src/es/CMAParams.cpp +++ b/eo/src/es/CMAParams.cpp @@ -113,16 +113,19 @@ CMAParams::CMAParams(eoParser& parser, unsigned dimensionality) { for (unsigned i = 0; i < weights.size(); ++i) { weights[i] = mu - i; } + break; } case 2: { weights = 1.; + break; } default : { for (unsigned i = 0; i < weights.size(); ++i) { weights[i] = log(mu+1.)-log(i+1.); } + break; } } diff --git a/eo/src/gp/parse_tree.h b/eo/src/gp/parse_tree.h index 84ec04d35..6b9ab80ae 100644 --- a/eo/src/gp/parse_tree.h +++ b/eo/src/gp/parse_tree.h @@ -468,8 +468,11 @@ private : switch(new_arity) { case 3 : args[2].copy(s.args[2]); args[2].parent = this; // no break! + [[fallthrough]]; case 2 : args[1].copy(s.args[1]); args[1].parent = this; + [[fallthrough]]; case 1 : args[0].copy(s.args[0]); args[0].parent = this; + [[fallthrough]]; case 0 : break; default : { @@ -523,7 +526,9 @@ private : switch(arity()) { case 3 : args[2].parent = 0; // no break! + [[fallthrough]]; case 2 : args[1].parent = 0; + [[fallthrough]]; case 1 : args[0].parent = 0; break; case 0 : break; default : @@ -542,7 +547,9 @@ private : switch(arity()) { case 3 : args[2].parent = this; // no break! + [[fallthrough]]; case 2 : args[1].parent = this; + [[fallthrough]]; case 1 : args[0].parent = this; break; case 0 : break; default : diff --git a/eo/src/mpi/implMpi.cpp b/eo/src/mpi/implMpi.cpp index 2dd1ca0d5..d045da3ac 100644 --- a/eo/src/mpi/implMpi.cpp +++ b/eo/src/mpi/implMpi.cpp @@ -161,7 +161,7 @@ namespace mpi MPI_Barrier( MPI_COMM_WORLD ); } - void broadcast( communicator & comm, int value, int root ) + void broadcast( communicator & /*comm*/, int value, int root ) { MPI_Bcast( &value, 1, MPI_INT, root, MPI_COMM_WORLD ); } diff --git a/eo/src/utils/pipecom.cpp b/eo/src/utils/pipecom.cpp index a175112f9..bef9ae2ce 100644 --- a/eo/src/utils/pipecom.cpp +++ b/eo/src/utils/pipecom.cpp @@ -42,16 +42,16 @@ int Check( PCom *com ) } -PCom * PipeComOpen( char *prog ) +PCom * PipeComOpen( const char *prog ) { char *args[2]; - args[0] = prog; + args[0] = strdup( prog ); args[1] = NULL; return PipeComOpenArgv( prog, args ); } -PCom * PipeComOpenArgv( char *prog, char *argv[] ) +PCom * PipeComOpenArgv( const char *prog, char *argv[] ) { int toFils[2]; int toPere[2]; diff --git a/eo/src/utils/pipecom.h b/eo/src/utils/pipecom.h index 56b031708..16685225c 100644 --- a/eo/src/utils/pipecom.h +++ b/eo/src/utils/pipecom.h @@ -23,8 +23,8 @@ typedef struct PipeCommunication { } PCom; -extern PCom *PipeComOpen( char *prog ); -extern PCom *PipeComOpenArgv( char *prog, char *argv[] ); +extern PCom *PipeComOpen( const char *prog ); +extern PCom *PipeComOpenArgv( const char *prog, char *argv[] ); extern int PipeComSend( PCom *to, const char *line ); extern int PipeComSendn( PCom *to, const char *data, int n ); diff --git a/moeo/src/do/make_checkpoint_moeo.h b/moeo/src/do/make_checkpoint_moeo.h index 188c340ea..98bb1e2a1 100644 --- a/moeo/src/do/make_checkpoint_moeo.h +++ b/moeo/src/do/make_checkpoint_moeo.h @@ -66,7 +66,7 @@ bool testDirRes(std::string _dirName, bool _erase); * @param _archive the archive of non-dominated solutions */ template < class MOEOT > -eoCheckPoint < MOEOT > & do_make_checkpoint_moeo (eoParser & _parser, eoState & _state, eoEvalFuncCounter < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoPop < MOEOT > & _pop, moeoArchive < MOEOT > & _archive) +eoCheckPoint < MOEOT > & do_make_checkpoint_moeo (eoParser & _parser, eoState & _state, eoEvalFuncCounter < MOEOT > & /*_eval*/, eoContinue < MOEOT > & _continue, eoPop < MOEOT > & _pop, moeoArchive < MOEOT > & _archive) { eoCheckPoint < MOEOT > & checkpoint = _state.storeFunctor(new eoCheckPoint < MOEOT > (_continue)); /* the objective vector type */ diff --git a/moeo/src/do/make_ea_moeo.h b/moeo/src/do/make_ea_moeo.h index aee4dcd0d..76559e198 100644 --- a/moeo/src/do/make_ea_moeo.h +++ b/moeo/src/do/make_ea_moeo.h @@ -85,7 +85,7 @@ * @param _archive the archive of non-dominated solutions */ template < class MOEOT > -moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalFunc < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoGenOp < MOEOT > & _op, moeoArchive < MOEOT > & _archive) +moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalFunc < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoGenOp < MOEOT > & _op, moeoArchive < MOEOT > & /*_archive*/) { /* the objective vector type */ diff --git a/moeo/src/metric/moeoHyperVolumeMetric.h b/moeo/src/metric/moeoHyperVolumeMetric.h index dc65ac4c9..ce1ee0c1c 100644 --- a/moeo/src/metric/moeoHyperVolumeMetric.h +++ b/moeo/src/metric/moeoHyperVolumeMetric.h @@ -55,7 +55,7 @@ class moeoHyperVolumeMetric : public moeoVectorUnaryMetric < ObjectiveVector , d * @param _normalize allow to normalize data (default true) * @param _rho coefficient to determine the reference point. */ - moeoHyperVolumeMetric(bool _normalize=true, double _rho=1.1): normalize(_normalize), rho(_rho), ref_point(NULL){ + moeoHyperVolumeMetric(bool _normalize=true, double _rho=1.1): normalize(_normalize), rho(_rho) { bounds.resize(ObjectiveVector::Traits::nObjectives()); // initialize bounds in case someone does not want to use them for (unsigned int i=0; i } template - U& findValueImpl(T& t, Arg&... arg, std::true_type) + U& findValueImpl(T& t, Arg&... /*arg*/, std::true_type) { return t; } diff --git a/smp/src/island.cpp b/smp/src/island.cpp index 783d42d75..eb8fa85ca 100644 --- a/smp/src/island.cpp +++ b/smp/src/island.cpp @@ -59,6 +59,10 @@ paradiseo::smp::Island::Island(eoPop& _pop, IntPolicy _pop, _intPolicy, _migPolicy, args...) { } +template