Commit 87238b50 authored by Joubert, Wayne's avatar Joubert, Wayne
Browse files

Began revision of nuccor_kernels.

parent 4d0e38cd
......@@ -455,8 +455,11 @@ def make_binary(build_dir_path, test):
#--------------------
elif compiler_type(test) == COMPILER_LLVM:
#--------------------
# TODO
substitutions = [
]
make_command += ';' + get_module_command('load clang')
make_command += ';' + get_module_command('load xlflang')
#--------------------
elif compiler_type(test) == COMPILER_XL:
......
#!/usr/bin/env python
"""
-------------------------------------------------------------------------------
File: build_executable.x
Author: Wayne Joubert (joubert@ornl.gov)
National Center for Computational Sciences, Scientific Computing Group.
Oak Ridge National Laboratory
Copyright (C) 2016 Oak Ridge National Laboratory, UT-Battelle, LLC.
-------------------------------------------------------------------------------
"""
import os
import argparse
import shutil
import re
#------------------------------------------------------------------------------
def process_command_line_args():
"""Get the command line arguments."""
command_description = (
'A driver program that builds the binary for the test.')
p_help = (
'The absolute path to the workspace. This path must have the '
'appropiate permissions to permit the user of the test to r, w, and x.')
i_help = (
'The test id string. The build program uses this string to make a '
'unique directory within path_to_workspace. We don\'t want concurrent '
'builds to clobber each other. The submit program uses this string '
'to write the job schedule id to Status/<test_id_string>/job_id.txt')
parser = argparse.ArgumentParser(description=command_description)
parser.add_argument('-p', help=p_help, required=True)
parser.add_argument('-i', help=i_help, required=True)
args = parser.parse_args()
return args
#------------------------------------------------------------------------------
def main():
"""Main program for building the executable."""
# Get the command line arguments.
args = process_command_line_args()
path_to_workspace = args.p
#test_id = args.i
# Create the temporary workspace.
# Save the tempoary workspace for the submit executable.
create_tmp_workspace(path_to_workspace)
# Make the binary.
build_dir_path = prepare_to_make(path_to_workspace)
dir_head1, _ = os.path.split(build_dir_path)
dir_head2, _ = os.path.split(dir_head1)
_, test = os.path.split(dir_head2)
exit_status = make_binary(build_dir_path, test)
if exit_status != 0:
return 1
return 0
#------------------------------------------------------------------------------
def prepare_to_make(path_to_workspace):
"""Perform preparations, e.g., copying source tree."""
# 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.
build_dir_path = os.path.join(path_to_workspace, 'build_directory')
# Copy Source to build directory.
print('Copying source tree ...')
shutil.copytree(path_to_source, build_dir_path, symlinks=True)
# Change to build directory.
os.chdir(build_dir_path)
return build_dir_path
##------------------------------------------------------------------------------
#
#def use_syslapack(test):
# """Helper: do we use system blas/lapack or build our own."""
#
# return re.search('_syslapack', test) != None
#
#------------------------------------------------------------------------------
COMPILER_GNU = 'GNU'
COMPILER_PGI = 'PGI'
COMPILER_CRAY = 'CRAY'
COMPILER_INTEL = 'INTEL'
COMPILER_LLVM = 'LLVM'
COMPILER_XL = 'XL'
#------------------------------------------------------------------------------
def compiler_type(test):
"""Helper: which compiler are we using."""
if re.search('_gnu', test) != None:
return COMPILER_GNU
elif re.search('_pgi', test) != None:
return COMPILER_PGI
elif re.search('_cray', test) != None:
return COMPILER_CRAY
elif re.search('_intel', test) != None:
return COMPILER_INTEL
elif re.search('_llvm', test) != None:
return COMPILER_LLVM
elif re.search('_xl', test) != None:
return COMPILER_XL
else:
assert False, 'Compiler type not recognized. ' + test
#------------------------------------------------------------------------------
def make_binary(build_dir_path, test):
"""Execute the make to build executable."""
make_command = './make.sh ' + compiler_type(test)
exit_status = os.system(make_command)
return exit_status
#------------------------------------------------------------------------------
def create_tmp_workspace(path1):
"""Create the workspace dir."""
os.makedirs(path1)
#------------------------------------------------------------------------------
if __name__ == '__main__':
main()
#------------------------------------------------------------------------------
#!/bin/bash
#==============================================================================
if [ "$PE_ENV" == "PGI" ] ; then
#------------------------------
echo "Compiling with PGI compiler, C version ..."
EXECUTABLE=nuccor_dgemm_titan_c_pgi
module load cudatoolkit
module load acml
#module load cray-libsci
cc -c get_wall_time.c
cc -o $EXECUTABLE nuccor_dgemm.c get_wall_time.o \
$CRAY_CUDATOOLKIT_INCLUDE_OPTS \
-fast -acc -ta=nvidia:rdc -Minfo=accel \
-lcublas -lacml
#-lsci_pgi
module unload acml
#module unload cray-libsci
module unload cudatoolkit
rm -f *.o
#------------------------------
echo "Compiling with PGI compiler, Fortran version ..."
EXECUTABLE=nuccor_dgemm_titan_f_pgi
module load cudatoolkit
module load acml
module unload cray-libsci_acc
cc -c get_wall_time.c
ftn -o $EXECUTABLE nuccor_dgemm.F90 get_wall_time.o \
$CRAY_CUDATOOLKIT_INCLUDE_OPTS \
-fast -acc -ta=nvidia -Minfo=accel -Mcuda \
-lacml
module load cray-libsci_acc
module unload acml
module unload cudatoolkit
rm -f *.o
#------------------------------
echo "Compiling with Cray compiler, Fortran version ..."
EXECUTABLE=nuccor_dgemm_titan_f_cray
module swap PrgEnv-pgi PrgEnv-cray
module load craype-accel-nvidia35
cc -c get_wall_time.c
ftn -o $EXECUTABLE nuccor_dgemm.F90 get_wall_time.o \
-m 3 -O 2 -e m -O noomp
# -lsci_cray
module swap PrgEnv-cray PrgEnv-pgi
module unload craype-accel-nvidia35
rm -f *.o
#------------------------------
# Exit immediately on error.
set -e -o pipefail
# Parse command line arguments.
COMPILER_TYPE="$1"
if [ -z ${CRAYPE_VERSION+x} ] ; then
IS_CRAY=0
else
IS_CRAY=1
fi
if [ "$(uname -n | grep '^crest' | wc -l)" = 1 ] ; then
#------------------------------
echo "Compiling with PGI compiler, C version ..."
EXECUTABLE=nuccor_dgemm_crest_c_pgi
module load pgi
module load cuda
pgcc -c get_wall_time.c
pgcc -o $EXECUTABLE nuccor_dgemm.c get_wall_time.o \
-fast -acc -ta=nvidia:rdc -Minfo=accel \
-L/usr/local/cuda-7.5/lib64/ \
-lcublas_static -lcudart -lculibos -ldl -lpthread \
-L/sw/power8/lapack/3.5.0/ppc64le_gnu4.9.2/lib -lrefblas \
/sw/power8/lapack/3.5.0/ppc64le_gnu4.9.2/lib/librefblas.a \
/usr/lib/gcc/powerpc64le-linux-gnu/4.9/libgfortran.a
#------------------------------------------------------------------------------
if [ $IS_CRAY = 1 ] ; then
if [ $COMPILER_TYPE = PGI ] ; then
#------------------------------
echo "Compiling with PGI compiler, C version ..."
EXECUTABLE=nuccor_dgemm_titan_c_pgi
module load cudatoolkit
module load acml
#module load cray-libsci
cc -c get_wall_time.c
cc -o $EXECUTABLE nuccor_dgemm.c get_wall_time.o \
$CRAY_CUDATOOLKIT_INCLUDE_OPTS \
-fast -acc -ta=nvidia:rdc -Minfo=accel \
-lcublas -lacml
#-lsci_pgi
module unload acml
#module unload cray-libsci
module unload cudatoolkit
rm -f *.o
#------------------------------
echo "Compiling with PGI compiler, Fortran version ..."
EXECUTABLE=nuccor_dgemm_titan_f_pgi
module load cudatoolkit
module load acml
module unload cray-libsci_acc
cc -c get_wall_time.c
ftn -o $EXECUTABLE nuccor_dgemm.F90 get_wall_time.o \
$CRAY_CUDATOOLKIT_INCLUDE_OPTS \
-fast -acc -ta=nvidia -Minfo=accel -Mcuda \
-lacml
module load cray-libsci_acc
module unload acml
module unload cudatoolkit
rm -f *.o
#------------------------------
fi
if [ $COMPILER_TYPE = CRAY ] ; then
#------------------------------
echo "Compiling with Cray compiler, Fortran version ..."
EXECUTABLE=nuccor_dgemm_titan_f_cray
module swap PrgEnv-pgi PrgEnv-cray
module load craype-accel-nvidia35
cc -c get_wall_time.c
ftn -o $EXECUTABLE nuccor_dgemm.F90 get_wall_time.o \
-m 3 -O 2 -e m -O noomp
# -lsci_cray
module swap PrgEnv-cray PrgEnv-pgi
module unload craype-accel-nvidia35
rm -f *.o
#------------------------------
#pgcc -o nuccor_dgemm nuccor_dgemm.c get_wall_time.o -lcublas -Mcuda
#pgf90 -o nuccor_dgemm nuccor_dgemm.F90 get_wall_time.o -O3
rm -f *.o
fi
fi
if [ -x $EXECUTABLE ]
then
#------------------------------------------------------------------------------
if [ $IS_CRAY = 0 ] ; then
if [ $COMPILER_TYPE = PGI ] ; then
#------------------------------
echo "Compiling with PGI compiler, C version ..."
EXECUTABLE=nuccor_dgemm_crest_c_pgi
module load pgi
module load cuda
pgcc -c get_wall_time.c
pgcc -o $EXECUTABLE nuccor_dgemm.c get_wall_time.o \
-fast -acc -ta=nvidia:rdc -Minfo=accel \
-L/usr/local/cuda-7.5/lib64/ \
-lcublas_static -lcudart -lculibos -ldl -lpthread \
-L/sw/power8/lapack/3.5.0/ppc64le_gnu4.9.2/lib -lrefblas \
/sw/power8/lapack/3.5.0/ppc64le_gnu4.9.2/lib/librefblas.a \
/usr/lib/gcc/powerpc64le-linux-gnu/4.9/libgfortran.a
#------------------------------
#pgcc -o nuccor_dgemm nuccor_dgemm.c get_wall_time.o -lcublas -Mcuda
#pgf90 -o nuccor_dgemm nuccor_dgemm.F90 get_wall_time.o -O3
rm -f *.o
#------------------------------
fi
fi
#------------------------------------------------------------------------------
if [ -x $EXECUTABLE ] ; then
echo "Build completed successfully."
else
exit_status="$?"
......@@ -79,4 +105,5 @@ else
fi
exit 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 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. ")