ADIOS1: Link Serial & Parallel Separately#254
Conversation
07d5824 to
86b51cf
Compare
| POSITION_INDEPENDENT_CODE ON | ||
| CXX_VISIBILITY_PRESET hidden | ||
| VISIBILITY_INLINES_HIDDEN ON | ||
| LINK_FLAGS "-Wl,--exclude-libs,libadios_nompi.a" |
There was a problem hiding this comment.
or simply -Wl,--exclude-libs,ALL
86b51cf to
c890f77
Compare
| if(openPMD_HAVE_ADIOS1) | ||
| target_link_libraries(openPMD PUBLIC ${ADIOS_LIBRARIES}) | ||
| target_include_directories(openPMD SYSTEM PUBLIC ${ADIOS_INCLUDE_DIRS}) | ||
| add_library(openPMD.ADIOS1.Serial SHARED ${IO_ADIOS1_SEQUENTIAL_SOURCE}) |
There was a problem hiding this comment.
ha, have to link this always xD
8618b33 to
5347c1e
Compare
|
@C0nsultant lol, I made it. That's the worst hack to isolate an upstream issue I ever did. I feel ashamed and a bit used 🤕 |
24ff86a to
33685b1
Compare
|
|
||
| # external library: ADIOS1 (optional) | ||
| # always search for a sequential lib first, so we can mock MPI | ||
| find_package(ADIOS 1.13.1 COMPONENTS sequential QUIET) |
There was a problem hiding this comment.
todo: the QUIET should be honored in FindADIOS.cmake
| set(ADIOS_LIBRARIES_SEQUENTIAL ${ADIOS_LIBRARIES}) | ||
| set(ADIOS_INCLUDE_DIRS_SEQUENTIAL ${ADIOS_INCLUDE_DIRS}) | ||
| unset(ADIOS_FOUND CACHE) | ||
| unset(ADIOS_VERSION CACHE) |
There was a problem hiding this comment.
we could use this and look for the parallel component with EXACT.
but actually it's not two, totally independent backends anyway.
nevertheless, same version makes life easier.
|
@ax3l You survived the war. Undoubtedly you have witnessed the bad and the worse, but you made it to the other side. People are going to love you for it. Great work! |
| endif() | ||
|
|
||
| add_library(openPMD.ADIOS1.Serial SHARED ${IO_ADIOS1_SEQUENTIAL_SOURCE}) | ||
| add_library(openPMD.ADIOS1.Parallel SHARED ${IO_ADIOS1_SOURCE}) |
There was a problem hiding this comment.
Just for better understanding:
Are all 4 combinations
SER PAR
N N
N Y
Y N
Y Y
possible with this change?
There was a problem hiding this comment.
Yes indeed 💃
Even though an ADIOS install of the form
SER PAR
N Y
is not build by ADIOS (it always ships at least a serial lib with its lovely mock magic).
There was a problem hiding this comment.
Impressive!
... and that only requires building two seperate library files by compiling with different options and linking them with tinkered symbols.
its lovely mock magic
😂
There was a problem hiding this comment.
Close: no symbol tinkering, just really aggressive symbols hiding for encapsulation 😈
And note the weird code sharing in the implementation files :-o
| protected: | ||
| int64_t m_group; | ||
| std::string m_groupName; | ||
| ADIOS_READ_METHOD m_readMethod; |
There was a problem hiding this comment.
If we don't use that varaible for both backends anymore, we cna probably hard-code the ADIOS_READ_METHOD used in each one.
There was a problem hiding this comment.
I don't fully get this but I guess we can do this in a follow-up as well.
There was a problem hiding this comment.
The methods are initialized once per handler in init()
openPMD-api/src/IO/ADIOS/ADIOS1IOHandler.cpp
Line 210 in 265828b
openPMD-api/src/IO/ADIOS/ParallelADIOS1IOHandler.cpp
Lines 221 to 222 in 551ab6d
With the hard separation of serial and parallel backend, we do not really need the variable any more.
|
|
||
| #define ADIOS1IOHandlerImpl ParallelADIOS1IOHandlerImpl | ||
| #include "ADIOS1IOCommon.cpp" | ||
| #undef ADIOS1IOHandlerImpl |
There was a problem hiding this comment.
When you think you've seen all the ways of sharing code between classes...
There was a problem hiding this comment.
yeah, that's my secret present for you.
did I mention it's the worst hack ever?
There was a problem hiding this comment.
Note that inheritance does not work since identical symbols do not mean identical implementation thanks to the MPI mock...
There was a problem hiding this comment.
I could inherit from yet another baseclass though, that we then hide again in symbols and compile twice... ahhhh... it must stop.
There was a problem hiding this comment.
The reason for the duplicated code is not too diffcult to understand. Just maybe replace ADIOS1IOHandlerImpl with CommonImpl in "ADIOS1IOCommon.cpp" and then do the #defines in both handlers?
b336a9b to
9e13f5b
Compare
| public: | ||
| #if openPMD_HAVE_MPI | ||
| ParallelADIOS1IOHandler(std::string const& path, AccessType, MPI_Comm); | ||
| #if openPMD_HAVE_ADIOS1 && openPMD_HAVE_MPI |
There was a problem hiding this comment.
This check is redundant with the # if openPMD_HAVE_MPI below.
|
Separating the two is probably a good thing. |
ba06b23 to
30ec032
Compare
Enable serial ADIOS1 backend usage even if MPI is present.
CMake draft to link the `_nompi` and MPI libs of ADIOS1 separately.
30ec032 to
2e9dec8
Compare
|
@C0nsultant I think we could merge this as well now. It's also hard to rebase if we keep this open for too long. |
We can not inhertit, we need unique symbols.
2e9dec8 to
e8c81d8
Compare
| src/IO/AbstractIOHandler.cpp | ||
| src/IO/AbstractIOHandlerImpl.cpp | ||
| src/auxiliary/Filesystem.cpp | ||
| # src/IO/IOTask.cpp |
There was a problem hiding this comment.
Remove if not required to build this library.
| src/IO/AbstractIOHandler.cpp | ||
| src/IO/AbstractIOHandlerImpl.cpp | ||
| src/auxiliary/Filesystem.cpp | ||
| # src/IO/IOTask.cpp |
There was a problem hiding this comment.
Remove if not required to build this library.
| CXX_EXTENSIONS OFF | ||
| CXX_STANDARD_REQUIRED ON | ||
| POSITION_INDEPENDENT_CODE ON | ||
| CXX_VISIBILITY_PRESET "hidden" |
There was a problem hiding this comment.
Is there a reasong why a string is used for CXX_VISIBILITY_PRESET here and a raw literal in openPMD.ADIOS1.Serial?
There was a problem hiding this comment.
That's unfortunately syntax in CMake to set -fvisibility-inlines-hidden (or equivalent)
There was a problem hiding this comment.
Ah, now I see. yes, we can skip the quotes. Updated.
| else() | ||
| message("ADIOS component ${COMP} is not supported. Please use fortran, readonly, or sequential") | ||
| if(NOT ADIOS_FIND_QUIETLY) | ||
| message("ADIOS component ${COMP} is not supported. Please use fortran, readonly, or sequential") |
There was a problem hiding this comment.
This is potentially a case where we could signal FATAL_ERROR.
The user is requesting a component we will never be able to provide.
There was a problem hiding this comment.
Oh, quite the contrary! We are inside a Find*.cmake script. The worst thing it is allowed to do is not find what is requested.
Fatal errors are controlled by setting REQUIRED in find_package or by handling the Package_FOUND variable manually.
So we are all set :-)
e8c81d8 to
e9e80a5
Compare
Clean up debug messages and honor QUIET in FindADIOS.cmake
e9e80a5 to
c54f6a1
Compare
Do not flush Attribute value until termination of IOHandler. Variable defines do not overwrite previous definitions. Only flush the very last value as the definition. Enable VERFIY macro for ADIOS backends (was disabled with openPMD#254).
Do not flush Attribute value until termination of IOHandler. Variable defines do not overwrite previous definitions. Only flush the very last value as the definition. Enable VERFIY macro for ADIOS backends (was disabled with openPMD#254).
CMake draft to link the
_nompiand MPI libs of ADIOS1 separately.Close #252
Current Status 1
It's ugly, it's verbose, it's hard to maintain, it excludes compilers that can not hide symbols such as pgc++ when building with ADIOS1, the system must have shared library support, it requires static ADIOS1 libraries (at least that's the default), ... but it works :-D
Current Status 2
It's complex but doable.
To Do
FindADIOS.cmakeshould honorQUIETin itsmessage()sadd CMake option for SHARED adios intermediate libs (default: on == MPI/Serial safe)?heeelp please :)Remove MPI from serial ADIOS interface #258objcopy --strip-symbols?maybe we need to either callMPI_Initialize()(if MPI context missing) if ADIOS is build with MPI even in serial mode... or load ADIOS viadlopento avoid symbol clashes/mismatches, etc.