go.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/bash
  2. HOST=`hostname`
  3. path_mri=$PWD; path_bin=$path_mri/bin; path_build=$path_mri/build
  4. path_src=$path_mri/src; path_data=$path_mri/data
  5. # Should be same as in cmake config in $path_src
  6. mri_bin="run-mri-phase-encoding"
  7. # Default values
  8. yes="yes"; no="no"
  9. echo base dir path: $path_mri
  10. # Check directory structure
  11. if [[ ! -d $path_src ]]; then
  12. echo ================ !ERROR! =================
  13. echo No source folder $path_src
  14. echo ================ !ERROR! =================
  15. exit 1
  16. fi
  17. force_new_build=$no
  18. if [[ -a $path_build ]]; then
  19. echo Found build folder.
  20. else
  21. echo Creating build folder...
  22. mkdir build
  23. force_new_build=$yes
  24. fi
  25. if [[ -a $path_bin ]]; then
  26. echo Found bin folder.
  27. else
  28. echo Creating build folder...
  29. mkdir bin
  30. fi
  31. #############################################################################
  32. # Compile settings
  33. #############################################################################
  34. echo Cleaning bin
  35. rm -r $path_bin/* >/dev/null 2>&1
  36. # Select OMPI_CXXFLAGS
  37. #debug
  38. #flags_O2="-std=c++11"
  39. flags_O2="-O2 -Wall -std=c++11"
  40. #flags_O2="-O2 -Wall -std=c++11 -stdlib=libc++"
  41. #flags_O2="-O2 -ftemplate-depth-30 -Wall -std=c++11"
  42. flags_debug="-ftemplate-depth-30 -Wall -std=c++11 -stdlib=libc++"
  43. #flags_debug_gcc="-ftemplate-depth-30 -std=c++11 -da -Q"
  44. flags_debug_gcc="-ftemplate-depth-30 -std=c++11 -g -O0"
  45. flags_O3="-O3 -ffast-math -ftemplate-depth-30 -march=native -mtune=native -mfpmath=both -malign-double -mstackrealign -ftree-vectorize -msse2 -ftree-vectorizer-verbose=5 -Wall -std=c++11 -stdlib=libc++"
  46. flags_with_google=" -Ofast -std=c++11 -lm -lrt /usr/lib/libtcmalloc_minimal.so.4 -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -march=native -mtune=native -msse4.2"
  47. export OMPI_CC=gcc
  48. export OMPI_CXX=g++
  49. export OMPI_CXXFLAGS=$flags_O2
  50. #export OMPI_CXXFLAGS=$flags_with_google
  51. #############################################################################
  52. # Build
  53. #############################################################################
  54. function BuildMRI {
  55. echo "Building MRI..."
  56. local path_tmp=`pwd`
  57. cd $path_build
  58. flag_cmake=
  59. echo $PWD
  60. ls $path_bin
  61. echo "Doing new build.."
  62. # echo CC=mpicc CXX=mpic++ VERBOSE=1 cmake $path_mri -DCMAKE_INSTALL_PREFIX="$path_bin" $flag_cmake
  63. # CC=mpicc CXX=mpic++ VERBOSE=1 cmake $path_mri \
  64. # -DCMAKE_INSTALL_PREFIX="$path_bin" \
  65. # $flag_cmake
  66. # make -j4
  67. # make install
  68. # g++ $path_src/main.cc -o $mri_bin
  69. OMPI_CXXFLAGS=$flags_O2 mpic++ -o $mri_bin $path_src/main.cc $path_src/jade.cc $path_src/generator-rf.cc $path_src/lock-in.cc
  70. cp $mri_bin $path_bin
  71. cd $path_tmp
  72. } # end of function BuildMRI
  73. BuildMRI
  74. #############################################################################
  75. # Run
  76. #############################################################################
  77. echo "Executing $mri_bin on host -> $HOST <-"
  78. MPI_options=
  79. #MPI_options="--bind-to-core"
  80. MPI_size=2
  81. cd $path_bin
  82. time mpirun -np $MPI_size $MPI_options ./$mri_bin