SixTrack / sixtracklib

Library for single charged particle simulations in accelerators
GNU Lesser General Public License v2.1
12 stars 16 forks source link

Making: strncpy and st::TrackJobCl / track_job_t #67

Closed aoeftiger closed 5 years ago

aoeftiger commented 5 years ago

Based, again, on the gcc 9.1.0 and cmake 3.11.1 set-up, I find errors compiling on the kronos cluster at GSI -- perhaps these errors again might have to do with the c++17 standards? I'm compiling only for CPU:

Settings.make

# ---- Backends and computing architectures:

option( SIXTRACKL_ENABLE_AUTOVECTORIZATION "Enable Autovectorization"     ON )
option( SIXTRACKL_ENABLE_MANUAL_SIMD       "Enable manual SIMD backend"   OFF )
option( SIXTRACKL_ENABLE_OPENMP            "Enable OpenMP backend"        ON )
option( SIXTRACKL_ENABLE_OPENCL            "Enable OpenCL 1.x backend"    OFF )
option( SIXTRACKL_ENABLE_CUDA              "Enable CUDA backend"          OFF )
option( SIXTRACKL_ENABLE_MPFR4             "Enable GMP/MPFR4 backend"     OFF )

option( SIXTRACKL_ENABLE_CXX               "Enable C++ bindings"          ON  )
option( SIXTRACKL_ENABLE_PYTHON            "Enable Python bindings"       ON  )

# ------------------------------------------------------------------------------
# ---- Program logistic options:

option( SIXTRACKL_BUILD_EXAMPLES         "Build sixtracklib examples"     ON  )
option( SIXTRACKL_ENABLE_PROGRAMM_TESTS  "Enable programmatic unit-tests" OFF )
option( SIXTRACKL_ENABLE_BENCHMARK_TESTS "Enable benchmark tests"         OFF )

cmake output

$ cmake ..
-- The C compiler identification is GNU 9.1.0
-- The CXX compiler identification is GNU 9.1.0
-- Check for working C compiler: /cvmfs/it.gsi.de/compiler/gcc/9.1.0/bin/gcc
-- Check for working C compiler: /cvmfs/it.gsi.de/compiler/gcc/9.1.0/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /cvmfs/it.gsi.de/compiler/gcc/9.1.0/bin/g++
-- Check for working CXX compiler: /cvmfs/it.gsi.de/compiler/gcc/9.1.0/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- ---- Project sixtracklib
-- ---- Inside main CMakeLists.txt
-- ---- Setting build type to 'Release' as none was specified.
-- ---- Loaded local settings file
                 /lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/Settings.cmake
-- ---- cmake_module_path: /lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/cmake
-- ---- Processing cmake/SetupCxx.cmake
-- ---- Processing cmake/SetupPython.cmake
-- Found PythonInterp: /u/aoeftige/anaconda3/bin/python3.7 (found version "3.7.3") 
-- Found PythonLibs: /u/aoeftige/anaconda3/lib/libpython3.7m.so (found version "3.7.3") 
-- ---- Processing cmake/SetupUnitTesting.cmake
-- ---- Disable creation unit-tests using CTest / GTest
-- ---- Processing cmake/SetupMultiPrecision.cmake
-- ---- Processing cmake/SetupAutoVecSIMD.cmake
-- ------ Optimizing for SSE2 architecture
-- ---- Processing cmake/SetupOpenMP.cmake
-- Found OpenMP_C: -fopenmp (found version "4.5") 
-- Found OpenMP_CXX: -fopenmp (found version "4.5") 
-- Found OpenMP: TRUE (found version "4.5")  
-- OpenMP_FOUND: TRUE
-- OPENMP_FOUND: TRUE
-- ---- Processing cmake/SetupOpenCL.cmake
-- ---- Processing cmake/SetupCuda.cmake
-- ---- processing sixtracklib/CMakeLists.txt
-- ---- processing sixtracklib/common/CMakeLists.txt
-- ------ python: providing a copy of library to /lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/python/pysixtracklib/libsixtrack.so
-- ---- processing examples/c99/CMakeLists.txt
-- ------ Preparing installation of examples/c99
-- ---- processing examples/cxx/CMakeLists.txt
-- ------ Preparing installation of examples/cxx
-- ---- processing tests/testdata_generators/CMakeLists.txt
-- ------ processing tests/sixtracklib/testlib/CMakeLists.txt
-- ------ python: providing a copy of testlib library to /lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/python/pysixtracklib_test/libsixtrack_test.so
-- ---- processing tests/python/CMakeLists.txt
-- Configuring done
-- Generating done
-- Build files have been written to: /lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/build

make output

