Open
Description
Hi, all
There is a MPI_Accumulate error at Open MPI when using datatype "MPI_SHORT_INT".
I thought that it was about the compress/uncompress of predefined datatype "MPI_SHORT_INT" at osc module.
The datatype "MPI_SHORT_INT" used at this case, its size of storage space is 8 byte (4-byte aligned), but its payload size is 6 byte (2 byte for short, and 4 byte for int.). When updating data from remote ranks, it was compressed (6 byte for each), but uncompress was not done when reading data, 8 byte was get for each element, so generated an error.
Please confirm and help to fix it. Thanks very much.
Source code of my test case:
#include <stdio.h>
#include "mpi.h"
#define LEN 100
#define SHIFT -1
int main( int argc, char **argv ) {
int my_rank, num_tasks;
int i, j;
MPI_Win win;
MPI_Group all_group, origin_group, target_group;
int root = 0;
typedef struct {
short val;
short pad;
int rank;
} short_int_t;
short_int_t Win[LEN], Array[LEN];
MPI_Init( &argc, &argv );
MPI_Comm_rank( MPI_COMM_WORLD, &my_rank );
MPI_Comm_size( MPI_COMM_WORLD, &num_tasks );
if (2 != num_tasks) {
printf("There should be 2 ranks at this case. \n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
MPI_Win_create( Win, sizeof(Win), sizeof(short_int_t),
MPI_INFO_NULL, MPI_COMM_WORLD, &win );
MPI_Win_fence( 0, win );
MPI_Comm_group( MPI_COMM_WORLD, &all_group );
MPI_Group_incl( all_group, 1, &root, &target_group );
MPI_Group_difference( all_group, target_group, &origin_group );
/* initialize all arrays for MPI_MINLOC*/
for( i=0; i<LEN; i++ ) {
if (my_rank == i%2) {
Array[i].val = Win[i].val = SHIFT;
}
else {
Array[i].val = Win[i].val = -1*SHIFT;
}
Array[i].rank = my_rank;
Win[i].rank = my_rank;
Win[i].pad = -i;
}
if( my_rank == root ) {
MPI_Win_post( origin_group, 0, win );
MPI_Win_wait( win );
}
else {
MPI_Win_start( target_group, 0, win );
MPI_Accumulate( Array, LEN, MPI_SHORT_INT, root, 0,
LEN, MPI_SHORT_INT, MPI_MINLOC, win );
MPI_Win_complete( win );
}
MPI_Win_fence( 0, win );
/* check results */
if( my_rank == root ) {
for( i=0; i<LEN; i++ ) {
if( Win[i].val != SHIFT ) {
printf( "MPI_Accumulate failed to obtain the proper value. The %dth should be %d, but it is %d\n", i, SHIFT, Win[i].val);
MPI_Abort( MPI_COMM_WORLD, -1 );
}
if( Win[i].rank != i%2) {
printf("MPI_Accumulate failed to obtain the proper rank. \n");
MPI_Abort( MPI_COMM_WORLD, -1 );
}
if( Win[i].pad != -i ) {
printf("MPI_Accumulate clobbered the pad.\n");
MPI_Abort( MPI_COMM_WORLD, -1 );
}
}
printf("MPI_Accumulate Check PASSED. \n");
}
MPI_Win_free( &win );
MPI_Finalize();
return(0);
}