Skip to content

Commit

Permalink
2.9 release
Browse files Browse the repository at this point in the history
  • Loading branch information
haykh committed Dec 27, 2024
1 parent 5e6f4b5 commit e0d1cfb
Show file tree
Hide file tree
Showing 168 changed files with 258 additions and 32,788 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ endif()

message(NOTICE "Compiler: ${CMAKE_Fortran_COMPILER}")

project(tristan-v2 VERSION 2.8
project(tristan-v2 VERSION 2.9
DESCRIPTION "Relativistic cartesian particle-in-cell code"
LANGUAGES Fortran)

Expand Down Expand Up @@ -178,9 +178,11 @@ add_compile_definitions(NGHOST=${nghosts})

if (${radiation} MATCHES "sync")
add_compile_definitions(SYNCHROTRON)
add_compile_definitions(RADIATION)
endif()
if (${radiation} MATCHES "ic")
add_compile_definitions(INVERSECOMPTON)
add_compile_definitions(RADIATION)
endif()

# select the dimension
Expand Down
4 changes: 2 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FFLAGS := @COMPILER_FLAGS@
PFLAGS := @PREPROCESSOR_FLAGS@
WARNFLAGS := @WARNING_FLAGS@

#H5OBJ := $(HDF5_INCDIR)
INC_DIRS := -I $(HDF5_ROOT)/include

PFLAGS += @DEFS@
# FFLAGS += $(WARNFLAGS)
Expand Down Expand Up @@ -53,7 +53,7 @@ $(EXECUTABLE): $(OBJ_FILES)

$(BUILD_DIR)%.o: %.F90
${HIDE}mkdir -p $(@D)
${HIDE}$(FC) $(FFLAGS) $(PFLAGS) -cpp $(addprefix -I, $(dir $(INC_FILES))) @MODULE@ $(BUILD_DIR) -c $< -o $@
${HIDE}$(FC) $(FFLAGS) $(PFLAGS) -cpp $(addprefix -I, $(dir $(INC_FILES))) $(INC_DIRS) -J $(BUILD_DIR) -c $< -o $@
${HIDE}echo [OK]: compiled $<

clean :
Expand Down
60 changes: 28 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tristan v2.8
# Tristan v2.9

[![DOI](https://zenodo.org/badge/234551890.svg)](https://zenodo.org/badge/latestdoi/234551890)

Expand All @@ -8,38 +8,47 @@ For detailed tutorials and code description please visit our [wiki](https://prin

### Prerequisites

* MPI (either OpenMPI or Intel-MPI)
* MPI (either OpenMPI or Intel-MPI; mpich is currently untested)
* GCC or Intel Fortran compiler
* (optional) Parallel HDF5 (compiled with either OpenMPI or Intel-MPI)

On clusters typically all you need to do is to load the specific modules see [here](https://princetonuniversity.github.io/tristan-v2/tristanv2-configure.html#cluster-specific-customization).

If you are, however, running on a local machine make sure to install the following prerequisites (assuming non-Intel compiler and `apt` package manager):
If you are, however, running on a local machine make sure to install the following prerequisites (assuming non-Intel compiler):

#### `apt` (Debian-like)
```sh
# gcc + openmpi
sudo apt install build-essential libopenmpi-dev
sudo apt install build-essential libopenmpi-dev
# hdf5
sudo apt libhdf5-openmpi-dev hdf5-tools
```

> Also make sure you have a working `python3` installation to be able to configure the code.
#### `pacman` (Arch-like)
```sh
# gcc + openmpi
sudo pacman -S base-devel gcc gcc-fortran openmpi
# hdf5
sudo pacman -S hdf5-openmpi
```

> Also make sure you have a working `python3` (v3.8+) installation to be able to configure the code or `Cmake`.
### Usage

#### `configure.py` + GNU Make
#### Compiling with `configure.py` + GNU Make

```shell
# to view all configuration options
python3 configure.py --help
python3 configure.py -h
# to configure the code (example)
python3 configure.py -mpi08 -hdf5 --user=user_2d_rec -2d
python3 configure.py -mpi08 --user=user_2d_rec -2d
# compile and link (-j compiles in parallel which is much faster)
make all -j
make -j
# executable will be in the `bin/` directory
```

#### Cmake
#### Compiling with `cmake`

Since `v2.8` we also support `cmake` for the code configuration.

Expand All @@ -51,22 +60,13 @@ cmake --build build -j
# executable will be in the `build/src/` directory (*.xc extension)
```

Running:
#### Running:

```sh
# run the code (on clusters need to do `srun`, or `irun` etc. depending on the cluster)
mpirun -np <NCORES> ./<EXECUTABLE> -input <INPUTFILE> -output <OUTPUTDIR>
```

#### `CMake` (experimental support)

```shell
# preconfigure the code using
cmake -B build -D user=<USERFILE> -D dim=3 ...
# compile
cmake --build build -j $(nproc)
```

### Docker

Another way to avoid the tedium of installing libraries (especially for local development) is to use [Docker containers](https://docs.docker.com/get-started/). This approach allows to quickly create an isolated linux environment with all the necessary packages already preinstalled (similar to a VM, but much lighter). The best thing is that VSCode can natively attach to a running container, and all the development can be done there (make sure to install the [appropriate extension](https://code.visualstudio.com/docs/remote/containers)).
Expand Down Expand Up @@ -116,17 +116,17 @@ Since `v2.4` code formatting policy is employed. To follow the proper formatting

```sh
# create a local pip environment
python3 -m virtualenv venv
python3 -m venv .venv
# activate it
source venv/bin/activate
source .venv/bin/activate
# install required modules
pip install -r dev-requirements.txt
pip install fprettify
```

After that one can either use the tool in a stand-alone manner:

```sh
./venv/bin/fprettify -i 2 -w 4 --whitespace-assignment true --enable-decl --whitespace-decl true --whitespace-relational true --whitespace-logical true --whitespace-plusminus true --whitespace-multdiv true --whitespace-print true --whitespace-type true --whitespace-intrinsics true --enable-replacements -l 1000 [FILENAME.F90]
.venv/bin/fprettify -i 2 -w 4 --whitespace-assignment true --enable-decl --whitespace-decl true --whitespace-relational true --whitespace-logical true --whitespace-plusminus true --whitespace-multdiv true --whitespace-print true --whitespace-type true --whitespace-intrinsics true --enable-replacements -l 1000 [FILENAME.F90]
```
or in the VSCode environment (see the extension list in the `.vscode/settings.json` of the current repo).

Expand All @@ -151,6 +151,10 @@ or in the VSCode environment (see the extension list in the `.vscode/settings.js
__@TODO__

## Latest Releases
* `v2.9` __Dec 2024__
* removed `tristanVis` (see [`graph-et`](https://pypi.org/project/graph-et/))
* cleanups & updated instructions
* minor bugfixes
* `v2.8` __Apr 2024__
* cmake support
* minor reformatting + bugfixes
Expand Down Expand Up @@ -225,11 +229,3 @@ __@TODO__
* Slice outputs for 3d added
* Particle momentum binning improved for downsampling
* Minor bugs fixed

---

We employ [semantic versioning](https://semver.org/) for this code. Given a version number `v<MAJOR>.<MINOR>.<PATCH>r<CANDIDATE>`, increment the:
- `MAJOR` version when you make incompatible changes,
- `MINOR` version when you add functionality in a backwards compatible manner, and
- `PATCH` version when you make backwards compatible bug fixes.
- `CANDIDATE`: release candidate for "nightly" builds
65 changes: 33 additions & 32 deletions configure.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#! /usr/bin/env python
#!/usr/bin/env python3
# -----------------------------------------------------------------------------------------

import sys

if sys.version_info[0] < 3 or sys.version_info[1] < 8:
raise Exception("Must be using python 3.8+")

import argparse
import glob
import re
Expand All @@ -21,7 +27,7 @@
flags_choices = ["intel", "generic"]

rad_choices = ["no", "sync", "ic", "sync+ic"]
clusters = ["frontera", "zaratan", "stellar", "ginsburg"]
clusters = ["frontera", "zaratan", "stellar", "ginsburg", "rusty"]

# system
parser.add_argument(
Expand All @@ -39,16 +45,15 @@
)

parser.add_argument(
"--vector",
"--vectorization",
default=None,
required=False,
choices=["avx2", "avx512"],
help="choose the vectorization option.",
)

parser.add_argument(
"-hdf5", action="store_true", default=False, help="enable HDF5 & use h5pfc compiler"
)
parser.add_argument("-nohdf5", action="store_true", default=False, help="disable HDF5")

parser.add_argument(
"-serial", action="store_true", default=False, help="enable serial output"
)
Expand All @@ -59,14 +64,6 @@
help="enable non-blocking mpi calls (faster simulation but non-reproducible)",
)

# vec_group = parser.add_mutually_exclusive_group(required=False)
# vec_group.add_argument(
# "-avx2", action="store_true", default=False, help="enable avx2 vectorization"
# )
# vec_group.add_argument(
# "-avx512", action="store_true", default=False, help="enable avx512 vectorization"
# )

parser.add_argument(
"-lowmem", action="store_true", default=False, help="enable low memory regime"
)
Expand Down Expand Up @@ -213,39 +210,43 @@
makefile_options["COMPILER_FLAGS"] = ""
makefile_options["PREPROCESSOR_FLAGS"] = ""
makefile_options["WARNING_FLAGS"] = ""
makefile_options[
"DEFS"
] = "-DSTR_MAX=280 -DTINYXYZ=1e-6 -DTINYREAL=1e-3 -DTINYFLD=1e-8 -DTINYWEI=1e-6 -DM_PI=3.141592653589793 -DVEC_LEN=16 "
makefile_options["DEFS"] = (
"-DSTR_MAX=280 -DTINYXYZ=1e-6 -DTINYREAL=1e-3 -DTINYFLD=1e-8 -DTINYWEI=1e-6 -DM_PI=3.141592653589793 -DVEC_LEN=16 "
)
makefile_options["ADD_INCLUDES"] = ""

# specific cluster:
specific_cluster = False
clustername = ""
if args["cluster"] is not None:
specific_cluster = True
clustername = args["cluster"].capitalize()
args["ifport"] = True
if args["cluster"] == "frontera":
args["flags"] = "intel"
args["vector"] = "avx512"
args["vectorization"] = "avx512"
args["lowmem"] = True
elif args["cluster"] == "stellar":
args["flags"] = "intel"
args["vector"] = "avx512"
args["vectorization"] = "avx512"
elif args["cluster"] == "zaratan":
args["flags"] = "generic"
args["vector"] = "avx2"
args["vectorization"] = "avx2"
makefile_options["ADD_INCLUDES"] = "$(HDF5_INCDIR)"
elif args["cluster"] == "ginsburg":
args["flags"] = "intel"
args["vector"] = "avx512"
args["vectorization"] = "avx512"
elif args["cluster"] == "rusty":
args["flags"] = "intel"
args["vectorization"] = "avx512"

# compilation command
if args["hdf5"]:
if not args["nohdf5"]:
makefile_options["COMPILER_COMMAND"] += "h5pfc "
makefile_options["PREPROCESSOR_FLAGS"] += "-DHDF5 "
else:
makefile_options["COMPILER_COMMAND"] += (
"mpif90 " if not args["compiler"] == "intel" else "mpiifort "
"mpif90 " if not args["flags"] == "intel" else "mpiifort "
)
if args["ifport"]:
makefile_options["PREPROCESSOR_FLAGS"] += "-DIFPORT "
Expand Down Expand Up @@ -277,13 +278,13 @@
"COMPILER_FLAGS"
] += "-fbacktrace -ffpe-trap=invalid,zero,overflow,underflow,denormal "
# @TODO: add aocc
if int(args["debug"]) >= 2 and (args["compiler"] == "intel"):
if int(args["debug"]) >= 2 and (args["flags"] == "intel"):
makefile_options["COMPILER_FLAGS"] += "-check all -check noarg_temp_created "
else:
makefile_options["COMPILER_FLAGS"] += "-Ofast "

if args["double"]:
if args["compiler"] == "intel":
if args["flags"] == "intel":
makefile_options["COMPILER_FLAGS"] += "-r8 "
else:
makefile_options["COMPILER_FLAGS"] += "-fdefault-real-8 "
Expand All @@ -306,17 +307,17 @@
] += (
"-diag-disable 10397 -diag-disable 10346 -diag-disable 8100 -diag-disable 6178 "
)
if args["vector"] is not None:
if args["vector"] == "avx2":
if args["vectorization"] is not None:
if args["vectorization"] == "avx2":
makefile_options["COMPILER_FLAGS"] += "-xCORE-AVX2 "
elif args["vector"] == "avx512":
elif args["vectorization"] == "avx512":
makefile_options["COMPILER_FLAGS"] += "-xCORE-AVX512 -qopt-zmm-usage:high "
elif args["vector"] == "amd-avx2":
elif args["vectorization"] == "amd-avx2":
makefile_options["COMPILER_FLAGS"] += "-mavx2 "
else:
makefile_options["MODULE"] = "-J "
makefile_options["COMPILER_FLAGS"] += "-O3 -DSoA -ffree-line-length-512 "
if args["vector"] is not None:
if args["vectorization"] is not None:
makefile_options["COMPILER_FLAGS"] += "-mavx "

if args["1d"]:
Expand Down Expand Up @@ -436,7 +437,7 @@

print("TECHNICAL ....................................................................")

print(" Flag types [vec.]: " + f'{args["flags"]} [{args["vector"]}]')
print(" Flag types [vec.]: " + f'{args["flags"]} [{args["vectorization"]}]')
print(" Precision: " + ("double" if args["double"] else "single"))
print(
" Debug mode: "
Expand All @@ -448,7 +449,7 @@
" Output: "
+ (
("HDF5" + (" (serial)" if args["serial"] else " (parallel)"))
if args["hdf5"]
if not args["nohdf5"]
else "N/A"
)
)
Expand Down
8 changes: 0 additions & 8 deletions dev-requirements.txt

This file was deleted.

Loading

0 comments on commit e0d1cfb

Please sign in to comment.