Skip to content

Commit

Permalink
improve parallelization
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen Schotthöfer committed Sep 13, 2024
1 parent 3156758 commit 1295161
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/common/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,15 +577,16 @@ double Mesh::GetDistanceToOrigin( unsigned idx_cell ) const {
return sqrt( distance );
}


unsigned Mesh::GetCellOfKoordinate( const double x, const double y ) const {
// Experimental parallel implementation
unsigned koordinate_cell_id = std::numeric_limits<unsigned>::max();
bool found = false;

#pragma omp parallel for shared( found )
//#pragma omp parallel for shared( found )
for( unsigned idx_cell = 0; idx_cell < _numCells; idx_cell++ ) {
if( IsPointInsideCell( idx_cell, x, y ) ) {
#pragma omp critical
//#pragma omp critical
{
if( !found ) {
koordinate_cell_id = idx_cell;
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ int main( int argc, char** argv ) {
// Py_SetProgramName( program );
#ifdef BUILD_MPI
MPI_Init( &argc, &argv );
printf( "MPI initialized\n" );
printf( "| KiT-RT compiled with MPI and OpenMP parallelization\n" );
#endif
#ifndef BUILD_MPI
printf( "MPI not initialized\n" );
printf( "| KiT-RT compiled with OpenMP, but without MPI parallelization\n" );
#endif

std::string filename = ParseArguments( argc, argv );
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/snsolver_hpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,7 @@ std::vector<unsigned> SNSolverHPC::linspace2D( const std::vector<double>& start,
result.resize( num_points );
double stepX = ( end[0] - start[0] ) / ( num_points - 1 );
double stepY = ( end[1] - start[1] ) / ( num_points - 1 );

#pragma omp parallel for
for( unsigned i = 0; i < num_points; ++i ) {
double x = start[0] + i * stepX;
double y = start[1] + i * stepY;
Expand Down

0 comments on commit 1295161

Please sign in to comment.