Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VirtualFluids
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iRMB
VirtualFluids
Commits
66415094
Commit
66415094
authored
5 years ago
by
Konstantin Kutscher
Browse files
Options
Downloads
Patches
Plain Diff
fix exeptions propagation for OpenMP
parent
6a445f02
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/VirtualFluidsCore/Grid/BasicCalculator.cpp
+114
-82
114 additions, 82 deletions
source/VirtualFluidsCore/Grid/BasicCalculator.cpp
with
114 additions
and
82 deletions
source/VirtualFluidsCore/Grid/BasicCalculator.cpp
+
114
−
82
View file @
66415094
...
...
@@ -15,7 +15,7 @@
//#define TIMING
//#include "UbTiming.h"
BasicCalculator
::
BasicCalculator
(
SPtr
<
Grid3D
>
grid
,
SPtr
<
UbScheduler
>
additionalGhostLayerUpdateScheduler
,
int
numberOfTimeSteps
)
:
BasicCalculator
::
BasicCalculator
(
SPtr
<
Grid3D
>
grid
,
SPtr
<
UbScheduler
>
additionalGhostLayerUpdateScheduler
,
int
numberOfTimeSteps
)
:
Calculator
(
grid
,
additionalGhostLayerUpdateScheduler
,
numberOfTimeSteps
)
{
...
...
@@ -33,9 +33,9 @@ void BasicCalculator::calculate()
try
{
int
minInitLevel
=
minLevel
;
int
maxInitLevel
=
maxLevel
-
minLevel
;
int
maxInitLevel
=
maxLevel
-
minLevel
;
int
straightStartLevel
=
minInitLevel
;
int
internalIterations
=
1
<<
(
maxInitLevel
-
minInitLevel
);
int
internalIterations
=
1
<<
(
maxInitLevel
-
minInitLevel
);
int
forwardStartLevel
;
int
threshold
;
...
...
@@ -44,22 +44,22 @@ void BasicCalculator::calculate()
double
time
[
6
];
#endif
for
(
calcStep
=
startTimeStep
;
calcStep
<=
numberOfTimeSteps
;
calcStep
++
)
for
(
calcStep
=
startTimeStep
;
calcStep
<=
numberOfTimeSteps
;
calcStep
++
)
{
//////////////////////////////////////////////////////////////////////////
#ifdef TIMING
UBLOG
(
logINFO
,
"calcStep = "
<<
calcStep
);
UBLOG
(
logINFO
,
"calcStep = "
<<
calcStep
);
#endif
//////////////////////////////////////////////////////////////////////////
for
(
int
staggeredStep
=
1
;
staggeredStep
<=
internalIterations
;
staggeredStep
++
)
for
(
int
staggeredStep
=
1
;
staggeredStep
<=
internalIterations
;
staggeredStep
++
)
{
forwardStartLevel
=
straightStartLevel
;
if
(
staggeredStep
==
internalIterations
)
straightStartLevel
=
minInitLevel
;
if
(
staggeredStep
==
internalIterations
)
straightStartLevel
=
minInitLevel
;
else
{
for
(
straightStartLevel
=
maxInitLevel
,
threshold
=
1
;
(
staggeredStep
&
threshold
)
!=
threshold
;
straightStartLevel
--
,
threshold
<<=
1
);
(
staggeredStep
&
threshold
)
!=
threshold
;
straightStartLevel
--
,
threshold
<<=
1
);
}
//////////////////////////////////////////////////////////////////////////
#ifdef TIMING
...
...
@@ -73,7 +73,7 @@ void BasicCalculator::calculate()
//////////////////////////////////////////////////////////////////////////
#ifdef TIMING
time
[
0
]
=
timer
.
stop
();
UBLOG
(
logINFO
,
"calculateBlocks time = "
<<
time
[
0
]);
UBLOG
(
logINFO
,
"calculateBlocks time = "
<<
time
[
0
]);
#endif
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
...
...
@@ -82,14 +82,14 @@ void BasicCalculator::calculate()
//////////////////////////////////////////////////////////////////////////
#ifdef TIMING
time
[
1
]
=
timer
.
stop
();
UBLOG
(
logINFO
,
"exchangeBlockData time = "
<<
time
[
1
]);
UBLOG
(
logINFO
,
"exchangeBlockData time = "
<<
time
[
1
]);
#endif
//////////////////////////////////////////////////////////////////////////
applyPostCollisionBC
(
straightStartLevel
,
maxInitLevel
);
//////////////////////////////////////////////////////////////////////////
#ifdef TIMING
time
[
2
]
=
timer
.
stop
();
UBLOG
(
logINFO
,
"applyBCs time = "
<<
time
[
2
]);
UBLOG
(
logINFO
,
"applyBCs time = "
<<
time
[
2
]);
#endif
//////////////////////////////////////////////////////////////////////////
//swap distributions in kernel
...
...
@@ -97,17 +97,17 @@ void BasicCalculator::calculate()
//////////////////////////////////////////////////////////////////////////
#ifdef TIMING
time
[
3
]
=
timer
.
stop
();
UBLOG
(
logINFO
,
"swapDistributions time = "
<<
time
[
3
]);
UBLOG
(
logINFO
,
"swapDistributions time = "
<<
time
[
3
]);
#endif
//////////////////////////////////////////////////////////////////////////
if
(
refinement
)
{
if
(
straightStartLevel
<
maxInitLevel
)
if
(
straightStartLevel
<
maxInitLevel
)
exchangeBlockData
(
straightStartLevel
,
maxInitLevel
);
//////////////////////////////////////////////////////////////////////////
#ifdef TIMING
time
[
4
]
=
timer
.
stop
();
UBLOG
(
logINFO
,
"refinement exchangeBlockData time = "
<<
time
[
4
]);
UBLOG
(
logINFO
,
"refinement exchangeBlockData time = "
<<
time
[
4
]);
#endif
//////////////////////////////////////////////////////////////////////////
//now ghost nodes have actual values
...
...
@@ -116,7 +116,7 @@ void BasicCalculator::calculate()
//////////////////////////////////////////////////////////////////////////
#ifdef TIMING
time
[
5
]
=
timer
.
stop
();
UBLOG
(
logINFO
,
"refinement interpolation time = "
<<
time
[
5
]);
UBLOG
(
logINFO
,
"refinement interpolation time = "
<<
time
[
5
]);
#endif
//////////////////////////////////////////////////////////////////////////
}
...
...
@@ -131,22 +131,24 @@ void BasicCalculator::calculate()
}
UBLOG
(
logDEBUG1
,
"OMPCalculator::calculate() - stoped"
);
}
catch
(
std
::
exception
&
e
)
catch
(
std
::
exception
&
e
)
{
UBLOG
(
logERROR
,
e
.
what
());
UBLOG
(
logERROR
,
" step = "
<<
calcStep
);
//throw;
exit
(
EXIT_FAILURE
);
UBLOG
(
logERROR
,
" step = "
<<
calcStep
);
//throw
e
;
//
exit(EXIT_FAILURE);
}
catch
(
std
::
string
&
s
)
catch
(
std
::
string
&
s
)
{
UBLOG
(
logERROR
,
s
);
exit
(
EXIT_FAILURE
);
//exit(EXIT_FAILURE);
//throw s;
}
catch
(...)
{
UBLOG
(
logERROR
,
"unknown exception"
);
exit
(
EXIT_FAILURE
);
//exit(EXIT_FAILURE);
//throw;
}
}
//////////////////////////////////////////////////////////////////////////
...
...
@@ -157,32 +159,31 @@ void BasicCalculator::calculateBlocks(int startLevel, int maxInitLevel, int calc
#endif
{
SPtr
<
Block3D
>
blockTemp
;
try
//startLevel bis maxInitLevel
for
(
int
level
=
startLevel
;
level
<=
maxInitLevel
;
level
++
)
{
//startLevel bis maxInitLevel
for
(
int
level
=
startLevel
;
level
<=
maxInitLevel
;
level
++
)
{
//timer.resetAndStart();
//call LBM kernel
int
size
=
(
int
)
blocks
[
level
].
size
();
//timer.resetAndStart();
//call LBM kernel
int
size
=
(
int
)
blocks
[
level
].
size
();
#ifdef _OPENMP
#pragma omp for schedule(OMP_SCHEDULE)
#endif
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
try
{
blockTemp
=
blocks
[
level
][
i
];
blockTemp
->
getKernel
()
->
calculate
(
calcStep
);
}
//timer.stop();
//UBLOG(logINFO, "level = " << level << " blocks = " << blocks[level].size() << " collision time = " << timer.getTotalTime());
catch
(
std
::
exception
&
e
)
{
UBLOG
(
logERROR
,
e
.
what
());
UBLOG
(
logERROR
,
blockTemp
->
toString
()
<<
" step = "
<<
calcStep
);
std
::
exit
(
EXIT_FAILURE
);
}
}
}
catch
(
std
::
exception
&
e
)
{
UBLOG
(
logERROR
,
e
.
what
());
//UBLOG(logERROR, blockTemp->toString()<<" step = "<<calcStep);
//throw;
exit
(
EXIT_FAILURE
);
//timer.stop();
//UBLOG(logINFO, "level = " << level << " blocks = " << blocks[level].size() << " collision time = " << timer.getTotalTime());
}
}
}
...
...
@@ -190,7 +191,7 @@ void BasicCalculator::calculateBlocks(int startLevel, int maxInitLevel, int calc
void
BasicCalculator
::
exchangeBlockData
(
int
startLevel
,
int
maxInitLevel
)
{
//startLevel bis maxInitLevel
for
(
int
level
=
startLevel
;
level
<=
maxInitLevel
;
level
++
)
for
(
int
level
=
startLevel
;
level
<=
maxInitLevel
;
level
++
)
{
//connectorsPrepareLocal(localConns[level]);
connectorsSendLocal
(
localConns
[
level
]);
...
...
@@ -209,13 +210,13 @@ void BasicCalculator::swapDistributions(int startLevel, int maxInitLevel)
#endif
{
//startLevel bis maxInitLevel
for
(
int
level
=
startLevel
;
level
<=
maxInitLevel
;
level
++
)
for
(
int
level
=
startLevel
;
level
<=
maxInitLevel
;
level
++
)
{
int
size
=
(
int
)
blocks
[
level
].
size
();
#ifdef _OPENMP
#pragma omp for schedule(OMP_SCHEDULE)
#endif
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
blocks
[
level
][
i
]
->
getKernel
()
->
swapDistributions
();
}
...
...
@@ -229,10 +230,18 @@ void BasicCalculator::connectorsPrepareLocal(std::vector< SPtr<Block3DConnector>
#ifdef _OPENMP
#pragma omp parallel for schedule(OMP_SCHEDULE)
#endif
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
connectors
[
i
]
->
prepareForReceive
();
connectors
[
i
]
->
prepareForSend
();
try
{
connectors
[
i
]
->
prepareForReceive
();
connectors
[
i
]
->
prepareForSend
();
}
catch
(
std
::
exception
&
e
)
{
UBLOG
(
logERROR
,
e
.
what
());
std
::
exit
(
EXIT_FAILURE
);
}
}
}
//////////////////////////////////////////////////////////////////////////
...
...
@@ -242,10 +251,18 @@ void BasicCalculator::connectorsSendLocal(std::vector< SPtr<Block3DConnector> >&
#ifdef _OPENMP
#pragma omp parallel for schedule(OMP_SCHEDULE)
#endif
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
connectors
[
i
]
->
fillSendVectors
();
connectors
[
i
]
->
sendVectors
();
try
{
connectors
[
i
]
->
fillSendVectors
();
connectors
[
i
]
->
sendVectors
();
}
catch
(
std
::
exception
&
e
)
{
UBLOG
(
logERROR
,
e
.
what
());
std
::
exit
(
EXIT_FAILURE
);
}
}
}
//////////////////////////////////////////////////////////////////////////
...
...
@@ -255,7 +272,7 @@ void BasicCalculator::connectorsReceiveLocal(std::vector< SPtr<Block3DConnector>
#ifdef _OPENMP
#pragma omp parallel for schedule(OMP_SCHEDULE)
#endif
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
connectors
[
i
]
->
receiveVectors
();
connectors
[
i
]
->
distributeReceiveVectors
();
...
...
@@ -264,7 +281,7 @@ void BasicCalculator::connectorsReceiveLocal(std::vector< SPtr<Block3DConnector>
void
BasicCalculator
::
connectorsPrepareRemote
(
std
::
vector
<
SPtr
<
Block3DConnector
>
>&
connectors
)
{
int
size
=
(
int
)
connectors
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
connectors
[
i
]
->
prepareForReceive
();
connectors
[
i
]
->
prepareForSend
();
...
...
@@ -274,7 +291,7 @@ void BasicCalculator::connectorsPrepareRemote(std::vector< SPtr<Block3DConnector
void
BasicCalculator
::
connectorsSendRemote
(
std
::
vector
<
SPtr
<
Block3DConnector
>
>&
connectors
)
{
int
size
=
(
int
)
connectors
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
connectors
[
i
]
->
fillSendVectors
();
connectors
[
i
]
->
sendVectors
();
...
...
@@ -284,7 +301,7 @@ void BasicCalculator::connectorsSendRemote(std::vector< SPtr<Block3DConnector> >
void
BasicCalculator
::
connectorsReceiveRemote
(
std
::
vector
<
SPtr
<
Block3DConnector
>
>&
connectors
)
{
int
size
=
(
int
)
connectors
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
connectors
[
i
]
->
receiveVectors
();
connectors
[
i
]
->
distributeReceiveVectors
();
...
...
@@ -293,19 +310,19 @@ void BasicCalculator::connectorsReceiveRemote(std::vector< SPtr<Block3DConnector
//////////////////////////////////////////////////////////////////////////
void
BasicCalculator
::
interpolation
(
int
startLevel
,
int
maxInitLevel
)
{
for
(
int
level
=
startLevel
;
level
<
maxInitLevel
;
level
++
)
for
(
int
level
=
startLevel
;
level
<
maxInitLevel
;
level
++
)
{
connectorsPrepareLocal
(
localInterConns
[
level
]);
connectorsPrepareRemote
(
remoteInterConns
[
level
]);
}
for
(
int
level
=
startLevel
;
level
<
maxInitLevel
;
level
++
)
for
(
int
level
=
startLevel
;
level
<
maxInitLevel
;
level
++
)
{
connectorsSendLocal
(
localInterConns
[
level
]);
connectorsSendRemote
(
remoteInterConns
[
level
]);
}
for
(
int
level
=
startLevel
;
level
<
maxInitLevel
;
level
++
)
for
(
int
level
=
startLevel
;
level
<
maxInitLevel
;
level
++
)
{
connectorsReceiveLocal
(
localInterConns
[
level
]);
connectorsReceiveRemote
(
remoteInterConns
[
level
]);
...
...
@@ -315,53 +332,68 @@ void BasicCalculator::interpolation(int startLevel, int maxInitLevel)
void
BasicCalculator
::
applyPreCollisionBC
(
int
startLevel
,
int
maxInitLevel
)
{
//startLevel bis maxInitLevel
for
(
int
level
=
startLevel
;
level
<=
maxInitLevel
;
level
++
)
for
(
int
level
=
startLevel
;
level
<=
maxInitLevel
;
level
++
)
{
int
size
=
(
int
)
blocks
[
level
].
size
();
#ifdef _OPENMP
#pragma omp parallel for schedule(OMP_SCHEDULE)
#endif
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
blocks
[
level
][
i
]
->
getKernel
()
->
getBCProcessor
()
->
applyPreCollisionBC
();
try
{
blocks
[
level
][
i
]
->
getKernel
()
->
getBCProcessor
()
->
applyPreCollisionBC
();
}
catch
(
std
::
exception
&
e
)
{
UBLOG
(
logERROR
,
e
.
what
());
exit
(
EXIT_FAILURE
);
}
catch
(
std
::
string
&
s
)
{
UBLOG
(
logERROR
,
s
);
exit
(
EXIT_FAILURE
);
}
catch
(...)
{
UBLOG
(
logERROR
,
"unknown exception"
);
exit
(
EXIT_FAILURE
);
}
}
}
}
//////////////////////////////////////////////////////////////////////////
void
BasicCalculator
::
applyPostCollisionBC
(
int
startLevel
,
int
maxInitLevel
)
{
try
{
//startLevel bis maxInitLevel
for
(
int
level
=
startLevel
;
level
<=
maxInitLevel
;
level
++
)
for
(
int
level
=
startLevel
;
level
<=
maxInitLevel
;
level
++
)
{
int
size
=
(
int
)
blocks
[
level
].
size
();
#ifdef _OPENMP
#pragma omp parallel for schedule(OMP_SCHEDULE)
#endif
for
(
int
i
=
0
;
i
<
size
;
i
++
)
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
blocks
[
level
][
i
]
->
getKernel
()
->
getBCProcessor
()
->
applyPostCollisionBC
();
try
{
blocks
[
level
][
i
]
->
getKernel
()
->
getBCProcessor
()
->
applyPostCollisionBC
();
}
catch
(
std
::
exception
&
e
)
{
UBLOG
(
logERROR
,
e
.
what
());
exit
(
EXIT_FAILURE
);
}
catch
(
std
::
string
&
s
)
{
UBLOG
(
logERROR
,
s
);
exit
(
EXIT_FAILURE
);
}
catch
(...)
{
UBLOG
(
logERROR
,
"unknown exception"
);
exit
(
EXIT_FAILURE
);
}
}
}
}
catch
(
std
::
exception
&
e
)
{
UBLOG
(
logERROR
,
e
.
what
());
//UBLOG(logERROR, " step = "<<calcStep);
//throw;
exit
(
EXIT_FAILURE
);
}
catch
(
std
::
string
&
s
)
{
UBLOG
(
logERROR
,
s
);
//throw;
exit
(
EXIT_FAILURE
);
}
catch
(...)
{
UBLOG
(
logERROR
,
"unknown exception"
);
//throw;
exit
(
EXIT_FAILURE
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment