|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2007 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Look for regressions in aggregator code. A more simple access pattern than
|
|
Packit Service |
c5cf8c |
* aggregation1 */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include <mpi.h>
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include <stdlib.h>
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include <time.h>
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include <sys/types.h>
|
|
Packit Service |
c5cf8c |
#include <unistd.h>
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include <string.h>
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#define BUFSIZE 512
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static void handle_error(int errcode, const char *str)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
char msg[MPI_MAX_ERROR_STRING];
|
|
Packit Service |
c5cf8c |
int resultlen;
|
|
Packit Service |
c5cf8c |
MPI_Error_string(errcode, msg, &resultlen);
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "%s: %s\n", str, msg);
|
|
Packit Service |
c5cf8c |
MPI_Abort(MPI_COMM_WORLD, 1);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPI_Info info = MPI_INFO_NULL;
|
|
Packit Service |
c5cf8c |
MPI_File fh;
|
|
Packit Service |
c5cf8c |
MPI_Offset off = 0;
|
|
Packit Service |
c5cf8c |
MPI_Status status;
|
|
Packit Service |
c5cf8c |
int errcode;
|
|
Packit Service |
c5cf8c |
int i, rank, errs = 0, toterrs, buffer[BUFSIZE], buf2[BUFSIZE];
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Info_create(&info;;
|
|
Packit Service |
c5cf8c |
MPI_Info_set(info, "romio_cb_write", "enable");
|
|
Packit Service |
c5cf8c |
MPI_Info_set(info, "cb_nodes", "1");
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
for (i = 0; i < BUFSIZE; i++) {
|
|
Packit Service |
c5cf8c |
buffer[i] = 10000 + rank;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
off = rank * sizeof(buffer);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
errcode = MPI_File_open(MPI_COMM_WORLD, argv[1], MPI_MODE_WRONLY | MPI_MODE_CREATE, info, &fh;;
|
|
Packit Service |
c5cf8c |
if (errcode != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
handle_error(errcode, "MPI_File_open");
|
|
Packit Service |
c5cf8c |
errcode = MPI_File_write_at_all(fh, off, buffer, BUFSIZE, MPI_INT, &status);
|
|
Packit Service |
c5cf8c |
if (errcode != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
handle_error(errcode, "MPI_File_write_at_all");
|
|
Packit Service |
c5cf8c |
errcode = MPI_File_close(&fh;;
|
|
Packit Service |
c5cf8c |
if (errcode != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
handle_error(errcode, "MPI_File_close");
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
errcode = MPI_File_open(MPI_COMM_WORLD, argv[1], MPI_MODE_RDONLY, info, &fh;;
|
|
Packit Service |
c5cf8c |
if (errcode != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
handle_error(errcode, "MPI_File_open");
|
|
Packit Service |
c5cf8c |
errcode = MPI_File_read_at_all(fh, off, buf2, BUFSIZE, MPI_INT, &status);
|
|
Packit Service |
c5cf8c |
if (errcode != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
handle_error(errcode, "MPI_File_read_at_all");
|
|
Packit Service |
c5cf8c |
errcode = MPI_File_close(&fh;;
|
|
Packit Service |
c5cf8c |
if (errcode != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
handle_error(errcode, "MPI_File_close");
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
for (i = 0; i < BUFSIZE; i++) {
|
|
Packit Service |
c5cf8c |
if (buf2[i] != 10000 + rank)
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Allreduce(&errs, &toterrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
if (toterrs > 0) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Found %d errors\n", toterrs);
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
fprintf(stdout, " No Errors\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Info_free(&info;;
|
|
Packit Service |
c5cf8c |
MPI_Finalize();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return 0;
|
|
Packit Service |
c5cf8c |
}
|