$ make -j 20 VERBOSE=1
[...]
[ 73%] Building C object examples/c99/CMakeFiles/track_job_cl_c99.dir/track_job_cl.c.o
cd /lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/build/examples/c99 && /cvmfs/it.gsi.de/compiler/gcc/9.1.0/bin/gcc  -I/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/tests -I/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib  -O3 -DNDEBUG   -msse2 -Wall -Werror -pedantic -std=gnu99 -o CMakeFiles/track_job_cl_c99.dir/track_job_cl.c.o   -c /lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_job_cl.c
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_job_cl.c: In function 'main':
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_job_cl.c:19:5: error: unknown type name 'st_TrackJobCl'; did you mean 'st_TrackJobCpu'?
   19 |     st_TrackJobCl*  job     = SIXTRL_NULLPTR;
      |     ^~~~~~~~~~~~~
      |     st_TrackJobCpu
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_job_cl.c:108:19: error: implicit declaration of function 'st_TrackJobCl_new'; did you mean 'st_TrackJobCpu_new'? [-Werror=implicit-function-declaration]
  108 |             job = st_TrackJobCl_new( argv[ 1 ], pb, eb );
      |                   ^~~~~~~~~~~~~~~~~
      |                   st_TrackJobCpu_new
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_job_cl.c:108:17: error: assignment to 'int *' from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
  108 |             job = st_TrackJobCl_new( argv[ 1 ], pb, eb );
      |                 ^
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_job_cl.c:112:19: error: implicit declaration of function 'st_TrackJobCl_new_with_output'; did you mean 'st_TrackJobCpu_new_with_output'? [-Werror=implicit-function-declaration]
  112 |             job = st_TrackJobCl_new_with_output(
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                   st_TrackJobCpu_new_with_output
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_job_cl.c:112:17: error: assignment to 'int *' from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
  112 |             job = st_TrackJobCl_new_with_output(
      |                 ^
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_job_cl.c:115:29: error: implicit declaration of function 'st_TrackJobCl_track_elem_by_elem'; did you mean 'st_TrackJobCpu_track_elem_by_elem'? [-Werror=implicit-function-declaration]
  115 |             track_status |= st_TrackJobCl_track_elem_by_elem(
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                             st_TrackJobCpu_track_elem_by_elem
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_job_cl.c:121:29: error: implicit declaration of function 'st_TrackJobCl_track_until_turn'; did you mean 'st_TrackJobCpu_track_until_turn'? [-Werror=implicit-function-declaration]
  121 |             track_status |= st_TrackJobCl_track_until_turn( job, NUM_TURNS );
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                             st_TrackJobCpu_track_until_turn
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_job_cl.c:128:9: error: implicit declaration of function 'st_TrackJobCl_collect'; did you mean  st_TrackJobCpu_collect'? [-Werror=implicit-function-declaration]
  128 |         st_TrackJobCl_collect( job );
      |         ^~~~~~~~~~~~~~~~~~~~~
      |         st_TrackJobCpu_collect
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_job_cl.c:194:5: error: implicit declaration of function 'st_TrackJobCl_delete'; did you mean 'st_TrackJobCpu_delete'? [-Werror=implicit-function-declaration]
  194 |     st_TrackJobCl_delete( job );
      |     ^~~~~~~~~~~~~~~~~~~~
      |     st_TrackJobCpu_delete

[...]

[ 76%] Building CXX object examples/cxx/CMakeFiles/track_job_cl_cxx.dir/track_job_cl.cpp.o
cd /lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/build/examples/cxx && /cvmfs/it.gsi.de/compiler/gcc/9.1.0/bin/g++   -I/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/tests -I/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib  -O3 -DNDEBUG   -msse2 -Wall -Werror -pedantic -std=gnu++11 -o CMakeFiles/track_job_cl_cxx.dir/track_job_cl.cpp.o -c /lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/cxx/track_job_cl.cpp
make[2]: Leaving directory '/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/build'
[ 76%] Built target normalize_cobject_dump
make[2]: Leaving directory '/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/build'
[ 76%] Built target dump_cbuffer
In file included from /usr/include/string.h:635,
                 from /lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_io.c:5:
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_io.c: In function 'main':
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_io.c:135:17: error: '__builtin_strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
  135 |                 strncpy( path_output_particles, argv[ 7 ],
      |                 ^~~~~~~
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/c99/track_io.c:123:40: note: length computed here
  123 |         size_t const output_path_len = strlen( argv[ 7 ] );
      |                                        ^~~~~~~~~~~~~~~~~~~

[...]

[ 91%] Linking C executable generate_track_be_drift_data
cd /lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/build/tests/testdata/generators && /cvmfs/fairroot.gsi.de/cbm/cbm_externals/may18/bin/cmake -E cmake_link_script CMakeFiles/generate_track_be_drift_data.dir/link.txt --verbose=1
/cvmfs/it.gsi.de/compiler/gcc/9.1.0/bin/gcc -O3 -DNDEBUG   CMakeFiles/generate_track_be_drift_data.dir/generate_track_be_drift_data.c.o  -o generate_track_be_drift_data -Wl,-rpath,/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/build/tests/sixtracklib/testlib:/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/build/sixtracklib ../../sixtracklib/testlib/libsixtrack_test.so ../../../sixtracklib/libsixtrack.so -lm -ldl 
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/cxx/track_job_cl.cpp: In function 'int main(int, char**)':
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/cxx/track_job_cl.cpp:18:29: error: 'TrackJobCl' in namespace 'st' does not name a type; did you mean 'TrackJobCpu'?
   18 |     using track_job_t = st::TrackJobCl;
      |                             ^~~~~~~~~~
      |                             TrackJobCpu
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/cxx/track_job_cl.cpp:85:9: error: 'track_job_t' was not declared in this scope
   85 |         track_job_t job( argv[ 1 ], pb, eb, nullptr, NUM_TURNS_ELEM_BY_ELEM );
      |         ^~~~~~~~~~~
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/cxx/track_job_cl.cpp:89:50: error: 'job' was not declared in this scope
   89 |             track_status |= st::trackElemByElem( job, NUM_TURNS_ELEM_BY_ELEM );
      |                                                  ^~~
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/cxx/track_job_cl.cpp:94:40: error: 'job' was not declared in this scope
   94 |             track_status |= st::track( job, NUM_TURNS );
      |                                        ^~~
/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/examples/cxx/track_job_cl.cpp:101:22: error: 'job' was not declared in this scope
  101 |         st::collect( job );
      |                      ^~~
make[2]: Leaving directory '/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/build'

[...]

make[1]: Leaving directory '/lustre/nyx/bhs/aoeftige/sixtracklib_kronos/sixtracklib/build'
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
aoeftiger commented 5 years ago

same error reproduced with gcc 6.4.0, so it's not gcc 9 specific:

$ cmake .. -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc
-- The C compiler identification is GNU 6.4.0
-- The CXX compiler identification is GNU 6.4.0
-- Check for working C compiler: /cvmfs/it.gsi.de/compiler/gcc/6.4.0/bin/gcc
-- Check for working C compiler: /cvmfs/it.gsi.de/compiler/gcc/6.4.0/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /cvmfs/it.gsi.de/compiler/gcc/6.4.0/bin/g++
-- Check for working CXX compiler: /cvmfs/it.gsi.de/compiler/gcc/6.4.0/bin/g++ -- works
[...]
martinschwinzerl commented 5 years ago

Thank you for testing this and for the feedback! I was able to reproduce the problem, it's not related to the g++/gcc toolchain at all but is caused by sloppy handling of the configuration flags in two CMakeLists.txt files (i.e. two opencl based examples were attempted to be built even if opencl is not available -> this causes the error messages).

Could you please try to

Thank you in advance & sorry for the hassle

aoeftiger commented 5 years ago

Great, indeed it is fixed with #64 (in particular commit d2ef27 )

Many thanks @martinschwinzerl !

PS: for reference, the Settings.cmake contained (as before):

# ---- Backends and computing architectures:

option( SIXTRACKL_ENABLE_AUTOVECTORIZATION "Enable Autovectorization"     ON )
option( SIXTRACKL_ENABLE_MANUAL_SIMD       "Enable manual SIMD backend"   OFF )
option( SIXTRACKL_ENABLE_OPENMP            "Enable OpenMP backend"        ON )
option( SIXTRACKL_ENABLE_OPENCL            "Enable OpenCL 1.x backend"    OFF )
option( SIXTRACKL_ENABLE_CUDA              "Enable CUDA backend"          OFF )
option( SIXTRACKL_ENABLE_MPFR4             "Enable GMP/MPFR4 backend"     OFF )

option( SIXTRACKL_ENABLE_CXX               "Enable C++ bindings"          ON  )
option( SIXTRACKL_ENABLE_PYTHON            "Enable Python bindings"       ON  )

# ------------------------------------------------------------------------------
# ---- Program logistic options:

option( SIXTRACKL_BUILD_EXAMPLES         "Build sixtracklib examples"     ON  )
option( SIXTRACKL_ENABLE_PROGRAMM_TESTS  "Enable programmatic unit-tests" OFF )
option( SIXTRACKL_ENABLE_BENCHMARK_TESTS "Enable benchmark tests"         OFF )