Sorry, complicated_computation() and f() are simplified too much. They do take more inputs.
Among the inputs to complicated_computation(), some is passed from the main() to f() by address since it is a big array, some is passed by value, some are created inside f() before the call to complicated_computation().
so actually (although not exactly) the code is like:
int main(int argc, char ** argv)
{
int size;
double *feature = new double[1000];
// compute values of elements of "feature"
// some operations
f(size, feature);
// some operations
delete [] feature;
return 0;
}
void f(int size, double *feature)
{
vector<double> coeff;
// read from a file into elements of coeff
MyClass myobj;
double * array = new double [coeff.size()];
for (int i = 0; i < coeff.size(); i++) // need to speed up by MPI.
{
array[i] = myobj.complicated_computation(size, coeff[i], feature); // time consuming
}
// some operations using all elements in array
delete [] array;
}
--- On Thu, 1/28/10, Eugene Loh <Eugene.Loh_at_[hidden]> wrote:
> From: Eugene Loh <Eugene.Loh_at_[hidden]>
> Subject: Re: [OMPI users] speed up this problem by MPI
> To: "Open MPI Users" <users_at_[hidden]>
> Date: Thursday, January 28, 2010, 11:40 PM
> Tim wrote:
>
> > Thanks Eugene!
> >
> > My case, after simplified, is to speed up the
> time-consuming computation in the loop below by assigning
> iterations to several nodes in a cluster by MPI. Each
> iteration of the loop computes each element of an array. The
> computation of each element is independent of others in the
> array.
> > int main(int argc, char
> ** argv) {
> // some operations
> f(size);
> // some
> operations
> return 0;
> }
> void f(int size)
> { // some
> operations
> int i;
> double * array = new double
> [size];
> for (i = 0; i < size; i++) // need to
> speed up by MPI.
> > {
> array[i] = complicated_computation(); //
> time consuming
> What are the inputs to complicated_computation()?
> Does each process know what the inputs are? Or, do
> they need to come from the master process? Are there
> many inputs?
>
> > }
> // some operations using all
> elements in array
> delete [] array;
> }
> >
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users
>
|