Commit 40ea027a authored by Philip Carns's avatar Philip Carns
Browse files

initial commit of Darshan examples

parents
This directory contains the support files needed for the ATPESC 2015 hands-on
exercises.
For documentation and instructions, please see
http://www.mcs.anl.gov/research/projects/darshan/tutorials/atpesc-2015-hands-on/
/*
* (C) 2014 The University of Chicago.
*/
/* COMPILE:
*
* mpicc -Wall teleportA.c -o teleportA
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
#include <mpi.h>
#include <errno.h>
#include <getopt.h>
#include <limits.h>
static int example2A(const char* dir, int rank, int nprocs);
int main(int argc, char **argv)
{
char* dir;
int ret;
int rank;
int nprocs;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
if(argc != 2)
{
if(rank == 0)
{
fprintf(stderr, "Usage: teleportA <directory>\n");
MPI_Finalize();
return(-1);
}
}
dir = strdup(argv[1]);
/*****************/
sleep(1);
MPI_Barrier(MPI_COMM_WORLD);
if(rank == 0) printf(" Running...\n");
ret = example2A(dir, rank, nprocs);
if(ret < 0)
{
if(rank == 0) fprintf(stderr, "Failure.\n");
MPI_Finalize();
return(-1);
}
if(rank == 0) printf(" Completed.\n");
free(dir);
MPI_Finalize();
return(0);
}
static int example2A(const char* dir, int rank, int nprocs)
{
char file_name[PATH_MAX];
int ret;
char *buffer;
int fd;
int i;
long I = 262144;
long J = 2;
buffer = malloc(I);
sprintf(file_name, "%s/teleportA", dir);
fd = open(file_name, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
if(fd < 0)
{
perror("open");
free(buffer);
return(-1);
}
lseek(fd, I*J*rank, SEEK_SET);
for(i=0; i < J; i++)
{
ret = write(fd, buffer, I);
if(ret < 0)
{
perror("write");
free(buffer);
close(fd);
return(-1);
}
}
ret = close(fd);
if(ret < 0)
{
perror("close");
free(buffer);
return(-1);
}
free(buffer);
return(0);
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 4
*
* vim: ts=4
* End:
*/
PROJ=ATPESC2015
# make sure scratch dir exists
mkdir -p /projects/$PROJ/$USER
# delete old file if present
rm -rf /projects/$PROJ/$USER/teleportA
# submit job
qsub -A $PROJ -n 1024 -t 15 --mode c16 ./teleportA /projects/$PROJ/$USER/
/*
* (C) 2014 The University of Chicago.
*/
/* COMPILE:
*
* mpicc -Wall teleportB.c -o teleportB
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
#include <mpi.h>
#include <errno.h>
#include <getopt.h>
#include <limits.h>
static int example2B(const char* dir, int rank, int nprocs);
int main(int argc, char **argv)
{
char* dir;
int ret;
int rank;
int nprocs;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
if(argc != 2)
{
if(rank == 0)
{
fprintf(stderr, "Usage: teleportB <directory>\n");
MPI_Finalize();
return(-1);
}
}
dir = strdup(argv[1]);
/*****************/
sleep(1);
MPI_Barrier(MPI_COMM_WORLD);
if(rank == 0) printf(" Running...\n");
ret = example2B(dir, rank, nprocs);
if(ret < 0)
{
if(rank == 0) fprintf(stderr, "Failure.\n");
MPI_Finalize();
return(-1);
}
if(rank == 0) printf(" Completed.\n");
free(dir);
MPI_Finalize();
return(0);
}
static int example2B(const char* dir, int rank, int nprocs)
{
char file_name[PATH_MAX];
int ret;
char *buffer;
int fd;
int i;
long I = 16384;
long J = 32;
buffer = malloc(I);
sprintf(file_name, "%s/teleportB", dir);
fd = open(file_name, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
if(fd < 0)
{
perror("open");
free(buffer);
return(-1);
}
lseek(fd, I*J*rank, SEEK_SET);
for(i=0; i < J; i++)
{
ret = write(fd, buffer, I);
if(ret < 0)
{
perror("write");
free(buffer);
close(fd);
return(-1);
}
}
ret = close(fd);
if(ret < 0)
{
perror("close");
free(buffer);
return(-1);
}
free(buffer);
return(0);
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 4
*
* vim: ts=4
* End:
*/
PROJ=ATPESC2015
# make sure scratch dir exists
mkdir -p /projects/$PROJ/$USER
# delete old file if present
rm -rf /projects/$PROJ/$USER/teleportB
# submit job
qsub -A $PROJ -n 1024 -t 15 --mode c16 ./teleportB /projects/$PROJ/$USER/
This directory contains the support files needed for the ATPESC 2015 hands-on
exercises.
For documentation and instructions, please see
http://www.mcs.anl.gov/research/projects/darshan/tutorials/atpesc-2015-hands-on/
/*
* (C) 2014 The University of Chicago.
*/
/* COMPILE:
*
* mpicc -Wall teleportA.c -o teleportA
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
#include <mpi.h>
#include <errno.h>
#include <getopt.h>
#include <limits.h>
static int example2A(const char* dir, int rank, int nprocs);
int main(int argc, char **argv)
{
char* dir;
int ret;
int rank;
int nprocs;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
if(argc != 2)
{
if(rank == 0)
{
fprintf(stderr, "Usage: teleportA <directory>\n");
MPI_Finalize();
return(-1);
}
}
dir = strdup(argv[1]);
/*****************/
sleep(1);
MPI_Barrier(MPI_COMM_WORLD);
if(rank == 0) printf(" Running...\n");
ret = example2A(dir, rank, nprocs);
if(ret < 0)
{
if(rank == 0) fprintf(stderr, "Failure.\n");
MPI_Finalize();
return(-1);
}
if(rank == 0) printf(" Completed.\n");
free(dir);
MPI_Finalize();
return(0);
}
static int example2A(const char* dir, int rank, int nprocs)
{
char file_name[PATH_MAX];
int ret;
char *buffer;
int fd;
int i;
long I = 262144;
long J = 2;
buffer = malloc(I);
sprintf(file_name, "%s/teleportA", dir);
fd = open(file_name, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
if(fd < 0)
{
perror("open");
free(buffer);
return(-1);
}
lseek(fd, I*J*rank, SEEK_SET);
for(i=0; i < J; i++)
{
ret = write(fd, buffer, I);
if(ret < 0)
{
perror("write");
free(buffer);
close(fd);
return(-1);
}
}
ret = close(fd);
if(ret < 0)
{
perror("close");
free(buffer);
return(-1);
}
free(buffer);
return(0);
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 4
*
* vim: ts=4
* End:
*/
PROJ=ATPESC2015
# make sure scratch dir exists
mkdir -p /projects/$PROJ/$USER
# delete old file if present
rm -rf /projects/$PROJ/$USER/teleportA
# submit job
qsub -A $PROJ -n 1024 -t 15 --mode c16 ./teleportA /projects/$PROJ/$USER/
/*
* (C) 2014 The University of Chicago.
*/
/* COMPILE:
*
* mpicc -Wall teleportB.c -o teleportB
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
#include <mpi.h>
#include <errno.h>
#include <getopt.h>
#include <limits.h>
static int example2B(const char* dir, int rank, int nprocs);
int main(int argc, char **argv)
{
char* dir;
int ret;
int rank;
int nprocs;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
if(argc != 2)
{
if(rank == 0)
{
fprintf(stderr, "Usage: teleportB <directory>\n");
MPI_Finalize();
return(-1);
}
}
dir = strdup(argv[1]);
/*****************/
sleep(1);
MPI_Barrier(MPI_COMM_WORLD);
if(rank == 0) printf(" Running...\n");
ret = example2B(dir, rank, nprocs);
if(ret < 0)
{
if(rank == 0) fprintf(stderr, "Failure.\n");
MPI_Finalize();
return(-1);
}
if(rank == 0) printf(" Completed.\n");
free(dir);
MPI_Finalize();
return(0);
}
static int example2B(const char* dir, int rank, int nprocs)
{
char file_name[PATH_MAX];
int ret;
char *buffer;
int fd;
int i;
long I = 16384;
long J = 32;
buffer = malloc(I);
sprintf(file_name, "%s/teleportB", dir);
fd = open(file_name, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
if(fd < 0)
{
perror("open");
free(buffer);
return(-1);
}
lseek(fd, I*J*rank, SEEK_SET);
for(i=0; i < J; i++)
{
ret = write(fd, buffer, I);
if(ret < 0)
{
perror("write");
free(buffer);
close(fd);
return(-1);
}
}
ret = close(fd);
if(ret < 0)
{
perror("close");
free(buffer);
return(-1);
}
free(buffer);
return(0);
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 4
*
* vim: ts=4
* End:
*/
PROJ=ATPESC2015
# make sure scratch dir exists
mkdir -p /projects/$PROJ/$USER
# delete old file if present
rm -rf /projects/$PROJ/$USER/teleportB
# submit job
qsub -A $PROJ -n 1024 -t 15 --mode c16 ./teleportB /projects/$PROJ/$USER/
/*
* (C) 2014 The University of Chicago.
*/
/* COMPILE:
*
* mpicc -Wall warpdriveA.c -o warpdriveA
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
#include <mpi.h>
#include <errno.h>
#include <getopt.h>
#include <limits.h>
#define IOSIZE 8192
static int example1A(const char* dir, int rank, int nprocs);
int main(int argc, char **argv)
{
char* dir;
int ret;
int rank;
int nprocs;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
if(argc != 2)
{
if(rank == 0)
{
fprintf(stderr, "Usage: warpdriveA <directory>\n");
MPI_Finalize();
return(-1);
}
}
dir = strdup(argv[1]);
/*****************/
sleep(1);
MPI_Barrier(MPI_COMM_WORLD);
if(rank == 0) printf(" Running...\n");