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

Add -z option to fakes to output a log that can be re-read

parent 5d810c1b
No related branches found
No related tags found
No related merge requests found
...@@ -174,9 +174,11 @@ void mpiuse_log_restore(const char *filename) { ...@@ -174,9 +174,11 @@ void mpiuse_log_restore(const char *filename) {
* @brief dump the logs for all ranks to a file. * @brief dump the logs for all ranks to a file.
* *
* @param nranks the number of ranks. * @param nranks the number of ranks.
* @param standard only write a standard log, this can be used as input to
* other runs.
* @param dumpfile the file to write * @param dumpfile the file to write
*/ */
void mpiuse_dump_logs(int nranks, const char *dumpfile) { void mpiuse_dump_logs(int nranks, int standard, const char *dumpfile) {
/* Make sure output file is empty, only on one rank. */ /* Make sure output file is empty, only on one rank. */
FILE *fd; FILE *fd;
...@@ -184,13 +186,21 @@ void mpiuse_dump_logs(int nranks, const char *dumpfile) { ...@@ -184,13 +186,21 @@ void mpiuse_dump_logs(int nranks, const char *dumpfile) {
fd = fopen(dumpfile, "w"); fd = fopen(dumpfile, "w");
/* Header. */ /* Header. */
fprintf(fd, if (standard) {
"# logticin logtic injtic endtic dtic step rank otherrank itype " fprintf(fd,
" isubtype tag size nr_tests tsum tmin tmax\n"); "# stic etic dtic step rank otherrank type itype "
" subtype isubtype activation tag size sum\n");
} else {
fprintf(fd,
"# logticin logtic injtic endtic dtic step rank otherrank itype "
" isubtype tag size nr_tests tsum tmin tmax\n");
}
fclose(fd); fclose(fd);
} }
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);
const char *types[] = {"send", "recv"};
/* Loop over all ranks, one by one, getting each rank to append their /* Loop over all ranks, one by one, getting each rank to append their
* logs. */ * logs. */
for (int k = 0; k < nranks; k++) { for (int k = 0; k < nranks; k++) {
...@@ -210,20 +220,31 @@ void mpiuse_dump_logs(int nranks, const char *dumpfile) { ...@@ -210,20 +220,31 @@ void mpiuse_dump_logs(int nranks, const char *dumpfile) {
* version to match the expected injection times for this new run. */ * version to match the expected injection times for this new run. */
size_t nlogs = mpiuse_log_count; size_t nlogs = mpiuse_log_count;
ticks basetics = 0; ticks basetics = 0;
long long sum = 0;
for (size_t k = 0; k < nlogs; k++) { for (size_t k = 0; k < nlogs; k++) {
struct mpiuse_log_entry *log = &mpiuse_log[k]; struct mpiuse_log_entry *log = &mpiuse_log[k];
if (log->rank == myrank && log->endtic > 0) { if (log->rank == myrank && log->endtic > 0) {
if (basetics == 0) basetics = log->tic; if (basetics == 0) basetics = log->tic;
fprintf(fd, if (standard) {
"%lld %.4f %.4f %.4f %.6f %d %d %d %d %d %d %zd %d %.4f %.6f " fprintf(fd, "%lld %lld %lld %d %d %d %s %d %s %d %d %d %zd %lld\n",
"%.6f\n", log->injtic, log->injtic, log->endtic - log->injtic,
log->tic, clocks_from_ticks(log->tic - basetics), log->step, log->rank, log->otherrank,
clocks_from_ticks(log->injtic - clocks_start_ticks), types[log->type - SEND_TYPE], log->type, "none",
clocks_from_ticks(log->endtic - clocks_start_ticks), log->subtype, log->activation, log->tag, log->size, sum);
clocks_from_ticks(log->endtic - log->injtic), log->step, sum += log->size;
log->rank, log->otherrank, log->type, log->subtype, log->tag, } else {
log->size, log->nr_tests, clocks_from_ticks(log->tsum), fprintf(
clocks_from_ticks(log->tmin), clocks_from_ticks(log->tmax)); fd,
"%lld %.4f %.4f %.4f %.6f %d %d %d %d %d %d %zd %d %.4f %.6f "
"%.6f\n",
log->tic, clocks_from_ticks(log->tic - basetics),
clocks_from_ticks(log->injtic - clocks_start_ticks),
clocks_from_ticks(log->endtic - clocks_start_ticks),
clocks_from_ticks(log->endtic - log->injtic), log->step,
log->rank, log->otherrank, log->type, log->subtype, log->tag,
log->size, log->nr_tests, clocks_from_ticks(log->tsum),
clocks_from_ticks(log->tmin), clocks_from_ticks(log->tmax));
}
} }
} }
fclose(fd); fclose(fd);
......
...@@ -88,7 +88,7 @@ struct mpiuse_log_entry { ...@@ -88,7 +88,7 @@ struct mpiuse_log_entry {
#ifndef SEND_TYPE #ifndef SEND_TYPE
#define SEND_TYPE 25 #define SEND_TYPE 25
#define RECV_TYPE 26 #define RECV_TYPE 26
#define NO_SUBTYPE 0 #define NO_SUBTYPE 1
#endif #endif
/* API. */ /* API. */
...@@ -99,7 +99,7 @@ struct mpiuse_log_entry *mpiuse_get_log(int ind); ...@@ -99,7 +99,7 @@ struct mpiuse_log_entry *mpiuse_get_log(int ind);
void mpiuse_log_restore(const char *filename); void mpiuse_log_restore(const char *filename);
int mpiuse_nr_logs(void); int mpiuse_nr_logs(void);
int mpiuse_nr_ranks(void); int mpiuse_nr_ranks(void);
void mpiuse_dump_logs(int nranks, const char *logfile); void mpiuse_dump_logs(int nranks, int standard, const char *logfile);
void mpiuse_log_generate(int nr_nodes, int nr_logs, int size, int random, void mpiuse_log_generate(int nr_nodes, int nr_logs, int size, int random,
long int seed, int uniform, const char *cdf, long int seed, int uniform, const char *cdf,
......
...@@ -388,7 +388,7 @@ static void pick_logs(int random) { ...@@ -388,7 +388,7 @@ static void pick_logs(int random) {
* @brief usage help. * @brief usage help.
*/ */
static void usage(char *argv[]) { static void usage(char *argv[]) {
fprintf(stderr, "Usage: %s [options] nr_messages logfile.dat\n", argv[0]); fprintf(stderr, "Usage: %s [vds:rgx:c:o:f:z] nr_messages logfile.dat\n", argv[0]);
fprintf(stderr, fprintf(stderr,
" options: -v verbose, -d data check, -s size (bytes/scale), \n" " options: -v verbose, -d data check, -s size (bytes/scale), \n"
"\t -f <1|2> randomize injection order, 1 == just sends, " "\t -f <1|2> randomize injection order, 1 == just sends, "
...@@ -398,7 +398,8 @@ static void usage(char *argv[]) { ...@@ -398,7 +398,8 @@ static void usage(char *argv[]) {
"\t-r -c <file> use cdf from file, size is a scale factor., |\n" "\t-r -c <file> use cdf from file, size is a scale factor., |\n"
"\t-r -o <file> use occurence sample of values in a file, size is a " "\t-r -o <file> use occurence sample of values in a file, size is a "
"scale factor.,] \n" "scale factor.,] \n"
"\t-x random seed\n"); "\t-x random seed\n"
"\t-z outout log in standard format, i.e. can be used as input");
fflush(stderr); fflush(stderr);
} }
...@@ -424,15 +425,16 @@ int main(int argc, char *argv[]) { ...@@ -424,15 +425,16 @@ int main(int argc, char *argv[]) {
/* Handle the command-line, we expect the number of messages to exchange per /* Handle the command-line, we expect the number of messages to exchange per
* rank an output log and some options, the interesting ones are a size and * rank an output log and some options, the interesting ones are a size and
* whether to use a random selections of various kinds. */ * whether to use a random selections of various kinds. */
int size = 1024;
int random = 0;
int randomorder = 0;
int uniform = 1;
char *cdf = NULL; char *cdf = NULL;
char *odata = NULL; char *odata = NULL;
int opt; int opt;
int random = 0;
int randomorder = 0;
int size = 1024;
int standard = 0;
int uniform = 1;
unsigned int seed = default_seed; unsigned int seed = default_seed;
while ((opt = getopt(argc, argv, "vds:rgx:c:o:f:")) != -1) { while ((opt = getopt(argc, argv, "vds:rgx:c:o:f:z")) != -1) {
switch (opt) { switch (opt) {
case 'd': case 'd':
datacheck = 1; datacheck = 1;
...@@ -458,6 +460,9 @@ int main(int argc, char *argv[]) { ...@@ -458,6 +460,9 @@ int main(int argc, char *argv[]) {
case 'v': case 'v':
verbose = 1; verbose = 1;
break; break;
case 'z':
standard = 1;
break;
case 'x': case 'x':
seed = atol(optarg); seed = atol(optarg);
break; break;
...@@ -557,7 +562,7 @@ int main(int argc, char *argv[]) { ...@@ -557,7 +562,7 @@ int main(int argc, char *argv[]) {
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);
fflush(stdout); fflush(stdout);
if (myrank == 0) message("Dumping updated log"); if (myrank == 0) message("Dumping updated log");
mpiuse_dump_logs(nranks, logfile); mpiuse_dump_logs(nranks, standard, logfile);
/* Shutdown MPI. */ /* Shutdown MPI. */
res = MPI_Finalize(); res = MPI_Finalize();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment