diff --git a/hpvm/install.sh b/hpvm/install.sh index 23f5db63b2ad6366b9db501791ff02b37dac35c6..776b8aa6d11c0d92af507a161fb902b183da7672 100644 --- a/hpvm/install.sh +++ b/hpvm/install.sh @@ -1,2 +1,11 @@ +#!/bin/bash + +SCRIPTS_DIR=scripts + +BASH=/bin/bash + # Run installer script -/bin/bash llvm_installer/llvm_installer.sh +$BASH $SCRIPTS_DIR/llvm_installer.sh + +# Run the tests +$BASH $SCRIPTS_DIR/automate_tests.sh diff --git a/hpvm/scripts/.llvm_installer.sh.swp b/hpvm/scripts/.llvm_installer.sh.swp new file mode 100644 index 0000000000000000000000000000000000000000..5cda96b1496227b052fcadd3d635ee3e1de299e8 Binary files /dev/null and b/hpvm/scripts/.llvm_installer.sh.swp differ diff --git a/hpvm/scripts/automate_tests.sh b/hpvm/scripts/automate_tests.sh new file mode 100644 index 0000000000000000000000000000000000000000..565d20754732b77f58acc96b08cd96bfb29ba6e2 --- /dev/null +++ b/hpvm/scripts/automate_tests.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +CURRENT_DIR=`pwd` +BUILD_DIR=$CURRENT_DIR/build + +if [ -x $BUILD_DIR/tools/hpvm/projects/$HPVM_RT ]; then + true +else + echo HPVM not installed! Exiting without running tests!. + exit 0 +fi + +LIT_DIR=$BUILD_DIR/bin/ + +LIT_TOOL=$LIT_DIR/llvm-lit + +TEST_DIR=$CURRENT_DIR/test +REG_TEST_DIR=$TEST_DIR/regressionTests +UNIT_TEST_DIR=$TEST_DIR/unitTests + +echo +echo Running tests ... +echo + +# Run regression tests +$LIT_TOOL -v $REG_TEST_DIR + +# Run unit tests +#$LIT_TOOL -v $UNIT_TEST_DIR diff --git a/hpvm/scripts/llvm_installer.sh b/hpvm/scripts/llvm_installer.sh new file mode 100755 index 0000000000000000000000000000000000000000..11dd5ca9a553142f0548a66e02cd2a0ff9c9d466 --- /dev/null +++ b/hpvm/scripts/llvm_installer.sh @@ -0,0 +1,194 @@ +#!/bin/bash + +VERSION="9.0.0" + +URL="http://releases.llvm.org" + +WGET=wget + +CURRENT_DIR=`pwd` +INSTALL_DIR=`pwd`/install +BUILD_DIR=$CURRENT_DIR/$LLVM_SRC/build + +# Using 2 threads by default +NUM_THREADS=2 + +SUFFIX=".tar.xz" +CLANG_SRC="cfe-$VERSION.src" +LLVM_SRC="llvm-$VERSION.src" +LIBCXX_SRC="libcxx-$VERSION.src" +LIBCXXABI_SRC="libcxxabi-$VERSION.src" + +HPVM_RT=hpvm-rt.bc + +AUTOMATE="y" + +read -p "Build and install HPVM automatically? (y or n): " AUTOMATE + +if [ ! $AUTOMATE == "y" ] && [ ! $AUTOMATE == "n" ]; then + echo invalid input! + exit -1 +fi + +echo +read -p "Number of threads: " NUM_THREADS + +if [ ! $NUM_THREADS -gt 0 ]; then + NUM_THREADS = 2 + echo + echo Using $NUM_THREADS threads by default. + echo +fi + + +if [ -d $LLVM_SRC ]; then + echo Found $LLVM_SRC! +elif [ -d llvm ]; then + echo Found llvm, not downloading $LLVM_SRC! +else + echo $WGET $URL/$VERSION/$LLVM_SRC$SUFFIX + $WGET $URL/$VERSION/$LLVM_SRC$SUFFIX + tar xf $LLVM_SRC$SUFFIX + rm $LLVM_SRC$SUFFIX +fi + +if [ -d $LLVM_SRC ]; then + echo Everything looks sane. + mv $LLVM_SRC llvm +elif [ -d llvm ]; then + echo Everything looks sane. +else + echo Install had problems. Quitting. + exit +fi + +LLVM_SRC=llvm + +if [ -d $CURRENT_DIR/$LLVM_SRC/tools ]; then + cd $CURRENT_DIR/$LLVM_SRC/tools + echo In tools. +else + echo Fail! Something is wrong with your $LLVM_SRC checkout! + exit 1 +fi + +if [ -d clang ]; then + echo Found clang! Not downloading clang again. +else + $WGET $URL/$VERSION/$CLANG_SRC$SUFFIX + tar xf $CLANG_SRC$SUFFIX + rm $CLANG_SRC$SUFFIX + mv $CLANG_SRC clang + if [ -d clang ]; then + echo Everything looks sane. + else + echo Install had problems. Quitting. + exit + fi +fi + +cd $CURRENT_DIR + +if [ -d $CURRENT_DIR/$LLVM_SRC/projects ]; then + cd $CURRENT_DIR/$LLVM_SRC/projects +else + echo Fail! Something is wrong wint $LLVM_SRC. + exit 1 +fi + +if [ -d libcxx ]; then + echo Found libcxx! Not downloading libcxx again. +else + $WGET $URL/$VERSION/$LIBCXX_SRC$SUFFIX + tar xf $LIBCXX_SRC$SUFFIX + rm $LIBCXX_SRC$SUFFIX + mv $LIBCXX_SRC libcxx + if [ -d libcxx ]; then + echo Everything looks sane. + else + echo Install had problems. Quitting. + exit + fi +fi + +if [ $LIBCXXABI_SRC != "" ]; then + if [ -d libcxxabi ]; then + echo Found libcxxabi! Not downloading libcxx again. + else + $WGET $URL/$VERSION/$LIBCXXABI_SRC$SUFFIX + tar xf $LIBCXXABI_SRC$SUFFIX + rm $LIBCXXABI_SRC$SUFFIX + mv $LIBCXXABI_SRC libcxxabi + if [ -d libcxxabi ]; then + echo Everything looks sane. + else + echo Install had problems. Quitting. + exit + fi + fi +fi + +HPVM_DIR=$CURRENT_DIR/$LLVM_SRC/tools/hpvm + +if [ ! -d $HPVM_DIR ]; then + echo Adding HPVM sources to tree + mkdir -p $HPVM_DIR + ln -s $CURRENT_DIR/CMakeLists.txt $HPVM_DIR + ln -s $CURRENT_DIR/include $HPVM_DIR/ + ln -s $CURRENT_DIR/lib $HPVM_DIR/ + ln -s $CURRENT_DIR/projects $HPVM_DIR/ + ln -s $CURRENT_DIR/test $HPVM_DIR/ +else + echo $CURRENT_DIR/$LLVM_SRC/tools/hpvm exists. +fi + +export LLVM_SRC_ROOT=$CURRENT_DIR/$LLVM_SRC + +echo Applying HPVM patches +cd $CURRENT_DIR/llvm_patches +/bin/bash ./construct_patch.sh +/bin/bash ./apply_patch.sh + +echo Patches applied. + +if [ ! $AUTOMATE == "y" ]; then + echo + echo HPVM not installed. Exiting. + exit +fi + +echo +echo Now building... + +echo Using $NUM_THREADS threads to build HPVM. +echo + +cd $CURRENT_DIR + +if [ ! -d $BUILD_DIR ]; then + mkdir -p $BUILD_DIR +fi + +if [ ! -d $INSTALL_DIR ]; then + mkdir -p $INSTALL_DIR +fi + +cd $BUILD_DIR +echo cmake ../$LLVM_SRC -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR +cmake ../$LLVM_SRC -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR + +echo make -j$NUM_THREADS +make -j$NUM_THREADS +#make install + + +if [ -x $BUILD_DIR/tools/hpvm/projects/$HPVM_RT ]; then + true +else + echo HPVM not installed properly. + exit 0 +fi + +cd $CURRENT_DIR + +