[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r27650 - in msh: . src
From: |
gnunet |
Subject: |
[GNUnet-SVN] r27650 - in msh: . src |
Date: |
Thu, 27 Jun 2013 15:23:29 +0200 |
Author: harsha
Date: 2013-06-27 15:23:29 +0200 (Thu, 27 Jun 2013)
New Revision: 27650
Added:
msh/Makefile.am
msh/bootstrap
msh/configure.ac
msh/src/
msh/src/Makefile.am
msh/src/mping.c
msh/src/test_mping.sh
Log:
- init build system
Added: msh/Makefile.am
===================================================================
--- msh/Makefile.am (rev 0)
+++ msh/Makefile.am 2013-06-27 13:23:29 UTC (rev 27650)
@@ -0,0 +1 @@
+SUBDIRS = src
\ No newline at end of file
Added: msh/bootstrap
===================================================================
--- msh/bootstrap (rev 0)
+++ msh/bootstrap 2013-06-27 13:23:29 UTC (rev 27650)
@@ -0,0 +1 @@
+autoreconf -if
Property changes on: msh/bootstrap
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: msh/configure.ac
===================================================================
--- msh/configure.ac (rev 0)
+++ msh/configure.ac 2013-06-27 13:23:29 UTC (rev 27650)
@@ -0,0 +1,25 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.69])
+AC_INIT([msh], [0.0.0], address@hidden)
+AM_INIT_AUTOMAKE([foreign -Wall -Werror])
+AC_CONFIG_SRCDIR([src/mping.c])
+AC_CONFIG_HEADERS([config.h])
+
+# Checks for programs.
+AC_PROG_CC([mpicc])
+
+# Checks for libraries.
+AC_CHECK_LIB([mpi],[MPI_Init],,[AC_MSG_ERROR([cannot find MPI libraries])])
+# Checks for header files.
+AC_CHECK_HEADERS([stdlib.h string.h unistd.h mpi.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+
+AC_CONFIG_FILES([Makefile
+ src/Makefile])
+AC_OUTPUT
Added: msh/src/Makefile.am
===================================================================
--- msh/src/Makefile.am (rev 0)
+++ msh/src/Makefile.am 2013-06-27 13:23:29 UTC (rev 27650)
@@ -0,0 +1,3 @@
+bin_PROGRAMS = mping
+
+mping_SOURCES = mping.c
Added: msh/src/mping.c
===================================================================
--- msh/src/mping.c (rev 0)
+++ msh/src/mping.c 2013-06-27 13:23:29 UTC (rev 27650)
@@ -0,0 +1,424 @@
+/*
+ * MPI ping program
+ *
+ * Patterned after the example in the Quadrics documentation
+ * Downloaded from:
http://www.open-mpi.org/community/lists/devel/att-0116/mpi-ping.c
+ */
+
+#define MPI_ALLOC_MEM 0
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/select.h>
+
+#include <getopt.h>
+
+#include "mpi.h"
+
+static int str2size(char *str)
+{
+ int size;
+ char mod[32];
+
+ switch (sscanf(str, "%d%1[mMkK]", &size, mod)) {
+ case 1:
+ return (size);
+
+ case 2:
+ switch (*mod) {
+ case 'm':
+ case 'M':
+ return (size << 20);
+
+ case 'k':
+ case 'K':
+ return (size << 10);
+
+ default:
+ return (size);
+ }
+
+ default:
+ return (-1);
+ }
+}
+
+
+static void usage(void)
+{
+ fprintf(stderr,
+ "Usage: mpi-ping [flags] <min bytes> [<max bytes>] [<inc bytes>]\n"
+ " mpi-ping -h\n");
+ exit(EXIT_FAILURE);
+}
+
+
+static void help(void)
+{
+ printf
+ ("Usage: mpi-ping [flags] <min bytes> [<max bytes>] [<inc bytes>]\n"
+ "\n" " Flags may be any of\n"
+ " -B use blocking send/recv\n"
+ " -C check data\n"
+ " -O overlapping pings\n"
+ " -W perform warm-up phase\n"
+ " -r number repetitions to time\n"
+ " -A use MPI_Alloc_mem to register memory\n"
+ " -h print this info\n" "\n"
+ " Numbers may be postfixed with 'k' or 'm'\n\n");
+
+ exit(EXIT_SUCCESS);
+}
+
+
+int main(int argc, char *argv[])
+{
+ MPI_Status status;
+ MPI_Request recv_request;
+ MPI_Request send_request;
+ unsigned char *rbuf;
+ unsigned char *tbuf;
+ int c;
+ int i;
+ int bytes;
+ int nproc;
+ int peer;
+ int proc;
+ int r;
+ int tag = 0x666;
+
+ /*
+ * default options / arguments
+ */
+ int reps = 10000;
+ int blocking = 0;
+ int check = 0;
+ int overlap = 0;
+ int warmup = 0;
+ int inc_bytes = 0;
+ int max_bytes = 0;
+ int min_bytes = 0;
+ int alloc_mem = 0;
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &proc);
+ MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+
+ while ((c = getopt(argc, argv, "BCOWAr:h")) != -1) {
+ switch (c) {
+
+ case 'B':
+ blocking = 1;
+ break;
+
+ case 'C':
+ check = 1;
+ break;
+
+ case 'O':
+ overlap = 1;
+ break;
+
+ case 'W':
+ warmup = 1;
+ break;
+
+
+ case 'A':
+ alloc_mem=1;
+ break;
+
+
+ case 'r':
+ if ((reps = str2size(optarg)) <= 0) {
+ usage();
+ }
+ break;
+
+ case 'h':
+ help();
+
+ default:
+ usage();
+ }
+ }
+
+ if (optind == argc) {
+ min_bytes = 0;
+ } else if ((min_bytes = str2size(argv[optind++])) < 0) {
+ usage();
+ }
+
+ if (optind == argc) {
+ max_bytes = min_bytes;
+ } else if ((max_bytes = str2size(argv[optind++])) < min_bytes) {
+ usage();
+ }
+
+ if (optind == argc) {
+ inc_bytes = 0;
+ } else if ((inc_bytes = str2size(argv[optind++])) < 0) {
+ usage();
+ }
+
+ if (nproc == 1) {
+ exit(EXIT_SUCCESS);
+ }
+
+ #if MPI_ALLOC_MEM
+ if(alloc_mem) {
+ MPI_Alloc_mem(max_bytes ? max_bytes: 8, MPI_INFO_NULL, &rbuf);
+ MPI_Alloc_mem(max_bytes ? max_bytes: 8, MPI_INFO_NULL, &tbuf);
+ }
+ else {
+ #endif
+ if ((rbuf = (unsigned char *) malloc(max_bytes ? max_bytes : 8)) ==
NULL) {
+ perror("malloc");
+ exit(EXIT_FAILURE);
+ }
+ if ((tbuf = (unsigned char *) malloc(max_bytes ? max_bytes : 8)) ==
NULL) {
+ perror("malloc");
+ exit(EXIT_FAILURE);
+ }
+ #if MPI_ALLOC_MEM
+ }
+ #endif
+
+ if (check) {
+ for (i = 0; i < max_bytes; i++) {
+ tbuf[i] = i & 255;
+ rbuf[i] = 0;
+ }
+ }
+
+ if (proc == 0) {
+ if (overlap) {
+ printf("mpi-ping: overlapping ping-pong\n");
+ } else if (blocking) {
+ printf("mpi-ping: ping-pong (using blocking send/recv)\n");
+ } else {
+ printf("mpi-ping: ping-pong\n");
+ }
+ if (check) {
+ printf("data checking enabled\n");
+ }
+ printf("nprocs=%d, reps=%d, min bytes=%d, max bytes=%d inc bytes=%d\n",
+ nproc, reps, min_bytes, max_bytes, inc_bytes);
+ fflush(stdout);
+ }
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ peer = proc ^ 1;
+
+ if ((peer < nproc) && (peer & 1)) {
+ printf("%d pings %d\n", proc, peer);
+ fflush(stdout);
+ }
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if (warmup) {
+
+ if (proc == 0) {
+ puts("warm-up phase");
+ fflush(stdout);
+ }
+
+ for (r = 0; r < reps; r++) {
+ if (peer >= nproc) {
+ break;
+ }
+ MPI_Irecv(rbuf, max_bytes, MPI_BYTE, peer, tag, MPI_COMM_WORLD,
+ &recv_request);
+ MPI_Isend(tbuf, max_bytes, MPI_BYTE, peer, tag, MPI_COMM_WORLD,
+ &send_request);
+ MPI_Wait(&send_request, &status);
+ MPI_Wait(&recv_request, &status);
+ }
+
+ if (proc == 0) {
+ puts("warm-up phase done");
+ fflush(stdout);
+ }
+ }
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /*
+ * Main loop
+ */
+
+ for (bytes = min_bytes; bytes <= max_bytes;
+ bytes = inc_bytes ? bytes + inc_bytes : bytes ? 2 * bytes : 1) {
+
+ double t = 0.0;
+ double tv[2];
+
+ r = reps;
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if (peer < nproc) {
+
+ if (overlap) {
+
+ /*
+ * MPI_Isend / MPI_Irecv overlapping ping-pong
+ */
+
+ tv[0] = MPI_Wtime();
+
+ for (r = 0; r < reps; r++) {
+
+ MPI_Irecv(rbuf, bytes, MPI_BYTE, peer, tag,
+ MPI_COMM_WORLD, &recv_request);
+ MPI_Isend(tbuf, bytes, MPI_BYTE, peer, tag,
+ MPI_COMM_WORLD, &send_request);
+ MPI_Wait(&send_request, &status);
+ MPI_Wait(&recv_request, &status);
+
+ if (check) {
+ for (i = 0; i < bytes; i++) {
+ if (rbuf[i] != (unsigned char)(i & 255)) {
+ fprintf(stderr, "Error: index=%d sent %d
received %d\n",
+ i, ((unsigned char)i)&255, (unsigned
char)rbuf[i]);
+ }
+ rbuf[i] = 0;
+ }
+ }
+ }
+
+ tv[1] = MPI_Wtime();
+
+ } else if (blocking) {
+
+ /*
+ * MPI_Send / MPI_Recv ping-pong
+ */
+
+ tv[0] = MPI_Wtime();
+
+ if (peer < nproc) {
+ if (proc & 1) {
+ r--;
+ MPI_Recv(rbuf, bytes, MPI_BYTE, peer, tag,
+ MPI_COMM_WORLD, &status);
+
+ if (check) {
+ for (i = 0; i < bytes; i++) {
+ if (rbuf[i] != (unsigned char)(i & 255)) {
+ fprintf(stderr, "Error: index=%d sent %d
received %d\n",
+ i, ((unsigned char)i)&255, (unsigned
char)rbuf[i]);
+ }
+ rbuf[i] = 0;
+ }
+ }
+ }
+
+ while (r-- > 0) {
+
+ MPI_Send(tbuf, bytes, MPI_BYTE, peer, tag,
+ MPI_COMM_WORLD);
+ MPI_Recv(rbuf, bytes, MPI_BYTE, peer, tag,
+ MPI_COMM_WORLD, &status);
+
+ if (check) {
+ for (i = 0; i < bytes; i++) {
+ if (rbuf[i] != (unsigned char)(i & 255)) {
+ fprintf(stderr, "Error: index=%d sent %d
received %d\n",
+ i, ((unsigned char)i)&255, (unsigned
char)rbuf[i]);
+ }
+ rbuf[i] = 0;
+ }
+ }
+ }
+
+ if (proc & 1) {
+ MPI_Send(tbuf, bytes, MPI_BYTE, peer, tag,
+ MPI_COMM_WORLD);
+ }
+ }
+
+ tv[1] = MPI_Wtime();
+
+ } else {
+
+ /*
+ * MPI_Isend / MPI_Irecv ping-pong
+ */
+
+ tv[0] = MPI_Wtime();
+
+ if (peer < nproc) {
+ if (proc & 1) {
+ r--;
+ MPI_Irecv(rbuf, bytes, MPI_BYTE, peer, tag,
+ MPI_COMM_WORLD, &recv_request);
+ MPI_Wait(&recv_request, &status);
+
+ if (check) {
+ for (i = 0; i < bytes; i++) {
+ if (rbuf[i] != (unsigned char)(i & 255)) {
+ fprintf(stderr, "Error: index=%d sent %d
received %d\n",
+ i, ((unsigned char)i)&255, (unsigned
char)rbuf[i]);
+ }
+ rbuf[i] = 0;
+ }
+ }
+ }
+
+ while (r-- > 0) {
+
+ MPI_Isend(tbuf, bytes, MPI_BYTE, peer, tag,
+ MPI_COMM_WORLD, &send_request);
+ MPI_Wait(&send_request, &status);
+ MPI_Irecv(rbuf, bytes, MPI_BYTE, peer, tag,
+ MPI_COMM_WORLD, &recv_request);
+ MPI_Wait(&recv_request, &status);
+
+ if (check) {
+ for (i = 0; i < bytes; i++) {
+ if (rbuf[i] != (unsigned char)(i & 255)) {
+ fprintf(stderr, "Error: index=%d sent %d
received %d\n",
+ i, ((unsigned char)i)&255, (unsigned
char)rbuf[i]);
+ }
+ rbuf[i] = 0;
+ }
+ }
+ }
+
+ if (proc & 1) {
+ MPI_Isend(tbuf, bytes, MPI_BYTE, peer, tag,
+ MPI_COMM_WORLD, &send_request);
+ MPI_Wait(&send_request, &status);
+ }
+ }
+
+ tv[1] = MPI_Wtime();
+ }
+
+ /*
+ * Calculate time interval in useconds (half round trip)
+ */
+
+ t = (tv[1] - tv[0]) * 1000000.0 / (2 * reps);
+
+ }
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ if ((peer < nproc) && (peer & 1)) {
+ printf("%3d pinged %3d: %8d bytes %9.2f uSec %8.2f MB/s\n",
+ proc, peer, bytes, t, bytes / (t));
+ fflush(stdout);
+ }
+ }
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Finalize();
+
+ return EXIT_SUCCESS;
+}
+
Added: msh/src/test_mping.sh
===================================================================
--- msh/src/test_mping.sh (rev 0)
+++ msh/src/test_mping.sh 2013-06-27 13:23:29 UTC (rev 27650)
@@ -0,0 +1,12 @@
+#!/bin/sh
+#SBATCH -o /home/hpc/pr86mo/di72zus/test/myjob.%j.%N.out
+#SBATCH -D /home/hpc/pr86mo/di72zus/test
+#SBATCH -J testjob
+#SBATCH --clusters=serial
+#SBATCH --partition=serial_std
+#SBATCH --mail-type=end
+#SBATCH address@hidden
+#SBATCH --time=00:01:00
+
+hostname
+uptime
Property changes on: msh/src/test_mping.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r27650 - in msh: . src,
gnunet <=