Skip to content
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

Discuss symbol naming and visibility #8

Open
wrwilliams opened this issue Dec 1, 2022 · 5 comments
Open

Discuss symbol naming and visibility #8

wrwilliams opened this issue Dec 1, 2022 · 5 comments

Comments

@wrwilliams
Copy link

Problem

Symbol names and visibility are part of an ABI. MPI says nothing about the former and only implicitly discusses the latter.

Proposal

We should IMO make the following explicit:

  • Procedures defined in the standard may ultimately be called through a C ABI with C names defined by the standard. (Basically, an F08 module should always have a well-defined C-mangled symbol it can use to provide its actual implementation, and a PMPI+F08 tool should be able to intercept the PMPI version of that well-defined symbol. I would however like to phrase this in a way that doesn't automatically bless the C bindings as the One True Bindings.)
  • Symbols for procedures, variables and constants specified by the standard shall be publicly visible from an MPI library
  • Symbols for implementation details shall not be publicly visible from an MPI library

...the problem on that last point of course is "how do you define implementation details, and how do you distinguish them from stuff like MPI_X?"

Impact on Implementations

Hopefully minimal, if they have already been standard-compliant...

Impact on Users

F08 modules become easier to write as independent things
PMPI tools can avoid a measure of guess-and-check name mangling and/or "just write a thin Fortran wrapper"
In general it becomes possible to iterate the symbols provided by an MPI library and do things with them in the absence of headers

@devreal
Copy link

devreal commented Dec 1, 2022

Symbols for implementation details shall not be publicly visible from an MPI library

I'm not sure that is feasible. We have tried hard to reduce the number of implementation-specific symbols visible in OMPI (and to properly namespace them) but hiding them entirely is another beast. What about shared libraries pulled in by libmpi? We cannot hide their symbols and they will become visible in the process. After all, what is the benefit of hiding implementation-specific symbols? I would rather state that implementation-specific symbols shall be properly namespaced to reduce the chance for collisions with application symbols.

@wrwilliams
Copy link
Author

I'm not sure that is feasible. We have tried hard to reduce the number of implementation-specific symbols visible in OMPI (and to properly namespace them) but hiding them entirely is another beast.

I think there's an important (but as-yet fuzzy) distinction between "this is implementation-specific" and "this is part of MPI's internals". The former I would want to allow (in particular for extensions); the latter I would want to prohibit or at least discourage.

What about shared libraries pulled in by libmpi? We cannot hide their symbols and they will become visible in the process.

But they won't be symbols in the MPI library; I would say this is fine.

After all, what is the benefit of hiding implementation-specific symbols? I would rather state that implementation-specific symbols shall be properly namespaced to reduce the chance for collisions with application symbols.

The question is rather one of "what symbols may a valid MPI program depend on an MPI library to provide?", and my goal here is "a valid program can compile against any valid ABI-compatible library and run with any other ABI-compatible library". If a program can see an implementation-specific symbol it can (accidentally or otherwise) depend on it...

@besnardjb
Copy link

Yes, this double PMPI has always been such a headache. When you see what the wrappers have to do: https://github.com/LLNL/wrap#notes-on-the-fortran-wrappers

Would be a big plus for tools.

Also, it would make the future QMPI approach Fortran compatible for free, I suppose.

@gonzalobg
Copy link

Symbols for implementation details shall not be publicly visible from an MPI library

What's the rationale for this being a requirement for an MPI ABI?

I understand that this is "nice to have" but what usages does this requirement enable that cannot be had without it?


My preference is to start by providing an a MPI C ABI - only for C - and just say that "this is C". That way the name mangling of function and variables, the call ABI, the layout of types, etc. is already specified by the platform's C ABI specification (e.g. x86_64 psABI for x86_64 x86 on Linux). I think that suffices since a cross-platform ABI seems an unsolvable problem.

A Fortran / Python / Rust/ Julia / Haskell / ... MPI ABI stub could be built on top of the C one by just having a thin fortran wrapper over the MPI C API stub that the MPI C ABI would enable.

@devreal
Copy link

devreal commented Dec 19, 2022

Another thought (based on a conversation I had the other day): should default handles be available for dlsym? That would allow some tool/library to use MPI without a header and might be useful for runtime decisions based on whether MPI is available.

This is somewhat cross-cutting with #1 and one does not preclude the other (i.e., we may have compile-time constants and have that same symbol defined publicly within the library).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants