Skip to content
Snippets Groups Projects
Commit 0406525b authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Add option to delay a fixed amount of time between injections

parent e95cd7c1
No related branches found
No related tags found
3 merge requests!9Draft: Multiple threads for inject, send and recv.,!3Draft: Multi injectors many,!1Increase no. of injection threads to 2
...@@ -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 = 0;
/* 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;
...@@ -76,10 +79,13 @@ static void injection_runner(int qid) { ...@@ -76,10 +79,13 @@ static void injection_runner(int qid) {
ticks looptics = 0; ticks looptics = 0;
double deadtime = 0.0; double deadtime = 0.0;
struct timespec sleep;
sleep.tv_sec = 0;
while (ind_req[qid] < nr_reqs[qid]) { while (ind_req[qid] < nr_reqs[qid]) {
struct mpiuse_log_entry *log = reqs[ind_req[qid]]; struct mpiuse_log_entry *log = reqs[ind_req[qid]];
if (usetics) { if (usetics && waitns == 0) {
/* Expect time between this request and the previous one. */ /* Expect time between this request and the previous one. */
ticks dt = log->tic - basetic; ticks dt = log->tic - basetic;
basetic = log->tic; basetic = log->tic;
...@@ -96,8 +102,7 @@ static void injection_runner(int qid) { ...@@ -96,8 +102,7 @@ static void injection_runner(int qid) {
/* Remember to be fair and remove the looptics, then convert to /* Remember to be fair and remove the looptics, then convert to
* nanoseconds. */ * nanoseconds. */
//double ns = (double)(dt - looptics) / log_clocks_cpufreq * 1.0e9; double ns = (double)(dt - looptics) / log_clocks_cpufreq * 1.0e9;
double ns = (double)(looptics) / log_clocks_cpufreq * 1.0e9;
if (ns < 1.0e9) { if (ns < 1.0e9) {
sleep.tv_nsec = (long)ns; sleep.tv_nsec = (long)ns;
} else { } else {
...@@ -109,6 +114,10 @@ static void injection_runner(int qid) { ...@@ -109,6 +114,10 @@ static void injection_runner(int qid) {
nanosleep(&sleep, NULL); nanosleep(&sleep, NULL);
deadtime += sleep.tv_nsec; deadtime += sleep.tv_nsec;
} }
} else if (waitns != 0) {
sleep.tv_nsec = waitns;
nanosleep(&sleep, NULL);
deadtime += sleep.tv_nsec;
} }
/* Initialise new log elements. */ /* Initialise new log elements. */
...@@ -392,9 +401,10 @@ static void pick_logs(void) { ...@@ -392,9 +401,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);
} }
...@@ -420,7 +430,7 @@ int main(int argc, char *argv[]) { ...@@ -420,7 +430,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, "vfn:")) != -1) {
switch (opt) { switch (opt) {
case 'f': case 'f':
usetics = 0; usetics = 0;
...@@ -428,6 +438,9 @@ int main(int argc, char *argv[]) { ...@@ -428,6 +438,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;
...@@ -465,6 +478,7 @@ int main(int argc, char *argv[]) { ...@@ -465,6 +478,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("==================");
if (waitns > 0) message("adding 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment