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

Formatting

parent 5222090f
Branches
Tags
No related merge requests found
......@@ -4,18 +4,18 @@
extern int myrank;
/* Exit in error macro. */
#define error(s, ...) \
({ \
fflush(stdout); \
fprintf(stderr, "[%03i] %s %s:%s():%i: " s "\n", myrank, \
clocks_get_timesincestart(), \
__FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
MPI_Abort(MPI_COMM_WORLD, -1); \
#define error(s, ...) \
({ \
fflush(stdout); \
fprintf(stderr, "[%03i] %s %s:%s():%i: " s "\n", myrank, \
clocks_get_timesincestart(), __FILE__, __FUNCTION__, __LINE__, \
##__VA_ARGS__); \
MPI_Abort(MPI_COMM_WORLD, -1); \
})
/* Print a message */
#define message(s, ...) \
({ \
printf("[%04i] %s %s: " s "\n", myrank, \
clocks_get_timesincestart(),__FUNCTION__, ##__VA_ARGS__); \
#define message(s, ...) \
({ \
printf("[%04i] %s %s: " s "\n", myrank, clocks_get_timesincestart(), \
__FUNCTION__, ##__VA_ARGS__); \
})
#include <stdio.h>
/* Injection of MPI_Isends and MPI_Irecvs into the queues. */
void inject_one(void) {
}
void inject_one(void) {}
......@@ -8,9 +8,9 @@
* exchanges of various data sizes and continuously checks the requests for
* completion. Also need timers to record the time taken by all this...
*/
#include <stdio.h>
#include <mpi.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include "atomic.h"
......@@ -32,7 +32,7 @@ static const int task_type_send = 22;
static const int task_type_recv = 23;
/* Global communicators for each of the subtypes. */
static const int task_subtype_count = 30; // Just some upper limit on subtype.
static const int task_subtype_count = 30; // Just some upper limit on subtype.
static MPI_Comm subtypeMPI_comms[30];
/* The local queues. */
......@@ -62,8 +62,7 @@ static double log_clocks_cpufreq = 2194844448.0;
*/
static void *inject_thread(void *arg) {
if (verbose)
message("%d: injection thread starts", *((int *)arg));
if (verbose) message("%d: injection thread starts", *((int *)arg));
ticks starttics = getticks();
/* Ticks of our last attempt and ticks the first loop takes (usetics == 1). */
......@@ -92,11 +91,11 @@ static void *inject_thread(void *arg) {
* nanoseconds. */
double ns = (double)(dt - looptics) / log_clocks_cpufreq * 1.0e9;
if (ns < 1.0e9) {
sleep.tv_nsec = (long) ns;
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;
sleep.tv_nsec = (long)1.0e9;
message("wait greater than one second");
}
nanosleep(&sleep, NULL);
......@@ -106,8 +105,8 @@ static void *inject_thread(void *arg) {
// Differences to SWIFT: MPI_BYTE might overflow, should use MPI_Type(?).
int err = 0;
if (log->type == task_type_send) {
err = MPI_Isend(log->data, log->size, MPI_BYTE, log->otherrank,
log->tag, subtypeMPI_comms[log->subtype], &log->req);
err = MPI_Isend(log->data, log->size, MPI_BYTE, log->otherrank, log->tag,
subtypeMPI_comms[log->subtype], &log->req);
/* Add a new send request. */
int ind = atomic_inc(&nr_sends);
......@@ -115,8 +114,8 @@ static void *inject_thread(void *arg) {
atomic_inc(&todo_send);
} else {
err = MPI_Irecv(log->data, log->size, MPI_BYTE, log->otherrank,
log->tag, subtypeMPI_comms[log->subtype], &log->req);
err = MPI_Irecv(log->data, log->size, MPI_BYTE, log->otherrank, log->tag,
subtypeMPI_comms[log->subtype], &log->req);
/* Add a new recv request. */
int ind = atomic_inc(&nr_recvs);
......@@ -166,7 +165,7 @@ static void *inject_thread(void *arg) {
*/
static void queue_runner(struct mpiuse_log_entry **logs, int volatile *nr_logs,
int volatile *todos, double *sum, int *ncalls,
ticks *mint, ticks *maxt ) {
ticks *mint, ticks *maxt) {
/* MPI_Test statistics. */
int lncalls = 0;
......@@ -217,8 +216,7 @@ static void queue_runner(struct mpiuse_log_entry **logs, int volatile *nr_logs,
*/
static void *send_thread(void *arg) {
if (verbose)
message("%d: send thread starts (%d)", *((int *)arg), injecting);
if (verbose) message("%d: send thread starts (%d)", *((int *)arg), injecting);
ticks starttics = getticks();
int ncalls;
......@@ -227,9 +225,11 @@ static void *send_thread(void *arg) {
ticks maxt;
queue_runner(sends_queue, &nr_sends, &todo_send, &sum, &ncalls, &mint, &maxt);
message("%d MPI_Test calls took: %.3f, mean time %.3f, min time %.3f, max time %.3f (%s)",
ncalls, clocks_from_ticks(sum), clocks_from_ticks(sum/ncalls),
clocks_from_ticks(mint), clocks_from_ticks(maxt), clocks_getunit());
message(
"%d MPI_Test calls took: %.3f, mean time %.3f, min time %.3f, max time "
"%.3f (%s)",
ncalls, clocks_from_ticks(sum), clocks_from_ticks(sum / ncalls),
clocks_from_ticks(mint), clocks_from_ticks(maxt), clocks_getunit());
message("took %.3f %s.", clocks_from_ticks(getticks() - starttics),
clocks_getunit());
......@@ -242,8 +242,7 @@ static void *send_thread(void *arg) {
*/
static void *recv_thread(void *arg) {
if (verbose)
message("%d: recv thread starts", *((int *)arg));
if (verbose) message("%d: recv thread starts", *((int *)arg));
ticks starttics = getticks();
int ncalls;
......@@ -252,9 +251,11 @@ static void *recv_thread(void *arg) {
ticks maxt;
queue_runner(recvs_queue, &nr_recvs, &todo_recv, &sum, &ncalls, &mint, &maxt);
message("%d MPI_Test calls took: %.3f, mean time %.3f, min time %.3f, max time %.3f (%s)",
ncalls, clocks_from_ticks(sum), clocks_from_ticks(sum/ncalls),
clocks_from_ticks(mint), clocks_from_ticks(maxt), clocks_getunit());
message(
"%d MPI_Test calls took: %.3f, mean time %.3f, min time %.3f, max time "
"%.3f (%s)",
ncalls, clocks_from_ticks(sum), clocks_from_ticks(sum / ncalls),
clocks_from_ticks(mint), clocks_from_ticks(maxt), clocks_getunit());
message("took %.3f %s.", clocks_from_ticks(getticks() - starttics),
clocks_getunit());
......@@ -270,10 +271,8 @@ static int cmp_logs(const void *p1, const void *p2) {
struct mpiuse_log_entry *l2 = *(struct mpiuse_log_entry **)p2;
/* Large unsigned values, so take care. */
if (l1->tic > l2->tic)
return 1;
if (l1->tic < l2->tic)
return -1;
if (l1->tic > l2->tic) return 1;
if (l1->tic < l2->tic) return -1;
return 0;
}
......@@ -286,14 +285,14 @@ static void pick_logs(void) {
size_t nlogs = mpiuse_nr_logs();
/* Duplicate of logs. */
reqs_queue = (struct mpiuse_log_entry **)
malloc(sizeof(struct mpiuse_log_entry *) * nlogs);
nr_reqs= 0;
sends_queue = (struct mpiuse_log_entry **)
malloc(sizeof(struct mpiuse_log_entry *) * nlogs);
nr_sends= 0;
recvs_queue = (struct mpiuse_log_entry **)
malloc(sizeof(struct mpiuse_log_entry *) * nlogs);
reqs_queue = (struct mpiuse_log_entry **)malloc(
sizeof(struct mpiuse_log_entry *) * nlogs);
nr_reqs = 0;
sends_queue = (struct mpiuse_log_entry **)malloc(
sizeof(struct mpiuse_log_entry *) * nlogs);
nr_sends = 0;
recvs_queue = (struct mpiuse_log_entry **)malloc(
sizeof(struct mpiuse_log_entry *) * nlogs);
nr_recvs = 0;
for (int k = 0; k < nlogs; k++) {
......@@ -318,7 +317,6 @@ static void pick_logs(void) {
qsort(reqs_queue, nr_reqs, sizeof(struct mpiuse_log_entry *), cmp_logs);
}
/**
* @brief main function.
*/
......@@ -338,8 +336,7 @@ int main(int argc, char *argv[]) {
int nr_nodes = 0;
res = MPI_Comm_size(MPI_COMM_WORLD, &nr_nodes);
if (res != MPI_SUCCESS)
error("MPI_Comm_size failed with error %i.", res);
if (res != MPI_SUCCESS) error("MPI_Comm_size failed with error %i.", res);
/* This should match the expected size. */
if (nr_nodes != nranks)
......
......@@ -141,8 +141,7 @@ void mpiuse_log_restore(const char *filename) {
/* Open the input file. */
FILE *fd;
if ((fd = fopen(filename, "r")) == NULL) {
message("Failed to open the MPI use log file '%s'.",
filename);
message("Failed to open the MPI use log file '%s'.", filename);
return;
}
......@@ -155,9 +154,9 @@ void mpiuse_log_restore(const char *filename) {
while (!feof(fd)) {
if (fgets(line, 132, fd) != NULL) {
if (line[0] != '#') {
sscanf(line, "%zd %zd %zd %d %d %d %s %d %s %d %d %d %zd %zd",
&stic, &etic, &dtic, &step, &rank, &otherrank, type, &itype,
subtype, &isubtype, &activation, &tag, &size, &sum);
sscanf(line, "%zd %zd %zd %d %d %d %s %d %s %d %d %d %zd %zd", &stic,
&etic, &dtic, &step, &rank, &otherrank, type, &itype, subtype,
&isubtype, &activation, &tag, &size, &sum);
mpiuse_log_allocation(rank, step, stic, itype, isubtype, activation,
size, otherrank, tag);
......@@ -172,18 +171,14 @@ void mpiuse_log_restore(const char *filename) {
*
* @result the number of log entries.
*/
int mpiuse_nr_logs(void) {
return mpiuse_log_count;
}
int mpiuse_nr_logs(void) { return mpiuse_log_count; }
/**
* @brief return the number of ranks in log.
*
* @result the number of ranks we've seen.
*/
int mpiuse_nr_ranks(void) {
return mpiuse_max_rank + 1;
}
int mpiuse_nr_ranks(void) { return mpiuse_max_rank + 1; }
/**
* @brief get a log entry.
......
......@@ -58,7 +58,6 @@ struct mpiuse_log_entry {
/* The request associated with the call. */
MPI_Request req;
};
/* API. */
......
#include <stdio.h>
/**
* @brief read the output from a run of SWIFT with the MPI communication
* logger enabled.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment