Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NP_TMcode
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giacomo Mulas
NP_TMcode
Commits
4e64f6db
Commit
4e64f6db
authored
11 months ago
by
Giovanni La Mura
Browse files
Options
Downloads
Patches
Plain Diff
Give each thread its own logger
parent
dde2a6de
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cluster/cluster.cpp
+17
-17
17 additions, 17 deletions
src/cluster/cluster.cpp
with
17 additions
and
17 deletions
src/cluster/cluster.cpp
+
17
−
17
View file @
4e64f6db
...
...
@@ -53,7 +53,7 @@ using namespace std;
// I would like to put it all in a struct, but then I'd have to write a constructor for it, due to members defined as references, creating a worse nightmare than the one I'd like to simplify...
int
cluster_jxi488_cycle
(
int
jxi488
,
ScattererConfiguration
*
sconf
,
GeometryConfiguration
*
gconf
,
ScatteringAngles
*
sa
,
ClusterIterationData
*
cid
,
FILE
*
output
,
const
string
&
output_path
,
fstream
&
tppoan
,
Logger
*
logger
);
int
cluster_jxi488_cycle
(
int
jxi488
,
ScattererConfiguration
*
sconf
,
GeometryConfiguration
*
gconf
,
ScatteringAngles
*
sa
,
ClusterIterationData
*
cid
,
FILE
*
output
,
const
string
&
output_path
,
fstream
&
tppoan
);
/*! \brief C++ implementation of CLU
*
...
...
@@ -176,7 +176,7 @@ void cluster(const string& config_file, const string& data_file, const string& o
// do the first iteration on jxi488 separately, since it seems to be different from the others
int
jxi488
=
1
;
chrono
::
time_point
<
chrono
::
high_resolution_clock
>
start_iter_1
=
chrono
::
high_resolution_clock
::
now
();
int
jer
=
cluster_jxi488_cycle
(
jxi488
,
sconf
,
gconf
,
p_scattering_angles
,
cid
,
output
,
output_path
,
tppoan
,
logger
);
int
jer
=
cluster_jxi488_cycle
(
jxi488
,
sconf
,
gconf
,
p_scattering_angles
,
cid
,
output
,
output_path
,
tppoan
);
chrono
::
time_point
<
chrono
::
high_resolution_clock
>
end_iter_1
=
chrono
::
high_resolution_clock
::
now
();
elapsed
=
start_iter_1
-
t_start
;
message
=
"INFO: Calculation setup took "
+
to_string
(
elapsed
.
count
())
+
"s.
\n
"
;
...
...
@@ -222,7 +222,7 @@ void cluster(const string& config_file, const string& data_file, const string& o
// ok, now I can actually start the parallel calculations
#pragma omp for
for
(
jxi488
=
2
;
jxi488
<=
nxi
;
jxi488
++
)
{
int
jer
=
cluster_jxi488_cycle
(
jxi488
,
sconf
,
gconf
,
p_scattering_angles
,
cid_2
,
output_2
,
output_path
,
*
tppoanp_2
,
logger
);
int
jer
=
cluster_jxi488_cycle
(
jxi488
,
sconf
,
gconf
,
p_scattering_angles
,
cid_2
,
output_2
,
output_path
,
*
tppoanp_2
);
}
#pragma omp barrier
...
...
@@ -233,15 +233,12 @@ void cluster(const string& config_file, const string& data_file, const string& o
tppoanp_2
->
close
();
delete
tppoanp_2
;
}
#pragma omp barrier
{
message
=
"INFO: Closing thread-local output files of thread "
+
to_string
(
myompthread
)
+
" and syncing threads.
\n
"
;
logger
->
log
(
message
);
}
}
// closes pragma omp parallel
#ifdef _OPENMP
#pragma omp barrier
{
message
=
"INFO: Thread-local output files closed and threads synchronized.
\n
"
;
logger
->
log
(
message
);
// thread 0 already wrote on global files, skip it and take care of appending the others
chrono
::
time_point
<
chrono
::
high_resolution_clock
>
t_output_start
=
chrono
::
high_resolution_clock
::
now
();
for
(
int
ri
=
1
;
ri
<
ompnumthreads
;
ri
++
)
{
...
...
@@ -308,11 +305,12 @@ void cluster(const string& config_file, const string& data_file, const string& o
delete
logger
;
}
int
cluster_jxi488_cycle
(
int
jxi488
,
ScattererConfiguration
*
sconf
,
GeometryConfiguration
*
gconf
,
ScatteringAngles
*
sa
,
ClusterIterationData
*
cid
,
FILE
*
output
,
const
string
&
output_path
,
fstream
&
tppoan
,
Logger
*
logger
)
int
cluster_jxi488_cycle
(
int
jxi488
,
ScattererConfiguration
*
sconf
,
GeometryConfiguration
*
gconf
,
ScatteringAngles
*
sa
,
ClusterIterationData
*
cid
,
FILE
*
output
,
const
string
&
output_path
,
fstream
&
tppoan
)
{
int
nxi
=
sconf
->
number_of_scales
;
Logger
*
logger
=
new
Logger
(
LOG_INFO
);
string
message
=
"INFO: running scale iteration "
+
to_string
(
jxi488
)
+
" of "
+
to_string
(
nxi
)
+
".
\n
"
;
//
logger->log(message);
logger
->
log
(
message
);
chrono
::
duration
<
double
>
elapsed
;
chrono
::
time_point
<
chrono
::
high_resolution_clock
>
interval_start
,
interval_end
;
int
jer
=
0
;
...
...
@@ -352,6 +350,7 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
hjv
(
exri
,
vkarg
,
jer
,
lcalc
,
cid
->
arg
,
cid
->
c1
,
cid
->
c1ao
,
cid
->
c4
);
if
(
jer
!=
0
)
{
fprintf
(
output
,
" STOP IN HJV
\n
"
);
delete
logger
;
return
jer
;
// break; // rewrite this to go to the end of the function, to free locally allocated variables and return jer
}
...
...
@@ -381,11 +380,13 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
);
if
(
jer
!=
0
)
{
fprintf
(
output
,
" STOP IN DME
\n
"
);
delete
logger
;
return
jer
;
//break;
}
}
if
(
jer
!=
0
)
{
delete
logger
;
return
jer
;
//break;
}
...
...
@@ -395,13 +396,13 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
interval_end
=
chrono
::
high_resolution_clock
::
now
();
elapsed
=
interval_end
-
interval_start
;
message
=
"INFO: matrix calculation for scale "
+
to_string
(
jxi488
)
+
" took "
+
to_string
(
elapsed
.
count
())
+
"s.
\n
"
;
//
logger->log(message);
logger
->
log
(
message
);
interval_start
=
chrono
::
high_resolution_clock
::
now
();
invert_matrix
(
cid
->
am
,
ndit
,
jer
,
mxndm
);
interval_end
=
chrono
::
high_resolution_clock
::
now
();
elapsed
=
interval_end
-
interval_start
;
message
=
"INFO: matrix inversion for scale "
+
to_string
(
jxi488
)
+
" took "
+
to_string
(
elapsed
.
count
())
+
"s.
\n
"
;
//
logger->log(message);
logger
->
log
(
message
);
if
(
jer
!=
0
)
{
return
jer
;
// break; // jxi488 loop: goes to memory clean
...
...
@@ -477,7 +478,7 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
interval_end
=
chrono
::
high_resolution_clock
::
now
();
elapsed
=
interval_end
-
interval_start
;
message
=
"INFO: average calculation for scale "
+
to_string
(
jxi488
)
+
" took "
+
to_string
(
elapsed
.
count
())
+
"s.
\n
"
;
//
logger->log(message);
logger
->
log
(
message
);
interval_start
=
chrono
::
high_resolution_clock
::
now
();
double
th
=
sa
->
th
;
for
(
int
jth486
=
1
;
jth486
<=
sa
->
nth
;
jth486
++
)
{
// OpenMP portable?
...
...
@@ -966,9 +967,8 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
interval_end
=
chrono
::
high_resolution_clock
::
now
();
elapsed
=
interval_end
-
interval_start
;
message
=
"INFO: angle loop for scale "
+
to_string
(
jxi488
)
+
" took "
+
to_string
(
elapsed
.
count
())
+
"s.
\n
"
;
// logger->log(message);
// logger->log("INFO: finished scale iteration " + to_string(jxi488) + " of " + to_string(nxi) + ".\n");
logger
->
log
(
message
);
logger
->
log
(
"INFO: finished scale iteration "
+
to_string
(
jxi488
)
+
" of "
+
to_string
(
nxi
)
+
".
\n
"
);
delete
logger
;
return
jer
;
}
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