Weiming-Hu / AnalogsEnsemble

The C++ and R packages for parallel ensemble forecasts using Analog Ensemble
https://weiming-hu.github.io/AnalogsEnsemble/
MIT License
18 stars 5 forks source link

PAnEn C++ on Onyx #66

Closed Weiming-Hu closed 4 years ago

Weiming-Hu commented 4 years ago

This is to document the process of building PAnEn C++ on Onyx.

Two problems emerged during the process.

First is that it seems like cross-compilation does not work out of the box on Onyx and therefore, dynamic linking to Boost is disabled. We are limited to use the system package for Boost.

...
-- BOOST_TYPE is set to BUILD
-- Cann't find the source files for Boost in /p/work/bhoch/AE6.1/anen/AnalogsEnsemble/dependency.
        Try to download the required modules using git.
Cloning into '/p/work/bhoch/AE6.1/anen/AnalogsEnsemble/dependency/program_options'...
Cloning into '/p/work/bhoch/AE6.1/anen/AnalogsEnsemble/dependency/system'...
Cloning into '/p/work/bhoch/AE6.1/anen/AnalogsEnsemble/dependency/filesystem'...
Cloning into '/p/work/bhoch/AE6.1/anen/AnalogsEnsemble/dependency/minimal_boost'...
Checking out files: 100% (12402/12402), done.
CMake Warning (dev) at dependency/system/CMakeLists.txt:20 (add_library):
  ADD_LIBRARY called with SHARED option but the target platform does not
  support dynamic linking.  Building a STATIC library instead.  This may lead
  to problems.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error at dependency/system/CMakeLists.txt:23 (install):
  install TARGETS given no ARCHIVE DESTINATION for static library target
  "system".

CMake Warning (dev) at dependency/filesystem/CMakeLists.txt:43 (add_library):
  ADD_LIBRARY called with SHARED option but the target platform does not
  support dynamic linking.  Building a STATIC library instead.  This may lead
  to problems.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error at dependency/filesystem/CMakeLists.txt:47 (install):
  install TARGETS given no ARCHIVE DESTINATION for static library target
  "filesystem".

CMake Warning (dev) at dependency/program_options/CMakeLists.txt:34 (add_library):
  ADD_LIBRARY called with SHARED option but the target platform does not
  support dynamic linking.  Building a STATIC library instead.  This may lead
  to problems.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error at dependency/program_options/CMakeLists.txt:37 (install):
  install TARGETS given no ARCHIVE DESTINATION for static library target
  "program_options".

-- ENABLE_MPI is set to OFF
...

So you need to load the Boost module.

Weiming-Hu commented 4 years ago

Then, the default compiler on Onxy is Intel. However, we have the following issue during the make process.

[ 48%] Building CXX object CAnEnIO/CMakeFiles/AnEnIO.dir/__/CAnEn/src/SimilarityMatrices.cpp.o

[ 48%] Building CXX object CAnEnIO/CMakeFiles/AnEnIO.dir/__/CAnEn/src/errorType.cpp.o

/p/work/bhoch/AE6.1/anen/AnalogsEnsemble/CAnEnIO/src/AnEnIO.cpp(2353): error: parallel loops with collapse must be perfectly nested

          for (size_t i = 0; i < data.shape()[same_dimensions[2]]; i++) {

                      ^

Error: the OpenMP "single" pragma must not be enclosed by the "for" pragma

Error: the OpenMP "single" pragma must not be enclosed by the "for" pragma

CAnEnIO/CMakeFiles/AnEnIO.dir/build.make:62: recipe for target 'CAnEnIO/CMakeFiles/AnEnIO.dir/src/AnEnIO.cpp.o' failed

make[2]: *** [CAnEnIO/CMakeFiles/AnEnIO.dir/src/AnEnIO.cpp.o] Error 2

make[2]: *** Waiting for unfinished jobs....

CMakeFiles/Makefile2:218: recipe for target 'CAnEnIO/CMakeFiles/AnEnIO.dir/all' failed

make[1]: *** [CAnEnIO/CMakeFiles/AnEnIO.dir/all] Error 2

Makefile:138: recipe for target 'all' failed

make: *** [all] Error 2

This is because the OpenMP interface between Intel and GNU compilers are not the same which creates the error.

Another issue will be created specifically for the support with Intel.

But at this point, let's use GNU compilers.

CC=<the GNU C compiler> CXX=<the GNU C++ compiler> cmake <the rest of the arguments> ..
Weiming-Hu commented 4 years ago

The make process went a bit further unitl it broke. This time, it is because of the linking to Boost.

[ 91%] Linking CXX executable ../../../output/bin/windFieldCalculator

[ 92%] Linking CXX executable ../../../output/test/runFunctions

/usr/bin/ld: CMakeFiles/analogSelector.dir/analogSelector.cpp.o: in function `void boost::program_options::validate<unsigned long, char>(boost::any&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, unsigned long*, long) [clone .constprop.318]':

analogSelector.cpp:(.text+0x9a5): undefined reference to `boost::program_options::invalid_option_value::invalid_option_value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

/usr/bin/ld: CMakeFiles/analogSelector.dir/analogSelector.cpp.o: in function `boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':

analogSelector.cpp:(.text._ZN5boost15program_options16validation_errorC2ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i[_ZN5boost15program_options16validation_errorC5ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i]+0x21): undefined reference to `boost::program_options::validation_error::get_template[abi:cxx11](boost::program_options::validation_error::kind_t)'

/usr/bin/ld: analogSelector.cpp:(.text._ZN5boost15program_options16validation_errorC2ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i[_ZN5boost15program_options16validation_errorC5ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i]+0x39): undefined reference to `boost::program_options::error_with_option_name::error_with_option_name(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'

/usr/bin/ld: CMakeFiles/analogSelector.dir/analogSelector.cpp.o: in function `boost::program_options::typed_value<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char>::xparse(boost::any&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) const':

Notice a message from previous output that we are using the Intel Boost package.

The linking flags for AnEnIO: /p/app/unsupported/COST/boost/1.58.0/intel/lib/libboost_program_options.a;/p/app/unsupported/COST/boost/1.58.0/intel/lib/libboost_system.a;/p/app/unsupported/COST/boost/1.58.0/intel/lib/libboost_filesystem.a;netcdf_cxx4_built;/p/app/unsupported/netcdf/4.6.2-intel-18.0.2.199/lib/libnetcdf.a;

But right now we are using GNU compilers rather than Intel compilers. We need to load GNU Boost.

Weiming-Hu commented 4 years ago

After the package swapping, the program compiles with all tests passed.

Weiming-Hu commented 4 years ago

Close this issue since the program compiles. For more information on Intel compilers, please refer to issue 67.