Added Astaroth 2.0

This commit is contained in:
jpekkila
2019-06-14 14:18:35 +03:00
parent 4e4f84c8ff
commit 0e48766a68
87 changed files with 18058 additions and 1 deletions

81
scripts/ac_mkbuilddir.sh Executable file
View File

@@ -0,0 +1,81 @@
#!/bin/bash
if [ -z $AC_HOME ]
then
echo "ASTAROTH_HOME environment variable not set, run \"source ./sourceme.sh\" in Astaroth home directory"
exit 1
fi
TIARA_SETUP_DEFAULT=""
DOUBLE_DEFAULT="OFF"
DEBUG_MODE_DEFAULT="OFF"
BUILD_DIR_DEFAULT=${AC_HOME}/build/
ALTER_CONF_DEFAULT="OFF"
BUILD_DIR=${BUILD_DIR_DEFAULT}
TIARA_SETUP=${TIARA_SETUP_DEFAULT}
DOUBLE=${DOUBLE_DEFAULT}
DEBUG_MODE=${DEBUG_MODE_DEFAULT}
ALTER_CONF=${ALTER_CONF_DEFAULT}
while [ "$#" -gt 0 ]
do
case $1 in
-h|--help)
echo "You can set up a build directory separe of the ASTAROTH_HOME"
echo "Available flags:"
echo "-b, --buildir [PATH] : Set build directory"
echo "-t,--tiara : Use TIARA cluster setting for cmake"
echo "-d, --double : Compile with double precision"
echo "-e, --debug: : Compile in debug mode"
echo "Example:"
echo "ac_mkbuilddir.sh -b my_build_dir/"
exit 0
;;
-b|--buildir)
shift
BUILD_DIR=${1}
shift
echo "Setting up build directory..."
ALTER_CONF="ON"
;;
-t|--tiara)
shift
TIARA_SETUP="-D CMAKE_C_COMPILER=icc -D CMAKE_CXX_COMPILER=icpc"
echo "Using TIARA cluster compiler settings"
;;
-d|--double)
shift
DOUBLE="ON"
echo "Double precision"
;;
-e|--debug)
shift
DEBUG_MODE="ON"
echo "Debug mode compilation"
;;
*)
break
esac
done
echo "Creating build directory: ${BUILD_DIR}"
mkdir ${BUILD_DIR}
cd ${BUILD_DIR}
#Set up the astaroth.conf to be define and customized in the build directory to
#not always alter the default use i.e. for unit test etc.
#Assumed by default if you do this thing anyway.
echo "cp ${AC_HOME}/config/astaroth.conf ${PWD}"
cp ${AC_HOME}/config/astaroth.conf .
CONF_DIR="-D ASTAROTH_CONF_PATH=${PWD}"
#cmake -D CMAKE_C_COMPILER=icc -D CMAKE_CXX_COMPILER=icpc -DDOUBLE_PRECISION=OFF -DBUILD_DEBUG=OFF ${AC_HOME}
echo "cmake ${TIARA_SETUP} ${CONF_DIR} -DDOUBLE_PRECISION=${DOUBLE} -DBUILD_DEBUG=${DEBUG_MODE} -DALTER_CONF=${ALTER_CONF} ${AC_HOME}"
cmake ${TIARA_SETUP} ${CONF_DIR} -DDOUBLE_PRECISION=${DOUBLE} -DBUILD_DEBUG=${DEBUG_MODE} -DALTER_CONF=${ALTER_CONF} ${AC_HOME}

51
scripts/auto_optimize.sh Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/bash
# Run this in your build directory (cd build && ../scripts/auto_optimize.sh)
# Generates a ${BENCHMARK_FILE} which contains the threadblock dims and other
# constants used in the integration in addition to the time used.
MAX_THREADS=1024 # Max size of the thread block, depends on hardware
BENCHMARK_FILE="benchmark.out"
TBCONFCREATOR_SRC_PATH="../scripts/gen_rk3_threadblockconf.c"
TBCONFFILE_DST_PATH="../src/core/kernels"
C_COMPILER_NAME="gcc"
rm ${BENCHMARK_FILE}
for (( tz=2; tz<=8; tz*=2))
do
for (( ty=1; ty<=1; ty+=1))
do
for (( tx=16; tx<=64; tx*=2))
do
if ( (${tx}*${ty}*${tz}) > ${MAX_THREADS})
then break
fi
for (( launch_bound=1; launch_bound<=8; launch_bound*=2))
do
for (( elems_per_thread=1; elems_per_thread<=128; elems_per_thread*=2))
do
# Generate the threadblock configuration
${C_COMPILER_NAME} ${TBCONFCREATOR_SRC_PATH} -o gen_rk3_threadblockconf
./gen_rk3_threadblockconf ${tx} ${ty} ${tz} ${elems_per_thread} ${launch_bound}
rm gen_rk3_threadblockconf
mv rk3_threadblock.conf ${TBCONFFILE_DST_PATH}
# Compile and run the test build
cmake -DBUILD_DEBUG=OFF -DDOUBLE_PRECISION=OFF -DAUTO_OPTIMIZE=ON .. && make -j
#if ./ac_run -t; then
# echo Success
./ac_run -b
#else
# echo fail!
#fi
done
done
done
done
done

