apt-sim / AdePT

Accelerated demonstrator of electromagnetic Particle Transport
Apache License 2.0
25 stars 34 forks source link

Minimal implementation of in-memory Geant4->VecGeom conversion with G4VG #289

Open drbenmorgan opened 4 months ago

drbenmorgan commented 4 months ago

This implements the minimal code/link to use G4VG for converting a Geant4 G4VPhysicalVolume to vecgeom::VPlacedVolume in-memory without an intermediary GDML file. Because of the link to CUDA-enabled VecGeom, the link structure originally trialled in #279 is also implemented, and now works properly thanks to the work done removing the old circular dependency described in that PR. Note that it's certain we'll need the --no-as-needed trick for linkers that use as-needed by default, but first things first. The major changes are thus:

  1. Import the CudaRdcUtils and FindVecGeom modules from Celeritas to support coherent linking/device linking of VecGeom into Cuda clients.
  2. Use and export the functions to compile and link the AdePT libraries/tests
  3. Move import of G4VG to top level and bump to latest upstream commit which better supports use and install
  4. Implement AdePTGeant4Integration::CreateVecGeomWorld(const G4VPhysicalVolume *physvol) to take the input Geant4 volume and convert to VecGeom using G4VG's interface.

Because of the linking issues seen before I haven't gone further yet in migrating the code to use CreateVecGeomWorld. I'd like to get a round of CI in first just to be sure there's no other issue. We then should confirm/decide how to solve the as-needed issue. Whilst it's a bit of a blunt instrument, we probably just link AdePT_G4_integration with -Wl,--no-as-needed, and perhaps enforce downstream clients to use that as well.

Supersedes #279 and #285.

phsft-bot commented 4 months ago

Can one of the admins verify this patch?

drbenmorgan commented 4 months ago

Following discussion this morning, I've submitted celeritas-project/g4vg#7 which fixes the install issue (G4VG cannot be re-found). Once that's merged I'll up this PR to use the new commit.

drbenmorgan commented 4 months ago

Latest commits update the G4VG commit to that providing full install support, so

find_package(AdePT)

in client code will now work without errors.

andresailer commented 4 months ago

I updated one of the GPU machines to alma9 (in view of centos7 going EOL), which caused your jenkins build to fail. I will submit a PR for the CI to use the new OS tomorrow I hope.

JuanGonzalezCaminero commented 4 months ago

Hi Ben, I get the same DSO Missing from command line link error we were seeing in your last PR, related to building in Debian. target_link_options(example1 PRIVATE "-Wl,--no-as-needed") solves it for me

JuanGonzalezCaminero commented 4 months ago

I haven't been able to link to AdePT from an external project because of find_dependency(G4VG REQUIRED) in AdePTConfig.cmake. Can this line actually work with the current way of pulling g4vg into adept?

drbenmorgan commented 4 months ago

Latest commit should fix the as-needed issue!

I haven't been able to link to AdePT from an external project because of find_dependency(G4VG REQUIRED) in AdePTConfig.cmake. Can this line actually work with the current way of pulling g4vg into adept?

The latest commit which this MR includes for G4VG should install a G4VGConfig.cmake file that addresses this. How are you installing and then pointing the project to the AdePT install?

JuanGonzalezCaminero commented 4 months ago

I see, I can't find G4VGConfig.cmake in the installation directory, I have:

AdePTConfig.cmake AdePTTargets.cmake AdePTTargets-release.cmake CudaRdcUtils.cmake FindVecGeom.cmake

JuanGonzalezCaminero commented 4 months ago

G4VGConfig.cmake is generated in the build directory, in _deps/g4vg-build, but apparently not installed with the rest of AdePT

drbenmorgan commented 4 months ago

It's installed parallel, so the structure is something like:

<CMAKE_INSTALL_PREFIX>
├── include
│   ├── ...headers
└── lib64
    ├── cmake
    │   ├── AdePT
    │   │   ├── AdePTConfig.cmake
    │   │   ├── AdePTTargets-relwithdebinfo.cmake
    │   │   ├── AdePTTargets.cmake
    │   │   ├── CudaRdcUtils.cmake
    │   │   └── FindVecGeom.cmake
    │   └── G4VG
    │       ├── G4VGConfig.cmake
    │       ├── G4VGConfigVersion.cmake
    │       ├── G4VGTargets-relwithdebinfo.cmake
    │       └── G4VGTargets.cmake
    ├── libAdePT_G4_integration.so
    ├── libAdePT_G4_integration_final.so
    ├── libAdePT_G4_integration_static.a
    └── libg4vg.so

Check that you have those, if not, try a from-scratch build just in case it's retained the older G4VG. The only other thing is to check that you're configuring the external project with CMAKE_PREFIX_PATH set to the prefix under which you installed AdePT (AdePT_DIR won't work in this case).

JuanGonzalezCaminero commented 4 months ago

I see, I did try a build from scratch several times but the G4VG directory is not there, building from the latest commit ef45fed.

I'm configuring the project with: cmake -S. -B./build -DCMAKE_PREFIX_PATH="..." -DCMAKE_INSTALL_PREFIX="../adept_install" -DCMAKE_CUDA_ARCHITECTURES=... -DCMAKE_BUILD_TYPE=Release, in case I'm missing an option

drbenmorgan commented 4 months ago

Those options look fine, what gets printed when you do make install for AdePT? This should list all the files that get installed. Locally, with that same ef45fed commit, I get (with ninja, but make should print the same)

$ ninja install
[0/1] Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /.../lib64/libg4vg.so
-- Set runtime path of "/.../lib64/libg4vg.so" to ""
-- Installing: /.../include
-- Installing: /.../include/G4VG.hh
-- Installing: /.../lib64/cmake/G4VG/G4VGConfigVersion.cmake
-- Installing: /.../lib64/cmake/G4VG/G4VGConfig.cmake
-- Installing: /.../lib64/cmake/G4VG/G4VGTargets.cmake
-- Installing: /.../lib64/cmake/G4VG/G4VGTargets-relwithdebinfo.cmake
-- Installing: /.../lib64/libAdePT_G4_integration_final.so
-- Set runtime path of "/.../lib64/libAdePT_G4_integration_final.so" to ""
-- Installing: /.../lib64/libAdePT_G4_integration_static.a
-- Installing: /.../lib64/libAdePT_G4_integration.so
-- Set runtime path of "/.../lib64/libAdePT_G4_integration.so" to ""
-- Installing: /.../include/AdePT
-- Installing: /.../include/AdePT/base
-- Installing: /.../include/AdePT/base/ArgParser.h
-- Installing: /.../include/AdePT/base/Atomic.h
-- Installing: /.../include/AdePT/base/BlockData.h
-- Installing: /.../include/AdePT/base/MParray.h
-- Installing: /.../include/AdePT/base/MParrayT.h
-- Installing: /.../include/AdePT/base/TrackManager.cuh
-- Installing: /.../include/AdePT/base/Utils.h
-- Installing: /.../include/AdePT/base/mpmc_bounded_queue.h
-- Installing: /.../include/AdePT/benchmarking
-- Installing: /.../include/AdePT/benchmarking/NVTX.h
-- Installing: /.../include/AdePT/benchmarking/TestManager.h
-- Installing: /.../include/AdePT/benchmarking/TestManagerStore.h
-- Installing: /.../include/AdePT/copcore
-- Installing: /.../include/AdePT/copcore/Allocator.h
-- Installing: /.../include/AdePT/copcore/CopCore.h
-- Installing: /.../include/AdePT/copcore/Global.h
-- Installing: /.../include/AdePT/copcore/Macros.h
-- Installing: /.../include/AdePT/copcore/PhysicalConstants.h
-- Installing: /.../include/AdePT/copcore/Ranluxpp.h
-- Installing: /.../include/AdePT/copcore/SystemOfUnits.h
-- Installing: /.../include/AdePT/copcore/VariableSizeObj.h
-- Installing: /.../include/AdePT/copcore/VariableSizeObjAllocator.h
-- Installing: /.../include/AdePT/copcore/ranluxpp
-- Installing: /.../include/AdePT/copcore/ranluxpp/helpers.h
-- Installing: /.../include/AdePT/copcore/ranluxpp/mulmod.h
-- Installing: /.../include/AdePT/copcore/ranluxpp/ranlux_lcg.h
-- Installing: /.../include/AdePT/core
-- Installing: /.../include/AdePT/core/AdePTConfiguration.hh
-- Installing: /.../include/AdePT/core/AdePTScoringTemplate.cuh
-- Installing: /.../include/AdePT/core/AdePTTransport.cuh
-- Installing: /.../include/AdePT/core/AdePTTransport.h
-- Installing: /.../include/AdePT/core/AdePTTransport.icc
-- Installing: /.../include/AdePT/core/AdePTTransportStruct.cuh
-- Installing: /.../include/AdePT/core/CommonStruct.h
-- Installing: /.../include/AdePT/core/HostScoringImpl.cuh
-- Installing: /.../include/AdePT/core/HostScoringStruct.cuh
-- Installing: /.../include/AdePT/core/Track.cuh
-- Installing: /.../include/AdePT/core/TrackData.h
-- Installing: /.../include/AdePT/integration
-- Installing: /.../include/AdePT/integration/AdePTConfigurationMessenger.hh
-- Installing: /.../include/AdePT/integration/AdePTPhysics.hh
-- Installing: /.../include/AdePT/integration/AdePTTrackingManager.hh
-- Installing: /.../include/AdePT/integration/HepEMPhysics.hh
-- Installing: /.../include/AdePT/integration/AdePTGeant4Integration.hh
-- Installing: /.../include/AdePT/kernels
-- Installing: /.../include/AdePT/kernels/electrons.cuh
-- Installing: /.../include/AdePT/kernels/gammas.cuh
-- Installing: /.../include/AdePT/magneticfield
-- Installing: /.../include/AdePT/magneticfield/CompareResponses.h
-- Installing: /.../include/AdePT/magneticfield/ConstBzFieldStepper.h
-- Installing: /.../include/AdePT/magneticfield/ConstFieldHelixStepper.h
-- Installing: /.../include/AdePT/magneticfield/DormandPrinceRK45.h
-- Installing: /.../include/AdePT/magneticfield/ErrorEstimatorRK.h
-- Installing: /.../include/AdePT/magneticfield/MagneticFieldEquation.h
-- Installing: /.../include/AdePT/magneticfield/PrintFieldVectors.h
-- Installing: /.../include/AdePT/magneticfield/RkIntegrationDriver.h
-- Installing: /.../include/AdePT/magneticfield/UniformMagneticField.h
-- Installing: /.../include/AdePT/magneticfield/fieldConstants.h
-- Installing: /.../include/AdePT/magneticfield/fieldPropagatorConstBany.h
-- Installing: /.../include/AdePT/magneticfield/fieldPropagatorConstBz.h
-- Installing: /.../include/AdePT/magneticfield/fieldPropagatorRungeKutta.h
-- Installing: /.../include/AdePT/navigation
-- Installing: /.../include/AdePT/navigation/BVHNavigator.h
-- Installing: /.../include/AdePT/navigation/LoopNavigator.h
-- Installing: /.../include/AdePT/navigation/SurfNavigator.h
-- Installing: /.../lib64/cmake/AdePT/AdePTConfig.cmake
-- Installing: /.../lib64/cmake/AdePT/CudaRdcUtils.cmake
-- Installing: /.../lib64/cmake/AdePT/FindVecGeom.cmake
-- Installing: /.../lib64/cmake/AdePT/AdePTTargets.cmake
-- Installing: /.../lib64/cmake/AdePT/AdePTTargets-relwithdebinfo.cmake
JuanGonzalezCaminero commented 4 months ago

In my case, I have everything except for the G4VG lines:

Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /.../lib/libAdePT_G4_integration_final.so
-- Set non-toolchain portion of runtime path of "/.../lib/libAdePT_G4_integration_final.so" to ""
-- Installing: /.../lib/libAdePT_G4_integration_static.a
-- Installing: /.../lib/libAdePT_G4_integration.so
-- Set non-toolchain portion of runtime path of "/.../lib/libAdePT_G4_integration.so" to ""
-- Installing: /.../include/AdePT
-- Installing: /.../include/AdePT/magneticfield
-- Installing: /.../include/AdePT/magneticfield/ErrorEstimatorRK.h
-- Installing: /.../include/AdePT/magneticfield/fieldConstants.h
-- Installing: /.../include/AdePT/magneticfield/fieldPropagatorConstBz.h
-- Installing: /.../include/AdePT/magneticfield/fieldPropagatorConstBany.h
-- Installing: /.../include/AdePT/magneticfield/RkIntegrationDriver.h
-- Installing: /.../include/AdePT/magneticfield/ConstFieldHelixStepper.h
-- Installing: /.../include/AdePT/magneticfield/DormandPrinceRK45.h
-- Installing: /.../include/AdePT/magneticfield/CompareResponses.h
-- Installing: /.../include/AdePT/magneticfield/PrintFieldVectors.h
-- Installing: /.../include/AdePT/magneticfield/fieldPropagatorRungeKutta.h
-- Installing: /.../include/AdePT/magneticfield/MagneticFieldEquation.h
-- Installing: /.../include/AdePT/magneticfield/UniformMagneticField.h
-- Installing: /.../include/AdePT/magneticfield/ConstBzFieldStepper.h
-- Installing: /.../include/AdePT/base
-- Installing: /.../include/AdePT/base/ArgParser.h
-- Installing: /.../include/AdePT/base/BlockData.h
-- Installing: /.../include/AdePT/base/TrackManager.cuh
-- Installing: /.../include/AdePT/base/mpmc_bounded_queue.h
-- Installing: /.../include/AdePT/base/Atomic.h
-- Installing: /.../include/AdePT/base/MParray.h
-- Installing: /.../include/AdePT/base/MParrayT.h
-- Installing: /.../include/AdePT/base/Utils.h
-- Installing: /.../include/AdePT/benchmarking
-- Installing: /.../include/AdePT/benchmarking/TestManagerStore.h
-- Installing: /.../include/AdePT/benchmarking/NVTX.h
-- Installing: /.../include/AdePT/benchmarking/TestManager.h
-- Installing: /.../include/AdePT/integration
-- Installing: /.../include/AdePT/integration/AdePTTrackingManager.hh
-- Installing: /.../include/AdePT/integration/HepEMPhysics.hh
-- Installing: /.../include/AdePT/integration/AdePTPhysics.hh
-- Installing: /.../include/AdePT/integration/AdePTConfigurationMessenger.hh
-- Installing: /.../include/AdePT/integration/AdePTGeant4Integration.hh
-- Installing: /.../include/AdePT/copcore
-- Installing: /.../include/AdePT/copcore/CopCore.h
-- Installing: /.../include/AdePT/copcore/PhysicalConstants.h
-- Installing: /.../include/AdePT/copcore/Global.h
-- Installing: /.../include/AdePT/copcore/VariableSizeObj.h
-- Installing: /.../include/AdePT/copcore/Macros.h
-- Installing: /.../include/AdePT/copcore/VariableSizeObjAllocator.h
-- Installing: /.../include/AdePT/copcore/SystemOfUnits.h
-- Installing: /.../include/AdePT/copcore/Ranluxpp.h
-- Installing: /.../include/AdePT/copcore/ranluxpp
-- Installing: /.../include/AdePT/copcore/ranluxpp/ranlux_lcg.h
-- Installing: /.../include/AdePT/copcore/ranluxpp/helpers.h
-- Installing: /.../include/AdePT/copcore/ranluxpp/mulmod.h
-- Installing: /.../include/AdePT/copcore/Allocator.h
-- Installing: /.../include/AdePT/navigation
-- Installing: /.../include/AdePT/navigation/BVHNavigator.h
-- Installing: /.../include/AdePT/navigation/SurfNavigator.h
-- Installing: /.../include/AdePT/navigation/LoopNavigator.h
-- Installing: /.../include/AdePT/kernels
-- Installing: /.../include/AdePT/kernels/electrons.cuh
-- Installing: /.../include/AdePT/kernels/gammas.cuh
-- Installing: /.../include/AdePT/core
-- Installing: /.../include/AdePT/core/TrackData.h
-- Installing: /.../include/AdePT/core/AdePTTransport.cuh
-- Installing: /.../include/AdePT/core/AdePTTransport.h
-- Installing: /.../include/AdePT/core/CommonStruct.h
-- Installing: /.../include/AdePT/core/HostScoringStruct.cuh
-- Installing: /.../include/AdePT/core/AdePTTransport.icc
-- Installing: /.../include/AdePT/core/AdePTTransportStruct.cuh
-- Installing: /.../include/AdePT/core/AdePTScoringTemplate.cuh
-- Installing: /.../include/AdePT/core/Track.cuh
-- Installing: /.../include/AdePT/core/AdePTConfiguration.hh
-- Installing: /.../include/AdePT/core/HostScoringImpl.cuh
-- Installing: /.../lib/cmake/AdePT/AdePTConfig.cmake
-- Installing: /.../lib/cmake/AdePT/CudaRdcUtils.cmake
-- Installing: /.../lib/cmake/AdePT/FindVecGeom.cmake
-- Installing: /.../lib/cmake/AdePT/AdePTTargets.cmake
-- Installing: /.../lib/cmake/AdePT/AdePTTargets-relwithdebinfo.cmake

git log -1
commit ef45fed89eb842a032cee0bc34b59b95644e0a0c (HEAD -> g4vg)
...
WitekPokorski commented 4 months ago

I am getting the right directory structure (like Ben), however, it fails to link the tests:

[ 51%] Linking CXX executable ../BuildProducts/bin/test_g4vg_link /usr/local/bin/ld: warning: libG4analysis.so, needed by /home/witoldp/Geant4/installation/lib64/libG4processes.so, not found (try using -rpath or -rpath-link) /usr/local/bin/ld: warning: libG4zlib.so, needed by /home/witoldp/Geant4/installation/lib64/libG4processes.so, not found (try using -rpath or -rpath-link) /usr/local/bin/ld: /home/witoldp/Geant4/installation/lib64/libG4processes.so: undefined reference to G4VAnalysisManager::CreateNtupleSColumn(int, G4String const&)' /usr/local/bin/ld: /home/witoldp/Geant4/installation/lib64/libG4processes.so: undefined reference toG4VAnalysisManager::CreateNtupleIColumn(int, G4String const&)' /usr/local/bin/ld: /home/witoldp/Geant4/installation/lib64/libG4processes.so: undefined reference to G4VAnalysisManager::FinishNtuple(int)' /usr/local/bin/ld: /home/witoldp/Geant4/installation/lib64/libG4processes.so: undefined reference toG4BaseFileManager::GetFileType() const' /usr/local/bin/ld: /home/witoldp/Geant4/installation/lib64/libG4processes.so: undefined reference to G4VAnalysisManager::OpenFile(G4String const&)' /usr/local/bin/ld: /home/witoldp/Geant4/installation/lib64/libG4processes.so: undefined reference toG4VAnalysisManager::CreateNtuple(G4String const&, G4String const&)' /usr/local/bin/ld: /home/witoldp/Geant4/installation/lib64/libG4processes.so: undefined reference to `G4VAnalysisManager::CreateNtupleDColumn(int, G4String const&)' collect2: error: ld returned 1 exit status make[2]: *** [test/CMakeFiles/test_g4vg_link.dir/build.make:98: BuildProducts/bin/test_g4vg_link] Error 1

This is very strange, because libG4analysis.so is in the same directory as libG4processes.so, so I don't understand why it can't link.

drbenmorgan commented 4 months ago

@JuanGonzalezCaminero though I know that you did a fresh build, all I can think of is that the old G4VG version is still present. Could you confirm that you fully deleted the build directory (i.e. not just a "make clean") and then re-cmaked from a completely empty directory? Which CMake version are you using?

@WitekPokorski that's very weird... Which Linux/gcc/CMake and Geant4 versions are you using?

WitekPokorski commented 4 months ago

RHEL9, gcc (GCC) 12.3.0, cmake version 3.27.4, G4.11.1.2

drbenmorgan commented 4 months ago

Thanks! I'll set up this locally (Rocky 9, but close enough) and see if I can reproduce.

drbenmorgan commented 4 months ago

@WitekPokorski, I think there is an issue in G4VG, but to help track this down, could you do a fresh build of AdePT (just run make clean first) and post the output of the link steps for

$ make g4vg VERBOSE=1

and

$ make test_g4vg_link VERBOSE=1 

please? Also, when you've done those, what's the output of

$ ldd BuildProducts/lib64/libg4vg.so

and

$ readelf -d BuildProducts/lib64/libg4vg.so

please?

WitekPokorski commented 4 months ago

make -f _deps/g4vg-build/src/CMakeFiles/g4vg.dir/build.make _deps/g4vg-build/src/CMakeFiles/g4vg.dir/depend make[3]: Entering directory '/home/witoldp/test_g4gv/AdePT/build' cd /home/witoldp/test_g4gv/AdePT/build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/witoldp/test_g4gv/AdePT /home/witoldp/test_g4gv/AdePT/build/_deps/g4vg-src/src /home/witoldp/test_g4gv/AdePT/build /home/witoldp/test_g4gv/AdePT/build/_deps/g4vg-build/src /home/witoldp/test_g4gv/AdePT/build/_deps/g4vg-build/src/CMakeFiles/g4vg.dir/DependInfo.cmake "--color=" make[3]: Leaving directory '/home/witoldp/test_g4gv/AdePT/build' make -f _deps/g4vg-build/src/CMakeFiles/g4vg.dir/build.make _deps/g4vg-build/src/CMakeFiles/g4vg.dir/build make[3]: Entering directory '/home/witoldp/test_g4gv/AdePT/build' [100%] Building CXX object _deps/g4vg-build/src/CMakeFiles/g4vg.dir/G4VG.cc.o cd /home/witoldp/test_g4gv/AdePT/build/_deps/g4vg-build/src && /usr/bin/c++ -DHEPMC3_FOUND -Dg4vg_EXPORTS -I/home/witoldp/test_g4gv/AdePT/build/_deps/g4vg-src/src -I/home/witoldp/test_g4gv/AdePT/build/_deps/celeritas-src/src -I/home/witoldp/test_g4gv/AdePT/build/_deps/celeritas-build/include -O2 -g -DNDEBUG -std=c++17 -fPIC -MD -MT _deps/g4vg-build/src/CMakeFiles/g4vg.dir/G4VG.cc.o -MF CMakeFiles/g4vg.dir/G4VG.cc.o.d -o CMakeFiles/g4vg.dir/G4VG.cc.o -c /home/witoldp/test_g4gv/AdePT/build/_deps/g4vg-src/src/G4VG.cc [100%] Linking CXX shared library ../../../BuildProducts/lib64/libg4vg.so cd /home/witoldp/test_g4gv/AdePT/build/_deps/g4vg-build/src && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/g4vg.dir/link.txt --verbose=1 /usr/bin/c++ -fPIC -O2 -g -DNDEBUG -shared -Wl,-soname,libg4vg.so -o ../../../BuildProducts/lib64/libg4vg.so CMakeFiles/g4vg.dir/G4VG.cc.o -Wl,-rpath,/home/witoldp/Geant4/installation/lib64:/usr/local/lib64:/home/witoldp/VecGeom/installation/lib64: ../../celeritas-build/lib64/libgeocel.a /home/witoldp/Geant4/installation/lib64/libG4persistency.so /home/witoldp/Geant4/installation/lib64/libG4run.so /home/witoldp/Geant4/installation/lib64/libG4event.so /home/witoldp/Geant4/installation/lib64/libG4tracking.so /home/witoldp/Geant4/installation/lib64/libG4processes.so /home/witoldp/Geant4/installation/lib64/libG4digits_hits.so /home/witoldp/Geant4/installation/lib64/libG4track.so /home/witoldp/Geant4/installation/lib64/libG4geometry.so /home/witoldp/Geant4/installation/lib64/libG4graphics_reps.so /home/witoldp/Geant4/installation/lib64/libG4materials.so /home/witoldp/Geant4/installation/lib64/libG4particles.so /home/witoldp/Geant4/installation/lib64/libG4expat.so /home/witoldp/Geant4/installation/lib64/libG4intercoms.so /home/witoldp/Geant4/installation/lib64/libG4global.so /home/witoldp/Geant4/installation/lib64/libG4clhep.so /home/witoldp/Geant4/installation/lib64/libG4ptl.so.2.3.3 /home/witoldp/VecGeom/installation/lib64/libvgdml.a /usr/local/lib64/libxerces-c.so /home/witoldp/VecGeom/installation/lib64/libvecgeomcuda.so /home/witoldp/VecGeom/installation/lib64/libvecgeom.a -lrt -lpthread -ldl ../../celeritas-build/lib64/libcorecel.a -Wl,-rpath-link,/home/witoldp/Geant4/installation/lib64 make[3]: Leaving directory '/home/witoldp/test_g4gv/AdePT/build' [100%] Built target g4vg make[2]: Leaving directory '/home/witoldp/test_g4gv/AdePT/build' /usr/local/bin/cmake -E cmake_progress_start /home/witoldp/test_g4gv/AdePT/build/CMakeFiles 0 make[1]: Leaving directory '/home/witoldp/test_g4gv/AdePT/build'

WitekPokorski commented 4 months ago

Consolidate compiler generated dependencies of target g4vg make[3]: Leaving directory '/home/witoldp/test_g4gv/AdePT/build' make -f _deps/g4vg-build/src/CMakeFiles/g4vg.dir/build.make _deps/g4vg-build/src/CMakeFiles/g4vg.dir/build make[3]: Entering directory '/home/witoldp/test_g4gv/AdePT/build' make[3]: Nothing to be done for '_deps/g4vg-build/src/CMakeFiles/g4vg.dir/build'. make[3]: Leaving directory '/home/witoldp/test_g4gv/AdePT/build' [ 93%] Built target g4vg make -f test/CMakeFiles/test_g4vg_link.dir/build.make test/CMakeFiles/test_g4vg_link.dir/depend make[3]: Entering directory '/home/witoldp/test_g4gv/AdePT/build' cd /home/witoldp/test_g4gv/AdePT/build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/witoldp/test_g4gv/AdePT /home/witoldp/test_g4gv/AdePT/test /home/witoldp/test_g4gv/AdePT/build /home/witoldp/test_g4gv/AdePT/build/test /home/witoldp/test_g4gv/AdePT/build/test/CMakeFiles/test_g4vg_link.dir/DependInfo.cmake "--color=" make[3]: Leaving directory '/home/witoldp/test_g4gv/AdePT/build' make -f test/CMakeFiles/test_g4vg_link.dir/build.make test/CMakeFiles/test_g4vg_link.dir/build make[3]: Entering directory '/home/witoldp/test_g4gv/AdePT/build' [100%] Building CXX object test/CMakeFiles/test_g4vg_link.dir/test_g4vg_link.cpp.o cd /home/witoldp/test_g4gv/AdePT/build/test && /usr/bin/c++ -DHEPMC3_FOUND -DVECCORE_ENABLE_CUDA -I/home/witoldp/test_g4gv/AdePT/build/_deps/g4vg-src/src -isystem /home/witoldp/VecGeom/installation/include -isystem /home/witoldp/VecCore/installation/include -isystem /usr/local/cuda-12.4/include -O2 -g -DNDEBUG -std=c++17 -faligned-new -msse2 -MD -MT test/CMakeFiles/test_g4vg_link.dir/test_g4vg_link.cpp.o -MF CMakeFiles/test_g4vg_link.dir/test_g4vg_link.cpp.o.d -o CMakeFiles/test_g4vg_link.dir/test_g4vg_link.cpp.o -c /home/witoldp/test_g4gv/AdePT/test/test_g4vg_link.cpp [100%] Linking CXX executable ../BuildProducts/bin/test_g4vg_link cd /home/witoldp/test_g4gv/AdePT/build/test && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/test_g4vg_link.dir/link.txt --verbose=1 /usr/bin/c++ -O2 -g -DNDEBUG -Wl,--no-as-needed CMakeFiles/test_g4vg_link.dir/test_g4vg_link.cpp.o -o ../BuildProducts/bin/test_g4vg_link -Wl,-rpath,/home/witoldp/test_g4gv/AdePT/build/BuildProducts/lib64:/home/witoldp/VecGeom/installation/lib64 ../BuildProducts/lib64/libg4vg.so /home/witoldp/VecGeom/installation/lib64/libvecgeomcuda.so /home/witoldp/VecGeom/installation/lib64/libvecgeom.a -lrt -lpthread -ldl /usr/local/bin/ld: warning: libG4analysis.so, needed by /home/witoldp/Geant4/installation/lib64/libG4processes.so, not found (try using -rpath or -rpath-link) /usr/local/bin/ld: warning: libG4zlib.so, needed by /home/witoldp/Geant4/installation/lib64/libG4processes.so, not found (try using -rpath or -rpath-link) /usr/local/bin/ld: /home/witoldp/Geant4/installation/lib64/libG4processes.so: undefined reference toG4VAnalysisManager::CreateNtupleSColumn(int, G4String const&)' /usr/local/bin/ld: /home/witoldp/Geant4/installation/lib64/libG4processes.so: undefined reference to G4VAnalysisManager::CreateNtupleIColumn(int, G4String const&)' /usr/local/bin/ld: /home/witoldp/Geant4/installation/lib64/libG4processes.so: undefined reference toG4VAnalysisManager::FinishNtuple(int)' /usr/local/bin/ld: /home/witoldp/Geant4/installation/lib64/libG4processes.so: undefined reference to G4BaseFileManager::GetFileType() const' /usr/local/bin/ld: /home/witoldp/Geant4/installation/lib64/libG4processes.so: undefined reference toG4VAnalysisManager::OpenFile(G4String const&)' /usr/local/bin/ld: /home/witoldp/Geant4/installation/lib64/libG4processes.so: undefined reference to G4VAnalysisManager::CreateNtuple(G4String const&, G4String const&)' /usr/local/bin/ld: /home/witoldp/Geant4/installation/lib64/libG4processes.so: undefined reference toG4VAnalysisManager::CreateNtupleDColumn(int, G4String const&)' collect2: error: ld returned 1 exit status make[3]: [test/CMakeFiles/test_g4vg_link.dir/build.make:98: BuildProducts/bin/test_g4vg_link] Error 1 make[3]: Leaving directory '/home/witoldp/test_g4gv/AdePT/build' make[2]: [CMakeFiles/Makefile2:1712: test/CMakeFiles/test_g4vg_link.dir/all] Error 2 make[2]: Leaving directory '/home/witoldp/test_g4gv/AdePT/build' make[1]: [CMakeFiles/Makefile2:1719: test/CMakeFiles/test_g4vg_link.dir/rule] Error 2 make[1]: Leaving directory '/home/witoldp/test_g4gv/AdePT/build' make: [Makefile:790: test_g4vg_link] Error 2 `

WitekPokorski commented 4 months ago

[witoldp@omenrtx ~/test_g4gv/AdePT/build]$ ldd BuildProducts/lib64/libg4vg.so linux-vdso.so.1 (0x00007ffcd1ae8000) libG4persistency.so => /home/witoldp/Geant4/installation/lib64/libG4persistency.so (0x00007fdc17d2b000) libG4run.so => /home/witoldp/Geant4/installation/lib64/libG4run.so (0x00007fdc17918000) libG4event.so => /home/witoldp/Geant4/installation/lib64/libG4event.so (0x00007fdc17896000) libG4tracking.so => /home/witoldp/Geant4/installation/lib64/libG4tracking.so (0x00007fdc17838000) libG4processes.so => /home/witoldp/Geant4/installation/lib64/libG4processes.so (0x00007fdc15c00000) libG4digits_hits.so => /home/witoldp/Geant4/installation/lib64/libG4digits_hits.so (0x00007fdc1775f000) libG4track.so => /home/witoldp/Geant4/installation/lib64/libG4track.so (0x00007fdc17d0c000) libG4geometry.so => /home/witoldp/Geant4/installation/lib64/libG4geometry.so (0x00007fdc15800000) libG4graphics_reps.so => /home/witoldp/Geant4/installation/lib64/libG4graphics_reps.so (0x00007fdc17709000) libG4materials.so => /home/witoldp/Geant4/installation/lib64/libG4materials.so (0x00007fdc15b0f000) libG4particles.so => /home/witoldp/Geant4/installation/lib64/libG4particles.so (0x00007fdc156c2000) libG4expat.so => /home/witoldp/Geant4/installation/lib64/libG4expat.so (0x00007fdc1568f000) libG4intercoms.so => /home/witoldp/Geant4/installation/lib64/libG4intercoms.so (0x00007fdc1561b000) libG4global.so => /home/witoldp/Geant4/installation/lib64/libG4global.so (0x00007fdc15594000) libG4clhep.so => /home/witoldp/Geant4/installation/lib64/libG4clhep.so (0x00007fdc154ed000) libG4ptl.so.2 => /home/witoldp/Geant4/installation/lib64/libG4ptl.so.2 (0x00007fdc17cdc000) libxerces-c-3.2.so => /usr/local/lib64/libxerces-c-3.2.so (0x00007fdc15000000) libvecgeomcuda.so => /home/witoldp/VecGeom/installation/lib64/libvecgeomcuda.so (0x00007fdc13400000) libstdc++.so.6 => /usr/local/lib64/libstdc++.so.6 (0x00007fdc13000000) libm.so.6 => /lib64/libm.so.6 (0x00007fdc14f25000) libgcc_s.so.1 => /usr/local/lib64/libgcc_s.so.1 (0x00007fdc154cc000) libc.so.6 => /lib64/libc.so.6 (0x00007fdc12c00000) /lib64/ld-linux-x86-64.so.2 (0x00007fdc17e8a000) libG4analysis.so => /home/witoldp/Geant4/installation/lib64/libG4analysis.so (0x00007fdc12600000) libG4zlib.so => /home/witoldp/Geant4/installation/lib64/libG4zlib.so (0x00007fdc154ae000) libcurl.so.4 => /lib64/libcurl.so.4 (0x00007fdc1335f000) libicuuc.so.67 => /lib64/libicuuc.so.67 (0x00007fdc12e15000) libicudata.so.67 => /lib64/libicudata.so.67 (0x00007fdc10a00000) libcudart.so.12 => /usr/local/cuda-12.4/lib64/libcudart.so.12 (0x00007fdc10600000) libnghttp2.so.14 => /lib64/libnghttp2.so.14 (0x00007fdc14efb000) libidn2.so.0 => /lib64/libidn2.so.0 (0x00007fdc1548d000) libssh.so.4 => /lib64/libssh.so.4 (0x00007fdc132ea000) libpsl.so.5 => /lib64/libpsl.so.5 (0x00007fdc14ee7000) libssl.so.3 => /lib64/libssl.so.3 (0x00007fdc13244000) libcrypto.so.3 => /lib64/libcrypto.so.3 (0x00007fdc10000000) libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007fdc125a9000) libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007fdc10925000) libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007fdc1322b000) libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007fdc12e0e000) libldap.so.2 => /lib64/libldap.so.2 (0x00007fdc12542000) liblber.so.2 => /lib64/liblber.so.2 (0x00007fdc12bee000) libbrotlidec.so.1 => /lib64/libbrotlidec.so.1 (0x00007fdc12be0000) libz.so.1 => /lib64/libz.so.1 (0x00007fdc12528000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fdc15b0a000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fdc14ee2000) librt.so.1 => /lib64/librt.so.1 (0x00007fdc12e09000) libunistring.so.2 => /lib64/libunistring.so.2 (0x00007fdc1047b000) libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007fdc10914000) libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007fdc12521000) libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fdc10900000) libevent-2.1.so.7 => /lib64/libevent-2.1.so.7 (0x00007fdc0ffa7000) libsasl2.so.3 => /lib64/libsasl2.so.3 (0x00007fdc108e0000) libbrotlicommon.so.1 => /lib64/libbrotlicommon.so.1 (0x00007fdc108bd000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fdc1044e000) libcrypt.so.2 => /lib64/libcrypt.so.2 (0x00007fdc0ff6d000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fdc0fed1000)

WitekPokorski commented 4 months ago

`[witoldp@omenrtx ~/test_g4gv/AdePT/build]$ readelf -d BuildProducts/lib64/libg4vg.so

Dynamic section at offset 0x2d3088 contains 48 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [libG4persistency.so] 0x0000000000000001 (NEEDED) Shared library: [libG4run.so] 0x0000000000000001 (NEEDED) Shared library: [libG4event.so] 0x0000000000000001 (NEEDED) Shared library: [libG4tracking.so] 0x0000000000000001 (NEEDED) Shared library: [libG4processes.so] 0x0000000000000001 (NEEDED) Shared library: [libG4digits_hits.so] 0x0000000000000001 (NEEDED) Shared library: [libG4track.so] 0x0000000000000001 (NEEDED) Shared library: [libG4geometry.so] 0x0000000000000001 (NEEDED) Shared library: [libG4graphics_reps.so] 0x0000000000000001 (NEEDED) Shared library: [libG4materials.so] 0x0000000000000001 (NEEDED) Shared library: [libG4particles.so] 0x0000000000000001 (NEEDED) Shared library: [libG4expat.so] 0x0000000000000001 (NEEDED) Shared library: [libG4intercoms.so] 0x0000000000000001 (NEEDED) Shared library: [libG4global.so] 0x0000000000000001 (NEEDED) Shared library: [libG4clhep.so] 0x0000000000000001 (NEEDED) Shared library: [libG4ptl.so.2] 0x0000000000000001 (NEEDED) Shared library: [libxerces-c-3.2.so] 0x0000000000000001 (NEEDED) Shared library: [libvecgeomcuda.so] 0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6] 0x0000000000000001 (NEEDED) Shared library: [libm.so.6] 0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1] 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] 0x0000000000000001 (NEEDED) Shared library: [ld-linux-x86-64.so.2] 0x000000000000000e (SONAME) Library soname: [libg4vg.so] 0x000000000000000f (RPATH) Library rpath: [/home/witoldp/Geant4/installation/lib64:/usr/local/lib64:/home/witoldp/VecGeom/installation/lib64:] 0x000000000000000c (INIT) 0x77000 0x000000000000000d (FINI) 0x29f464 0x0000000000000019 (INIT_ARRAY) 0x2cb6d0 0x000000000000001b (INIT_ARRAYSZ) 680 (bytes) 0x000000000000001a (FINI_ARRAY) 0x2cb978 0x000000000000001c (FINI_ARRAYSZ) 8 (bytes) 0x000000006ffffef5 (GNU_HASH) 0x298 0x0000000000000005 (STRTAB) 0x18270 0x0000000000000006 (SYMTAB) 0x5688 0x000000000000000a (STRSZ) 268775 (bytes) 0x000000000000000b (SYMENT) 24 (bytes) 0x0000000000000003 (PLTGOT) 0x2d3fe8 0x0000000000000002 (PLTRELSZ) 17472 (bytes) 0x0000000000000014 (PLTREL) RELA 0x0000000000000017 (JMPREL) 0x72860 0x0000000000000007 (RELA) 0x5b718 0x0000000000000008 (RELASZ) 94536 (bytes) 0x0000000000000009 (RELAENT) 24 (bytes) 0x000000006ffffffe (VERNEED) 0x5b558 0x000000006fffffff (VERNEEDNUM) 5 0x000000006ffffff0 (VERSYM) 0x59c58 0x000000006ffffff9 (RELACOUNT) 109 0x0000000000000000 (NULL) 0x0 `

