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

Capture final state

parent 593038d5
No related branches found
No related tags found
1 merge request!10Draft: Ragged one side registered buffers.
...@@ -29,6 +29,10 @@ ...@@ -29,6 +29,10 @@
// //
// Also the send side has no associated window, as it only pushes data, so we // Also the send side has no associated window, as it only pushes data, so we
// cannot seem to register that? // cannot seem to register that?
//
// Broken method with OpenMPI which has a limit on the number of
// memory regions that can be attached to a window (32). Runs with
// Intel MPI, but not as fast as ptp.
#include <limits.h> #include <limits.h>
...@@ -44,7 +48,8 @@ ...@@ -44,7 +48,8 @@
#include "error.h" #include "error.h"
#include "mpiuse.h" #include "mpiuse.h"
#define maxtags 1000 // XXX broken for sure...
#define maxtags 6000
/* Global: Our rank for all to see. */ /* Global: Our rank for all to see. */
int myrank = -1; int myrank = -1;
...@@ -208,8 +213,8 @@ static void *send_thread(void *arg) { ...@@ -208,8 +213,8 @@ static void *send_thread(void *arg) {
log->rank, log->otherrank, log->subtype, log->tag)]; log->rank, log->otherrank, log->subtype, log->tag)];
log->offset = ranklog_offsets[INDEX4(nr_ranks, nr_ranks, task_subtype_count, log->offset = ranklog_offsets[INDEX4(nr_ranks, nr_ranks, task_subtype_count,
log->rank, log->otherrank, log->subtype, index)]; log->rank, log->otherrank, log->subtype, index)];
message("Using offset %zd at index %d (%d %d)", log->offset, index, //message("Using offset %zd at index %d (%d %d)", log->offset, index,
log->otherrank, log->tag ); // log->otherrank, log->tag );
/* And define header; dataptr[0] can be any value except UNLOCKED. */ /* And define header; dataptr[0] can be any value except UNLOCKED. */
dataptr[0] = 0; dataptr[0] = 0;
...@@ -227,6 +232,13 @@ static void *send_thread(void *arg) { ...@@ -227,6 +232,13 @@ static void *send_thread(void *arg) {
mpi_window[log->subtype], &log->req); mpi_window[log->subtype], &log->req);
if (ret != MPI_SUCCESS) mpi_error_message(ret, "Failed to accumulate data"); if (ret != MPI_SUCCESS) mpi_error_message(ret, "Failed to accumulate data");
// Push. Sadly all messages, not just this one. Restores order... But slow.
//if (k % 4 == 0 || k == nr_send - 1) {
// ret = MPI_Win_flush_local(log->otherrank, mpi_window[log->subtype]);
// if (ret != MPI_SUCCESS)
// mpi_error_message(ret, "MPI_Win_flush failed");
//}
/* Add to the requests queue. */ /* Add to the requests queue. */
int ind = atomic_inc(&nr_req); int ind = atomic_inc(&nr_req);
req_queue[ind] = log; req_queue[ind] = log;
...@@ -252,31 +264,25 @@ static void *req_thread(void *arg) { ...@@ -252,31 +264,25 @@ static void *req_thread(void *arg) {
while (injecting || (!injecting && todo_req > 0)) { while (injecting || (!injecting && todo_req > 0)) {
int nlogs = nr_req; int nlogs = nr_req;
int ndone = 0;
for (int k = 0; k < nlogs; k++) { for (int k = 0; k < nlogs; k++) {
struct mpiuse_log_entry *log = req_queue[k]; struct mpiuse_log_entry *log = req_queue[k];
if (log != NULL && !log->done) { if (log != NULL && !log->done) {
int res; int res;
MPI_Status stat; MPI_Status stat;
int err = MPI_Test(&log->req, &res, &stat); int err = MPI_Test(&log->req, &res, &stat);
if (err != MPI_SUCCESS) { if (err != MPI_SUCCESS) error("MPI_Test call failed");
error("MPI_Test call failed");
}
if (res) { if (res) {
log->endtic = getticks();
// Get update. XXX is this needed?
int ret =
MPI_Win_flush_local(log->otherrank, mpi_window[log->subtype]);
if (ret != MPI_SUCCESS)
mpi_error_message(ret, "MPI_Win_flush failed");
/* Send the UNLOCKED message. */ /* Send the UNLOCKED message. */
BLOCKTYPE newval[1]; BLOCKTYPE newval[1];
BLOCKTYPE oldval[1]; BLOCKTYPE oldval[1];
newval[0] = UNLOCKED; newval[0] = UNLOCKED;
oldval[0] = 0; oldval[0] = 0;
ret = MPI_Compare_and_swap(&newval[0], log->data, &oldval[0], int ret = MPI_Compare_and_swap(&newval[0], log->data, &oldval[0],
MPI_BLOCKTYPE, log->otherrank, log->offset, MPI_BLOCKTYPE, log->otherrank, log->offset,
mpi_window[log->subtype]); mpi_window[log->subtype]);
if (ret != MPI_SUCCESS) if (ret != MPI_SUCCESS)
mpi_error_message(ret, "MPI_Compare_and_swap error"); mpi_error_message(ret, "MPI_Compare_and_swap error");
...@@ -288,7 +294,8 @@ static void *req_thread(void *arg) { ...@@ -288,7 +294,8 @@ static void *req_thread(void *arg) {
/* Done. */ /* Done. */
log->done = 1; log->done = 1;
log->endtic = getticks(); ndone++;
log->tmin = getticks();
MPI_Free_mem(log->data); MPI_Free_mem(log->data);
atomic_dec(&todo_req); atomic_dec(&todo_req);
} }
...@@ -345,6 +352,7 @@ static void *recv_thread(void *arg) { ...@@ -345,6 +352,7 @@ static void *recv_thread(void *arg) {
/* Done, clean up. */ /* Done, clean up. */
log->done = 1; log->done = 1;
log->endtic = getticks(); log->endtic = getticks();
log->tmin = getticks();
atomic_dec(&todo_recv); atomic_dec(&todo_recv);
if (todo_recv == 0) break; if (todo_recv == 0) break;
...@@ -412,7 +420,7 @@ static void pick_logs(void) { ...@@ -412,7 +420,7 @@ static void pick_logs(void) {
for (int k = 0; k < maxtags * task_subtype_count * nr_ranks *nr_ranks; k++) ranklog_indices[k] = -1; for (int k = 0; k < maxtags * task_subtype_count * nr_ranks *nr_ranks; k++) ranklog_indices[k] = -1;
message("nlogs = %zd", nlogs); message("nlogs = %zd", nlogs);
for (int k = 0; k < nlogs; k++) { for (int k = 0, kk = 0; k < nlogs; k++) {
struct mpiuse_log_entry *log = mpiuse_get_log(k); struct mpiuse_log_entry *log = mpiuse_get_log(k);
if (log->rank == myrank && log->activation) { if (log->rank == myrank && log->activation) {
if (log->type == task_type_send || log->type == task_type_recv) { if (log->type == task_type_send || log->type == task_type_recv) {
...@@ -438,24 +446,25 @@ static void pick_logs(void) { ...@@ -438,24 +446,25 @@ static void pick_logs(void) {
/* Get MPI address and global log index. */ /* Get MPI address and global log index. */
MPI_Get_address(log->data, &log->offset); MPI_Get_address(log->data, &log->offset);
//log->offset = (MPI_Aint) &log->data; //log->offset = (MPI_Aint) &log->data;
log->index = k; log->index = kk;
kk++;
if (log->type == task_type_recv) { if (log->type == task_type_recv) {
message("recv log from rank: %d/%d/%d/%d %zd %zd", //message("recv log from rank: %d/%d/%d/%d %zd %zd",
log->otherrank, myrank, log->subtype, // log->otherrank, myrank, log->subtype,
log->tag, log->offset, log->index); // log->tag, log->offset, log->index);
/* Keep offset for sharing with send side. */ /* Keep offset for sharing with send side. */
ranklog_offsets[INDEX4(nr_ranks, nr_ranks, task_subtype_count, ranklog_offsets[INDEX4(nr_ranks, nr_ranks, task_subtype_count,
log->otherrank, myrank, log->otherrank, myrank,
log->subtype, log->index)] = log->offset; log->subtype, log->index)] = log->offset;
ranklog_indices[INDEX4(nr_ranks, nr_ranks, task_subtype_count, ranklog_indices[INDEX4(nr_ranks, nr_ranks, task_subtype_count,
log->otherrank, myrank, log->otherrank, myrank,
log->subtype, log->tag)] = log->index; log->subtype, log->tag)] = log->index;
/* And attach to window. */ /* And attach to window. */
message("%d recv log->size = %zd", kk, tobytes(log->size));
MPI_Win_attach(mpi_window[log->subtype], log->data, tobytes(log->size)); MPI_Win_attach(mpi_window[log->subtype], log->data, tobytes(log->size));
recv_queue[nr_recv] = log; recv_queue[nr_recv] = log;
...@@ -465,7 +474,11 @@ static void pick_logs(void) { ...@@ -465,7 +474,11 @@ static void pick_logs(void) {
//message("send log to rank: %d %zd %d", log->otherrank, //message("send log to rank: %d %zd %d", log->otherrank,
// log->offset, log->tag); // log->offset, log->tag);
/* Sends local data that is not in a window. */ /* And attach to window. Attempt to register this side as well. No
* difference. */
message("%d send log->size = %zd", kk, tobytes(log->size));
MPI_Win_attach(mpi_window[log->subtype], log->data, tobytes(log->size));
send_queue[nr_send] = log; send_queue[nr_send] = log;
nr_send++; nr_send++;
} }
...@@ -476,7 +489,8 @@ static void pick_logs(void) { ...@@ -476,7 +489,8 @@ static void pick_logs(void) {
log->nr_tests = 0; log->nr_tests = 0;
log->tsum = 0.0; log->tsum = 0.0;
log->tmax = 0; log->tmax = 0;
log->tmin = LONG_MAX; log->tmin = 0;
log->injtic = 0;
log->endtic = 0; log->endtic = 0;
// XXX test XXX // XXX test XXX
...@@ -498,9 +512,9 @@ static void pick_logs(void) { ...@@ -498,9 +512,9 @@ 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 [-vfdc:s:] SWIFT_mpiuse-log-file.dat logfile.dat\n", fprintf(stderr, "Usage: %s [-vdc:s:] SWIFT_mpiuse-log-file.dat logfile.dat\n",
argv[0]); argv[0]);
fprintf(stderr, " options: -v verbose, -f fast injections, " fprintf(stderr, " options: -v verbose, "
"-d fill messages and check values on receive, " "-d fill messages and check values on receive, "
"-s <value> use fixed message of this size (bytes), " "-s <value> use fixed message of this size (bytes), "
"-c <value> scale factor for all messages\n"); "-c <value> scale factor for all messages\n");
...@@ -590,10 +604,12 @@ int main(int argc, char *argv[]) { ...@@ -590,10 +604,12 @@ int main(int argc, char *argv[]) {
/* We need to share all the offsets for each log so they can push data into /* We need to share all the offsets for each log so they can push data into
* the correct parts of our receive window. */ * the correct parts of our receive window. */
size_t nlogs = mpiuse_nr_logs(); size_t nlogs = mpiuse_nr_logs();
MPI_Allreduce(MPI_IN_PLACE, ranklog_offsets, nr_ranks * nr_ranks * task_subtype_count * size_t count = nr_ranks * nr_ranks * (size_t)task_subtype_count * (size_t)(nlogs/2);
nlogs, MPI_AINT, MPI_MAX, MPI_COMM_WORLD); message("1 count = %zd / %d", count, (int)count);
MPI_Allreduce(MPI_IN_PLACE, ranklog_indices, nr_ranks * nr_ranks * task_subtype_count * MPI_Allreduce(MPI_IN_PLACE, ranklog_offsets, count, MPI_AINT, MPI_MAX, MPI_COMM_WORLD);
maxtags, MPI_INT, MPI_MAX, MPI_COMM_WORLD); count = nr_ranks * nr_ranks * (size_t) task_subtype_count * (size_t) maxtags;
message("2 count = %zd / %d", count, (int)count);
MPI_Allreduce(MPI_IN_PLACE, ranklog_indices, count, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
if (myrank == 0) { if (myrank == 0) {
int count = 0; int count = 0;
...@@ -620,6 +636,7 @@ int main(int argc, char *argv[]) { ...@@ -620,6 +636,7 @@ int main(int argc, char *argv[]) {
/* Time to start time. Try to make it synchronous across the ranks. */ /* Time to start time. Try to make it synchronous across the ranks. */
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);
sleep(3);
clocks_set_cpufreq(0); clocks_set_cpufreq(0);
if (myrank == 0) { if (myrank == 0) {
message("Start of MPI tests"); message("Start of MPI tests");
...@@ -664,7 +681,7 @@ int main(int argc, char *argv[]) { ...@@ -664,7 +681,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(nr_ranks, logfile); mpiuse_dump_logs(nr_ranks, 0, 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