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

Update MPI_Status definition to give implementers flexibility #33

Closed
wants to merge 1 commit into from

Conversation

dalcinl
Copy link
Collaborator

@dalcinl dalcinl commented Mar 20, 2024

No description provided.

@jeffhammond
Copy link
Member

i'll merge after MPI Forum discussion

@dalcinl dalcinl marked this pull request as draft March 20, 2024 10:14
@dalcinl
Copy link
Collaborator Author

dalcinl commented Mar 20, 2024

I'm afraid we cannot give a lot of flexibility to implementations. They will have to work with what what they are provided, otherwise alignment issues will break binary interoperability across implementations.

Rather than keeping discussing it in the abstract, let me trough some code to it to make my point.

#include <stdio.h>
#include <stdint.h>

typedef int64_t MPI_Count;

typedef struct {
  int MPI_SOURCE;
  int MPI_TAG;
  int MPI_ERROR;
#if FLAG == 0
  int MPI_internal[5];
#else
  int       MPI_internal_cancelled;
  MPI_Count MPI_internal_count;
  char      MPI_internal_unused[2*sizeof(int)];
#endif
} MPI_Status;

int main() {
  printf("size:  %d\n", (int)sizeof(MPI_Status));
  printf("align: %d\n", (int)_Alignof(MPI_Status));
}
$ cc -DFLAG=0 status.c; ./a.out
size:  32
align: 4

$ cc -DFLAG=1 status.c; ./a.out
size:  32
align: 8

Unfortunately, looks like we cannot give implementations absolute freedom about what to put in MPI_Status. They can have some, but they should at guarantee that whatever they put, the final MPI_Status has the same alignment as int.
Therefore, unless proven wrong with actual evidence, I stand by the original proposal of using int MPI_internal[5];

Implementations, welcome to the new world order!

@jeffhammond
Copy link
Member

we can use C11 https://en.cppreference.com/w/c/language/_Alignas to force 8 byte alignment

@dalcinl dalcinl closed this Mar 25, 2024
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

Successfully merging this pull request may close these issues.

2 participants