Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] MPI One-Sided Communication, indexed datatype and segmentation fault.
From: Ziaul Haque Olive (mzh.olive_at_[hidden])
Date: 2012-06-06 12:44:54


I am not sure, if my code is correct according to Open MPI(v1.6). the code
is given as follows, I am doing MPI one-sided communication inside a
function - data_transfer. this function is being called inside a fence
epoch. inside data_transfer, I am allocating memory for non-contiguous
data, creating derived data type, using this datatype in MPI_Accumulate,
and after calling MPI_Accumulate, freeing the indexed data type and also
freeing the memory containing indices for indexed data type. is it okay
that I am freeing memory for derived datatype before the closing fence?

I am getting segmentation fault with this code. if I comment out the
MPI_Accumulate call, then no seg-fault occurs.

void data_transfer(void *data, int *sources_disp, int *targets_disp, int
*target, int size, int *blength, int func, MPI_Op op, MPI_Win win,
MPI_Datatype dtype){

int i,j, index;
 int tmp_target;
int *flag;
int *source_disp;
 int *target_disp;
MPI_Datatype source_type, target_type;
  MPI_Alloc_mem( size*sizeof(int), MPI_INFO_NULL, &source_disp);
MPI_Alloc_mem( size*sizeof(int), MPI_INFO_NULL, &target_disp);
 MPI_Alloc_mem( size*sizeof(int), MPI_INFO_NULL, &flag );

memset(flag, 0, size*sizeof(int));

tmp_target = target[i];
 index = 0;
for(j=i; j<size; j++){
 if(flag[j]==0 && tmp_target == target[j] ){
source_disp[index] = sources_disp[j];
 target_disp[index] = targets_disp[j];
//printf("src, target disp %d %d\n", j, disp[j]);
flag[j] = 1;

MPI_Type_indexed(index, blength , source_disp, dtype, &source_type);
MPI_Type_indexed(index, blength , target_disp, dtype, &target_type);
  MPI_Accumulate( data, 1, source_type, tmp_target, 0, 1, target_type , op,



void main(){
int i;
 MPI_Win_fence(MPI_MODE_NOPRECEDE, queue2_win);


 MPI_Win_fence(MPI_MODE_NOSUCCEED, queue2_win);