drbenmorgan commented 4 months ago

Thanks @WitekPokorski! This looks like it may be a GCC 12/binutils issue with increased strictness around link paths/resolving libraries through rpath/etc (I couldn't reproduce in a GCC 11 environment). I'll submit a workaround to upstream in G4VG, but in the meantime could you check if adding /home/witoldp/Geant4/installation/lib64 to LD_LIBRARY_PATH resolves things for you please? You may need to do a fresh build to fully pick that change up after doing it.

drbenmorgan commented 4 months ago

Latest commit should fix @WitekPokorski's issue (TBC), but see discussion and links in celeritas-project/g4vg#8 for more details. This'll get us working for now, longer term we should review build environments for development (things like RPATH/RUNPATH on installed dependencies, use of LD_LIBRARY_PATH etc).

WitekPokorski commented 4 months ago

Thanks @drbenmorgan ! I confirm that the linking problem is gone now. Btw, I have noticed that the bin/ directory does not get installed (it's stays inside BuildProducts only). Not sure this is a new problem, or it was always like this, @JuanGonzalezCaminero ? One last question, what is the G4VG_BUILD_TESTS flag for? When I set it on, it fails, and complains about GTest_DIR not set.

JuanGonzalezCaminero commented 4 months ago

That's normal, the bin directory is not part of the installation @WitekPokorski

JuanGonzalezCaminero commented 4 months ago

@JuanGonzalezCaminero though I know that you did a fresh build, all I can think of is that the old G4VG version is still present. Could you confirm that you fully deleted the build directory (i.e. not just a "make clean") and then re-cmaked from a completely empty directory? Which CMake version are you using?

@WitekPokorski that's very weird... Which Linux/gcc/CMake and Geant4 versions are you using?

@drbenmorgan I'm always starting from a new directory, however I'll try on a different machine and update

drbenmorgan commented 4 months ago

G4VG_BUILD_TESTS is to enable the unit tests of G4VG itself, which use Googletest. It can be set to off inside AdePT, but if you want it on, then you'll need to install googletest.

JuanGonzalezCaminero commented 4 months ago

@drbenmorgan I installed on a different machine, running Alma 9, and indeed it installs correctly. However I still can't get it to work on my machine. As a last attempt I did a separate clean installation of all dependencies and AdePT, but the result is still the same.

This is the CMakeLists.txt inside my build/_deps/g4vg_src, which I believe is the updated version:

#---------------------------------*-CMake-*----------------------------------#
# Copyright 2020-2024 UT-Battelle, LLC, and other Celeritas developers.
# See the top-level COPYRIGHT file for details.
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
#----------------------------------------------------------------------------#

cmake_minimum_required(VERSION 3.14...3.28)
project(G4VG VERSION 0.1.0 LANGUAGES CXX)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

#----------------------------------------------------------------------------#
# Utilities

include(GNUInstallDirs)

macro(g4vg_set_default name value)
  if(NOT DEFINED ${name})
    message(VERBOSE "G4VG: set default ${name}=${value}")
    set(${name} "${value}")
  endif()
endmacro()

#----------------------------------------------------------------------------#
# Options

option(G4VG_BUILD_TESTS "Build G4VG unit tests" OFF)
g4vg_set_default(BUILD_TESTING ${G4VG_BUILD_TESTS})

g4vg_set_default(CMAKE_CXX_EXTENSIONS OFF)

#----------------------------------------------------------------------------#
# Dependencies
# Found here because we need the targets visible to both import Celeritas and
# to declare them as-needed in g4vg itself for correct downstream use

find_package(Geant4 REQUIRED)
find_package(VecGeom REQUIRED)

#----------------------------------------------------------------------------#
# Add code

add_subdirectory(external)
add_subdirectory(src)

#----------------------------------------------------------------------------#
# Add tests

if(BUILD_TESTING)
  include(CTest)
endif()
if(G4VG_BUILD_TESTS)
  if(NOT GTest_FOUND)
    find_package(GTest 1.10 REQUIRED)
  endif()
  add_subdirectory(test)
endif()

#----------------------------------------------------------------------------#
# Export CMake for installation downstream

set(G4VG_INSTALL_CMAKECONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/G4VG")

# Install 'G4VGConfig.cmake'
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/G4VGConfigVersion.cmake"
  COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(
  "cmake/G4VGConfig.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/G4VGConfig.cmake"
  INSTALL_DESTINATION "${G4VG_INSTALL_CMAKECONFIGDIR}"
  NO_SET_AND_CHECK_MACRO
  NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

install(FILES
  "${CMAKE_CURRENT_BINARY_DIR}/G4VGConfigVersion.cmake"
  "${CMAKE_CURRENT_BINARY_DIR}/G4VGConfig.cmake"
  DESTINATION "${G4VG_INSTALL_CMAKECONFIGDIR}"
  COMPONENT development
)

# Install 'G4VGTargets.cmake', included by G4VGConfig.cmake, which
# references the targets we install.
install(EXPORT g4vg-targets
  FILE G4VGTargets.cmake
  NAMESPACE G4VG::
  DESTINATION "${G4VG_INSTALL_CMAKECONFIGDIR}"
  COMPONENT development
)

As a separate issue, while doing this I initially installed Geant4 11.2.1. AdePT master compiles correctly, however when I tried to compile this PR I got the following warnings:

-- Found Geant4: /.../Geant4Config.cmake (found version "11.2.1") 
-- Set CELERITAS_CORE_RNG=xorwow
CMake Warning (dev) at build/_deps/celeritas-src/cmake/CeleritasUtils.cmake:650 (message):
  No Geant4 library 'Geant4::G4persistency' exists
Call Stack (most recent call first):
  build/_deps/celeritas-src/src/geocel/CMakeLists.txt:54 (celeritas_get_g4libs)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at build/_deps/celeritas-src/cmake/CeleritasUtils.cmake:650 (message):
  No Geant4 library 'Geant4::G4tasking' exists
Call Stack (most recent call first):
  build/_deps/celeritas-src/src/celeritas/CMakeLists.txt:115 (celeritas_get_g4libs)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at build/_deps/celeritas-src/cmake/CeleritasUtils.cmake:650 (message):
  No Geant4 library 'Geant4::G4persistency' exists
Call Stack (most recent call first):
  build/_deps/celeritas-src/app/celer-g4/CMakeLists.txt:35 (celeritas_get_g4libs)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at build/_deps/celeritas-src/cmake/CeleritasUtils.cmake:650 (message):
  No Geant4 library 'Geant4::G4tasking' exists
Call Stack (most recent call first):
  build/_deps/celeritas-src/app/celer-g4/CMakeLists.txt:35 (celeritas_get_g4libs)
This warning is for project developers.  Use -Wno-dev to suppress it.

Which cause an error during the build, so I had to go back to Geant4 11.1.2

drbenmorgan commented 4 months ago

@JuanGonzalezCaminero which Platform/CMake version is your machine running (I recall Ubuntu, but just to be sure). I'll check again with Geant4 11.2.1 locally, nominally those should just be warnings and not result in an error.

JuanGonzalezCaminero commented 4 months ago

@drbenmorgan I'm running Debian with cmake 3.28.3

JuanGonzalezCaminero commented 4 months ago

@drbenmorgan Going back to linking an external project, in the machine where I can install G4VG properly, I saw the following:

I was wondering whether it could be related to the new FindVecGeom.cmake Do you maybe have some external application that I could try to build?

drbenmorgan commented 4 months ago

Thanks for the spot on the type @JuanGonzalezCaminero! Fixed upstream, and the latest commit here should include that plus a fix to install G4VG for CMake 3.28 and newer.

I have been able to build this with Geant4 11.2.1 locally so if you're still seeing and error when compiling things, please post the messages here.

JuanGonzalezCaminero commented 4 months ago

I see, in my case I get:

[ 25%] Built target corecel
[ 25%] Building CXX object _deps/celeritas-build/src/geocel/CMakeFiles/geocel_geant4.dir/GeantUtils.cc.o
/.../build/_deps/celeritas-src/src/geocel/GeantUtils.cc:10:10: fatal error: G4RunManager.hh: No such file or directory
   10 | #include <G4RunManager.hh>
drbenmorgan commented 4 months ago

Could you run make VERBOSE=1 and post the full compile command it's trying to execute please?

JuanGonzalezCaminero commented 4 months ago
cd /.../build/_deps/celeritas-build/src/geocel && /usr/bin/c++ -DG4LIB_BUILD_DLL -DHEPMC3_FOUND -DPTL_BUILD_DLL -I/.../build/_deps/celeritas-src/src -I/.../build/_deps/celeritas-build/include -isystem /.../geant4/source/global/HEPGeometry/include -isystem /.../geant4/source/global/HEPNumerics/include -isystem /.../geant4/source/global/HEPRandom/include -isystem /.../geant4/source/global/management/include -isystem /.../geant4_installation/source/global/include -isystem /.../geant4/source/externals/clhep/include -isystem /.../geant4/source/externals/ptl/include -isystem /.../geant4_installation/source/externals/ptl/src -isystem /.../geant4/source/geometry/biasing/include -isystem /.../geant4/source/geometry/divisions/include -isystem /.../geant4/source/geometry/magneticfield/include -isystem /.../geant4/source/geometry/management/include -isystem /.../geant4/source/geometry/navigation/include -isystem /.../geant4/source/geometry/solids/Boolean/include -isystem /.../geant4/source/geometry/solids/CSG/include -isystem /.../geant4/source/geometry/solids/specific/include -isystem /.../geant4/source/geometry/volumes/include -isystem /.../geant4/source/intercoms/include -isystem /.../geant4/source/particles/management/include -isystem /.../geant4/source/track/include -isystem /.../geant4_installation/source/geometry/include -isystem /.../geant4/source/graphics_reps/include -O3 -DNDEBUG -std=c++17 -fPIC -MD -MT _deps/celeritas-build/src/geocel/CMakeFiles/geocel_geant4.dir/GeantUtils.cc.o -MF CMakeFiles/geocel_geant4.dir/GeantUtils.cc.o.d -o CMakeFiles/geocel_geant4.dir/GeantUtils.cc.o -c /.../build/_deps/celeritas-src/src/geocel/GeantUtils.cc
drbenmorgan commented 4 months ago

O.k., looks like you pointed AdePT to a build directory of Geant4 rather than an install directory. That is nominally supported, but clearly an issue with Celerity's build in this case. I'll try and debug that upstream, but for now, please try against a full install of Geant4 (i.e. "make install" Geant4 itself).

JuanGonzalezCaminero commented 4 months ago

Yes, I noticed it picked up the build directory when I sent it. Actually I never gave it that path when configuring it, so I'll try to figure out why it's doing that on my side

JuanGonzalezCaminero commented 4 months ago

It was related to the way I was installing geant4, it compiles properly for me as well once adept picks up just the install directory @drbenmorgan. It should be fine given that we will eventually drop the celeritas dependency

drbenmorgan commented 4 months ago

Great! As long as everything else is o.k., I think this is ready to merge on approval from the reviewers!

JuanGonzalezCaminero commented 4 months ago

@drbenmorgan On my side I still haven't been able to link an external application, I mentioned the issue in my previous comment. This is an application that links correctly with AdePT master, in which I've replaced the target_include_directories and target_link_libraries with the corresponding cuda_rdc ones. When using this PR VecGeom is not found during compilation (No warnings on configuration).

WitekPokorski commented 4 months ago

I confirm, I have the same issue as Juan. When I so cmake, it says 'Found VecGeom', but then during the installation it gives me:

In file included from /home/witoldp/test_g4gv/findpackage_test/Example1/src/ActionInitialisation.cc:31: /home/witoldp/test_g4gv/findpackage_test/Example1/include/RunAction.hh:32:10: fatal error: VecGeom/base/Stopwatch.h: No such file or directory 32 | #include <VecGeom/base/Stopwatch.h> | ^~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.

drbenmorgan commented 4 months ago

What does your link line look like in the external package? The target name to use outside of AdePT is AdePT::AdePT_G4_integration, so:

cuda_rdc_target_link_libraries(example1 PRIVATE AdePT::AdePT_G4_integration ...)

not

cuda_rdc_target_link_libraries(example1 PRIVATE AdePT_G4_integration ...)

There is a mixup I can do to makes this fully consistent internally to AdePT and for external projects, but I'd prefer to do that in a separate PR.

WitekPokorski commented 4 months ago

the link line is:

cuda_rdc_target_link_libraries(example1 PRIVATE ${AdePT_LIBRARIES}

so, I guess it's OK. When I look at the compilation line, there is the AdePT include dir, but not the VecGeom one.

JuanGonzalezCaminero commented 4 months ago

We are using ${AdePT_Libraries}, so it is AdePT::AdePT_G4_integration

I suspect we are having trouble with this simple external application because it has this dependency to VecGeom::Stopwatch in it's RunAction (Although we also get error messages for the compilation of AdePT files)

/.../include/AdePT/core/AdePTTransport.h:12:10: fatal error: VecGeom/base/Config.h: No such file or directory
   12 | #include <VecGeom/base/Config.h>

However I found something else. I adapted the HGCALTB example integration to work with this PR. It compiles correctly (I don't know whether that is because it doesn't use vecgeom itself) but it throws a CUDA error when running (Illegal memory access). I haven't seen this error with the AdePT examples.

I'll try to investigate where exactly it is coming from. If you would like to try to replicate it, the modifications needed are:

drbenmorgan commented 4 months ago

Could you share the code for the external application you're trying to build please? Thanks for the link to the HGCALTB example, but let's try and resolve what's happening in the simplest case first.

JuanGonzalezCaminero commented 4 months ago

Yes, of course. This is the application with just the basic modification (cuda_rdc link and include). It works with master like this, however I have also tried explicitly linking to VecGeom, although with no difference in my case.

link_test.zip

drbenmorgan commented 4 months ago

I think I've now fixed the problem - ALIAS targets need to be explicitly created in the build so these propagate correctly to installs (it's a slight bug/oversight in CudaRdcUtils which should be addressed in Celeritas' version as well). I was able to reproduce the problem with the link_test project @JuanGonzalezCaminero and the latest commit fixes things for me locally.

WitekPokorski commented 4 months ago

Hi Ben, yes, it seems to work for me now.

JuanGonzalezCaminero commented 4 months ago

The application builds correctly for me as well! @drbenmorgan