Skip to content

Instantly share code, notes, and snippets.

@pkpio
Last active February 23, 2016 23:36
Show Gist options
  • Select an option

  • Save pkpio/e7e25b17fac47f2710dd to your computer and use it in GitHub Desktop.

Select an option

Save pkpio/e7e25b17fac47f2710dd to your computer and use it in GitHub Desktop.
MPI_Datatype row_type;
MPI_Datatype col_type;
// Row definition
MPI_Type_vector(DIM_LEN, DIM_LEN, 0, MPI_INT, &row_type);
MPI_Type_commit(&row_type);
// Column definition
MPI_Type_vector(DIM_LEN, 1, DIM_LEN, MPI_INT, &col_type);
MPI_Type_commit(&col_type);
int *sendcnts;
int *disps;
sendcnts = malloc(sizeof(int) * comm_size);
disps = malloc(sizeof(int) * comm_size);
int i;
for(i=0; i<comm_size; i++){
sendcnts[i] = DIM_LEN / comm_size;
disps[i] = i;
}
MPI_Scatterv(mat_1, sendcnts, disps, row_type, mat_1, DIM_LEN, row_type, 0, MPI_COMM_WORLD);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment