mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add ifdefs for OpenMP usage.
This commit is contained in:
parent
81a93a80fd
commit
02944f4eca
@ -59,7 +59,10 @@
|
|||||||
#include <cmath> // Needed for HUGE_VAL on Linux
|
#include <cmath> // Needed for HUGE_VAL on Linux
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#ifdef USE_OPENMP
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// ECLIPSE cell numbering layout:
|
/// ECLIPSE cell numbering layout:
|
||||||
@ -138,7 +141,10 @@ bool transferGridCellData( RigMainGrid* mainGrid,
|
|||||||
// Loop over cells and fill them with data
|
// Loop over cells and fill them with data
|
||||||
#pragma omp parallel
|
#pragma omp parallel
|
||||||
{
|
{
|
||||||
int cellCountPerThread = std::max( 1, cellCount / omp_get_num_threads() );
|
int cellCountPerThread = cellCount;
|
||||||
|
#ifdef USE_OPENMP
|
||||||
|
cellCountPerThread = std::max( 1, cellCount / omp_get_num_threads() );
|
||||||
|
#endif
|
||||||
|
|
||||||
int computedThreadCellCount = 0;
|
int computedThreadCellCount = 0;
|
||||||
|
|
||||||
@ -210,13 +216,18 @@ bool transferGridCellData( RigMainGrid* mainGrid,
|
|||||||
// if (!invalid && (cell.isInCoarseCell() || (!cell.isActiveInMatrixModel() &&
|
// if (!invalid && (cell.isInCoarseCell() || (!cell.isActiveInMatrixModel() &&
|
||||||
// !cell.isActiveInFractureModel()) ) )
|
// !cell.isActiveInFractureModel()) ) )
|
||||||
cell.setInvalid( cell.isLongPyramidCell() );
|
cell.setInvalid( cell.isLongPyramidCell() );
|
||||||
|
#ifdef USE_OPENMP
|
||||||
if ( omp_get_thread_num() == 0 )
|
if ( omp_get_thread_num() == 0 )
|
||||||
{
|
{
|
||||||
computedThreadCellCount++;
|
computedThreadCellCount++;
|
||||||
if ( computedThreadCellCount <= maxProgressCell && computedThreadCellCount % cellsPrProgressTick == 0 )
|
if ( computedThreadCellCount <= maxProgressCell && computedThreadCellCount % cellsPrProgressTick == 0 )
|
||||||
progInfo.incrementProgress();
|
progInfo.incrementProgress();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
computedThreadCellCount++;
|
||||||
|
if ( computedThreadCellCount <= maxProgressCell && computedThreadCellCount % cellsPrProgressTick == 0 )
|
||||||
|
progInfo.incrementProgress();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1428,7 +1439,7 @@ cvf::Vec3d interpolate3DPosition( const std::vector<SegmentPositionContribution>
|
|||||||
// distance = 1.0;
|
// distance = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
distance = 1.0 / distance;
|
distance = 1.0 / distance;
|
||||||
nominators[i] = distance;
|
nominators[i] = distance;
|
||||||
denominator += distance;
|
denominator += distance;
|
||||||
|
|
||||||
|
@ -44,7 +44,10 @@
|
|||||||
#include "cvfStructGridGeometryGenerator.h"
|
#include "cvfStructGridGeometryGenerator.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#ifdef USE_OPENMP
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
@ -857,11 +860,20 @@ void RimContourMapProjection::generateTrianglesWithVertexValues()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_OPENMP
|
||||||
std::vector<std::vector<std::vector<cvf::Vec4d>>> threadTriangles( omp_get_max_threads() );
|
std::vector<std::vector<std::vector<cvf::Vec4d>>> threadTriangles( omp_get_max_threads() );
|
||||||
|
#else
|
||||||
|
std::vector<std::vector<std::vector<cvf::Vec4d>>> threadTriangles( 1 );
|
||||||
|
#endif
|
||||||
|
|
||||||
#pragma omp parallel
|
#pragma omp parallel
|
||||||
{
|
{
|
||||||
|
#ifdef USE_OPENMP
|
||||||
int myThread = omp_get_thread_num();
|
int myThread = omp_get_thread_num();
|
||||||
|
#else
|
||||||
|
int myThread = 0;
|
||||||
|
#endif
|
||||||
threadTriangles[myThread].resize( std::max( (size_t)1, m_contourPolygons.size() ) );
|
threadTriangles[myThread].resize( std::max( (size_t)1, m_contourPolygons.size() ) );
|
||||||
|
|
||||||
#pragma omp for schedule( dynamic )
|
#pragma omp for schedule( dynamic )
|
||||||
|
@ -28,7 +28,9 @@
|
|||||||
#include "cvfAssert.h"
|
#include "cvfAssert.h"
|
||||||
#include "cvfBoundingBoxTree.h"
|
#include "cvfBoundingBoxTree.h"
|
||||||
|
|
||||||
|
#ifdef USE_OPENMP
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
RigMainGrid::RigMainGrid()
|
RigMainGrid::RigMainGrid()
|
||||||
: RigGridBase( this )
|
: RigGridBase( this )
|
||||||
@ -740,7 +742,10 @@ void RigMainGrid::buildCellSearchTree()
|
|||||||
|
|
||||||
#pragma omp parallel
|
#pragma omp parallel
|
||||||
{
|
{
|
||||||
size_t threadCellCount = std::ceil( cellCount / static_cast<double>( omp_get_num_threads() ) );
|
size_t threadCellCount = cellCount;
|
||||||
|
#ifdef USE_OPENMP
|
||||||
|
threadCellCount = std::ceil( cellCount / static_cast<double>( omp_get_num_threads() ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
std::vector<size_t> threadIndicesForBoundingBoxes;
|
std::vector<size_t> threadIndicesForBoundingBoxes;
|
||||||
std::vector<cvf::BoundingBox> threadBoundingBoxes;
|
std::vector<cvf::BoundingBox> threadBoundingBoxes;
|
||||||
|
@ -39,7 +39,7 @@ if (RESINSIGHT_USE_OPENMP)
|
|||||||
if(OPENMP_FOUND)
|
if(OPENMP_FOUND)
|
||||||
message(STATUS "Enabling OpenMP support")
|
message(STATUS "Enabling OpenMP support")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -DUSE_OPENMP")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
|
||||||
else()
|
else()
|
||||||
message(STATUS "Disabling OpenMP support")
|
message(STATUS "Disabling OpenMP support")
|
||||||
|
Loading…
Reference in New Issue
Block a user