Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
LHCb
Rec
Commits
fb3d475c
Commit
fb3d475c
authored
3 years ago
by
Christoph Hasse
Browse files
Options
Downloads
Patches
Plain Diff
protect multi-job jit compilation from race conditions
parent
1b65336b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2699
FunctorFactory, replace CLING backend with native compiler
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Phys/FunctorCore/src/Components/Factory.cpp
+14
-1
14 additions, 1 deletion
Phys/FunctorCore/src/Components/Factory.cpp
with
14 additions
and
1 deletion
Phys/FunctorCore/src/Components/Factory.cpp
+
14
−
1
View file @
fb3d475c
...
...
@@ -16,6 +16,7 @@
#include
<chrono>
#include
<cstdio>
#include
<dlfcn.h>
#include
<filesystem>
#include
<fstream>
#include
<set>
#include
<vector>
...
...
@@ -164,10 +165,17 @@ struct FunctorFactory : public extends<Service, Functors::IFactory> {
out
.
close
();
}
// In a multi job scenario we want to avoid many jobs directly writing to
// the same file and potentially causing problems. Thus we first create a
// uniquely named library and then later rename it. The rename is atomic
// in the sense that a dlopen call will either load the already existing
// file or the newly renamed one. But it can't fail due to e.g. the file
// not having been fully overwritten or similar weird things.
auto
const
lib_tmp_full_path
=
m_jit_lib_dir
+
"FunctorJitLib_tmp_"
+
std
::
to_string
(
getpid
()
);
// functor_jitter is a shell script generated by cmake to invoke the
// correct compiler with the correct flags see:
// Phys/FunctorCore/CMakeLists.txt
auto
cmd
=
"functor_jitter "
+
cpp_filename
+
" "
+
lib_full_path
;
auto
cmd
=
"functor_jitter "
+
cpp_filename
+
" "
+
lib_
tmp_
full_path
;
if
(
msgLevel
(
MSG
::
VERBOSE
)
)
{
verbose
()
<<
"Command that will be executed:
\n
"
<<
cmd
<<
endmsg
;
}
...
...
@@ -178,6 +186,11 @@ struct FunctorFactory : public extends<Service, Functors::IFactory> {
info
()
<<
"Compilation of functor library took "
<<
total_time
.
count
()
<<
" seconds"
<<
endmsg
;
if
(
return_code
!=
0
)
{
throw
exception
(
"Non zero return code!
\n
"
);
}
if
(
msgLevel
(
MSG
::
VERBOSE
)
)
{
verbose
()
<<
"Rename "
<<
lib_tmp_full_path
<<
" to "
<<
lib_full_path
<<
endmsg
;
}
std
::
filesystem
::
rename
(
lib_tmp_full_path
,
lib_full_path
);
m_lib_handle
=
LibHandle
{
dlopen
(
lib_full_path
.
c_str
(),
RTLD_LOCAL
|
RTLD_LAZY
),
lib_closer
};
}
...
...
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