Sunday, July 28, 2019

Compiling GCC 10

NOTE:
- Some applications require C++11, this is only supported on GCC 4.8 or newer
- intel 2018 support gcc versions 4.3 - 6.3
https://software.intel.com/en-us/articles/intel-c-compiler-180-for-linux-release-notes-for-intel-parallel-studio-xe-2018

1. Download:
https://gcc.gnu.org/releases.html

check all availabe versions GCC :
svn ls svn://gcc.gnu.org/svn/gcc/tags | grep gcc | grep release
#or http://ftp.tsukuba.wide.ad.jp/software/gcc/releases

wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-10.3.0/gcc-10.3.0.tar.gz
tar xvf gcc-10.3.0.tar.gz

2. Install
a. download prerequisites:
cd gcc-10.3
./contrib/download_prerequisites

b. Configure:
note: compile GCC out source-dir, to avoid modifying source code when compiling get fail


## USC1: (eagle)
## (if any) error: Couldn't resolve host 'github.com' while ....
git config --global --unset http.proxy    
git config --global --unset https.proxy 
####
git clone -b releases/gcc-11.2.0 https://github.com/gcc-mirror/gcc gcc-11.2.0
cd gcc-11.2
git checkout releases/gcc-11.2
./contrib/download_prerequisites
mkdir build && cd build
module load compiler/gcc-10.3         # to avoid:  uint64_t or int64_t not found 
../configure --enable-languages=c,c++,objc,obj-c++,fortran \
--enable-checking=release --enable-shared --disable-multilib --with-system-zlib \
--prefix=/uhome/p001cao/local/app/compiler/gcc-11.2
make    # note use -j to know what error

## USC 2
--prefix=/home1/p001cao/local/app/compiler/gcc-10.3
## CAN
--prefix=/home/thang/local/app/compiler/gcc-10.3
## CAN_GPU
--prefix=/home/thang/local/app/compiler/gcc-10.3
#configure: error: uint64_t or int64_t not found       --> need at least gcc-4.5
module load compiler/gcc-7.4

https://stackoverflow.com/questions/7412548/error-gnu-stubs-32-h-no-such-file-or-directory-while-compiling-nachos-source

c. Installing:
make -j 8
make install

check: g++ -v

3.Make module file 
at directory: /uhome/p001cao/local/share/lmodfiles/GCC
create file "gcc-10.3"
# for Tcl script use only set topdir /home1/p001cao/local/app/compiler/gcc-10.3
set version gcc-10.3.0
setenv gcc $topdir

# gcc compiler

prepend-path    PATH                    $topdir/bin
prepend-path    INCLUDE         $topdir/include
prepend-path    LD_LIBRARY_PATH         $topdir/lib
prepend-path    LD_LIBRARY_PATH         $topdir/lib64
prepend-path    LD_LIBRARY_PATH         $topdir/libexec


ref:
https://m.blog.naver.com/PostView.nhn?blogId=shumin&logNo=220823075261&proxyReferer=https%3A%2F%2Fwww.google.com%2F
https://gcc.gnu.org/wiki/InstallingGCC
https://serverkurma.com/linux/how-to-install-newer-version-of-gcc-on-centos-6-x/
https://trilinos.github.io/install_gcc.html

Saturday, July 27, 2019

Install FFTW, BLAS & LAPACK



II. BLAS & LAPACK
https://ahmadzareei.github.io/azareei/linux/2016/04/08/configuring-blas-lapack.html
1. Dowloand LAPACK
https://thelinuxcluster.com/2012/04/09/building-lapack-3-4-with-intel-and-gnu-compiler/
wget http://www.netlib.org/lapack/lapack-3.9.0.tgz
tar -zxvf lapack-3.9.0.tgz
cd lapack-3.9.0
## Use gfortran 64-bits compiler
module load compiler/gcc-10.2
##  copy and create make.inc
cp INSTALL/make.inc.gfortran make.inc

Edit the make.inc

