Thanks!
How to send/recieve and broadcast objects of self-defined class and of std::vector?
How to deal with serialization problems?
BTW: I would like to find some official documentation of OpenMP, but there seems none?
--- On Fri, 1/29/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: Friday, January 29, 2010, 12:50 AM
> Tim wrote:
>
> > 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:
> >
> I think I'm agreeing with Terry. But, to add more
> detail:
>
> > int main(int argc, char **
> argv) {
> int size;
> > double *feature = new
> double[1000];
> > // compute values of elements
> of "feature"
> > // some operations
> >
> The array "feature" can be computed by the master and then
> broadcast, or it could be computed redundantly by each
> process.
>
> > 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
> >
> Similarly, coeff can be read in by the master and then
> broadcast, or it could be read redundantly by each process,
> or each process could read only the portion that it will
> need.
>
> >
> > 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
> }
> >
> Each process loops only over the iterations that correspond
> to its rank. Then, the master gathers all results.
>
> > // some operations using all
> elements in array
> delete [] array;
> > }
> >
> Once the slaves have finished their computations and sent
> their results to the master, they may exit. The slaves
> will be launched at the same time as the master, but
> presumably have less to do than the master does before the
> "parallel loop" starts. If you don't want slaves
> consuming excessive CPU time while they wait for the master,
> fix that problem later once you have the basic code
> working.
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users
>
|