#!/bin/bash HOST=`hostname` path_mri=$PWD; path_bin=$path_mri/bin; path_build=$path_mri/build path_src=$path_mri/src; path_data=$path_mri/data # Should be same as in cmake config in $path_src mri_bin="run-mri-phase-encoding" # Default values yes="yes"; no="no" echo base dir path: $path_mri # Check directory structure if [[ ! -d $path_src ]]; then echo ================ !ERROR! ================= echo No source folder $path_src echo ================ !ERROR! ================= exit 1 fi force_new_build=$no if [[ -a $path_build ]]; then echo Found build folder. else echo Creating build folder... mkdir build force_new_build=$yes fi if [[ -a $path_bin ]]; then echo Found bin folder. else echo Creating build folder... mkdir bin fi ############################################################################# # Compile settings ############################################################################# echo Cleaning bin rm -r $path_bin/* >/dev/null 2>&1 # Select OMPI_CXXFLAGS #debug #flags_O2="-std=c++11" flags_O2="-O2 -Wall -std=c++11" #flags_O2="-O2 -Wall -std=c++11 -stdlib=libc++" #flags_O2="-O2 -ftemplate-depth-30 -Wall -std=c++11" flags_debug="-ftemplate-depth-30 -Wall -std=c++11 -stdlib=libc++" #flags_debug_gcc="-ftemplate-depth-30 -std=c++11 -da -Q" flags_debug_gcc="-ftemplate-depth-30 -std=c++11 -g -O0" 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++" 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" export OMPI_CC=gcc export OMPI_CXX=g++ export OMPI_CXXFLAGS=$flags_O2 #export OMPI_CXXFLAGS=$flags_with_google ############################################################################# # Build ############################################################################# function BuildMRI { echo "Building MRI..." local path_tmp=`pwd` cd $path_build flag_cmake= echo $PWD ls $path_bin echo "Doing new build.." # echo CC=mpicc CXX=mpic++ VERBOSE=1 cmake $path_mri -DCMAKE_INSTALL_PREFIX="$path_bin" $flag_cmake # CC=mpicc CXX=mpic++ VERBOSE=1 cmake $path_mri \ # -DCMAKE_INSTALL_PREFIX="$path_bin" \ # $flag_cmake # make -j4 # make install # g++ $path_src/main.cc -o $mri_bin 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 cp $mri_bin $path_bin cd $path_tmp } # end of function BuildMRI BuildMRI ############################################################################# # Run ############################################################################# echo "Executing $mri_bin on host -> $HOST <-" MPI_options= #MPI_options="--bind-to-core" MPI_size=2 cd $path_bin time mpirun -np $MPI_size $MPI_options ./$mri_bin