make -j 12
## copy lib to new place
mkdir -p /uhome/p001cao/local/app/lapack-3.9
cp liblapack.a /uhome/p001cao/local/app/lapack-3.9/liblapack.a
## Use:
export LAPACK=/uhome/p001cao/local/app/lapack-3.9/liblapack.a


2. Install BLAS
- should use BLAS source include in LAPACK source
cd lapack-3.9.0/BLAS
## Use gfortran 64-bits compiler
module load compiler/gcc-10.2
gfortran -O3 -std=legacy -m64 -fno-second-underscore -fPIC -c *.f
ar r libfblas.a *.o   # creates libblas.a
ranlib libfblas.a
## copy lib to new place
mkdir -p /uhome/p001cao/local/app/blas
cp libfblas.a /uhome/p001cao/local/app/blas/libfblas.a  
## Use:
export BLAS=/uhome/p001cao/local/app/blas/libfblas.a





Friday, July 26, 2019

Compiling OpenMPI 4

- Some applications require C++11, this is only supported on GCC 4.8 or newer, which is not always available on system, then newer GCC need to be installed before compiling Openmpi
- Make sure to build OpenMPI with 64-bit support. To check whether the currently available 

OpenMPI do support 64-bit or not, type this:
                ompi_info -a | grep 'Fort integer size'

If the output is 8, then it supports 64-bit. If output is 4, then it just supports 32-bit.* configuration for 64-bit support:

+ For Intel compilers use:
           FFLAGS=-i8 FCFLAGS=-i8 CFLAGS=-m64 CXXFLAGS=-m64
+ For GNU compilers type:
           FFLAGS="-m64 -fdefault-integer-8" FCFLAGS="-m64 -fdefault-integer-8" CFLAGS=-m64 CXXFLAGS=-m64

- must keep the source after compiling


Install UCX and libfabric:
################
Installation OPTIONS in README.txt
or ./configure -h

tar xvzf openmpi-4.0.2.tar.gz
cd openmpi-4.0.2
mkdir build
cd build

I. OpenMPI-4.0.4 + Intel-2020xe (USC)

Note: Intel2019 on cluster has wrong path, cannot work

- "--with-verbs" to use InfiniBand
- Use infiniband may limit the number of nodes?
-without-verbs/--without-ucx... can be turned at run-time:
mpirun --mca btl ^tcp,openib -np 4 a.out
export OMPI_MCA_btl=^tcp,openib
export OMPI_MCA_btl=^tcp
So just compile the whole thing.
#--
# USC1
module load intel/compiler-xe19u5
module load compiler/gcc/9.1.0

check: icpc -v
Configure OpenMPI
../configure CC=icc CXX=icpc FC=ifort F77=ifort \
--with-sge --with-verbs --without-ucx --without-cma \
--prefix=/uhome/p001cao/local/app/openmpi/4.0.2-intelxe19u5-IB 
make -j 8
make install

3. Test openMPI
the only thing that users need to do to use Open MPI is ensure that: 
<prefix>/bin is in their PATH, and
<prefix>/lib is in their LD_LIBRARY_PATH.
Users may need to ensure to set the PATH and LD_LIBRARY_PATH in their shell setup files (e.g., .bashrc, .cshrc) so that non-interactive rsh/ssh-based logins will be able to find the Open MPI executables.

Create Module file:
.............

TEST: mpic++ -v

#2.2. USC 2: 
# use linker lld (include in Intel-bin, require GLIBC >2.15)
module load compiler/gcc-10.1.0
module load intel/compiler-xe19u5       # lld
#--
export myUCX=/home1/p001cao/local/app/tool_dev/ucx-1.8-intel  
../configure CC=icc CXX=icpc FC=ifort F77=ifort LDFLAGS="-fuse-ld=lld -lrt" \
--with-sge --without-verbs --with-ucx=${myUCX} \
--prefix=/home1/p001cao/local/app/openmpi/4.0.4-intelxe19u5
## consider link to lib
export myIntel=/home1/p001cao/local/app/intel/xe19u5/compilers_and_libraries_2019.5.281/linux/compiler/lib
LDFLAGS="-L${myIntel}/intel64_lin -Wl,-rpath,${myIntel}/intel64_lin" \
##--
export PATH=/home1/p001cao/local/app/intel/xe19u5/compilers_and_libraries_2019.5.281/linux/bin/intel64:$PATH
export CC=icc  export CXX=icpc  export FORTRAN=ifort

