I am learning how to program with MPI and I can't seem to find an example anywhere about scattering two different arrays. Can someone point me in the right direction?

I'll post some of my code below, that way you'll have an idea about what I'm trying to do.

Thanks!

``````unsigned int* assignStarsToClusters(double *stars, double *clusters, unsigned int *azimuth)
{
double start = 0;

if(my_rank == 0)
start = MPI_Wtime();

int slice_size = NUMOFSTARS / comm_sz;

// Assign a star to the closest cluster
double smallDistance;
double tmpDistance;
int indice = 0;
for(unsigned int i = 0; i <= NUMOFSTARS; i+=3)
{
smallDistance = sqrt(sqr(stars[i] - clusters) + sqr(stars[i+1] - clusters) + sqr(stars[i+2] - clusters));

for(int j = 0; j <= (NUMOFCLUSTERS * 3); j+=3)
{
tmpDistance = sqrt(sqr(stars[i] - clusters[j]) + sqr(stars[i+1] - clusters[j+1]) + sqr(stars[i+2] - clusters[j+2]));

if(tmpDistance < smallDistance)
{
smallDistance = tmpDistance;
indice = j;
}

}
azimuth[i/3] = indice / 3;

}

return azimuth;
}
``````

A couple of issues. MPI is a parallel computation framework. Where do you distribute the work to other members of the computational cluster? What I see is what would run on one system (cpu/core etc).

Anyway, go here for more help/tutorials and such: http://www.mcs.anl.gov/research/projects/mpi/