acts-project / algebra-plugins

Mozilla Public License 2.0
3 stars 10 forks source link

Repository Re-organisation, main branch (2021.10.15.) #27

Closed krasznaa closed 2 years ago

krasznaa commented 2 years ago

Unfortunately the code is not working correctly at the moment (more on that further down), but I thought I would still open a PR with all of these, just give time for people to familiarize themselves with what I've done.

What I started doing was to update the CMake configuration in traccc, to make sure that it could build SYCL code consistently with how vecmem builds SYCL code. (For the work that @konradkusiak97 will be doing.) But I had to realise that to do this, I would need to do some cleanup in every project. So I decided to start with this one...

Let's start with the main features of the "new" CMake configuration:

I have to say, I really don't like how the source code is laid out in the repository at the moment. So this PR re-organises that quite a bit as well. All (INTERFACE) libraries are now put into "top level directories" in the project. I also renamed the vecmem and vc directories to vecmem_array and vc_array, to be in sync with the names of the CMake libraries. Though I guess the synchronisation could've been done the other way around as well, by renaming the CMake libraries.

The libraries are now set up as follows:

I hope I understood the intent of the code correctly. Since I found it very confusing how ALGEBRA_PLUGIN_USE_VECMEM and ALGEBRA_PLUGIN_INCLUDE_VC are used in the configuration at the moment...

I also re-shuffled the unit test source files a bit, to reduce the "depth" of the project's directory structure a bit.

The packaging of the project works such, that when I build it with:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install -DALGEBRA_PLUGIN_INCLUDE_ARRAY=TRUE -DALGEBRA_PLUGIN_INCLUDE_EIGEN=TRUE -DALGEBRA_PLUGIN_SETUP_EIGEN3=TRUE -DALGEBRA_PLUGIN_USE_SYSTEM_EIGEN3=FALSE -DALGEBRA_PLUGIN_INCLUDE_VC=TRUE -DALGEBRA_PLUGIN_SETUP_VC=TRUE -DALGEBRA_PLUGIN_USE_SYSTEM_VC=FALSE -DALGEBRA_PLUGIN_INCLUDE_VECMEM=TRUE -DALGEBRA_PLUGIN_SETUP_VECMEM=TRUE -DALGEBRA_PLUGIN_USE_SYSTEM_VECMEM=FALSE ../algebra-plugins/

, I would get an installation like the following:

[bash][Legolas]:algebra-plugins > find install/ -maxdepth 3
install/
install/lib
install/lib/cmake
install/lib/cmake/algebra-plugins-0.1
install/lib/cmake/Vc
install/lib/cmake/vecmem-0.5.0
install/lib/libVc.a
install/lib/libvecmem_core.so.0.5.0
install/lib/libvecmem_core.so.0
install/lib/libvecmem_core.so
install/share
install/share/eigen3
install/share/eigen3/cmake
install/share/pkgconfig
install/share/pkgconfig/eigen3.pc
install/include
install/include/vecmem
install/include/vecmem/memory
install/include/vecmem/containers
install/include/vecmem/vecmem_core_export.hpp
install/include/vecmem/utils
install/include/eigen3
install/include/eigen3/unsupported
install/include/eigen3/Eigen
install/include/eigen3/signature_of_eigen3_matrix_library
install/include/algebra
install/include/algebra/definitions
install/include/algebra/common
install/include/Vc
install/include/Vc/vector.h
install/include/Vc/Allocator
install/include/Vc/version.h
install/include/Vc/array
install/include/Vc/IO
install/include/Vc/traits
install/include/Vc/cpuid.h
install/include/Vc/avx
install/include/Vc/vector
install/include/Vc/span
install/include/Vc/limits
install/include/Vc/support.h
install/include/Vc/sse
install/include/Vc/Utils
install/include/Vc/algorithm
install/include/Vc/Vc
install/include/Vc/type_traits
install/include/Vc/iterators
install/include/Vc/scalar
install/include/Vc/Memory
install/include/Vc/simdize
install/include/Vc/SimdArray
install/include/Vc/global.h
install/include/Vc/fwddecl.h
install/include/Vc/common
[bash][Legolas]:algebra-plugins >

And what's more, the project can even be set up successfully in a child project at that point.

[bash][Legolas]:test-build > more ../test/CMakeLists.txt                  

cmake_minimum_required( VERSION 3.10 )
project( AlgebraTest LANGUAGES CXX )

find_package( algebra-plugins REQUIRED )

[bash][Legolas]:test-build > cmake -DCMAKE_PREFIX_PATH=../install ../test/
-- The CXX compiler identification is GNU 9.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detected Compiler: GCC 9
-- Performing Test Vc_HAVE_SSE_SINCOS
-- Performing Test Vc_HAVE_SSE_SINCOS - Success
-- Performing Test Vc_HAVE_AVX_SINCOS
-- Performing Test Vc_HAVE_AVX_SINCOS - Success
-- Performing Test check_cxx_compiler_flag__Wabi
-- Performing Test check_cxx_compiler_flag__Wabi - Success
-- Performing Test check_cxx_compiler_flag__fabi_version_0
-- Performing Test check_cxx_compiler_flag__fabi_version_0 - Success
-- Performing Test check_cxx_compiler_flag__fabi_compat_version_0
-- Performing Test check_cxx_compiler_flag__fabi_compat_version_0 - Success
-- Performing Test check_cxx_compiler_flag__ffp_contract_fast
-- Performing Test check_cxx_compiler_flag__ffp_contract_fast - Success
-- target changed from "" to "auto"
-- Detected CPU: zen
-- Performing Test check_cxx_compiler_flag__march_znver1
-- Performing Test check_cxx_compiler_flag__march_znver1 - Success
-- Performing Test check_cxx_compiler_flag__msse2
-- Performing Test check_cxx_compiler_flag__msse2 - Success
-- Performing Test check_cxx_compiler_flag__msse3
-- Performing Test check_cxx_compiler_flag__msse3 - Success
-- Looking for C++ include pmmintrin.h
-- Looking for C++ include pmmintrin.h - found
-- Performing Test check_cxx_compiler_flag__mssse3
-- Performing Test check_cxx_compiler_flag__mssse3 - Success
-- Looking for C++ include tmmintrin.h
-- Looking for C++ include tmmintrin.h - found
-- Performing Test check_cxx_compiler_flag__msse4_1
-- Performing Test check_cxx_compiler_flag__msse4_1 - Success
-- Looking for C++ include smmintrin.h
-- Looking for C++ include smmintrin.h - found
-- Performing Test check_cxx_compiler_flag__msse4_2
-- Performing Test check_cxx_compiler_flag__msse4_2 - Success
-- Performing Test check_cxx_compiler_flag__msse4a
-- Performing Test check_cxx_compiler_flag__msse4a - Success
-- Looking for C++ include ammintrin.h
-- Looking for C++ include ammintrin.h - found
-- Performing Test check_cxx_compiler_flag__mavx
-- Performing Test check_cxx_compiler_flag__mavx - Success
-- Looking for C++ include immintrin.h
-- Looking for C++ include immintrin.h - found
-- Performing Test check_cxx_compiler_flag__mfma
-- Performing Test check_cxx_compiler_flag__mfma - Success
-- Performing Test check_cxx_compiler_flag__mbmi2
-- Performing Test check_cxx_compiler_flag__mbmi2 - Success
-- Performing Test check_cxx_compiler_flag__mavx2
-- Performing Test check_cxx_compiler_flag__mavx2 - Success
-- Performing Test check_cxx_compiler_flag__mno_xop
-- Performing Test check_cxx_compiler_flag__mno_xop - Success
-- Performing Test check_cxx_compiler_flag__mno_fma4
-- Performing Test check_cxx_compiler_flag__mno_fma4 - Success
-- Performing Test check_cxx_compiler_flag__mno_avx512f
-- Performing Test check_cxx_compiler_flag__mno_avx512f - Success
-- Performing Test check_cxx_compiler_flag__mno_avx512vl
-- Performing Test check_cxx_compiler_flag__mno_avx512vl - Success
-- Performing Test check_cxx_compiler_flag__mno_avx512pf
-- Performing Test check_cxx_compiler_flag__mno_avx512pf - Success
-- Performing Test check_cxx_compiler_flag__mno_avx512er
-- Performing Test check_cxx_compiler_flag__mno_avx512er - Success
-- Performing Test check_cxx_compiler_flag__mno_avx512cd
-- Performing Test check_cxx_compiler_flag__mno_avx512cd - Success
-- Performing Test check_cxx_compiler_flag__mno_avx512dq
-- Performing Test check_cxx_compiler_flag__mno_avx512dq - Success
-- Performing Test check_cxx_compiler_flag__mno_avx512bw
-- Performing Test check_cxx_compiler_flag__mno_avx512bw - Success
-- Performing Test check_cxx_compiler_flag__mno_avx512ifma
-- Performing Test check_cxx_compiler_flag__mno_avx512ifma - Success
-- Performing Test check_cxx_compiler_flag__mno_avx512vbmi
-- Performing Test check_cxx_compiler_flag__mno_avx512vbmi - Success
-- Found vecmem: /data/ssd-1tb/projects/algebra-plugins/install/lib/cmake/vecmem-0.5.0/vecmem-config.cmake (found version "0.5.0") 
-- Found algebra-plugins: /data/ssd-1tb/projects/algebra-plugins/install/lib/cmake/algebra-plugins-0.1/algebra-plugins-config.cmake (found version "0.1") 
-- Configuring done
-- Generating done
-- Build files have been written to: /data/ssd-1tb/projects/algebra-plugins/test-build
[bash][Legolas]:test-build > 