II. install OpenMPI + GCC (USC)

NOTE: 
* install libfabric, knem,... in UCX (openMPI 4.0,3 --> ucx-1.7 or older), or install with openMPI 
* use UCX is recommended: --without-verbs  

## consider lld linker: 
module load llvm/llvm-gcc10-lld                   # to use lld  
LDFLAGS="-fuse-ld=lld -lrt"    

## gold linker:
module load tool_dev/binutils-2.32                                         
LDFLAGS="-fuse-ld=gold -lrt"     

# 2.1. USC 1:
## 1. not use UCX
module load tool_dev/binutils-2.36                       # gold, should use to avoid link-error
module load compiler/gcc-11.2
export myKNEM=/uhome/p001cao/local/app/tool_dev/knem-1.1.4
    
## IB cluster
mkdir build_eagle && cd build_eagle 
../configure CC=gcc CXX=g++ FC=gfortran F77=gfortran LDFLAGS="-fuse-ld=gold -lrt" \
--with-sge --without-ucx --with-verbs --with-knem=${myKNEM} \
--prefix=/uhome/p001cao/local/app/openmpi/4.1.1-gcc11.2-noUCX-eagle
## noIB cluster
mkdir build_lion && cd build_lion
../configure CC=gcc CXX=g++ FC=gfortran F77=gfortran LDFLAGS="-fuse-ld=gold -lrt" \
--with-sge --without-ucx --without-verbs --with-knem=${myKNEM} \
--prefix=/uhome/p001cao/local/app/openmpi/4.1.1-gcc11.2-noUCX-lion

### 2. with ucx
# ucx Error: ib_md.c:329  UCX  ERROR ibv_reg_mr(address=0x145cb580, length=263504, access=0xf) failed: Resource temporarily unavailable

## use the same procedure to compile on Lion and Eagle
module load tool_dev/binutils-2.35                        # gold 
module load compiler/gcc-10.2                 
export myUCX=/uhome/p001cao/local/app/tool_dev/ucx-1.9
export myKNEM=/uhome/p001cao/local/app/tool_dev/knem-1.1.4
../configure CC=gcc CXX=g++ FC=gfortran F77=gfortran LDFLAGS="-fuse-ld=gold -lrt" \
--with-sge --without-verbs --with-ucx=${myUCX} --with-knem=${myKNEM} \
--prefix=/uhome/p001cao/local/app/openmpi/4.1.1-gcc10.3-eagle


##2.2. USC 2: 
## with UCX: on Tacheon, ucx gives better performance (but raise posibility of err)
cd openmpi-4.1.1
mkdir buildGCC && cd buildGCC
#--
module load tool_dev/binutils-2.35                        # gold
module load compiler/gcc-10.3
export myUCX=/home1/p001cao/local/app/tool_dev/ucx-1.10               ## UCX
../configure CC=gcc CXX=g++ FC=gfortran F77=gfortran LDFLAGS="-fuse-ld=gold -lrt" \
--with-sge --without-verbs --with-ucx=${myUCX}  \
--prefix=/home1/p001cao/local/app/openmpi/4.1.1-gcc10.3
#not use
export myKNEM=/home1/p001cao/local/app/tool_dev/knem-1.1.4
--with-knem=${myKNEM}

## without UCX: 
module load tool_dev/binutils-2.35                        # gold
module load compiler/gcc-10.3
../configure CC=gcc CXX=g++ FC=gfortran F77=gfortran LDFLAGS="-fuse-ld=gold -lrt" \
--with-sge --with-verbs --without-ucx \
--prefix=/home1/p001cao/local/app/openmpi/4.1.1-gcc10.3-noUCX

