Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
swiftmpistepsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
SWIFT
swiftmpistepsim
Commits
abd4ed4d
Commit
abd4ed4d
authored
5 years ago
by
Peter W. Draper
Browse files
Options
Downloads
Patches
Plain Diff
Use a fix timer in the injection loop
Doesn't make any difference
parent
3f28aa34
No related branches found
No related tags found
1 merge request
!2
Use a fix timer in the injection loop
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swiftmpistepsim.c
+20
-33
20 additions, 33 deletions
swiftmpistepsim.c
with
20 additions
and
33 deletions
swiftmpistepsim.c
+
20
−
33
View file @
abd4ed4d
...
@@ -38,6 +38,9 @@ static int verbose = 0;
...
@@ -38,6 +38,9 @@ static int verbose = 0;
/* Attempt to keep original injection time differences. */
/* Attempt to keep original injection time differences. */
static
int
usetics
=
1
;
static
int
usetics
=
1
;
/* The wait between injections, nanosecs. */
static
long
long
waitns
=
10000
;
/* Integer types of send and recv tasks, must match log. */
/* Integer types of send and recv tasks, must match log. */
static
const
int
task_type_send
=
22
;
static
const
int
task_type_send
=
22
;
static
const
int
task_type_recv
=
23
;
static
const
int
task_type_recv
=
23
;
...
@@ -81,38 +84,16 @@ static void *inject_thread(void *arg) {
...
@@ -81,38 +84,16 @@ static void *inject_thread(void *arg) {
ticks
looptics
=
0
;
ticks
looptics
=
0
;
double
deadtime
=
0
.
0
;
double
deadtime
=
0
.
0
;
struct
timespec
sleep
;
sleep
.
tv_sec
=
0
;
while
(
ind_req
<
nr_reqs
)
{
while
(
ind_req
<
nr_reqs
)
{
struct
mpiuse_log_entry
*
log
=
reqs_queue
[
ind_req
];
struct
mpiuse_log_entry
*
log
=
reqs_queue
[
ind_req
];
if
(
usetics
)
{
if
(
usetics
)
{
/* Expect time between this request and the previous one. */
sleep
.
tv_nsec
=
waitns
;
ticks
dt
=
log
->
tic
-
basetic
;
nanosleep
(
&
sleep
,
NULL
);
basetic
=
log
->
tic
;
deadtime
+=
sleep
.
tv_nsec
;
/* We guess some time below which we should not attempt to wait,
* otherwise we'll start to overrun, and just inject the next call if we
* are below that (we time the ticks this loop takes without any waiting
* and use that). Otherwise we wait a while. Note we need to convert the
* ticks of the log file into nanoseconds, that requires the original
* CPU frequency. */
if
(
dt
>
looptics
)
{
struct
timespec
sleep
;
sleep
.
tv_sec
=
0
;
/* Remember to be fair and remove the looptics, then convert to
* nanoseconds. */
double
ns
=
(
double
)(
dt
-
looptics
)
/
log_clocks_cpufreq
*
1.0e9
;
if
(
ns
<
1.0e9
)
{
sleep
.
tv_nsec
=
(
long
)
ns
;
}
else
{
/* Wait more than one second. Must be an error, but complain and
* continue. */
sleep
.
tv_nsec
=
(
long
)
1.0e9
;
message
(
"wait greater than one second"
);
}
nanosleep
(
&
sleep
,
NULL
);
deadtime
+=
sleep
.
tv_nsec
;
}
}
}
/* Initialise new log elements. */
/* Initialise new log elements. */
...
@@ -151,7 +132,8 @@ static void *inject_thread(void *arg) {
...
@@ -151,7 +132,8 @@ static void *inject_thread(void *arg) {
/* Set looptics on the first pass. Assumes MPI_Isend and MPI_Irecv are
/* Set looptics on the first pass. Assumes MPI_Isend and MPI_Irecv are
* equally timed. */
* equally timed. */
if
(
looptics
==
0
&&
usetics
)
{
if
(
looptics
==
0
&&
usetics
)
{
looptics
=
getticks
()
-
starttics
;
/* Not well matched, so try a lower value. */
looptics
=
(
getticks
()
-
starttics
)
/
4
;
if
(
verbose
)
if
(
verbose
)
message
(
"injection loop took %.3f %s."
,
clocks_from_ticks
(
looptics
),
message
(
"injection loop took %.3f %s."
,
clocks_from_ticks
(
looptics
),
clocks_getunit
());
clocks_getunit
());
...
@@ -355,9 +337,10 @@ static void pick_logs(void) {
...
@@ -355,9 +337,10 @@ static void pick_logs(void) {
* @brief usage help.
* @brief usage help.
*/
*/
static
void
usage
(
char
*
argv
[])
{
static
void
usage
(
char
*
argv
[])
{
fprintf
(
stderr
,
"Usage: %s [-vf] SWIFT_mpiuse-log-file.dat logfile.dat
\n
"
,
fprintf
(
stderr
,
"Usage: %s [-vf] [-n nanosec] SWIFT_mpiuse-log-file.dat "
argv
[
0
]);
"logfile.dat
\n
"
,
argv
[
0
]);
fprintf
(
stderr
,
" options: -v verbose, -f fast injections
\n
"
);
fprintf
(
stderr
,
" options: -v verbose, -f fast injections, "
"-n nanoseconds to wait
\n
"
);
fflush
(
stderr
);
fflush
(
stderr
);
}
}
...
@@ -383,7 +366,7 @@ int main(int argc, char *argv[]) {
...
@@ -383,7 +366,7 @@ int main(int argc, char *argv[]) {
/* Handle the command-line, we expect a mpiuse data file to read and various
/* Handle the command-line, we expect a mpiuse data file to read and various
* options. */
* options. */
int
opt
;
int
opt
;
while
((
opt
=
getopt
(
argc
,
argv
,
"vf"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"vf
n:
"
))
!=
-
1
)
{
switch
(
opt
)
{
switch
(
opt
)
{
case
'f'
:
case
'f'
:
usetics
=
0
;
usetics
=
0
;
...
@@ -391,6 +374,9 @@ int main(int argc, char *argv[]) {
...
@@ -391,6 +374,9 @@ int main(int argc, char *argv[]) {
case
'v'
:
case
'v'
:
verbose
=
1
;
verbose
=
1
;
break
;
break
;
case
'n'
:
waitns
=
atoll
(
optarg
);
break
;
default:
default:
if
(
myrank
==
0
)
usage
(
argv
);
if
(
myrank
==
0
)
usage
(
argv
);
return
1
;
return
1
;
...
@@ -428,6 +414,7 @@ int main(int argc, char *argv[]) {
...
@@ -428,6 +414,7 @@ int main(int argc, char *argv[]) {
if
(
myrank
==
0
)
{
if
(
myrank
==
0
)
{
message
(
"Start of MPI tests"
);
message
(
"Start of MPI tests"
);
message
(
"=================="
);
message
(
"=================="
);
message
(
"injecting fixed waits of %lld ns"
,
waitns
);
}
}
/* Make three threads, one for injecting tasks and two to check for
/* Make three threads, one for injecting tasks and two to check for
...
...
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