-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADIOS1: Link Serial & Parallel Separately #254
Conversation
07d5824
to
86b51cf
Compare
CMakeLists.txt
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or simply -Wl,--exclude-libs,ALL
86b51cf
to
c890f77
Compare
CMakeLists.txt
Outdated
@@ -277,10 +296,99 @@ else() | |||
endif() | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -119,7 +119,15 @@ if(openPMD_HAVE_HDF5 AND HDF5_IS_PARALLEL AND NOT openPMD_HAVE_MPI) | |||
"to disable HDF5 or provide a serial install of HDF5.") | |||
endif() | |||
|
|||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: the QUIET should be honored in FindADIOS.cmake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
CMakeLists.txt
Outdated
@@ -276,15 +289,95 @@ else() | |||
target_compile_definitions(openPMD PUBLIC "-DopenPMD_HAVE_HDF5=0") | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The methods are initialized once per handler in init()
openPMD-api/src/IO/ADIOS/ADIOS1IOHandler.cpp
Line 210 in 265828b
m_readMethod = ADIOS_READ_METHOD_BP; |
openPMD-api/src/IO/ADIOS/ParallelADIOS1IOHandler.cpp
Lines 221 to 222 in 551ab6d
/** @todo ADIOS_READ_METHOD_BP_AGGREGATE */ | |
m_readMethod = ADIOS_READ_METHOD_BP; |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you think you've seen all the ways of sharing code between classes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that's my secret present for you.
did I mention it's the worst hack ever?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 #define
s in both handlers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, thought so, too!
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
CMakeLists.txt
Outdated
src/IO/AbstractIOHandler.cpp | ||
src/IO/AbstractIOHandlerImpl.cpp | ||
src/auxiliary/Filesystem.cpp | ||
# src/IO/IOTask.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove if not required to build this library.
CMakeLists.txt
Outdated
src/IO/AbstractIOHandler.cpp | ||
src/IO/AbstractIOHandlerImpl.cpp | ||
src/auxiliary/Filesystem.cpp | ||
# src/IO/IOTask.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove if not required to build this library.
CMakeLists.txt
Outdated
CXX_EXTENSIONS OFF | ||
CXX_STANDARD_REQUIRED ON | ||
POSITION_INDEPENDENT_CODE ON | ||
CXX_VISIBILITY_PRESET "hidden" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's unfortunately syntax in CMake to set -fvisibility-inlines-hidden
(or equivalent)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, now I see. yes, we can skip the quotes. Updated.
@@ -107,7 +107,9 @@ if(ADIOS_FIND_COMPONENTS) | |||
elseif(comp STREQUAL "sequential") | |||
set(OPTLIST "${OPTLIST}s") | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
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
_nompi
and 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.cmake
should honorQUIET
in 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 viadlopen
to avoid symbol clashes/mismatches, etc.