Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DP3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Mattia Mancini
DP3
Commits
fe2606d5
Commit
fe2606d5
authored
1 year ago
by
Sarod Yatawatta
Committed by
Sarod Yatawatta
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
add h5parm singleton
parent
791b90f3
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
steps/SagecalPredict.cc
+17
-1
17 additions, 1 deletion
steps/SagecalPredict.cc
steps/SagecalPredict.h
+24
-0
24 additions, 0 deletions
steps/SagecalPredict.h
with
41 additions
and
1 deletion
steps/SagecalPredict.cc
+
17
−
1
View file @
fe2606d5
...
...
@@ -315,6 +315,20 @@ SagecalPredict::BeamDataSingle::~BeamDataSingle() {
}
#endif
/* HAVE_LIBDIRAC || HAVE_LIBDIRAC_CUDA */
schaapcommon
::
h5parm
::
H5Parm
&
SagecalPredict
::
H5ParmSingle
::
open_file
(
const
std
::
string
&
h5_name
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
if
(
is_opened_
)
{
return
h5_parm_
;
}
h5_parm_
=
H5Parm
(
h5_name
,
false
);
is_opened_
=
true
;
return
h5_parm_
;
}
void
SagecalPredict
::
SetOperation
(
const
std
::
string
&
operation
)
{
if
(
operation
==
"replace"
)
{
operation_
=
Operation
::
kReplace
;
...
...
@@ -434,7 +448,9 @@ void SagecalPredict::init(
}
std
::
vector
<
std
::
string
>
h5directions
;
if
(
parm_on_disk_
)
{
h5_parm_
=
H5Parm
(
h5_name_
,
false
);
// Create a singleton to only open and read the H5 file once
h5_parm_reference_
=
SagecalPredict
::
H5ParmSingle
::
get_instance
();
h5_parm_
=
h5_parm_reference_
->
open_file
(
h5_name_
);
// Check to see soltab is initialized at the constructor
if
(
soltab_name_
.
empty
())
{
soltab_name_
=
parset
.
getString
(
prefix
+
"applycal.correction"
);
...
...
This diff is collapsed.
Click to expand it.
steps/SagecalPredict.h
+
24
−
0
View file @
fe2606d5
...
...
@@ -129,6 +129,29 @@ class SagecalPredict : public ModelDataStep {
};
#endif
/* HAVE_LIBDIRAC || HAVE_LIBDIRAC_CUDA */
// Singleton to open and read H5 file only by one thread
// But H5Parm itself is assumed thread-safe
class
H5ParmSingle
{
private:
explicit
H5ParmSingle
()
:
is_opened_
(
false
)
{}
std
::
mutex
mutex_
;
bool
is_opened_
;
public
:
H5ParmSingle
(
H5ParmSingle
const
&
)
=
delete
;
H5ParmSingle
&
operator
=
(
H5ParmSingle
const
&
)
=
delete
;
~
H5ParmSingle
(){};
static
H5ParmSingle
*
get_instance
()
{
static
H5ParmSingle
instance
;
return
&
instance
;
}
schaapcommon
::
h5parm
::
H5Parm
&
open_file
(
const
std
::
string
&
h5_name
);
schaapcommon
::
h5parm
::
H5Parm
h5_parm_
;
};
public
:
SagecalPredict
(
const
common
::
ParameterSet
&
,
const
std
::
string
&
prefix
,
MsType
input_type
=
MsType
::
kRegular
);
...
...
@@ -203,6 +226,7 @@ class SagecalPredict : public ModelDataStep {
// H5 solutions handling
schaapcommon
::
h5parm
::
H5Parm
h5_parm_
;
H5ParmSingle
*
h5_parm_reference_
{
nullptr
};
std
::
string
solset_name_
;
std
::
string
soltab_name_
;
bool
invert_
{
false
};
...
...
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