3
scripts/buildtest.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
cmake -DCUDA_BUILD_LEGACY=OFF -DDOUBLE_PRECISION=ON .. && make -j && valgrind --leak-check=full --show-leak-kinds=all ./ac_run -t && make clean &&\
cmake -DCUDA_BUILD_LEGACY=OFF -DDOUBLE_PRECISION=OFF .. && make -j && valgrind --leak-check=full --show-leak-kinds=all ./ac_run -t

52
scripts/compile_acc.sh Executable file
View File

@@ -0,0 +1,52 @@
#!/bin/bash
#!/bin/bash
if [ -z $AC_HOME ]
then
echo "ASTAROTH_HOME environment variable not set, run \"source ./sourceme.sh\" in Astaroth home directory"
exit 1
fi
KERNEL_DIR=${AC_HOME}"/src/core/kernels"
ACC_DIR=${AC_HOME}"/acc"
ACC_DEFAULT_SAS="mhd_solver/stencil_assembly.sas"
ACC_DEFAULT_SPS="mhd_solver/stencil_process.sps"
${ACC_DIR}/clean.sh
${ACC_DIR}/build_acc.sh
ACC_SAS=${ACC_DEFAULT_SAS}
ACC_SPS=${ACC_DEFAULT_SPS}
while [ "$#" -gt 0 ]
do
case $1 in
-h|--help)
echo "You can set a custom files for DSL under the path $AC_HOME/"
echo "Example:"
echo "compile_acc.sh -a custom_setup/custom_assembly.sas -p custom_setup/custom_process.sps"
exit 0
;;
-a|--assembly)
shift
ACC_SAS=${1}
shift
echo "CUSTOM Assembly file!"
;;
-p|--process)
shift
ACC_SPS=${1}
shift
echo "CUSTOM Process file!"
;;
*)
break
esac
done
echo "Assembly file: ${ACC_DIR}/${ACC_SAS}"
echo "Process file: ${ACC_DIR}/${ACC_SPS}"
cd ${KERNEL_DIR}
${ACC_DIR}/compile.sh ${ACC_DIR}/${ACC_SAS}
${ACC_DIR}/compile.sh ${ACC_DIR}/${ACC_SPS}

9
scripts/fix_style.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
if [[ $1 == "DO" && $2 == "IT!" ]]; then
find -name \*.h -o -name \*.cc -o -name \*.cu -o -name \*.cuh | xargs clang-format-6.0 -i -style=file
echo "It is done."
else
find -name \*.h -o -name \*.cc -o -name \*.cu -o -name \*.cuh
echo "I'm going to try to fix the style of these files."
echo "If you're absolutely sure, give \"DO IT!\" (without quotes) as a parameter."
fi

View File

@@ -0,0 +1,60 @@
/*
Copyright (C) 2014-2018, Johannes Pekkilae, Miikka Vaeisalae.
This file is part of Astaroth.
Astaroth is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Astaroth is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Astaroth. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
* \brief Generates a threadblock config file for RK3 using the given parameters.
*
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
const char* rk3_threadblockconf_path = "rk3_threadblock.conf";
int
write_to_file(int threads_x, int threads_y, int threads_z, int elems_per_thread, int launch_bound)
{
FILE* fp;
fp = fopen(rk3_threadblockconf_path, "w");
if (fp != NULL) {
fprintf(fp, "#define RK_THREADS_X (%d)\n", threads_x);
fprintf(fp, "#define RK_THREADS_Y (%d)\n", threads_y);
fprintf(fp, "#define RK_THREADS_Z (%d)\n", threads_z);
fprintf(fp, "#define RK_ELEMS_PER_THREAD (%d)\n", elems_per_thread);
fprintf(fp, "#define RK_LAUNCH_BOUND_MIN_BLOCKS (%d)\n", launch_bound);
fclose(fp);
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}
// Takes arguments and writes them into a file
// RK_THREADS_X, RK_THREADS_Y, RK_THREADS_Z, RK_ELEMS_PER_THREAD, RK_LAUNCH_BOUND_MIN_BLOCKS
int
main(int argc, char* argv[])
{
assert(argc == 6);
return write_to_file(atoi(argv[1]), atoi(argv[2]),atoi(argv[3]), atoi(argv[4]), atoi(argv[5]));
}

2
scripts/generate_doc.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
doxygen doxyfile