MPI.jl
MPI.jl copied to clipboard
Guidelines/rules for datatypes in constants files
I am currently looking through some of the constants files to understand which datatype is used when. For example, it seems like
@const_ref MPI_VARNAME Cint 12345
Is used both for constants defined as enum
s and as #define
s in the corresponding MPI implementation's mpi.h
. Why is it OK to map these (ostensibly) different source types to the same Julia type? And why are some other constants defined as
const MPI_MAX_ERROR_STRING = Cint(256)
That is, as proper integer constants, even though in mpi.h
they are also just #define
s?
Also, I noticed that sometimes C types are translated to Julia C types and sometimes to regular Julia types, and for some there does not seem to be a 1-to-1 correspondence used. For example, for OpenMPI's there is https://github.com/JuliaParallel/MPI.jl/blob/e4479cfe16f1fdbbdab7423eca03c98764b0c671/src/consts/openmpi.jl#L18-L21
While in the OpenMPI headers on HLRS' Hawk I find
-
MPI_Aint
to be ofptrdiff_t
type, which is implementation defined (Q: isn't that a potential issue that it can vary?) -
MPI_Fint
to be ofint
type (Q: why useInt32
and notCint
?) -
MPI_Count
andMPI_Offset
to be oflong long
type (Q: why not useClong
then?)
Right afterwards in the definition of MPI_Status
, the C types are used again:
https://github.com/JuliaParallel/MPI.jl/blob/e4479cfe16f1fdbbdab7423eca03c98764b0c671/src/consts/openmpi.jl#L24-L30
Maybe it is documented somewhere but I was not able to find it in the docs. Any help understanding how to properly understand (and possibly create) such a constants file would be appreciated!
As a follow-up questions, was it intentional to remove all typed pointers for https://github.com/JuliaParallel/MPI.jl/blob/e4479cfe16f1fdbbdab7423eca03c98764b0c671/src/consts/openmpi.jl#L245-L248
While in mpi.h
the first two should be pointers to int
/Cint
(ref)?
As a follow-up questions, was it intentional to remove all typed pointers for
This was fixed by #598
MPI_Aint
to be ofptrdiff_t
type, which is implementation defined (Q: isn't that a potential issue that it can vary?)
MPI_Fint
to be ofint
type (Q: why useInt32
and notCint
?)
MPI_Count
andMPI_Offset
to be oflong long
type (Q: why not useClong
then?)
Mostly it was trial and error on my part: it would probably make sense to use the C aliases if that is how they're defined in the headers.
MPI_Aint
to be ofptrdiff_t
type, which is implementation defined (Q: isn't that a potential issue that it can vary?)
MPI_Fint
to be ofint
type (Q: why useInt32
and notCint
?)MPI_Count
andMPI_Offset
to be oflong long
type (Q: why not useClong
then?)Mostly it was trial and error on my part: it would probably make sense to use the C aliases if that is how they're defined in the headers.
I added a note regarding this to the docs in ff29239.
Would you mind making a PR on the existing const files?
Would you mind making a PR on the existing const files?
What do you mean exactly? One that fixes the types I've pointed out above?
What do you mean exactly? One that fixes the types I've pointed out above?
yes