##2.3. CAN: 

module load gcc/gcc-7.4.0
check:   g++   -v

2. Configuration

cd openmpi-4.0.2
mkdir build
cd build

../configure CC=gcc CXX=g++ FC=gfortran F77=gfortran \
--with-sge --without-verbs --without-ucx  \
--prefix=/home/thang/local/app/openmpi/4.0.2-gcc7.4.0

##2.4. CAN-GPU: 

I. Install Cuda with Intel-xe19: (Runfile Installation)
Download:  wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_rhel6.run

Install: (root acc)
1. disable the graphical target, to update Nvidia driver
systemctl isolate multi-user.target
modprobe -r nvidia-drm

module load compiler/gcc-7.4
sh cuda_10.2.89_440.33.01_rhel6.run --toolkitpath=/home/thang/local/app/cuda-10.2

2. after install Cuda, start the graphical environment again
systemctl start graphical.target

II. Install OpenMPI
# need binutils 2.22 or newer to link cuda

cd openmpi-4.1.1
mkdir build && cd build

Load compilers:
module load compiler/gcc-7.4   # cuda-10 only support to gcc-8
module load binutils-2.35 

../configure CC=gcc CXX=g++ FC=gfortran F77=gfortran \
--with-sge --without-ucx \
--with-cuda=/home/thang/local/app/cuda-10.2 \
--prefix=/home/thang/local/app/openmpi/4.1.1-gcc7.4-cuda



Wednesday, July 10, 2019

Compiling Lammps/22Aug18 with Intel 14.0, OpenMPI 1.8.1 and FFTW 3.3.4 (USC)

I.  Assum that Intel compiler and correspoding OpenMPI & FFTW werer be installed

 module avail
 module display "module_name"

II:  Load modules

 module load   intel/intel-14.0
 module load   intel/mkl-14.0
 module load   mpi/intel-14.0/openmpi-1.8.1
 module load   fftw/3.3.4/openmpi-1.8.1/intel-14.0/double/fftw-3.3.4
check 
 module list

III: Compiling LAMMPS

tar -xzvf lammps*.tar.gz

Step 1: chose the packages

Go to src directory
cd lammps_folder

1a. Check which packages are included
make package-status
1b. Choose all the standard
make yes-standard

make yes-user-fep
make yes-user-misc
make yes-user-phonon
make yes-user-meamc
make yes-user-reaxc
1c. Exclude packages that are not required
 make no-voronoi
 make no-kim
 make no-gpu
 make no-kokkos
 make no-mscg

make no-latte
make no-message

Step2: Prepare libraries for the chosed packages

2a. lib/reax
make -f Makefile.ifort
2b. lib/meam
There are 2 ways to do:
way 1: manually
$ cd lib/meam
$ vi Makefile.lammps.ifort
      - - - as below - - - (in Vi press "i" to insert mode --> Esc --> :wq)

