Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

void Impala::Util::Mpi::Reduce ( std::vector< double > &  v  ) 

mpi reduce double vector by adding

Definition at line 15 of file Reduce.h.

Referenced by Impala::Core::Training::ParameterSearcher::SearchParallel().

00016 {
00017 #ifdef MPI_USED
00018     MPI_Barrier(MPI_COMM_WORLD);
00019     int gridSize = v.size();
00020     // note: copying might be a problem for large vectors...
00021     double* grid = new double[gridSize];
00022     int i;
00023     for(i=0 ; i<gridSize ; ++i)
00024         grid[i] = v[i];
00025 
00026     double* reducedGrid = 0;
00027     if(Link::Mpi::MyId() == 0)
00028         reducedGrid = new double[gridSize];
00029     MPI_Reduce(grid, reducedGrid, gridSize, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
00030     if(Link::Mpi::MyId() == 0)
00031     {
00032         for(i=0 ; i<gridSize ; ++i)
00033             v[i] = reducedGrid[i];
00034         delete reducedGrid;
00035     }
00036 #endif
00037 }


Generated on Fri Mar 19 11:41:36 2010 for ImpalaSrc by  doxygen 1.5.1