Commit aa9869dc authored by Joubert, Wayne's avatar Joubert, Wayne
Browse files

Added uptime_monitor application target.

parent 96fb4d35
../Crest/uptime_monitor
\ No newline at end of file
CXX = mpCC
CFLAGS = -g -DMPI_PROTOCOL -DMPICH_IGNORE_CXX_SEEK
LFLAGS = -g -DMPI_PROTOCOL -DMPICH_IGNORE_CXX_SEEK
src = main.cpp
.cpp.o:
$(CXX) -c $(CFLAGS) -o $@ $<
obj = ${src:.cpp=.o}
executable = helloworld.x
${executable} : ${obj}
${CXX} ${LFLAGS} ${obj} -o ${executable}
all:
make clean
make ${executable}
clean :
rm -f ${executable}
rm -f ${obj}
#include <iostream>
#include <fstream>
#include <mpi.h>
using namespace std;
int main(int argc, char *argv[])
{
MPI_Init(&argc, &argv);
int numprocs, rank, namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Get_processor_name(processor_name, &namelen);
printf("Process %d on %s out of %d\n", rank, processor_name, numprocs);
// Create an array to broadcast.
int array_size=numprocs;
int * iarray = new int [array_size];
if (rank == 0)
{
for (int ip=0; ip <array_size; ip++)
{
iarray[ip] = ip;
}
}
else
{
for (int ip=0; ip <array_size; ip++)
{
iarray[ip] = -1;
}
}
// Time a single broadcast.
double start_time;
double end_time;
double elapsed_bcast_time;
MPI_Barrier(MPI_COMM_WORLD);
//Start the timer.
start_time = MPI_Wtime();
// Broadcast the array.
MPI_Bcast(iarray,numprocs,MPI_INT,0,MPI_COMM_WORLD);
//Stop the timer.
end_time = MPI_Wtime();
elapsed_bcast_time = end_time - start_time;
delete [] iarray;
if (rank==0)
{
ofstream data_file;
data_file.open("bcast_time");
data_file << elapsed_bcast_time << endl;
data_file.close();
}
MPI_Finalize();
printf("Success\n");
return 0;
}
#!/usr/bin/env python
import getopt
import sys
import os
import shutil
#import popen2
import subprocess
#
# Author: Arnold Tharrington
# Email: arnoldt@ornl.gov
# National Center for Computational Sciences, Scientific Computing Group.
#
# Modified by: Veronica G. Vergara Larrea
# National Center for Computational Sciences, User Assistance Group.
#
# This build the simple fortran program.
#
def main():
#
# Get the command line arguments.
#
try:
opts,args = getopt.getopt(sys.argv[1:],"hi:p:")
except getopt.GetoptError:
usage()
sys.exit(2)
#
# Parse the command line arguments.
#
if opts == []:
usage()
sys.exit()
for o, a in opts:
if o == "-p":
path_to_workspace = a
elif o == "-i":
test_id_string = a
elif o in ("-h", "--help"):
usage()
sys.exit()
else:
usage()
sys.exit()
#
# Create the temporary workspace.
# Save the tempoary workspace for the submit executable.
#
create_tmp_workspace(path_to_workspace)
#
#--Making the binary.
#
make_exit_status = make_binary(path_to_workspace)
if make_exit_status == 0:
make_exit_value = 0
else:
make_exit_value = 1
return make_exit_value
def make_binary(path_to_workspace):
#
# Get the current working directory.
#
cwd = os.getcwd()
#
# Get the 2 tail paths in the cwd.
#
(dir_head1, dir_tail1) = os.path.split(cwd)
(dir_head2, dir_tail2) = os.path.split(dir_head1)
#
# Get the path to the Source directory for the application.
#
path_to_source = os.path.join(dir_head2,"Source")
#
# Now make the path to the build directory.
#
path_to_build_directory = os.path.join(path_to_workspace,"build_directory")
#
#Copy Source to build directory.
#
shutil.copytree(path_to_source,path_to_build_directory)
#
# Change back to build directory.
#
os.chdir(path_to_build_directory)
# Make executable.
make_command = "./make.sh"
make_exit_status = os.system(make_command)
return make_exit_status
def usage():
print("Usage: build_executable.x [-h|--help] -p <path_to_worspace> -i <test_id_string>")
print("A driver program that the build the binary for the test.")
print()
print("-h, --help Prints usage information.")
print("-p The absolute path to the workspace. This path ")
print(" must have the appropiate permissions to permit ")
print(" the user of the test to r,w, and x. ")
print("-i The test id string. The build program ")
print(" uses this string to make a unique directory ")
print(" within path_to_workspace. We don't want ")
print(" concurrent builds to clobber each other. ")
def create_tmp_workspace(path1):
#
# Fisrt check to see if the path1 does not already exist.
#
os.makedirs(path1)
if __name__ == "__main__" :
main()
#! /usr/bin/env python
import sys
import os
import getopt
import filecmp
import re
def main():
#
# Get the command line arguments.
#
try:
opts,args = getopt.getopt(sys.argv[1:],"hi:p:")
except getopt.GetoptError:
usage()
sys.exit(2)
#
# Parse the command line arguments.
#
for o, a in opts:
if o == "-p":
path_to_results = a
elif o == "-i":
test_id_string = a
elif o == ("-h", "--help"):
usage()
sys.exit()
else:
usage()
sys.exit()
#
# Get path to the correct results.
#
path_to_correct_results = get_path_to_correct_results()
#
# Compare the results.
#
jstatus = check_results(path_to_results)
#
# Write the statis of the results to job data file.
#
write_to_job_data(path_to_results,jstatus)
def get_path_to_correct_results():
cwd = os.getcwd()
#
# Get the head path in the cwd.
#
(dir_head1, dir_tail1) = os.path.split(cwd)
#
# This is the path to the correct results.
#
crslts = os.path.join(dir_head1,"Correct_Results")
return crslts
def check_results(path_to_results):
#-----------------------------------------------------
#Define good and bad results.
# -
#-----------------------------------------------------
GOOD_RESULTS=1
BAD_RESULTS=0
#
# Make the file name paths to numbers squared.
#
file1 = os.path.join(path_to_results,"std.out.txt")
file_obj = open(file1,"r")
alllines = file_obj.readlines()
file_obj.close()
num_failures = -1
lastline = alllines[-1]
# Check to make sure job completed
match = re.search('FINAL',lastline)
# And if it did, retrieve the number of failures
if match:
match_failures = re.search('num_failures (\d+)',lastline)
if match_failures:
num_failures = int(match_failures.group(1))
if num_failures == 0:
ival = GOOD_RESULTS
else:
ival = BAD_RESULTS
return ival
def write_to_job_data(path_to_results,jstatus):
(dir_head1, dir_tail1) = os.path.split(path_to_results)
(dir_head2, dir_tail2) = os.path.split(dir_head1)
file1 = os.path.join(dir_head2,"Status",dir_tail1,"job_status.txt")
file1_obj = open(file1,"w")
# Set the string to write to the job_status.txt file.
if jstatus == 0:
pf = "1"
elif jstatus == 1:
pf = "0"
elif jstatus >= 2:
pf = "2"
string1 = "%s\n" % (pf)
file1_obj.write(string1)
file1_obj.close()
def usage():
print("Usage: check_executable.x [-h|--help] [-i <test_id_string>] [-p <path_to_results>]")
print("A program that checks the results located at <path_to_results>")
print("The check executable must write the status of the results to the file")
print("Status/<test_id_string>/job_status.txt'.")
print("")
print("-h, --help Prints usage information.")
print("-p <path_to_results> The absoulte path to the results of a test.")
print("-i <test_id_string> The test string unique id.")
if __name__ == "__main__":
main()
#! /bin/bash -l
#BSUB -q __batchqueue__
#BSUB -J __jobname__
#BSUB -o __jobname__.o%J
#BSUB -e __jobname__.e%J
#BSUB -n __nodes__
#BSUB -W __walltime__
#BSUB -b __starttime__
#-----------------------------------------------------
# Set up the environment for use of the harness. -
# -
#-----------------------------------------------------
source __rgtenvironmentalfile__
module load __nccstestharnessmodule__
module load pgi
module load cuda
module list
#-----------------------------------------------------
# Define some variables. -
# -
#-----------------------------------------------------
EXECUTABLE="__pathtoexecutable__"
STARTINGDIRECTORY="__startingdirectory__"
WORKDIR="__workdir__"
RESULTSDIR="__resultsdir__"
UNIQUE_ID_STRING="__unique_id_string__"
#-----------------------------------------------------
# Ensure that we are in the correct starting -
# directory. -
# -
#-----------------------------------------------------
cd $STARTINGDIRECTORY
echo "Starting directory is `pwd`"
#-----------------------------------------------------
# Make the working scratch space directory. -
# -
#-----------------------------------------------------
if [ ! -e $WORKDIR ]
then
mkdir -p $WORKDIR
fi
#-----------------------------------------------------
# Make the results directory. -
# -
#-----------------------------------------------------
if [ ! -e $RESULTSDIR ]
then
mkdir -p $RESULTSDIR
fi
# Copy input to workdir
cd ../Inputs
cp sizes.txt $WORKDIR/
#-----------------------------------------------------
# Change directory to the working directory. -
# -
#-----------------------------------------------------
cd $WORKDIR
#-----------------------------------------------------
# Run the executable. -
# -
#-----------------------------------------------------
log_binary_execution_time.py --scriptsdir $STARTINGDIRECTORY --uniqueid $UNIQUE_ID_STRING --mode start
__joblaunchcommand__
log_binary_execution_time.py --scriptsdir $STARTINGDIRECTORY --uniqueid $UNIQUE_ID_STRING --mode final
sleep 30
#-----------------------------------------------------
# Enusre that we return to the starting directory. -
# -
#-----------------------------------------------------
cd $STARTINGDIRECTORY
#-----------------------------------------------------
# Copy the results back to the $RESULTSDIR -
# -
#-----------------------------------------------------
cp -rf $WORKDIR/* $RESULTSDIR # && rm -rf $WORKDIR
#-----------------------------------------------------
# Move the batch file name to $RESULTSDIR -
# -
#-----------------------------------------------------
mv __batchfilename__ $RESULTSDIR
#-----------------------------------------------------
# Check the final results. -
# -
#-----------------------------------------------------
check_executable_driver.py -p $RESULTSDIR -i $UNIQUE_ID_STRING
#-----------------------------------------------------
# The script now determines if we are to resubmit -
# itself. -
# -
#-----------------------------------------------------
case __resubmitme__ in
0)
test_harness_driver.py -r;;
1)
echo "No resubmit";;
esac
#! /bin/bash -l
#PBS -e __resultsdir__
#PBS -o __resultsdir__
#PBS -N __jobname__
#PBS -l walltime=__walltime__
#PBS -l nodes=__nodes__
#PBS -q __batchqueue__
#PBS -A __pbsaccountid__
#PBS -a __starttime__
#-----------------------------------------------------
# Set up the environment for use of the harness. -
# -
#-----------------------------------------------------
source __rgtenvironmentalfile__
module load __nccstestharnessmodule__
#-----------------------------------------------------
# Define some variables. -
# -
#-----------------------------------------------------
EXECUTABLE="__pathtoexecutable__"
STARTINGDIRECTORY="__startingdirectory__"
WORKDIR="__workdir__"
RESULTSDIR="__resultsdir__"
UNIQUE_ID_STRING="__unique_id_string__"
#-----------------------------------------------------
# Enusre that we are in the correct starting -
# directory. -
# -
#-----------------------------------------------------
cd $STARTINGDIRECTORY
#-----------------------------------------------------
# Make the working scratch space directory. -
# -
#-----------------------------------------------------
if [ ! -e $WORKDIR ]
then
mkdir -p $WORKDIR
fi
#-----------------------------------------------------
# Make the results directory. -
# -
#-----------------------------------------------------
if [ ! -e $RESULTSDIR ]
then
mkdir -p $RESULTSDIR
fi
#-----------------------------------------------------
# Change directory to the working directory. -
# -
#-----------------------------------------------------
cd $WORKDIR
#-----------------------------------------------------
# Run the executable. -
# -
#-----------------------------------------------------
log_binary_execution_time.py --scriptsdir $STARTINGDIRECTORY --uniqueid $UNIQUE_ID_STRING --mode start
__joblaunchcommand__
log_binary_execution_time.py --scriptsdir $STARTINGDIRECTORY --uniqueid $UNIQUE_ID_STRING --mode final
sleep 30
#-----------------------------------------------------
# Enusre that we return to the starting directory. -
# -
#-----------------------------------------------------
cd $STARTINGDIRECTORY
#-----------------------------------------------------
# Copy the results back to the $RESULTSDIR -
# -
#-----------------------------------------------------
cp -rf $WORKDIR/* $RESULTSDIR # && rm -rf $WORKDIR
#-----------------------------------------------------
# Move the batch file name to $RESULTSDIR -
# -
#-----------------------------------------------------
mv __batchfilename__ $RESULTSDIR
#-----------------------------------------------------
# Check the final results. -
# -
#-----------------------------------------------------
check_executable_driver.py -p $RESULTSDIR -i $UNIQUE_ID_STRING
#-----------------------------------------------------
# The script now determines if we are to resubmit -
# itself. -
# -
#-----------------------------------------------------
case __resubmitme__ in
0)
test_harness_driver.py -r;;
1)
echo "No resubmit";;
esac
#!/usr/bin/env python
#==============================================================================
<