$ make -f Makefile.ifort
[Makefile.lammps.ifort modify
meam_SYSINC =
meam_SYSLIB =
meam_SYSPATH =
way 2: perform in lammps/src

cd lammps/src

make lib-meam # print help message
make lib-meam args="-m mpi" # build with default Fortran compiler compatible with your MPI library
make lib-meam args="-m serial" # build with compiler compatible with "make serial" (GNU Fortran)
make lib-meam args="-m ifort" # build with Intel Fortran compiler using Makefile.ifort
2c. lib/poems
cd lib/poems
make -f Makefile.icc
2d. lib/atc
 cd lib/atc
 vi Makefile.lammps.installed
        - - - as below- - -

 make -f Makefile.mpic++
[Makefile.lammps.installed modify]


user-atc_SYSINC =
user-atc_SYSLIB =
user-atc_SYSPATH =
2e. lib/awpmd


$ cd lib/awpmd
$ vi Makefile.lammps.installed
     - - - as below - - -

$ make -f Makefile.mpicc
[Makefile.lammps.installed 수정]


user-awpmd_SYSINC =
user-awpmd_SYSLIB =
user-awpmd_SYSPATH =
2f. lib/linalg


$ cd lib/linalg
$ cp -p Makefile.gfortran Makefile.ifort
$ vi Makefile.ifort
- - - 수정 사항은 아래 참조 - - -
$ make -f Makefile.ifort
[Makefile.ifort 수정]


FC = ifort
FFLAGS = -O3 -fPIC
FFLAGS0 = -O0 -fPIC
2g. lib/latte


finding way...

Step 3: Edit makefile

Copy file src/MAKE/Makefile.mpi
to  src/MAKE/MINE/Makefile.f3mpi   and then edit file Makefile.f3mpi

3a # compiler/linker settings:


CCFLAGS = -O3 -fno-alias -restrict -ip -unroll0 -shared-intel
LINKFLAGS = -O -L/opt/intel/composer_xe_2013_sp1.3.174/mkl/lib/intel64
LIB = -lstdc++ -lpthread -lmkl_sequential -lmkl_intel_lp64 -lmkl_core 

3b MPI Library
MPI_INC =   -I/opt/mpi/intel-14.0/openmpi-1.8.1/include -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1
MPI_PATH =    
MPI_LIB = -L/opt/mpi/intel-14.0/openmpi-1.8.1/lib
3c FFT library
FFT_INC =   -I/opt/fftw/3.3.4/openmpi-1.8.1/intel-14.0/double/include/fftw3 
FFT_PATH = 
FFT_LIB = /opt/fftw/3.3.4/openmpi-1.8.1/intel-14.0/double/lib/libfftw3.a

Step 4: Compile LAMMPS

Check make options. Go to src  (delete previous make --> make clean-all)
# make
# make f3mpi -j8
test:  mpirun -np 2 lmp_f3mpi


Step 5: Create a /usr/local/lammps/11Aug17ti/bin and copy libraries. 

Go to lammps root directory
 cp -Rv  bench   /uhome/p001cao/local/lammps/11Aug18/bench 
 cp -Rv  doc      /uhome/p001cao/local/lammps/11Aug17ti/doc
 cp -Rv  examples    /uhome/p001cao/local/lammps/11Aug17ti/examples
 cp -Rv  potentials   /uhome/p001cao/local/lammps/11Aug17ti/potentials
 cp -Rv tools   /uhome/p001cao/local/lammps/11Aug17ti/tools
 cp -Rv lib     /uhome/p001cao/local/lammps/11Aug17ti/lib
    cd src
 cp -p lmp_f3mpi  /uhome/p001cao/local/lammps/11Aug17ti/bin


cd /uhome/p001cao/local/lammps/11Aug17ti/bin
cp -p  lmp_f3mpi  lmp_mpi 
* Test: at /bin
mpirun -np 2 lmp_mpi
LAMMPS (11 Aug 2017)


Step 6. Create a Modulefile

create modulefile:  lammps/11Aug17ti
and put it into folder:  /uhome/p001cao/local/share/lmodfiles
# for Tcl script use only
set     topdir          /uhome/p001cao/local/lammps
set     version         11.Aug.2017fep

module load   mpi/intel-14.0/openmpi-1.8.1
module load   fftw/3.3.4/openmpi-1.8.1/intel-14.0/double/fftw-3.3.4

setenv          LAMMPS                  $topdir/11Aug17ti
prepend-path    PATH                    $topdir/11Aug17ti/bin
prepend-path    LD_LIBRARY_PATH         $topdir/11Aug17ti/lib
load module

. /etc/profile
module use /uhome/p001cao/local/share/lmodfiles
module load lammps/11Aug17ti
mpirun -np $NSLOTS -machinefile $TMPDIR/machines lmp_mpi ...
Step 7. (Optional) make module usable:
# attach the following command to .bashrc file
module use /uhome/p001cao/local/share/lmodfiles
cd ~ls -la                                                        # to see invisible filesvi .bashrc

References:

Notes:
If copy lmp_linux file using WinSCP, then have to use this command to set it as executable file (assume staying .../bin
#   chmod  +x  lmp_linux 

Install OpenMPI-2.1.5 with GCC-4.4 (USC user)

1. Assum that GCC compiler was installed on USC
check 
$ gcc -v
gcc version 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)
Note: install Conda2, will have GCC-7.2.0
2. Configuration and install OpenMPI
cd openmpi-2.1.5 ./configure --prefix=/uhome/p001cao/local/openmpi-2.1.5-gcc-4.4 CC=gcc CXX=g++ F77=gfortran FC=gfortran --with-devel-headers --enable-binaries make -j8 make all install
Test the result
# mpicc -v
gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
3. Make module file

create file "openmpi-2.1.5"
# for Tcl script use only
set topdir /uhome/p001cao/local/openmpi-2.1.5-gcc-4.4
set version 2.1.5
prepend-path PATH $topdir/bin
prepend-path LD_LIBRARY_PATH $topdir/lib
prepend-path INCLUDE $topdir/include
prepend-path MANPATH $topdir/share/man

save it in: /uhome/p001cao/local/share/lmodfiles/mpi/gcc-4.4

Thursday, June 20, 2019

Numerical analysis

What is numerical analysis?
Numerical analysis is solving the mathematical problems (engineering and physical applications) by using numerical methods, i.e., the Algorithms that are used to obtain the numerical solutions.

Why do we need numerical analysis?
In engineering and physical applications, there are a lot of problems which are difficult or impossible to solve algebraically using elementary calculus. They need systemic methods, i.e., numerical methods, for solving them numerically on computers or calculators. Typical numerical methods are iterative in nature and, for a well-chosen problem and a good starting value, will frequently converge to a desired value.
Think about solving such below problem by using your calculus?



Floating-point forms of Numbers
In decimal notation, every real number can be presented by a finite or an infinite sequence  of decimal digits. Most computers have two ways of representing numbers, called fixed point and floating point.


(under constructed)


Ref.:
1. How to Post Math Equations in Blogger Using Latex

Friday, January 4, 2019

Install OpenMPI-2.1.5 with Intel-14.0 (USC user)

I. Assum that Intel compiler was installed on USC
module avail 
module display "module_name" 

Load modules
module load intel/intel-14.0
check
module list
2. Configuration Information and install OpenMPI
cd openmpi-2.1.5
./configure --prefix=/uhome/p001cao/local/openmpi-2.1.5-intel-14.0 CC=icc CXX=icpc F77=ifort FC=ifort --with-devel-headers --enable-binaries make -j8
make all install
Test the result
# mpicc -v
icc version 14.0.3 (gcc version 4.4.7 compatibility)
3. Make module file
create file "openmpi-2.1.5"
# for Tcl script use only 
set topdir /uhome/p001cao/local/openmpi-2.1.5-intel-14.0 
set version 2.1.5  
module           load intel/intel-14.0
prepend-path         PATH                                   $topdir/bin  
prepend-path         LD_LIBRARY_PATH        $topdir/lib  
prepend-path         INCLUDE                          $topdir/include  
prepend-path         MANPATH                        $topdir/share/man
save it in: /uhome/p001cao/local/share/lmodfiles/mpi/intel-14.0
Ref: 

Thursday, December 13, 2018

Environment Modules on Ubuntu 18.04

Download : http://modules.sourceforge.net/
https://modules.readthedocs.io/en/stable/INSTALL.html

http://www.admin-magazine.com/HPC/Articles/Environment-Modules

http://manpages.ubuntu.com/manpages/bionic/man1/module.1.html


1. Install:


Tuesday, December 11, 2018

Ubuntu Stuff

I. Office 2016 on Ubuntu
           using PlayOnLinux

1. Install winbind
sudo apt-get install winbind

2. on PlayOnLinux
search Office

Notes: remember to copy source_folder to an accessible that can run by WINE

II. SSH connect:
using Remmina

III Taskbar - desktop - theme:
Tweak
Setting --> Dock