Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-feliks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Feliks Kiszkurno
ogs-feliks
Commits
cb5cf798
Commit
cb5cf798
authored
7 months ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
Add boolean conversion to ThreadException
This slightly simplifies code avoiding extra boolean variable.
parent
5cf9379c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
BaseLib/ThreadException.h
+7
-0
7 additions, 0 deletions
BaseLib/ThreadException.h
ProcessLib/Assembly/ParallelVectorMatrixAssembler.cpp
+2
-5
2 additions, 5 deletions
ProcessLib/Assembly/ParallelVectorMatrixAssembler.cpp
with
9 additions
and
5 deletions
BaseLib/ThreadException.h
+
7
−
0
View file @
cb5cf798
...
...
@@ -14,6 +14,11 @@
/// Initial code from
/// https://stackoverflow.com/questions/11828539/elegant-exception-handling-in-openmp
///
/// The implementation does not guarantee, that while the exception is being
/// checked for nullptr in the bool-conversion operator, the capture is not
/// changing the pointer. This might lead to an exception being lost if there
/// are two exceptions thrown simultaneously.
class
ThreadException
{
public:
...
...
@@ -31,6 +36,8 @@ public:
}
}
explicit
operator
bool
()
const
noexcept
{
return
exception_
!=
nullptr
;
}
private
:
std
::
exception_ptr
exception_
=
nullptr
;
std
::
mutex
lock_
;
...
...
This diff is collapsed.
Click to expand it.
ProcessLib/Assembly/ParallelVectorMatrixAssembler.cpp
+
2
−
5
View file @
cb5cf798
...
...
@@ -136,7 +136,6 @@ void ParallelVectorMatrixAssembler::assembleWithJacobian(
ConcurrentMatrixView
Jac_view
(
Jac
);
ThreadException
exception
;
bool
assembly_error
=
false
;
#pragma omp parallel num_threads(num_threads_)
{
#ifdef _OPENMP
...
...
@@ -172,7 +171,7 @@ void ParallelVectorMatrixAssembler::assembleWithJacobian(
for
(
std
::
ptrdiff_t
element_id
=
0
;
element_id
<
n_loc_asm
;
++
element_id
)
{
if
(
assembly_error
)
if
(
exception
)
{
continue
;
}
...
...
@@ -187,7 +186,6 @@ void ParallelVectorMatrixAssembler::assembleWithJacobian(
catch
(...)
{
exception
.
capture
();
assembly_error
=
true
;
continue
;
}
...
...
@@ -206,7 +204,7 @@ void ParallelVectorMatrixAssembler::assembleWithJacobian(
#pragma omp for nowait
for
(
std
::
ptrdiff_t
i
=
0
;
i
<
n_act_elem
;
++
i
)
{
if
(
assembly_error
)
if
(
exception
)
{
continue
;
}
...
...
@@ -223,7 +221,6 @@ void ParallelVectorMatrixAssembler::assembleWithJacobian(
catch
(...)
{
exception
.
capture
();
assembly_error
=
true
;
continue
;
}
...
...
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