Commit ffc2ef63 authored by Philip Carns's avatar Philip Carns

add cxx test case

-  also fix misc. bash comparison operator goofs
parent 4831753d
......@@ -41,24 +41,33 @@ fi
# set up c compiler for this platform
DARSHAN_CC=`$DARSHAN_PLATFORM/setup-cc.sh`
if [ $? != 0 ]; then
if [ $? -ne 0 ]; then
exit 1
fi
export DARSHAN_CC
# set up c++ compiler for this platform
DARSHAN_CXX=`$DARSHAN_PLATFORM/setup-cxx.sh`
if [ $? -ne 0 ]; then
exit 1
fi
export DARSHAN_CXX
# set up job execution wrapper for this platform
DARSHAN_RUNJOB=`$DARSHAN_PLATFORM/setup-runjob.sh`
if [ $? != 0 ]; then
if [ $? -ne 0 ]; then
exit 1
fi
export DARSHAN_RUNJOB
for i in `ls test-cases/*.sh`; do
echo Running ${i}...
$i
if [ $? != 0 ]; then
if [ $? -ne 0 ]; then
echo "Error: failed to execute test case $i"
exit 1
fi
echo Done.
done
exit 0
#!/bin/bash
PROG=cxxpi
# set log file path; remove previous log if present
export DARSHAN_LOGFILE=$DARSHAN_TMP/${PROG}.darshan.gz
rm -f ${DARSHAN_LOGFILE}
# compile
echo $DARSHAN_CXX test-cases/src/${PROG}.cxx -o $DARSHAN_TMP/${PROG}
$DARSHAN_CXX test-cases/src/${PROG}.cxx -o $DARSHAN_TMP/${PROG}
if [ $? -ne 0 ]; then
echo "Error: failed to compile ${PROG}" 1>&2
exit 1
fi
# execute
$DARSHAN_RUNJOB $DARSHAN_TMP/${PROG} -f $DARSHAN_TMP/${PROG}.tmp.dat
if [ $? -ne 0 ]; then
echo "Error: failed to execute ${PROG}" 1>&2
exit 1
fi
# parse log
$DARSHAN_PATH/bin/darshan-parser $DARSHAN_LOGFILE > $DARSHAN_TMP/${PROG}.darshan.txt
if [ $? -ne 0 ]; then
echo "Error: failed to parse ${DARSHAN_LOGFILE}" 1>&2
exit 1
fi
# check results
# in this case we want to confirm that the open counts are zero; cxxpi does not do any IO
POSIX_OPENS=`grep CP_POSIX_OPENS $DARSHAN_TMP/${PROG}.darshan.txt |cut -f 4`
if [ $POSIX_OPENS != "" ]; then
echo "Error: Found unexpected POSIX open count of $POSIX_OPENS" 1>&2
exit 1
fi
exit 0
......@@ -8,21 +8,21 @@ rm -f ${DARSHAN_LOGFILE}
# compile
$DARSHAN_CC test-cases/src/${PROG}.c -o $DARSHAN_TMP/${PROG}
if [ $? != 0 ]; then
if [ $? -ne 0 ]; then
echo "Error: failed to compile ${PROG}" 1>&2
exit 1
fi
# execute
$DARSHAN_RUNJOB $DARSHAN_TMP/${PROG} -f $DARSHAN_TMP/${PROG}.tmp.dat
if [ $? != 0 ]; then
if [ $? -ne 0 ]; then
echo "Error: failed to execute ${PROG}" 1>&2
exit 1
fi
# parse log
$DARSHAN_PATH/bin/darshan-parser $DARSHAN_LOGFILE > $DARSHAN_TMP/${PROG}.darshan.txt
if [ $? != 0 ]; then
if [ $? -ne 0 ]; then
echo "Error: failed to parse ${DARSHAN_LOGFILE}" 1>&2
exit 1
fi
......@@ -30,12 +30,12 @@ fi
# check results
# in this case we want to confirm that both the MPI and POSIX open counters were triggered
MPI_OPENS=`grep CP_INDEP_OPENS $DARSHAN_TMP/${PROG}.darshan.txt |cut -f 4`
if [ ! $MPI_OPENS > 0 ]; then
if [ ! $MPI_OPENS -gt 0 ]; then
echo "Error: MPI open count of $MPI_OPENS is incorrect" 1>&2
exit 1
fi
POSIX_OPENS=`grep CP_POSIX_OPENS $DARSHAN_TMP/${PROG}.darshan.txt |cut -f 4`
if [ ! $POSIX_OPENS > 0 ]; then
if [ ! $POSIX_OPENS -gt 0 ]; then
echo "Error: POSIX open count of $POSIX_OPENS is incorrect" 1>&2
exit 1
fi
......
/* -*- Mode: C++; c-basic-offset:4 ; -*- */
/*
* (C) 2004 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include "mpi.h"
#include <iostream>
using namespace std;
#include <math.h>
double f(double);
double f(double a)
{
return (4.0 / (1.0 + a*a));
}
int main(int argc,char **argv)
{
int n, myid, numprocs, i;
double PI25DT = 3.141592653589793238462643;
double mypi, pi, h, sum, x;
double startwtime = 0.0, endwtime;
int namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
MPI::Init(argc,argv);
numprocs = MPI::COMM_WORLD.Get_size();
myid = MPI::COMM_WORLD.Get_rank();
MPI::Get_processor_name(processor_name,namelen);
cout << "Process " << myid << " of " << numprocs << " is on " <<
processor_name << endl;
n = 10000; /* default # of rectangles */
if (myid == 0)
startwtime = MPI::Wtime();
MPI::COMM_WORLD.Bcast(&n, 1, MPI_INT, 0);
h = 1.0 / (double) n;
sum = 0.0;
/* A slightly better approach starts from large i and works back */
for (i = myid + 1; i <= n; i += numprocs)
{
x = h * ((double)i - 0.5);
sum += f(x);
}
mypi = h * sum;
MPI::COMM_WORLD.Reduce(&mypi, &pi, 1, MPI_DOUBLE, MPI_SUM, 0);
if (myid == 0) {
endwtime = MPI::Wtime();
cout << "pi is approximately " << pi << " Error is " <<
fabs(pi - PI25DT) << endl;
cout << "wall clock time = " << endwtime-startwtime << endl;
}
MPI::Finalize();
return 0;
}
......@@ -17,7 +17,7 @@
# subsequent tests should be generated from this using darshan-gen-cc.pl.
$DARSHAN_PATH/bin/darshan-gen-cc.pl `which mpicc` --output $DARSHAN_TMP/mpicc
if [ $? != 0 ]; then
if [ $? -ne 0 ]; then
echo "Error: failed to generate c compiler." 1>&2
exit 1
fi
......
#!/bin/bash
# General notes
#######################
# Script to set up the C++ compiler to use for subsequent test cases. This
# script may load optional modules (as in a Cray PE), set LD_PRELOAD
# variables (as in a dynamically linked environment), or generate mpicxx
# wrappers (as in a statically linked environment).
# The script should produce a single string to stdout, which is the command
# line to use for invoking the C compiler
# Notes specific to this platform (ws)
########################
# This particular version of the setup-cxx script assumes that mpicxx is
# present in the path already, and that the C++ compiler to use for
# subsequent tests should be generated from this using darshan-gen-cxx.pl.
$DARSHAN_PATH/bin/darshan-gen-cxx.pl `which mpicxx` --output $DARSHAN_TMP/mpicxx
if [ $? -ne 0 ]; then
echo "Error: failed to generate c compiler." 1>&2
exit 1
fi
echo $DARSHAN_TMP/mpicxx
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment