1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-14 01:35:36 +00:00
Grid/README.md

412 lines
16 KiB
Markdown
Raw Normal View History

2020-04-03 19:52:15 +01:00
# Grid [![Teamcity status](http://ci.cliath.ph.ed.ac.uk/app/rest/builds/aggregated/strob:(buildType:(affectedProject(id:GridBasedSoftware_Grid)),branch:name:develop)/statusIcon.svg)](http://ci.cliath.ph.ed.ac.uk/project.html?projectId=GridBasedSoftware_Grid&tab=projectOverview) [![Travis status](https://travis-ci.org/paboyle/Grid.svg?branch=develop)](https://travis-ci.org/paboyle/Grid)
2016-08-03 12:38:54 +01:00
**Data parallel C++ mathematical object library.**
License: GPL v2.
2017-06-29 11:42:25 +01:00
Last update June 2017.
2016-10-31 18:21:52 +00:00
2016-11-03 13:48:20 +00:00
_Please do not send pull requests to the `master` branch which is reserved for releases._
2016-10-31 18:21:52 +00:00
2017-07-01 10:20:07 +01:00
### Description
This library provides data parallel C++ container classes with internal memory layout
that is transformed to map efficiently to SIMD architectures. CSHIFT facilities
are provided, similar to HPF and cmfortran, and user control is given over the mapping of
array indices to both MPI tasks and SIMD processing elements.
* Identically shaped arrays then be processed with perfect data parallelisation.
* Such identically shaped arrays are called conformable arrays.
The transformation is based on the observation that Cartesian array processing involves
identical processing to be performed on different regions of the Cartesian array.
The library will both geometrically decompose into MPI tasks and across SIMD lanes.
Local vector loops are parallelised with OpenMP pragmas.
Data parallel array operations can then be specified with a SINGLE data parallel paradigm, but
optimally use MPI, OpenMP and SIMD parallelism under the hood. This is a significant simplification
for most programmers.
The layout transformations are parametrised by the SIMD vector length. This adapts according to the architecture.
Presently SSE4, ARM NEON (128 bits) AVX, AVX2, QPX (256 bits), IMCI and AVX512 (512 bits) targets are supported.
These are presented as `vRealF`, `vRealD`, `vComplexF`, and `vComplexD` internal vector data types.
The corresponding scalar types are named `RealF`, `RealD`, `ComplexF` and `ComplexD`.
MPI, OpenMP, and SIMD parallelism are present in the library.
Please see [this paper](https://arxiv.org/abs/1512.03487) for more detail.
2017-05-06 18:39:54 +01:00
### Compilers
Intel ICPC v16.0.3 and later
2017-05-06 18:40:55 +01:00
2017-05-06 18:39:54 +01:00
Clang v3.5 and later (need 3.8 and later for OpenMP)
2017-05-06 18:40:55 +01:00
2017-05-06 18:39:54 +01:00
GCC v4.9.x (recommended)
2017-05-06 18:40:55 +01:00
2017-05-06 18:39:54 +01:00
GCC v6.3 and later
2019-10-25 16:43:55 +01:00
### Specific machine compilation instructions - Summit, Tesseract
[The Wiki contains specific instructions for some Summit, Tesseract and GPU compilation](https://github.com/paboyle/Grid/wiki)
2017-05-06 18:41:27 +01:00
### Important:
2017-05-06 18:39:54 +01:00
2017-05-06 18:42:11 +01:00
Some versions of GCC appear to have a bug under high optimisation (-O2, -O3).
2017-05-06 18:40:55 +01:00
2017-05-06 18:42:11 +01:00
The safety of these compiler versions cannot be guaranteed at this time. Follow Issue 100 for details and updates.
2017-05-06 18:40:55 +01:00
2017-05-06 18:39:54 +01:00
GCC v5.x
2017-05-06 18:40:55 +01:00
2017-05-06 18:39:54 +01:00
GCC v6.1, v6.2
2016-10-31 18:21:52 +00:00
### Bug report
_To help us tracking and solving more efficiently issues with Grid, please report problems using the issue system of GitHub rather than sending emails to Grid developers._
When you file an issue, please go though the following checklist:
1. Check that the code is pointing to the `HEAD` of `develop` or any commit in `master` which is tagged with a version number.
2016-11-03 13:48:20 +00:00
2. Give a description of the target platform (CPU, network, compiler). Please give the full CPU part description, using for example `cat /proc/cpuinfo | grep 'model name' | uniq` (Linux) or `sysctl machdep.cpu.brand_string` (macOS) and the full output the `--version` option of your compiler.
2016-10-31 18:21:52 +00:00
3. Give the exact `configure` command used.
4. Attach `config.log`.
5. Attach `grid.config.summary`.
2016-10-31 18:21:52 +00:00
6. Attach the output of `make V=1`.
7. Describe the issue and any previous attempt to solve it. If relevant, show how to reproduce the issue using a minimal working example.
2017-07-01 10:20:07 +01:00
### Required libraries
Grid requires:
2017-07-01 10:24:41 +01:00
2017-07-01 10:20:07 +01:00
[GMP](https://gmplib.org/),
2017-07-01 10:24:41 +01:00
2017-07-01 10:20:07 +01:00
[MPFR](http://www.mpfr.org/)
2016-10-31 18:21:52 +00:00
2017-07-01 10:20:07 +01:00
Bootstrapping grid downloads and uses for internal dense matrix (non-QCD operations) the Eigen library.
2016-08-03 12:38:54 +01:00
2017-07-01 10:20:07 +01:00
Grid optionally uses:
2017-07-01 10:24:41 +01:00
2017-07-01 10:20:07 +01:00
[HDF5](https://support.hdfgroup.org/HDF5/)
2017-07-01 10:24:41 +01:00
[LIME](http://usqcd-software.github.io/c-lime/) for ILDG and SciDAC file format support.
[FFTW](http://www.fftw.org) either generic version or via the Intel MKL library.
LAPACK either generic version or Intel MKL library.
2015-03-07 07:20:12 +00:00
2017-06-29 11:42:25 +01:00
2016-10-31 18:21:52 +00:00
### Quick start
2016-08-03 12:38:54 +01:00
First, start by cloning the repository:
2015-03-07 07:20:12 +00:00
2016-08-03 12:38:54 +01:00
``` bash
git clone https://github.com/paboyle/Grid.git
```
2015-03-07 07:20:12 +00:00
2016-08-03 12:38:54 +01:00
Then enter the cloned directory and set up the build system:
``` bash
cd Grid
./bootstrap.sh
```
Now you can execute the `configure` script to generate makefiles (here from a build directory):
``` bash
mkdir build; cd build
2016-08-04 16:27:02 +01:00
../configure --enable-precision=double --enable-simd=AVX --enable-comms=mpi-auto --prefix=<path>
2016-08-03 12:38:54 +01:00
```
2016-10-31 18:21:52 +00:00
where `--enable-precision=` set the default precision,
`--enable-simd=` set the SIMD type, `--enable-
comms=`, and `<path>` should be replaced by the prefix path where you want to
install Grid. Other options are detailed in the next section, you can also use `configure
2016-08-04 16:27:02 +01:00
--help` to display them. Like with any other program using GNU autotool, the
`CXX`, `CXXFLAGS`, `LDFLAGS`, ... environment variables can be modified to
customise the build.
2016-08-03 12:38:54 +01:00
2017-05-06 18:39:54 +01:00
Finally, you can build, check, and install Grid:
2015-03-07 07:20:12 +00:00
2016-08-03 12:38:54 +01:00
``` bash
2017-05-06 18:39:54 +01:00
make; make check; make install
2016-08-03 12:38:54 +01:00
```
2015-03-07 07:20:12 +00:00
2016-08-03 12:38:54 +01:00
To minimise the build time, only the tests at the root of the `tests` directory are built by default. If you want to build tests in the sub-directory `<subdir>` you can execute:
2015-05-19 05:36:03 +01:00
2016-08-03 12:38:54 +01:00
``` bash
make -C tests/<subdir> tests
```
If you want to build all the tests at once just use `make tests`.
2015-03-07 07:20:12 +00:00
2016-10-31 18:21:52 +00:00
### Build configuration options
- `--prefix=<path>`: installation prefix for Grid.
- `--with-gmp=<path>`: look for GMP in the UNIX prefix `<path>`
- `--with-mpfr=<path>`: look for MPFR in the UNIX prefix `<path>`
- `--with-fftw=<path>`: look for FFTW in the UNIX prefix `<path>`
- `--enable-lapack[=<path>]`: enable LAPACK support in Lanczos eigensolver. A UNIX prefix containing the library can be specified (optional).
- `--enable-mkl[=<path>]`: use Intel MKL for FFT (and LAPACK if enabled) routines. A UNIX prefix containing the library can be specified (optional).
2016-11-19 12:17:35 +00:00
- `--enable-numa`: enable NUMA first touch optimisation
2016-10-31 18:21:52 +00:00
- `--enable-simd=<code>`: setup Grid for the SIMD target `<code>` (default: `GEN`). A list of possible SIMD targets is detailed in a section below.
2016-11-19 12:17:35 +00:00
- `--enable-gen-simd-width=<size>`: select the size (in bytes) of the generic SIMD vector type (default: 32 bytes).
2016-10-31 18:21:52 +00:00
- `--enable-precision={single|double}`: set the default precision (default: `double`).
- `--enable-precision=<comm>`: Use `<comm>` for message passing (default: `none`). A list of possible SIMD targets is detailed in a section below.
2017-05-06 18:39:54 +01:00
- `--enable-rng={sitmo|ranlux48|mt19937}`: choose the RNG (default: `sitmo `).
2016-10-31 18:21:52 +00:00
- `--disable-timers`: disable system dependent high-resolution timers.
- `--enable-chroma`: enable Chroma regression tests.
2016-11-19 12:17:35 +00:00
- `--enable-doxygen-doc`: enable the Doxygen documentation generation (build with `make doxygen-doc`)
2016-10-31 18:21:52 +00:00
### Possible communication interfaces
2016-11-08 14:07:59 +00:00
The following options can be use with the `--enable-comms=` option to target different communication interfaces:
2016-10-31 18:21:52 +00:00
2016-11-03 13:48:20 +00:00
| `<comm>` | Description |
| -------------- | ------------------------------------------------------------- |
| `none` | no communications |
| `mpi[-auto]` | MPI communications |
| `mpi3[-auto]` | MPI communications using MPI 3 shared memory |
| `shmem ` | Cray SHMEM communications |
2016-10-31 18:21:52 +00:00
For the MPI interfaces the optional `-auto` suffix instructs the `configure` scripts to determine all the necessary compilation and linking flags. This is done by extracting the informations from the MPI wrapper specified in the environment variable `MPICXX` (if not specified `configure` will scan though a list of default names). The `-auto` suffix is not supported by the Cray environment wrapper scripts. Use the standard versions instead.
2016-10-31 18:21:52 +00:00
2016-08-03 12:38:54 +01:00
### Possible SIMD types
2015-03-07 07:20:12 +00:00
2016-08-03 12:38:54 +01:00
The following options can be use with the `--enable-simd=` option to target different SIMD instruction sets:
2016-10-31 18:21:52 +00:00
| `<code>` | Description |
2016-08-03 12:38:54 +01:00
| ----------- | -------------------------------------- |
| `GEN` | generic portable vector code |
| `SSE4` | SSE 4.2 (128 bit) |
| `AVX` | AVX (256 bit) |
2016-10-31 18:21:52 +00:00
| `AVXFMA` | AVX (256 bit) + FMA |
| `AVXFMA4` | AVX (256 bit) + FMA4 |
2016-08-03 12:38:54 +01:00
| `AVX2` | AVX 2 (256 bit) |
| `AVX512` | AVX 512 bit |
2017-06-29 11:48:11 +01:00
| `NEONv8` | [ARM NEON](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0024a/ch07s03.html) (128 bit) |
2017-06-29 11:42:25 +01:00
| `QPX` | IBM QPX (256 bit) |
2016-08-03 12:38:54 +01:00
Alternatively, some CPU codenames can be directly used:
2016-10-31 18:21:52 +00:00
| `<code>` | Description |
2016-08-03 12:38:54 +01:00
| ----------- | -------------------------------------- |
2016-10-31 18:21:52 +00:00
| `KNL` | [Intel Xeon Phi codename Knights Landing](http://ark.intel.com/products/codename/48999/Knights-Landing) |
2018-01-30 11:42:36 +00:00
| `SKL` | [Intel Skylake with AVX512 extensions](https://ark.intel.com/products/codename/37572/Skylake#@server) |
2016-10-31 18:21:52 +00:00
| `BGQ` | Blue Gene/Q |
#### Notes:
2018-01-30 11:44:20 +00:00
- We currently support AVX512 for the Intel compiler and GCC (KNL and SKL target). Support for clang will appear in future versions of Grid when the AVX512 support in the compiler will be more advanced.
2016-10-31 18:21:52 +00:00
- For BG/Q only [bgclang](http://trac.alcf.anl.gov/projects/llvm-bgq) is supported. We do not presently plan to support more compilers for this platform.
- BG/Q performances are currently rather poor. This is being investigated for future versions.
2016-11-19 12:17:35 +00:00
- The vector size for the `GEN` target can be specified with the `configure` script option `--enable-gen-simd-width`.
2016-10-31 18:21:52 +00:00
### Build setup for Intel Knights Landing platform
The following configuration is recommended for the Intel Knights Landing platform:
``` bash
../configure --enable-precision=double\
--enable-simd=KNL \
2017-07-01 09:48:00 +01:00
--enable-comms=mpi-auto \
2016-10-31 18:21:52 +00:00
--enable-mkl \
CXX=icpc MPICXX=mpiicpc
```
2017-07-01 09:48:00 +01:00
The MKL flag enables use of BLAS and FFTW from the Intel Math Kernels Library.
2016-10-31 18:21:52 +00:00
2017-07-01 09:48:00 +01:00
If you are working on a Cray machine that does not use the `mpiicpc` wrapper, please use:
2016-10-31 18:21:52 +00:00
``` bash
../configure --enable-precision=double\
--enable-simd=KNL \
2016-11-03 13:48:20 +00:00
--enable-comms=mpi \
2016-10-31 18:21:52 +00:00
--enable-mkl \
CXX=CC CC=cc
2017-06-29 11:48:11 +01:00
```
2017-07-01 09:48:00 +01:00
If gmp and mpfr are NOT in standard places (/usr/) these flags may be needed:
2017-07-01 09:53:15 +01:00
``` bash
--with-gmp=<path> \
2017-07-01 09:48:00 +01:00
--with-mpfr=<path> \
```
where `<path>` is the UNIX prefix where GMP and MPFR are installed.
Knight's Landing with Intel Omnipath adapters with two adapters per node
presently performs better with use of more than one rank per node, using shared memory
for interior communication. This is the mpi3 communications implementation.
We recommend four ranks per node for best performance, but optimum is local volume dependent.
``` bash
../configure --enable-precision=double\
--enable-simd=KNL \
2017-07-01 09:53:15 +01:00
--enable-comms=mpi3-auto \
2017-07-01 09:48:00 +01:00
--enable-mkl \
2017-07-01 09:53:15 +01:00
CC=icpc MPICXX=mpiicpc
2017-07-01 09:48:00 +01:00
```
### Build setup for Intel Haswell Xeon platform
2017-07-01 09:53:15 +01:00
The following configuration is recommended for the Intel Haswell platform:
2017-07-01 09:48:00 +01:00
``` bash
../configure --enable-precision=double\
--enable-simd=AVX2 \
2017-07-01 09:53:15 +01:00
--enable-comms=mpi3-auto \
2017-07-01 09:48:00 +01:00
--enable-mkl \
2017-07-01 09:53:15 +01:00
CXX=icpc MPICXX=mpiicpc
2017-07-01 09:48:00 +01:00
```
The MKL flag enables use of BLAS and FFTW from the Intel Math Kernels Library.
If gmp and mpfr are NOT in standard places (/usr/) these flags may be needed:
2017-07-01 09:53:15 +01:00
``` bash
--with-gmp=<path> \
2017-07-01 09:48:00 +01:00
--with-mpfr=<path> \
```
where `<path>` is the UNIX prefix where GMP and MPFR are installed.
If you are working on a Cray machine that does not use the `mpiicpc` wrapper, please use:
``` bash
../configure --enable-precision=double\
--enable-simd=AVX2 \
--enable-comms=mpi3 \
--enable-mkl \
CXX=CC CC=cc
```
Since Dual socket nodes are commonplace, we recommend MPI-3 as the default with the use of
one rank per socket. If using the Intel MPI library, threads should be pinned to NUMA domains using
```
export I_MPI_PIN=1
```
This is the default.
### Build setup for Intel Skylake Xeon platform
2017-07-01 09:53:15 +01:00
The following configuration is recommended for the Intel Skylake platform:
2017-07-01 09:48:00 +01:00
``` bash
../configure --enable-precision=double\
--enable-simd=AVX512 \
--enable-comms=mpi3 \
--enable-mkl \
CXX=mpiicpc
```
The MKL flag enables use of BLAS and FFTW from the Intel Math Kernels Library.
If gmp and mpfr are NOT in standard places (/usr/) these flags may be needed:
2017-07-01 09:53:15 +01:00
``` bash
--with-gmp=<path> \
2017-07-01 09:48:00 +01:00
--with-mpfr=<path> \
```
where `<path>` is the UNIX prefix where GMP and MPFR are installed.
If you are working on a Cray machine that does not use the `mpiicpc` wrapper, please use:
``` bash
../configure --enable-precision=double\
--enable-simd=AVX512 \
--enable-comms=mpi3 \
--enable-mkl \
CXX=CC CC=cc
```
Since Dual socket nodes are commonplace, we recommend MPI-3 as the default with the use of
one rank per socket. If using the Intel MPI library, threads should be pinned to NUMA domains using
2017-07-01 09:55:36 +01:00
```
2017-07-01 09:48:00 +01:00
export I_MPI_PIN=1
```
This is the default.
2017-07-14 22:59:16 +01:00
#### Expected Skylake Gold 6148 dual socket (single prec, single node 20+20 cores) performance using NUMA MPI mapping):
2017-07-14 22:52:16 +01:00
mpirun -n 2 benchmarks/Benchmark_dwf --grid 16.16.16.16 --mpi 2.1.1.1 --cacheblocking 2.2.2.2 --dslash-asm --shm 1024 --threads 18
2017-07-17 09:53:07 +01:00
TBA
2017-07-14 22:52:16 +01:00
2017-07-09 00:11:54 +01:00
### Build setup for AMD EPYC / RYZEN
The AMD EPYC is a multichip module comprising 32 cores spread over four distinct chips each with 8 cores.
So, even with a single socket node there is a quad-chip module. Dual socket nodes with 64 cores total
are common. Each chip within the module exposes a separate NUMA domain.
There are four NUMA domains per socket and we recommend one MPI rank per NUMA domain.
MPI-3 is recommended with the use of four ranks per socket,
and 8 threads per rank.
The following configuration is recommended for the AMD EPYC platform.
``` bash
../configure --enable-precision=double\
--enable-simd=AVX2 \
--enable-comms=mpi3 \
CXX=mpicxx
```
If gmp and mpfr are NOT in standard places (/usr/) these flags may be needed:
``` bash
--with-gmp=<path> \
--with-mpfr=<path> \
```
where `<path>` is the UNIX prefix where GMP and MPFR are installed.
Using MPICH and g++ v4.9.2, best performance can be obtained using explicit GOMP_CPU_AFFINITY flags for each MPI rank.
This can be done by invoking MPI on a wrapper script omp_bind.sh to handle this.
It is recommended to run 8 MPI ranks on a single dual socket AMD EPYC, with 8 threads per rank using MPI3 and
shared memory to communicate within this node:
mpirun -np 8 ./omp_bind.sh ./Benchmark_dwf --mpi 2.2.2.1 --dslash-unroll --threads 8 --grid 16.16.16.16 --cacheblocking 4.4.4.4
Where omp_bind.sh does the following:
```
#!/bin/bash
numanode=` expr $PMI_RANK % 8 `
basecore=`expr $numanode \* 16`
core0=`expr $basecore + 0 `
core1=`expr $basecore + 2 `
core2=`expr $basecore + 4 `
core3=`expr $basecore + 6 `
core4=`expr $basecore + 8 `
core5=`expr $basecore + 10 `
core6=`expr $basecore + 12 `
core7=`expr $basecore + 14 `
export GOMP_CPU_AFFINITY="$core0 $core1 $core2 $core3 $core4 $core5 $core6 $core7"
echo GOMP_CUP_AFFINITY $GOMP_CPU_AFFINITY
$@
```
2017-07-14 22:52:16 +01:00
Performance:
2017-07-14 22:59:16 +01:00
#### Expected AMD EPYC 7601 dual socket (single prec, single node 32+32 cores) performance using NUMA MPI mapping):
2017-07-14 22:52:16 +01:00
mpirun -np 8 ./omp_bind.sh ./Benchmark_dwf --threads 8 --mpi 2.2.2.1 --dslash-unroll --grid 16.16.16.16 --cacheblocking 4.4.4.4
2017-07-17 09:53:07 +01:00
TBA
2017-07-14 22:52:16 +01:00
2017-07-01 10:05:46 +01:00
### Build setup for BlueGene/Q
To be written...
### Build setup for ARM Neon
2017-07-01 10:06:24 +01:00
To be written...
2017-07-01 10:05:46 +01:00
2017-07-01 10:04:32 +01:00
### Build setup for laptops, other compilers, non-cluster builds
Many versions of g++ and clang++ work with Grid, and involve merely replacing CXX (and MPICXX),
and omit the enable-mkl flag.
Single node builds are enabled with
```
--enable-comms=none
```
FFTW support that is not in the default search path may then enabled with
```
--with-fftw=<installpath>
```
BLAS will not be compiled in by default, and Lanczos will default to Eigen diagonalisation.
2017-07-01 09:48:00 +01:00