Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Most efficient way to send data using MPI
New Posts  All Forums:Forum Nav:

Most efficient way to send data using MPI

post #1 of 2
Thread Starter 
For one of my courses, we have to write a couple programs using the MPI interface to allow them to run in parallel.

I've already finished the assignment, but there is a 5% bonus for the most efficient solution, and I want it.

The programs deal with passing huge matrices (3200 x 3200) back and forth between the master and worker nodes.

Since matrix[n][n] is not a continuous block of memory, it does not seem trivial to pass it in one function call.

Instead, I use a loop to pass the matrices one row at a time; it works, but it invokes way too much overhead.

I've found a bit of information online, and it seems that it is definitely possible to use one function call, it just requires defining an MPI datatype for the matrix.

I'm just not sure how to define this, and I am having trouble finding concrete answers.


Thanks for the help guys.
post #2 of 2
Thread Starter 
Actually, I think I just found the solution:

Code:
 /* Dynamic allocation */
 int **array;
 array = (int**) malloc (rows * sizeof(int*));
 if (array == NULL) exit (-1);
 
 array[0] = (int*) malloc (rows * columns * sizeof(int));
 if (array[0] == NULL) exit (-1);
 
 for (i=1; i<rows; i++)
   array[i] = array[0] + i * columns;
 
 /* Send either kind of array */
 MPI_Send (array[0],rows*columns,MPI_INT,0,0,MPI_COMM_WORLD);
I can't test it until tomorrow though.
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Most efficient way to send data using MPI