i'm trying to send an array of strings to the slaves process in MPI, but i can't figure out how to do it. I have a big array of strings, which i've read from a file, and i need to send parts of this array to the slaves. I'm allocating a new array with some elements from the main one and trying to send this. Here's the send part of the code:
int w = 0;
int division = size / (procs -1);
for(i=1; i<procs; i++){
//allocating
char **array1 = (char**) malloc(sizeof(*array1) * division);
array1[0] = (char*) malloc(sizeof(*array1[0]) * division * buf);
for(j=1; j<division; j++)
array1[i] = &(array1[0][i*buf]);
// filling it up
for(j=0; j<division; j++)
array1[j] = array[w++];
// sending
MPI_Send(&array1, division[i], MPI_CHAR, i, tag, MPI_COMM_WORLD);
// clearing memory
free(array1);
}
printf("%d: All Sent\n", rank);
If i change the send method to something like this
MPI_SEND(&array[0][0] ...)
it works, but i need to send more than one string per process.