And finally, the elephant in the room... The CI doesn't actually work. Because of: https://gitlab.kitware.com/cmake/cmake/-/issues/22766 Or at least that's the best that I could identify the problem as. :frowning:

Still, that problem affects the current configuration as well. This configuration just identified the problem by attempting to use VecMem on macOS in the CI...

So... I'm curious about any feedback. :wink:

krasznaa commented 2 years ago

Weird that the tests didn't trigger automatically. I guess I'll need @niermann999 to sign off on starting the tests.

The "local ones" in my fork did run.

https://github.com/krasznaa/algebra-plugins/actions

That's how I know that there are problem... :frowning:

Also pinging @paulgessinger, so he would share in this fun as well. :stuck_out_tongue:

krasznaa commented 2 years ago

I now see that I'll also need to update the project's README.md as part of this PR. But I'll wait with that until it would seem that people are at large friendly towards these changes.

Also pinging @asalzburger. :wink:

paulgessinger commented 2 years ago

On the CI trigger not firing: that's really odd. I don't immediately have an idea why it wouldn't trigger.

beomki-yeo commented 2 years ago

That's what happened to detray. I think it is CI is trying to use master in build.yml. it will run normally once we change it to main.

krasznaa commented 2 years ago

And the point goes to Beomki! :smile: Indeed, the actions were set up to run on pull-requests into master and not into main...

niermann999 commented 2 years ago

I am always happy about help with cmake!

krasznaa commented 2 years ago

Let me try to further debug the issue with the new hints from https://gitlab.kitware.com/cmake/cmake/-/issues/22766. I may be able to make this PR fully functional after all... So let's wait with it just a little longer... :wink:

krasznaa commented 2 years ago

The macOS tests still have to start, but I believe the builds will succeed this time around.

As scary as this sounds, the problem was with the order in which the externals were set up. :frowning: When building GoogleTest at first, that is the one that first "pulls in" some of the files that use try_compile to determine what the build system is capable of doing.

And the very latest version of googletest still only requires a minimum of CMake 3.5.

https://github.com/google/googletest/blob/master/CMakeLists.txt#L4

Which, to be fair, is very understandable from their side.

So when check_cxx_source_compiles is used for the first time during the configuration, because of the CMake 3.5 requirement, CMP0067 is "frozen into" the OLD value. :frowning: Even though vecmem is very clear that it needs at least CMake 3.10...

So... for now I just reversed the include-order of googletest and vecmem. Which is a super fragile thing to have to do to make the build work, I absolutely agree. But I think this is the best that we can do for the moment... :thinking:

We will also need to look out for this with all the other projects. But I'll take a look at those as well myself as well.

krasznaa commented 2 years ago

Okay, the PR is ready to be merged from my side. :wink:

krasznaa commented 2 years ago

Unfortunately I could just not get rid of:

CMake Deprecation Warning at /home/krasznaa/ATLAS/projects/algebra-plugins/build/_deps/eigen3-src/CMakeLists.txt:3 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

:frowning: This one can only be disabled from the command line, with -Wno-dev. It can not be influenced by any (cache) variable. :frowning:

Still, the Eigen build looks a bit better with at least the

CMake Warning (dev) at /atlas/software/cmake/3.21.3/x86_64-ubuntu1804-gcc7-opt/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (CHOLMOD)
  does not match the name of the calling package (Cholmod).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  /home/krasznaa/ATLAS/projects/algebra-plugins/build/_deps/eigen3-src/cmake/FindCholmod.cmake:86 (find_package_handle_standard_args)
  /home/krasznaa/ATLAS/projects/algebra-plugins/build/_deps/eigen3-src/bench/spbench/CMakeLists.txt:16 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

type of warnings gone. Which you can still turn on by calling CMake explicitly with -Wdev when configuring this project.

krasznaa commented 2 years ago

I don't have modification rights for this repository, so if you're happy, you should press the merge button Joana. :wink: