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));
for(i=0;i<size;i++){
if(flag[i]==0){
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]);
index++;
flag[j] = 1;
}
}
MPI_Type_indexed(index, blength , source_disp, dtype, &source_type);
MPI_Type_commit(&source_type);
MPI_Type_indexed(index, blength , target_disp, dtype, &target_type);
MPI_Type_commit(&target_type);
MPI_Accumulate( data, 1, source_type, tmp_target, 0, 1, target_type , op, win);
MPI_Type_free(&source_type);
MPI_Type_free(&target_type);
}
}
MPI_Free_mem(source_disp);
MPI_Free_mem(target_disp);
MPI_Free_mem(flag);
}
void main(){
int i;
while(i<N){
MPI_Win_fence(MPI_MODE_NOPRECEDE, queue2_win);
data_transfer();
MPI_Win_fence(MPI_MODE_NOSUCCEED, queue2_win);
}
}
thanks,
Ziaul