Add use of OpenMP for a heavy loop (#42)

This commit is contained in:
WurmD 2020-02-10 17:04:36 +00:00 committed by GitHub
parent aeafbbfe47
commit 908732a091
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -9,6 +9,9 @@ cmake_minimum_required (VERSION 3.11)
project (UVAtlas LANGUAGES CXX)
# #pragma omp is used to specify Directives and Clauses. If /openmp is not specified in a compilation, the compiler ignores OpenMP clauses and directives
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/openmp>)
option(BUILD_TOOLS "Build UVAtlasTool" ON)
set(CMAKE_CXX_STANDARD 14)

View File

@ -395,14 +395,17 @@ float CIsochartMesh::CalOptimalAvgL2SquaredStretch(
bool bAllChartSatisfiedStretch = true;
const CBaseMeshInfo& baseInfo = chartList[0]->m_baseInfo;
float fSumSqrtEiiaii = 0;
for (size_t ii=0; ii<chartList.size(); ii++)
#pragma omp parallel for
for (int ii = 0; ii < chartList.size(); ii++)
{
float fEii = chartList[ii]->m_fParamStretchL2;
float faii = chartList[ii]->m_fChart2DArea;
bAllChartSatisfiedStretch =
bAllChartSatisfiedStretch =
(bAllChartSatisfiedStretch && (fEii == faii));
fSumSqrtEiiaii += IsochartSqrtf(fEii * faii);
auto temp = IsochartSqrtf(fEii * faii); // For better profiling
#pragma atomic
fSumSqrtEiiaii += temp;
}
if (bAllChartSatisfiedStretch)