diff --git a/examples/precise/cos.F90 b/examples/precise/cos.F90 new file mode 100644 index 0000000000000000000000000000000000000000..0fa41ea0996bd3de22da172e7cd1b3435582ffdb --- /dev/null +++ b/examples/precise/cos.F90 @@ -0,0 +1,16 @@ +program main + real :: a + a = '26.47527' + call calc(a) +end program main + +subroutine calc(a) + real :: res + res=cos(3.14159*a/180.) + write(*,100) res + 100 FORMAT('', b32.32) +end subroutine calc + +# The result is not the same if change ARM -O0 to -O3, flang will use constant transfer, skip the KML math library, uses system libmath library. +# X86: ifort -O3 -fp-model precise -no-ftz -lm cos.F90 && ./a.out +# ARM: flang -O0 -mllvm -disable-sincos-opt -ffp-model=precise -ffp-contract=off -L/usr/local/kml/lib/ -lkm_l9 cos.F90 && ./a.out diff --git a/examples/precise/exp.F90 b/examples/precise/exp.F90 new file mode 100644 index 0000000000000000000000000000000000000000..af656c1e5da3eea67bec02dab280e6389e5496a8 --- /dev/null +++ b/examples/precise/exp.F90 @@ -0,0 +1,29 @@ +program main + real :: a, b, c + a = b'11000000000100110101110110001110' + b = b'01000111000110111101111101111010' + c = b'01000100011000010000000000000000' + + call calc_exp(a, b, c) +end program main + +subroutine calc_exp(a, b, c) + real :: res + real :: t1, t2, t3 + res = exp(a * b / c) + t1 = a * b + t2 = t1 / c + t3 = a * b / c + print*,'res = exp(a * b / c) = ' + write(*,100) res + + 100 FORMAT('', b32.32) +end subroutine calc_exp + +! The result is not the same if remove -ffp-contract=off +! X86: ifort -O3 -fp-model precise -no-ftz exp.F90 && ./a.out +! export LD_LIBRARY_PATH=/workspace/public/software/libs/kml/1.6.0/lib:$LD_LIBRARY_PATH +!echo "/workspace/public/software/libs/kml/1.6.0/lib" >> /etc/ld.so.conf +! ldconfig +! export LD_PRELOAD=/workspace/public/software/libs/kml/1.6.0/lib/libkm.so +! ARM: flang -O3 -mllvm -disable-sincos-opt -ffp-model=precise -ffp-contract=off exp.F90 && ./a.out diff --git a/examples/precise/fp-contract.F90 b/examples/precise/fp-contract.F90 new file mode 100644 index 0000000000000000000000000000000000000000..cc0ec7002dbe4d8533b082df07f988afa544e5f1 --- /dev/null +++ b/examples/precise/fp-contract.F90 @@ -0,0 +1,22 @@ +program main + real :: a, b, c, d, e, f + a = b'11000001110101010000111101101010' + b = b'00000000000000000000000000000000' + c = b'01000000010000000000000000000001' + d = b'11000001101100100001111010101010' + e = b'01000001001000000000000000000000' + f = b'01000000010000000000000000000001' + call calc(a, b, c, d, e, f) +end program main + +subroutine calc(a, b, c, d, e, f) + real :: res + res = ((a - b) * c) ** 2 + & + ((d - e) * f) ** 2 + write(*,100) res + 100 FORMAT('', b32.32) +end subroutine calc + +! The result is not the same if remove -ffp-contract=off +! X86: ifort -O3 -fp-model precise -no-ftz fp-contract.F90 && ./a.out +! ARM: flang -O3 -mllvm -disable-sincos-opt -ffp-model=precise -ffp-contract=off fp-contract.F90 && ./a.out diff --git a/init.sh b/init.sh index 6062a6ea6656540762bfc491152b6789d68592c4..0d638117763a464e0c3d3c263c52ec3682d7015d 100644 --- a/init.sh +++ b/init.sh @@ -13,8 +13,10 @@ export JARVIS_UTILS=${CUR_PATH}/software/utils export JARVIS_DOWNLOAD=${CUR_PATH}/downloads export JARVIS_TMP=${CUR_PATH}/tmp export DOWNLOAD_TOOL=${CUR_PATH}/package/common/download.sh +export CHECK_DEPS=${CUR_PATH}/package/common/check_deps.sh +export CHECK_ROOT=${CUR_PATH}/package/common/check_root.sh #Install modules if ! type module >/dev/null 2>&1;then echo "Install environment-modules" - yum install -y environment-modules || apt install -y environment-modules + . $CHECK_ROOT && yum install -y environment-modules || apt install -y environment-modules fi diff --git a/package/R/3.6.3/install.sh b/package/R/3.6.3/install.sh index 66c0e2e9fb80bf29175e48330179bb10faa3758a..3e7c0f6655d88ef669384d447eb348dc8f00dbde 100755 --- a/package/R/3.6.3/install.sh +++ b/package/R/3.6.3/install.sh @@ -1,5 +1,5 @@ #!/bin/bash -#yum install libXt-devel.aarch64 readline-devel.aarch64 +. $CHECK_ROOT && yum install libXt-devel.aarch64 readline-devel.aarch64 set -x set -e . ${DOWNLOAD_TOOL} -u https://cloud.r-project.org/src/base/R-3/R-3.6.3.tar.gz diff --git a/package/bedtools/2.28.0/clang/install.sh b/package/bedtools/2.28.0/clang/install.sh index 9741bcaa25d6f05810acc4def916531796ad30c4..0b671fa40b0cd40c30fc188da38edab7ff3cdef2 100644 --- a/package/bedtools/2.28.0/clang/install.sh +++ b/package/bedtools/2.28.0/clang/install.sh @@ -1,6 +1,4 @@ #!/bin/bash - -#wget https://github.com/arq5x/bedtools2/releases/download/v2.28.0/bedtools-2.28.0.tar.gz set -x set -e . ${DOWNLOAD_TOOL} -u https://github.com/arq5x/bedtools2/releases/download/v2.28.0/bedtools-2.28.0.tar.gz diff --git a/package/bisheng/2.1.0/install.sh b/package/bisheng/2.1.0/install.sh index 9bf1856bd0960f15d92f6d45d2fbd2e8d320190c..55b47aa1caa8a9c1a5f88815289868b6402a3e9d 100644 --- a/package/bisheng/2.1.0/install.sh +++ b/package/bisheng/2.1.0/install.sh @@ -1,7 +1,6 @@ -#download from https://mirrors.huaweicloud.com/kunpeng/archive/compiler/bisheng_compiler/bisheng-compiler-2.1.0-aarch64-linux.tar.gz #!/bin/bash set -e . ${DOWNLOAD_TOOL} -u https://mirrors.huaweicloud.com/kunpeng/archive/compiler/bisheng_compiler/bisheng-compiler-2.1.0-aarch64-linux.tar.gz cd ${JARVIS_TMP} -yum -y install libatomic libstdc++ libstdc++-devel +. $CHECK_ROOT && yum -y install libatomic libstdc++ libstdc++-devel tar xzvf ${JARVIS_DOWNLOAD}/bisheng-compiler-2.1.0-aarch64-linux.tar.gz -C $1 --strip-components=1 \ No newline at end of file diff --git a/package/bisheng/2.3.0/install.sh b/package/bisheng/2.3.0/install.sh index 5445d1d211f3b04021cf98c1c0acef4e8b9ad4a2..d5a5f8c92ba6b32ac7cf6ffe75104cac61590207 100644 --- a/package/bisheng/2.3.0/install.sh +++ b/package/bisheng/2.3.0/install.sh @@ -7,5 +7,5 @@ if [ x$(arch) = xaarch64 ];then fi . ${DOWNLOAD_TOOL} -u https://mirrors.huaweicloud.com/kunpeng/archive/compiler/bisheng_compiler/bisheng-compiler-${bisheng_version}-${arch}-linux.tar.gz cd ${JARVIS_TMP} -yum -y install libatomic libstdc++ libstdc++-devel +. $CHECK_ROOT && yum -y install libatomic libstdc++ libstdc++-devel tar xzvf ${JARVIS_DOWNLOAD}/bisheng-compiler-${bisheng_version}-${arch}-linux.tar.gz -C $1 --strip-components=1 diff --git a/package/blas/3.10.0/install.sh b/package/blas/3.10.0/install.sh index 7f19d0bd375b8aad68275712b2ab0a9789b9f772..a4266b32d8d35dbbcbbc716b716e8c8b2823641a 100644 --- a/package/blas/3.10.0/install.sh +++ b/package/blas/3.10.0/install.sh @@ -9,5 +9,5 @@ cd BLAS-3.10.0 #sed -i "35s/ftp/http/g" ./contrib/download_prerequisites gfortran -c -O3 ./*.f ar rv libblas.a ./*.o -cp libblas.a /usr/local/lib - +mkdir $1/lib +cp libblas.a $1/lib diff --git a/package/cmake/3.23.1/install.sh b/package/cmake/3.23.1/install.sh index f4107262ca5f17de98eaa55134096c6dfd9a4a3e..4a1e91596e69070dd3bba9db76aa626ff1ffac84 100755 --- a/package/cmake/3.23.1/install.sh +++ b/package/cmake/3.23.1/install.sh @@ -1,5 +1,6 @@ #!/bin/bash set -e -. ${DOWNLOAD_TOOL} -u https://github.com/Kitware/CMake/releases/download/v3.23.1/cmake-3.23.1-linux-`arch`.tar.gz +cmake_ver='3.23.1' +. ${DOWNLOAD_TOOL} -u https://github.com/Kitware/CMake/releases/download/v${cmake_ver}/cmake-${cmake_ver}-linux-`arch`.tar.gz cd ${JARVIS_TMP} -tar -xvf ${JARVIS_DOWNLOAD}/cmake-3.23.1-linux-`arch`.tar.gz -C $1 --strip-components=1 \ No newline at end of file +tar -xvf ${JARVIS_DOWNLOAD}/cmake-${cmake_ver}-linux-`arch`.tar.gz -C $1 --strip-components=1 \ No newline at end of file diff --git a/package/common/check_deps.sh b/package/common/check_deps.sh new file mode 100644 index 0000000000000000000000000000000000000000..71a4e6bf6f92cd2d1c00f45531fceb44c1755d4c --- /dev/null +++ b/package/common/check_deps.sh @@ -0,0 +1,27 @@ +#!/bin/bash +#循环遍历脚本入参,查看是否存在 +if [ $# -eq 0 ];then + echo "Usage: $0 para1 para2" + exit 1 +fi +flag=0 +result='' +echo "Start checking dependency..." +for i in $* #在$*中遍历参数,此时每个参数都是独立的,会遍历$#次 +do + result=$(env|grep $i) + if [ -z "$result" ];then + echo "Please load $i first." + flag=1 + else + echo "$i detected." + fi +done + +if [ $flag == 0 ]; then + echo 'CHECK SUCCESS' + exit 0 +else + echo 'CHECK FAILED' + exit 1 +fi \ No newline at end of file diff --git a/package/common/check_root.sh b/package/common/check_root.sh new file mode 100644 index 0000000000000000000000000000000000000000..fd506e0bc99562b4a64dbe43eb5e650d7f9df451 --- /dev/null +++ b/package/common/check_root.sh @@ -0,0 +1,5 @@ +if [[ $EUID -ne 0 ]]; then + echo "Warning:Permissions need to be elevated, some package may need to be installed by root or sudo." + return 1 +fi +return 0 \ No newline at end of file diff --git a/package/ctffind/4.1.14/clang/install.sh b/package/ctffind/4.1.14/clang/install.sh index ee713e6f853553199b06d4c9a6cef7bb4221b694..572db52214a097997ca3c83d91d364d9602089a4 100644 --- a/package/ctffind/4.1.14/clang/install.sh +++ b/package/ctffind/4.1.14/clang/install.sh @@ -10,7 +10,7 @@ cd ctffind-4.1.14 sed -i "7s%^%//%g" src/core/matrix.cpp sed -i '7i #define _AL_SINCOS(x, s, c) s = sinf(x); c = cosf(x);' src/core/matrix.cpp -#yum install -y libjpeg* libtiff* fftw* +. $CHECK_ROOT && yum install -y libjpeg* libtiff* fftw* autoreconf -f -i ./configure --prefix=$1 --disable-mkl --enable-openmp --enable-debugmode CC=clang CXX=clang++ FC=flang sed -i "296s/-O2/-O0/g" Makefile diff --git a/package/cuda/11.4.0/install.sh b/package/cuda/11.4.0/install.sh index d5a7d0f7e579d013df73341bf9aba97744fb61c8..43928b2ea2ca5fd33d7ace97e2102d8ffde27297 100644 --- a/package/cuda/11.4.0/install.sh +++ b/package/cuda/11.4.0/install.sh @@ -1,11 +1,12 @@ #!/bin/bash set -x set -e -. ${DOWNLOAD_TOOL} -u https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda_11.4.0_470.42.01_linux_sbsa.run +cuda_ver='11.4.4_470.82.01' +. ${DOWNLOAD_TOOL} -u https://developer.download.nvidia.com/compute/cuda/11.4.4/local_installers/cuda_${cuda_ver}_linux_sbsa.run #禁用nouveau驱动 mv /etc/modprobe.d/disable-nouveau.conf /etc/modprobe.d/disable-nouveau.conf.bak echo -e 'blacklist nouveau\noptions nouveau modeset=0' >/etc/modprobe.d/disable-nouveau.conf cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img dracut -f /boot/initramfs-$(uname -r).img $(uname -r) -sh $JARVIS_DOWNLOAD/cuda_11.4.0_470.42.01_linux_sbsa.run +sh $JARVIS_DOWNLOAD/cuda_${cuda_ver}_linux_sbsa.run diff --git a/package/darshan/3.4/install.sh b/package/darshan/3.4/install.sh index 6dc2794aa1197347abe4d32f854f9a11ab63de81..01c54c17b7e0a6cac81ec5084e2d31c5995a1bef 100644 --- a/package/darshan/3.4/install.sh +++ b/package/darshan/3.4/install.sh @@ -5,7 +5,7 @@ set -x set -e version='3.4.0' -#yum install -y texlive* gnuplot perl-Pod-LaTeX perl-HTML-Parser zlib-devel ghostscript +. $CHECK_ROOT && yum install -y texlive* gnuplot perl-Pod-LaTeX perl-HTML-Parser zlib-devel ghostscript . ${DOWNLOAD_TOOL} -u https://ftp.mcs.anl.gov/pub/darshan/releases/darshan-${version}.tar.gz cd ${JARVIS_TMP} tar xvf ${JARVIS_DOWNLOAD}/darshan-${version}.tar.gz diff --git a/package/fftw/3.3.8/install.sh b/package/fftw/3.3.8/install.sh index e984238a045217640a745d7e30e374c04c092d6c..1e21de5e73378e2b65a9d041eecc0c8f9f7f0959 100644 --- a/package/fftw/3.3.8/install.sh +++ b/package/fftw/3.3.8/install.sh @@ -5,5 +5,5 @@ set -e cd ${JARVIS_TMP} tar -xvf ${JARVIS_DOWNLOAD}/fftw-3.3.8.tar.gz cd fftw-3.3.8 -./configure --prefix=$1 --enable-shared --enable-threads --enable-openmp --enable-mpi CC=mpicc #--enable-float --enable-fma --enable-neon +./configure --prefix=$1 --enable-shared --enable-threads --enable-openmp --enable-mpi #--enable-float --enable-fma --enable-neon make -j install diff --git a/package/hdf5/1.12.0/install.sh b/package/hdf5/1.12.0/install.sh index 7c899721f65c5fabcc680b8826e6913ac2a4e6bf..011e37e0da87e749576f577d2c2850ac0e60960f 100644 --- a/package/hdf5/1.12.0/install.sh +++ b/package/hdf5/1.12.0/install.sh @@ -2,7 +2,7 @@ set -x set -e hdf5_big_version='1.12' -hdf5_version='${hdf5_big_version}.0' +hdf5_version="${hdf5_big_version}.0" . ${DOWNLOAD_TOOL} -u https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-${hdf5_big_version}/hdf5-${hdf5_version}/src/hdf5-${hdf5_version}.tar.gz cd ${JARVIS_TMP} rm -rf hdf5-${hdf5_version} diff --git a/package/hmpi/1.1.1/install.sh b/package/hmpi/1.1.1/install.sh index c859770ddccaf652a0de9e347f6a42d3629365a5..3f1ba8f8149cbf159adf8e9e7dd63e69f9faf43d 100644 --- a/package/hmpi/1.1.1/install.sh +++ b/package/hmpi/1.1.1/install.sh @@ -5,7 +5,7 @@ set -e . ${DOWNLOAD_TOOL} -u https://github.com/kunpengcompute/xucg/archive/refs/tags/v1.1.1-huawei.zip -f xucg-1.1.1-huawei.zip . ${DOWNLOAD_TOOL} -u https://github.com/kunpengcompute/hmpi/archive/refs/tags/v1.1.1-huawei.zip -f hmpi-1.1.1-huawei.zip cd ${JARVIS_TMP} -yum install -y perl-Data-Dumper autoconf automake libtool binutils flex +. $CHECK_ROOT && yum install -y perl-Data-Dumper autoconf automake libtool binutils flex rm -rf hmpi-1.1.1-huawei hucx-1.1.1-huawei xucg-1.1.1-huawei unzip ${JARVIS_DOWNLOAD}/hucx-1.1.1-huawei.zip unzip ${JARVIS_DOWNLOAD}/xucg-1.1.1-huawei.zip diff --git a/package/hmpi/1.2.0/install.sh b/package/hmpi/1.2.0/install.sh index ec90065e17e99a1b5810ee661c6cfb12142159c6..6f891288e2131fec1964d99f881465f69b4ae6e9 100644 --- a/package/hmpi/1.2.0/install.sh +++ b/package/hmpi/1.2.0/install.sh @@ -6,7 +6,7 @@ hmpi_version='1.2.0' . ${DOWNLOAD_TOOL} -u https://github.com/kunpengcompute/xucg/archive/refs/tags/v${hmpi_version}-huawei.zip -f xucg-${hmpi_version}-huawei.zip . ${DOWNLOAD_TOOL} -u https://github.com/kunpengcompute/hmpi/archive/refs/tags/v${hmpi_version}-huawei.zip -f hmpi-${hmpi_version}-huawei.zip cd ${JARVIS_TMP} -yum install -y perl-Data-Dumper autoconf automake libtool binutils flex +. $CHECK_ROOT && yum install -y perl-Data-Dumper autoconf automake libtool binutils flex rm -rf hmpi-${hmpi_version}-huawei hucx-${hmpi_version}-huawei xucg-${hmpi_version}-huawei unzip ${JARVIS_DOWNLOAD}/hucx-${hmpi_version}-huawei.zip unzip ${JARVIS_DOWNLOAD}/xucg-${hmpi_version}-huawei.zip diff --git a/package/ncview/2.1.7/install.sh b/package/ncview/2.1.7/install.sh index 620d3c03f9adc632352d99eecee3f6e87495ee6f..ff0dbe7a4594216fbb935dfa154ad15623d6bdf2 100644 --- a/package/ncview/2.1.7/install.sh +++ b/package/ncview/2.1.7/install.sh @@ -1,7 +1,7 @@ #!/bin/bash # download from ftp://cirrus.ucsd.edu/pub/ncview/ncview-2.1.7.tar.gz -# yum install libX11 libX11-devel libXaw libXaw-devel libpng-devel libpng +. $CHECK_ROOT && yum install libX11 libX11-devel libXaw libXaw-devel libpng-devel libpng set -x set -e . ${DOWNLOAD_TOOL} -u ftp://cirrus.ucsd.edu/pub/ncview/ncview-2.1.7.tar.gz diff --git a/package/oneapi/2021.1.0/install.sh b/package/oneapi/2021.1.0/install.sh index 631fb2f94a7cfbbc73072c89d329376bd78aec9e..ba89ee4a6b7e53bc0e96b66632371a0668d02354 100644 --- a/package/oneapi/2021.1.0/install.sh +++ b/package/oneapi/2021.1.0/install.sh @@ -21,4 +21,4 @@ cd .. cd l_HPCKit_p_2021.1.0.2684_offline ./install.sh --silent --eula accept --install-dir /opt/intel/oneapi -echo -e "\033[0;32m[Info]\033[0m:Please use 'source /opt/intel/oneapi/setenv.sh' to set up your development environment." +echo -e "\033[0;32m[Info]\033[0m:Please use 'source /opt/intel/oneapi/setvars.sh' to set up your development environment." diff --git a/package/openmpi/4.0.1/gpu/install.sh b/package/openmpi/4.0.1/gpu/install.sh index f70e346d0112ac3d146c97027927e4b5de8370cd..7797988d0deaf78cb3dcd1fa5d9004ea77348ea7 100644 --- a/package/openmpi/4.0.1/gpu/install.sh +++ b/package/openmpi/4.0.1/gpu/install.sh @@ -2,7 +2,7 @@ set -x set -e sudo yum groupinstall 'Development Tools' -sudo yum install dkms rpm-build make check check-devel subunit subunit-devel +sudo . $CHECK_ROOT && yum install dkms rpm-build make check check-devel subunit subunit-devel cd ${JARVIS_TMP} ucx_version='1.12.1' gdr_ver='2.3' diff --git a/package/openmpi/4.1.2/gpu/install.sh b/package/openmpi/4.1.2/gpu/install.sh index 38d2f4cbbb4f3b49322d323c79d14ea30edefd16..110b451079d13bec597f61da56a26c960051c6eb 100644 --- a/package/openmpi/4.1.2/gpu/install.sh +++ b/package/openmpi/4.1.2/gpu/install.sh @@ -2,7 +2,7 @@ set -x set -e sudo yum groupinstall 'Development Tools' -sudo yum install dkms rpm-build make check check-devel subunit subunit-devel +sudo . $CHECK_ROOT && yum install dkms rpm-build make check check-devel subunit subunit-devel cd ${JARVIS_TMP} ucx_version='1.12.1' gdr_ver='2.3' diff --git a/package/parmetis/4.0.3/install.sh b/package/parmetis/4.0.3/install.sh index f6da60a66a560869898384431b963e5c35b4f595..8c0073eba374790d11978d6a1005d19e0d461bbb 100644 --- a/package/parmetis/4.0.3/install.sh +++ b/package/parmetis/4.0.3/install.sh @@ -1,7 +1,7 @@ #!/bin/bash set -x set -e -yum install libstdc++-devel.aarch64 bison flex cmake -y +. $CHECK_ROOT && yum install libstdc++-devel.aarch64 bison flex cmake -y . ${DOWNLOAD_TOOL} -u http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis/parmetis-4.0.3.tar.gz cd ${JARVIS_TMP} rm -rf parmetis-4.0.3 diff --git a/package/picard/2.27.0/install.sh b/package/picard/2.27.0/install.sh index 6c4d0e5e191240f17acf61b8873641ac3c38380a..f581e4331275a0ad46e509b2acce6c0d1de11a21 100644 --- a/package/picard/2.27.0/install.sh +++ b/package/picard/2.27.0/install.sh @@ -1,5 +1,5 @@ #!/bin/bash -#yum install -y git java-1.8.0-openjdk +#. $CHECK_ROOT && yum install -y git java-1.8.0-openjdk set -x set -e cd ${JARVIS_TMP} diff --git a/package/python3/3.7.10/install.sh b/package/python3/3.7.10/install.sh index 38b87d0acefd46a429d0628b77cdb7d7a21080f7..eb7affe570fd701beb4050672bd4459acd5eeeb4 100644 --- a/package/python3/3.7.10/install.sh +++ b/package/python3/3.7.10/install.sh @@ -3,7 +3,7 @@ set -x set -e . ${DOWNLOAD_TOOL} -u https://repo.huaweicloud.com/python/3.7.10/Python-3.7.10.tgz cd ${JARVIS_TMP} -#yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel +. $CHECK_ROOT && yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel tar -zxvf ${JARVIS_DOWNLOAD}/Python-3.7.10.tgz cd Python-3.7.10 ./configure --prefix=$1 diff --git a/package/relion/3.1.2/install.sh b/package/relion/3.1.2/install.sh index cc4da6662f6ebfa5ef40ca3c1ee1a4a64ce343a8..fba7d1e2a41380462eb18e8c0fff45d909d198e5 100644 --- a/package/relion/3.1.2/install.sh +++ b/package/relion/3.1.2/install.sh @@ -9,7 +9,7 @@ rm -rf relion-3.1.2 tar -xvf ${JARVIS_DOWNLOAD}/relion-3.1.2.tar.gz cd relion-3.1.2 mkdir build && cd build -#yum install -y libtiff-* fltk* fltk-devel* +#. $CHECK_ROOT && yum install -y libtiff-* fltk* fltk-devel* #yum -y install xorg-x11-xauth #export CC=clang CXX=clang++ FC=flang cmake -DCUDA=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=release -DCMAKE_INSTALL_PREFIX=$1 .. diff --git a/package/scotch/7.0.1/install.sh b/package/scotch/7.0.1/install.sh index a494f6b5dc1dfdeaacf9ee7ac5edd2894cfad3d1..f61326f15821f34cfa0a701692672d823d5f57ec 100644 --- a/package/scotch/7.0.1/install.sh +++ b/package/scotch/7.0.1/install.sh @@ -1,7 +1,7 @@ #!/bin/bash set -x set -e -yum install libstdc++-devel.aarch64 bison flex +. $CHECK_ROOT && yum install libstdc++-devel.aarch64 bison flex . ${DOWNLOAD_TOOL} -u https://gitlab.inria.fr/scotch/scotch/-/archive/v7.0.1/scotch-v7.0.1.tar.gz cd ${JARVIS_TMP} rm -rf scotch-v7.0.1 diff --git a/package/singularity/3.8.4/install.sh b/package/singularity/3.8.4/install.sh index 3382f0c052aecb630b4eab4c973172e1f14c7f3c..6559ee1dac250a1f62a14972a5e80a2a6cbd58cd 100644 --- a/package/singularity/3.8.4/install.sh +++ b/package/singularity/3.8.4/install.sh @@ -3,7 +3,7 @@ set -x set -e cd ${JARVIS_TMP} export PATH=/usr/local/go/bin:$PATH -#sudo yum install -y libseccomp-devel squashfs-tools cryptsetup +. $CHECK_ROOT && yum install -y libseccomp-devel squashfs-tools cryptsetup file_noext='singularity-ce-3.8.4' file_name="${file_noext}.tar.gz" . ${DOWNLOAD_TOOL} -u https://github.com/sylabs/singularity/releases/download/v3.8.4/${file_name} diff --git a/package/singularity/3.9.6/install.sh b/package/singularity/3.9.6/install.sh index d7bd2760b1ef68bcea0a5df686171004715d4c7d..4a5ad7e5f9baca4f2ed7aa31b665d0c3fb18b082 100755 --- a/package/singularity/3.9.6/install.sh +++ b/package/singularity/3.9.6/install.sh @@ -3,7 +3,7 @@ set -x set -e cd ${JARVIS_TMP} export PATH=/usr/local/go/bin:$PATH -#sudo yum install -y libseccomp-devel squashfs-tools cryptsetup +. $CHECK_ROOT && yum install -y libseccomp-devel squashfs-tools cryptsetup file_noext='singularity-ce-3.9.6' file_name="${file_noext}.tar.gz" . ${DOWNLOAD_TOOL} -u https://github.com/sylabs/singularity/releases/download/v3.9.6/${file_name} diff --git a/package/singularity/3.9.9/install.sh b/package/singularity/3.9.9/install.sh index 87079272675a498b29219fb347e53fc10a8c18d7..eef5569feea9e9557e14981a3782b3bf8e13f3d7 100644 --- a/package/singularity/3.9.9/install.sh +++ b/package/singularity/3.9.9/install.sh @@ -3,7 +3,6 @@ set -x set -e cd ${JARVIS_TMP} export PATH=/usr/local/go/bin:$PATH -#sudo yum install -y libseccomp-devel squashfs-tools cryptsetup file_noext='singularity-ce-3.9.9' file_name="${file_noext}.tar.gz" . ${DOWNLOAD_TOOL} -u https://github.com/sylabs/singularity/releases/download/v3.9.9/${file_name} diff --git a/src/analysisService.py b/src/analysisService.py index 1c769c53d93db01e0e27ce1396e982eb63b40be7..b88495bd53dd9a8ab06c4d0dbd6229e329f4bc31 100644 --- a/src/analysisService.py +++ b/src/analysisService.py @@ -12,6 +12,7 @@ from perfService import PerfService from testService import TestService from benchService import BenchmarkService from containerService import ContainerService +from loopService import LoopService class AnalysisService: def __init__(self): @@ -25,6 +26,7 @@ class AnalysisService: self.jperf = PerfService() self.jbenchmark = BenchmarkService() self.jcontainer = ContainerService() + self.jloop = LoopService() self.jtest = TestService() def get_machine_info(self): @@ -92,3 +94,6 @@ class AnalysisService: def gen_def(self, image): self.jcontainer.gen_def(image) + + def gen_simucode(self): + self.jloop.get_simulate_code() diff --git a/src/dataService.py b/src/dataService.py index b4522c3dece29e704dde68442f89018e114d17c1..ef7c27d69a5338b7694adbd4d0bd9d2c5b194052 100644 --- a/src/dataService.py +++ b/src/dataService.py @@ -35,15 +35,19 @@ class DataService(object,metaclass=Singleton): clean_cmd = '' run_cmd = {} batch_cmd = '' + loop_cmd = '' #Other Info config_file = 'data.config' meta_file = '.meta' root_path = os.getcwd() download_info = '' #perf info + kperf_para = '' perf_para = '' nsys_para = '' ncu_para = '' + hpccollect_para = '' + hpcreport_para = '' def get_abspath(self, relpath): return os.path.join(DataService.root_path, relpath) @@ -70,16 +74,20 @@ class DataService(object,metaclass=Singleton): def is_empty(self, content): return len(content) == 0 or content.isspace() or content == '\n' - def read_rows(self, rows, start_row): + def read_rows(self, rows, start_row, needs_strip=True): data = '' - row = rows[start_row].strip() + row = rows[start_row] + if needs_strip: + row = row.strip() while not row.startswith('['): if not self.is_empty(row): data += row + '\n' start_row += 1 if start_row == len(rows): break - row = rows[start_row].strip() + row = rows[start_row] + if needs_strip: + row = row.strip() return start_row, data def read_rows_kv(self, rows, start_row): @@ -102,9 +110,12 @@ class DataService(object,metaclass=Singleton): DataService.case_dir = data['case_dir'] def set_perf_info(self, data): + DataService.kperf_para = data['kperf'] if 'kperf' in data else '' DataService.perf_para = data['perf'] if 'perf' in data else '' DataService.nsys_para = data['nsys'] if 'nsys' in data else '' DataService.ncu_para = data['ncu'] if 'ncu' in data else '' + DataService.hpccollect_para = data['hpccollect'] if 'hpccollect' in data else '' + DataService.hpcreport_para = data['hpcreport'] if 'hpcreport' in data else '' def split_two_part(self, data): split_list = data.split(' ', 1) @@ -141,6 +152,8 @@ class DataService(object,metaclass=Singleton): rowIndex, DataService.run_cmd = self.read_rows_kv(rows, rowIndex+1) elif row == '[BATCH]': rowIndex, DataService.batch_cmd = self.read_rows(rows, rowIndex+1) + elif row == '[LOOP]': + rowIndex, DataService.loop_cmd = self.read_rows(rows, rowIndex+1, False) elif row == '[PERF]': rowIndex, perf_data = self.read_rows_kv(rows, rowIndex+1) self.set_perf_info(perf_data) diff --git a/src/installService.py b/src/installService.py index ab25f89eb1b95cb3f1cc11b1f5ff549599302c07..a76ca0b25cd8b005546778e760504cd7c2169942 100644 --- a/src/installService.py +++ b/src/installService.py @@ -210,7 +210,7 @@ class InstallService: file_list = [d for d in glob(abs_path+'/**', recursive=True)] return file_list - def get_module_file_content(self, install_path, sversion): + def get_module_file_content(self, install_path, sname, sversion): module_file_content = '' file_list = self.get_files(install_path) bins_dir_type = ["bin"] @@ -242,6 +242,7 @@ class InstallService: set prefix {install_path} set version {sversion} +setenv {sname.upper()}_PATH {install_path} {bins_str} {libs_str} {incs_str} @@ -270,7 +271,7 @@ set version {sversion} cname = env_info['cname'] cmversion = env_info['cmversion'] software_str = sname + self.get_main_version(sversion) - module_file_content = self.get_module_file_content(install_path, sversion) + module_file_content = self.get_module_file_content(install_path, sname, sversion) if not self.is_installed(install_path): return # if install_path is empty, The module file should not generated. @@ -440,4 +441,4 @@ chmod +x {depend_file} content = content.replace(search_old_path.group(1), self.ROOT) self.tool.write_file(file, content) print("update successfully.") - + \ No newline at end of file diff --git a/src/jarvis.py b/src/jarvis.py index 6b90d049d076762eb4af3882f6a734f0b9c347ec..fb7105091cb27f3f650c0132c7d847bb7490d3c0 100644 --- a/src/jarvis.py +++ b/src/jarvis.py @@ -15,6 +15,7 @@ class Jarvis: parser.add_argument("-use","--use", help="Switch config file...", nargs=1) parser.add_argument("-i","--info", help=f"get machine info", action="store_true") parser.add_argument("-l","--list", help=f"get installed package info", action="store_true") + parser.add_argument("-loop","--loop", help=f"get loop simulation code", action="store_true") #accept software_name/version GCC/GCC+MPI/CLANG/CLANG+MPI parser.add_argument("-install","--install", help=f"install dependency", nargs=2) #remove @@ -31,6 +32,8 @@ class Jarvis: parser.add_argument("-kp","--kperf", help=f"auto kperf {DataService.app_name}", action="store_true") # GPU perf parser.add_argument("-gp","--gpuperf", help="GPU perf...", action="store_true") + # hpctool perf + parser.add_argument("-hpctool","--hpctool", help="hpctool perf...", action="store_true") # NCU perf parser.add_argument("-ncu","--ncuperf", help="NCU perf...", nargs=1) @@ -48,6 +51,8 @@ class Jarvis: parser.add_argument("-bench","--benchmark", help="start benchmark test...", nargs=1) # start test parser.add_argument("-t","--test", help="start Jarvis test...", action="store_true") + # start Roce + parser.add_argument("-R","--roce", help="start roce run...", nargs=2) # update modulefile path when hpcrunner is moved parser.add_argument("-u","--update", help="start update jarvis...", action="store_true") self.args = parser.parse_args() @@ -101,6 +106,9 @@ class Jarvis: if self.args.gpuperf: self.analysis.gpu_perf() + if self.args.hpctool: + self.analysis.hpctool_perf() + if self.args.ncuperf: self.analysis.ncu_perf(self.args.ncuperf[0]) @@ -121,9 +129,15 @@ class Jarvis: if self.args.test: self.analysis.test() + + if self.args.roce: + self.analysis.get_roceinfo(self.args.roce[0],self.args.roce[1]) if self.args.update: self.analysis.update() + if self.args.loop: + self.analysis.gen_simucode() + if __name__ == '__main__': Jarvis().main() diff --git a/src/loopService.py b/src/loopService.py new file mode 100644 index 0000000000000000000000000000000000000000..d154ec0269a0716ecd39c330901ca5a9295ee827 --- /dev/null +++ b/src/loopService.py @@ -0,0 +1,143 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# 本程序自动根据循环内变量生成模拟数据和可直接运行的代码 +# 优点: +# 1.极速调优,可添加向量化和并行化支持 +# 2.自动性能评测,性能优劣一目了然 +# 3.快速查看不同编译选项下的汇编代码,辅助调优 +# 4.快速调试,直观了解程序逻辑 +# 5.快速校验性能是否影响精度问题 +# 缺点:数据规模需要自己调节 +# 使用步骤: +# 1.将循环粘贴到LOOP处 +# 2.修改代码以编译、运行,添加正确性验证代码(只需添加改变值的数组的初始化) +# 3.修改数据规模让运行总耗时在1000ms以上 +# 4.优化代码,使优化效果稳定在20%以上 +# 5.回合循环,查看加速效果 +import time +import os +import re +from toolService import ToolService +from dataService import DataService + +MARK_FOR_KEYWORD = '!' +VAR_REG = '[_a-zA-Z]\w*' +ITER_NUM = 1000 + +class LoopService: + def __init__(self): + self.tool = ToolService() + self.data = DataService() + + def remove_mk(self, content): + #注释的处理 + content_line = content.split('\n') + nomk_content = '' + for line in content_line: + exclamation_index = line.find(MARK_FOR_KEYWORD) + if exclamation_index >= 0: + line = line[0:exclamation_index] + if line: + nomk_content += line + '\n' + return nomk_content + + def remove_line_break(self, content): + return content.replace('&\n', '').replace('& \n', '').replace('&', '') + + def get_dim_str(self, dim_list, level = 1): + if len(dim_list) > 0: + dimensions = ','.join(['nnxx']*level) + dim_str = ','.join(dim_list) + return f' integer, dimension ({dimensions}) ::{dim_str}\n' + return '' + + def get_simulate_code(self): + loop_code = DataService.loop_cmd + print(loop_code) + if loop_code.strip() == '': + print("No Loop code detected! please add your code under [LOOP] section.") + return + filename = "simulated.F90" + content = self.remove_mk(loop_code) + content = self.remove_line_break(content) + integer_list = [] + dim1_list = [] + dim2_list = [] + dim3_list = [] + dim4_list = [] + init_list = [] + fortran_keywords = ['THEN','SELECT','PROGRAM','PRINT','STOP','END','ENDDO','WRITE','INTEGER','REAL','COMPLEX','CHARACTER','LOGICAL','READ','FORMAT','IMPLICIT','PARAMETER','DATA','EQUIVALENCE','TYPE','PAUSE','CONTINUE','CYCLE','EXIT','IF','SELECT','DO','ALLOCATE','DEALLOCATE','WHERE','FORALL','SUBROUTINE','CALL','RETURN','FUNCTION','COMMON','BLOCKDATA','SAVE','INTERFACE','CONTAINS','MODULE','USE','PUBLIC','PRIVATE','ENTRY','OPEN','INQUIRE','CLOSE','NAMELIST','POINTER','NULLFY','REWIND','BACKSPACE','ENDFILE','_r8'] + # searching all variable + all_words = re.findall(VAR_REG, content,re.M) + variable_list = [] + for word in all_words: + if word.upper() in fortran_keywords: + continue + if word in variable_list: + continue + variable_list.append(word) + # start category + for variable in variable_list: + init_list.append(f" {variable}=1") + ismatch = re.search("\W"+variable+r' *(\([^\)]*\))', content, re.M) + if not ismatch: + integer_list.append(variable) + continue + # arrays + paras = ismatch.groups(1)[0] + if paras.count(',') == 0: + dim1_list.append(variable) + elif paras.count(',') == 1: + dim2_list.append(variable) + elif paras.count(',') == 2: + dim3_list.append(variable) + elif paras.count(',') == 3: + dim4_list.append(variable) + + array_define = "" + array_define += self.get_dim_str(dim1_list, 1) + array_define += self.get_dim_str(dim2_list, 2) + array_define += self.get_dim_str(dim3_list, 3) + array_define += self.get_dim_str(dim4_list, 4) + init_str = '\n'.join(init_list) + amplifier = 100 + vector_template = f''' +program SimulateExample + implicit none + integer :: t_start,t_stop,time1,time2, ii, flag + + integer {','.join(integer_list)} + integer,parameter:: nnxx={ITER_NUM} + {array_define} + flag = 0 + {init_str} + write(*,*) '********The optimize code START******' + call system_clock(t_start) + do ii=1, {amplifier} + {loop_code} + end do + call system_clock(t_stop) + time1 = t_stop-t_start + write(*,*) '********The optimize loop time used(ms)******',time1 + write(*,*) '********The origin code START******' + call system_clock(t_start) + do ii=1, {amplifier} + {loop_code} + end do + call system_clock(t_stop) + time2 = t_stop-t_start + write(*,*) ''********The origin loop time used(ms)'********',time2 + write(*,*) ' ACC:', (time2-time1)*100.0/time2,'%' + write(*,*) 'Check if two result is consistent, Please add your code here:' + loop_i: {loop_code.strip()} loop_i + if(flag .eq. 0) then + write(*,*) 'Correct result' + else + write(*,*) 'Wrong result' + end if +end program SimulateExample + ''' + self.tool.write_file(filename,vector_template) + print("**********Successfully simulated************") + print("compile and run: flang -O3 -fopenmp -g -ffast-math simulated.F90 && ./a.out") + print("reassamblely: objdump -S ./a.out > assemble.txt") diff --git a/src/perfService.py b/src/perfService.py index 4a7c0d03d34cda5fe256634f20d5020f23aac614..fd0e349253bcedae164f5759d8d012ec2cd35191 100644 --- a/src/perfService.py +++ b/src/perfService.py @@ -3,6 +3,8 @@ import platform import sys import re +import os +from glob import glob from dataService import DataService from executeService import ExecuteService @@ -13,6 +15,7 @@ class PerfService: self.hpc_data = DataService() self.exe = ExecuteService() self.tool = ToolService() + self.ROOT = os.getcwd() self.isARM = platform.machine() == 'aarch64' def get_pid(self): @@ -33,10 +36,26 @@ class PerfService: pid = self.get_pid() #start perf && analysis perf_cmd = f''' +yum install -y perf perf record {DataService.perf_para} -a -g -p {pid} perf report -i ./perf.data -F period,sample,overhead,symbol,dso,comm -s overhead --percent-limit 0.1% --stdio ''' self.exe.exec_raw(perf_cmd) + + def kperf(self): + print(f"start kperf {DataService.app_name}") + python3_libs_path = './software/libs/python3/' + #get pid + pid = self.get_pid() + kperf_script = os.path.join(python3_libs_path,'kperf', 'src/kperf.py') + kperf_log = '> kperf.data.txt' + #start kperf + kperf_cmd = f''' +chmod +x {kperf_script} +python3 {kperf_script} --rawdata --hotfunc --topdown --cache --tlb --imix {DataService.kperf_para} --duration 1 --interval 15 --pid {pid} {kperf_log} +''' + self.exe.exec_raw(kperf_cmd) + print("kperf.data.txt is generated") def get_arch(self): arch = 'arm' @@ -73,3 +92,67 @@ ncu --export ncu-{self.get_arch()}-{self.get_cur_time()} --import-source=yes --s ''' self.exe.exec_raw(ncu_cmd) + def compared_version(self, ver1, ver2): + ''' + 传入不带英文的版本号,特殊情况:"10.12.2.6.5">"10.12.2.6" + :param ver1: 版本号1 + :param ver2: 版本号2 + :return: ver1< = >ver2返回-1/0/1 + ''' + list1 = str(ver1).split(".") + list2 = str(ver2).split(".") + # 循环次数为短的列表的len + for i in range(len(list1)) if len(list1) < len(list2) else range(len(list2)): + if int(list1[i]) == int(list2[i]): + pass + elif int(list1[i]) < int(list2[i]): + return -1 + else: + return 1 + # 循环结束,哪个列表长哪个版本号高 + if len(list1) == len(list2): + return 0 + elif len(list1) < len(list2): + return -1 + else: + return 1 + + def get_maximum_version(self, version_path): + file_list = [d for d in glob(version_path+'/**', recursive=False)] + max_version = '0.0' + for file in file_list: + if os.path.isdir(file): + version = os.path.basename(file) + if self.compared_version(max_version, version): + max_version = version + return max_version + + def hpctool_perf(self): + print(f"start hpctool perf") + output_file = f'output-{self.get_cur_time()}' + hpctool_path = os.path.join(self.ROOT, 'software/utils/hpctool') + max_version = self.get_maximum_version(hpctool_path) + #collect + hpccollect_path = f'$JARVIS_UTILS/hpctool/{max_version}/bin/hpccollect' + hpccollect_para = f' -l detail -o ./{output_file}' + if DataService.hpccollect_para != '': + hpccollect_para = DataService.hpccollect_para + hpccollect_para + collect_cmd = self.hpc_data.get_run(f'{hpccollect_path} {hpccollect_para}') + #analysis + hpcreport_path = f'$JARVIS_UTILS/hpctool/{max_version}/bin/hpcreport' + if 'mpi' not in collect_cmd: + hpcreport_para = f'-i ./{output_file}.v{max_version}.hpcstat hotspots -g parallel-region function' + else: + hpcreport_para = f'-i ./{output_file}.v{max_version}.hpcstat mpi-wait -g function' + if DataService.hpcreport_para != '': + hpcreport_para = DataService.hpcreport_para + report_cmd = f'{hpcreport_path} {hpcreport_para}' + collect_and_report_cmd = f''' +{self.hpc_data.get_env()} +./jarvis -install hpctool/{max_version} any +echo "1">/proc/sys/kernel/perf_event_paranoid +cd {DataService.case_dir} +{collect_cmd} +{report_cmd} +''' + self.exe.exec_raw(collect_and_report_cmd) \ No newline at end of file diff --git a/src/runService.py b/src/runService.py index 13fcd38eaee4910f8c935c12d40b735c34cf9244..ade3d417b6e4a144ed4ac2231d1e461c91cff9a0 100644 --- a/src/runService.py +++ b/src/runService.py @@ -38,6 +38,7 @@ class RunService: batch_file_path = os.path.join(self.ROOT, batch_file) print(f"start batch run {DataService.app_name}") batch_content = f''' +{self.hpc_data.get_env()} cd {DataService.case_dir} {DataService.batch_cmd} ''' diff --git a/templates/amber/20/data.amber.arm.gpu.config b/templates/amber/20/data.amber.arm.gpu.config index 5b6c0ed29ae68d1bfff9b740c262d2c252fd12bc..9ce66695a7b23b174c329e068da66d102743a767 100644 --- a/templates/amber/20/data.amber.arm.gpu.config +++ b/templates/amber/20/data.amber.arm.gpu.config @@ -2,6 +2,8 @@ 1.1.1.1 [DEPENDENCY] +yum install -y flex* bison* zlib* libzip* boost* bzip2* + ./jarvis -install kgcc/9.3.1 com module purge module use ./software/modulefiles @@ -9,6 +11,12 @@ module load kgcc9/9.3.1 module load openmpi4/4.1.2 #test if mpi is normal ./jarvis -bench mpi +tar -jxvf $JARVIS_DOWNLOAD/A20.tar.bz2 +tar -jxvf $JARVIS_DOWNLOAD/AmberTools21.tar.bz2 +tar -xzvf $JARVIS_DOWNLOAD/Amber20_Benchmark_Suite.tar.gz +cd $JARVIS_ROOT/PME/Cellulose_production_NPT_4fs/ +cp ../Coordinates/Cellulose.inpcrd inpcrd +cp ../Topologies/Cellulose.prmtop prmtop [ENV] # add gcc ompi @@ -29,14 +37,14 @@ export LIBRARY_PATH=$CUDA_HOME/lib64:$LIBRARY_PATH app_name = Amber build_dir = $JARVIS_ROOT/amber20_src/build/ binary_dir = $JARVIS_ROOT/amber20/bin/ -case_dir = $JARVIS_ROOT/workloads/Amber/Cellulose/ +case_dir = $JARVIS_ROOT/PME/Cellulose_production_NPT_4fs/ [BUILD] sed -i 's/-DMPI=FALSE/-DMPI=TRUE/g' run_cmake sed -i 's/-DCUDA=FALSE/-DCUDA=TRUE/g' run_cmake sed -i 's/-DINSTALL_TESTS=TRUE/-DINSTALL_TESTS=FALSE/g' run_cmake sed -i 's/-DDOWNLOAD_MINICONDA=TRUE/-DDOWNLOAD_MINICONDA=FALSE/g' run_cmake -sed -i 's/-DMINICONDA_USE_PY3=TRUE/-DMINICONDA_USE_PY3=FALSE/g' run_cmake +sed -i 's/-DMINICONDA_USE_PY3=TRUE/-DMINICONDA_USE_PY3=FALSE -DBUILD_PYTHON=FALSE/g' run_cmake ./run_cmake make -j 96 install