https://github.com/cement-psaap/mcdc-tnt
MCDC - Toy Neutronics Testbed: A series of codes to investigate the viability of various metaprogramming techniques on a striped down version of MCDC
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: ieee.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.2%) to scientific vocabulary
Last synced: 10 months ago
·
JSON representation
Repository
MCDC - Toy Neutronics Testbed: A series of codes to investigate the viability of various metaprogramming techniques on a striped down version of MCDC
Basic Info
Statistics
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 0
- Releases: 0
Created over 4 years ago
· Last pushed almost 4 years ago
https://github.com/CEMeNT-PSAAP/MCDC-TNT/blob/main/
# MC/DC-TNT
**Monte Carlo / Dynamic Code - Toy Neutronics Testbed**
We seek to explore acceleration schemes from Python to see if we can implement performance portable and easier to produce code for a Monte Carlo neutron transport code: [MC/DC](https://github.com/CEMeNT-PSAAP/MCDC). MC/DC is the ultimate deliverable this code is just for testing methods of implementation
## Current Kernel Status
0. Pure Python: working transient
1. Numba CPU: working transient
2. PyOPM CPU: working transient
3. Numba CUDA: working transient
4. Pykokkos: working transient
5. PyCUDA: working static*
6. PyOpenCL: working static*
*static kernels might fail
## Methods of Implementation
We explore three methods to implement our transport functions on:
1. [PyKokkos](https://github.com/kokkos/pykokkos) portability framework;
2. Hardware code generating libraries [PyOpenCL](https://documen.tician.de/pyopencl/) and [PyCUDA](https://wiki.tiker.net/PyCuda/Installation/Linux/) which have been implemented before in [PyFR](https://github.com/PyFR/PyFR) (tho their use has been depricated there); and
3. [Numba](https://numba.pydata.org/)
## Implemented Physics
The neutronic physics we target are:
1. mono-energetic;
2. multi-region (slab geometry);
3. particles produced from fissions;
4. surface tracking and track length estimators; and
5. transient modeling
## Quick Setup
I don't expect anyone to run this but for those who are interested; have at it. Find all my embarsing mistakes! This process will get you the dependancies required for Numba (CPU/GPU) and pure Python. *NOTE:* For Numba CUDA you must have **(a)** a [proper graphics card](https://numba.pydata.org/numba-doc/latest/cuda/overview.html#) and; **(b)** the correct [drivers installed](https://numba.pydata.org/numba-doc/latest/cuda/overview.html#) and in your path. Other than that the process is pretty stright forward:
1. From a terminal with conda installed set up a conda environment with `conda create -n mcdc_tnt numba matplotlib pyyaml pytest` which will install all package dependencies for the Numba (no pyomp) and Pure Python implementations
2. run `conda activate mcdc_tnt`
3. Clone this github
4. Run `pip install --user -e .` in project directory to install mcdc_tnt as a local package.
5. Run `python run.py -i tc_1.yaml` for a numba threading
6. To change to GPU or pure Python appened the run command with `-t nb_gpu` or `-t pp` respectively
## More complicated Installations
Warning: *Here be dragons!* Unfortunately some of these packages are not only complicated to build but also conflicting meaning the conda environment manager is required to be able to switch back and forth. Note that these builds all have there own required dependencies and potentialy there own bugs that might be exposed on your particular system with your particular drivers.
### Installation of PyKokkos
This is subject to change and should be compared to the PyKokkos build instructions but this is what it looked like for me. Cation is reqired when using various versions of CUDA (10.2), gcc (8 or 9), and cmake (16). If you don't have acess to a machine that has a `module` system then check out [update-alternatives](https://linuxconfig.org/how-to-switch-between-multiple-gcc-and-g-compiler-versions-on-ubuntu-20-04-lts-focal-fossa) to switch things that cannot be installed via conda (gcc). While most machines should be able to operate with the OpenMP backend, I have gotten the Lassen Machine to install the CUDA version. If you don't want to touch the more difficult CUDA instiliation then switch to the OpenMP only version change `-DENABLE_CUDA` from `ON` to `OFF`.
1. `git clone` [`pykokkos-base`](https://github.com/kokkos/pykokkos-base) and the develop branch of [`pykokkos`](github.com/kokkos/pykokkos). To do this in the pykokkos directory run `git fetch` then `git checkout develop`
2. Prep conda environment by snagging requirements listed in requirements.txt from pykokkos-base and pykokkos. (1. `conda create -n pyk` 2. `conda activate pyk` 3. in pyk-base directory run `conda install --file requirments.txt` 4. in pykokkos directory run `conda install --file requirments.txt`) *ensure that cmake is of version 18 or higher and that gcc/g++ versions are at least 9*
3. Install Pykokkos-base for both OpenMP, and CUDA implementations by running (OpenMP much quicker and seems to have less issues, if that's all you need switch `-DENABLE_CUDA=OFF`):
`python setup.py install -- -DCMAKE_CXX_COMPILER=g++ -DENABLE_LAYOUTS=ON -DENABLE_MEMORY_TRAITS=OFF -DENABLE_VIEW_RANKS=3 -DENABLE_CUDA=ON -DENABLE_THREADS=OFF -DENABLE_OPENMP=ON -G "Unix Makefiles" -- -j 4` *this will take upwards of 2 hours to build and will consume a considerable ammount of RAM*
4. Install pykokkos using `pip install --user -e .`
5. Run!
### Installation of PyOpenMP
This process was described in a [paper](https://ieeexplore.ieee.org/document/9658236) that the larger prgoraming framework was described in
1. Make a new conda environment seperate from the normal one in which you have installed the current release of Numba
2. Install all dependinces and packages with `conda install numba -c drtodd13 -c conda-forge --override-channels`
3. Install other MCDC-TNT requirements (pyyaml, matplotlib)
### Installation of PyCUDA
1. Follow [PyCUDA documentation](https://wiki.tiker.net/PyCuda/Installation/Linux/)
2. Install other MCDC-TNT requirements (pyyaml, matplotlib, numba) (only the advance function is implemented via this method for hcgls)
### Installation of PyOpenCL
1. Follow [PyOpenCL documentation](https://documen.tician.de/pyopencl/misc.html)
2. Install other MCDC-TNT requirements (pyyaml, matplotlib, numba)
## Interface
This project is designed to be interfaced with via the command line and an input.yaml file. An example is listed here:
```
name: 'fissioning_slab' #name of the simluation (any string)
number of particles: 1e5 #number of particles top initiate in the
rng seed: 777 #random number seed (int)
particle speed: 1 #particle speed (float)
neutrons per fission: 2 #how many neutrons to produce per fission event
isotropic: Ture #isotropic source? if true than particles produced with a random direction
length of slab: 1 #width of the slab
surface locations: [0,1] #region geometry deffitinition (vector of floats)
mesh mod generation: n #n for number of desieredd cells, dx for desiered cell width)
dx: 0.01 #mesh width (for error and scalar flux tracking) (float)
n: 81
hardware target: nb_cpu #specifying the hardware target: pp/nb_cpu/nb_gpu/pyk_cpu/pyk_gpu
print warmup times: True #print warm up times
assemble mesh: True #assemble mesh from crossections listed here
capture cross section: 0.333 #should be as many values here as regions specified in surface_locations
scatter cross section: 0.333
fission cross section: 0.333
transient tally: True #to see transient behavior must be true
tally dt: 1 #time inbetween census snap shots
max time: 20 #time of simulation end
file output: True #should it output flux and stats? if a special file name is desiered supple in command line
error plot: True #produce the error plot?
flux plot: True #produce the flux plot?
#Issues might arries for gpus without the ability to do 64bit math
#note that native python "float" is a 64bit
floating point accuracy: float #float (np.float32) double (np.float64)
phase space vec: 4 #defining actual static size of phase space vectors
```
Then to run a simulation it can be done from a python file using:
```
import mcdc_tnt
mcdc_tnt.run('input.yaml','output.out','hardware_target')
```
or from the command line in the mcdc_tnt directory with:
`python run.py -i input.yaml -o output.out -t 'hardware_target'`
*For thoes about to rock, we salute you*
Owner
- Name: CEMeNT
- Login: CEMeNT-PSAAP
- Kind: organization
- Location: Corvallis, Oregon, USA
- Website: https://cement-psaap.github.io
- Repositories: 5
- Profile: https://github.com/CEMeNT-PSAAP
Center for Exascale Monte Carlo Neutron Transport
GitHub Events
Total
Last Year
Dependencies
requirements.txt
pypi
- blas =1.0=mkl
- brotli =1.0.9=he6710b0_2
- ca-certificates =2022.2.1=h06a4308_0
- certifi =2021.10.8=py39h06a4308_2
- cycler =0.11.0=pyhd3eb1b0_0
- dbus =1.13.18=hb2f20db_0
- expat =2.4.4=h295c915_0
- fontconfig =2.13.1=h6c09931_0
- fonttools =4.25.0=pyhd3eb1b0_0
- freetype =2.11.0=h70c0345_0
- giflib =5.2.1=h7b6447c_0
- glib =2.69.1=h4ff587b_1
- gst-plugins-base =1.14.0=h8213a91_2
- gstreamer =1.14.0=h28cd5cc_2
- icu =58.2=he6710b0_3
- intel-openmp =2021.4.0=h06a4308_3561
- jpeg =9d=h7f8727e_0
- kiwisolver =1.3.2=py39h295c915_0
- lcms2 =2.12=h3be6417_0
- ld_impl_linux-64 =2.35.1=h7274673_9
- libffi =3.3=he6710b0_2
- libgcc-ng =9.3.0=h5101ec6_17
- libgomp =9.3.0=h5101ec6_17
- libllvm11 =11.1.0=h3826bc1_1
- libpng =1.6.37=hbc83047_0
- libstdcxx-ng =9.3.0=hd4cf53a_17
- libtiff =4.2.0=h85742a9_0
- libuuid =1.0.3=h7f8727e_2
- libwebp =1.2.2=h55f646e_0
- libwebp-base =1.2.2=h7f8727e_0
- libxcb =1.14=h7b6447c_0
- libxml2 =2.9.12=h03d6c58_0
- llvmlite =0.37.0=py39h295c915_1
- lz4-c =1.9.3=h295c915_1
- matplotlib =3.5.1=py39h06a4308_1
- matplotlib-base =3.5.1=py39ha18d171_1
- mkl =2021.4.0=h06a4308_640
- mkl-service =2.4.0=py39h7f8727e_0
- mkl_fft =1.3.1=py39hd3c417c_0
- mkl_random =1.2.2=py39h51133e4_0
- munkres =1.1.4=py_0
- ncurses =6.3=h7f8727e_2
- numba =0.54.1=py39h51133e4_0
- numpy =1.20.3=py39hf144106_0
- numpy-base =1.20.3=py39h74d4b33_0
- openssl =1.1.1m=h7f8727e_0
- packaging =21.3=pyhd3eb1b0_0
- pcre =8.45=h295c915_0
- pillow =9.0.1=py39h22f2fdc_0
- pip =21.2.4=py39h06a4308_0
- pyparsing =3.0.4=pyhd3eb1b0_0
- pyqt =5.9.2=py39h2531618_6
- python =3.9.7=h12debd9_1
- python-dateutil =2.8.2=pyhd3eb1b0_0
- pyyaml =6.0=py39h7f8727e_1
- qt =5.9.7=h5867ecd_1
- readline =8.1.2=h7f8727e_1
- setuptools =58.0.4=py39h06a4308_0
- sip =4.19.13=py39h295c915_0
- six =1.16.0=pyhd3eb1b0_1
- sqlite =3.38.0=hc218d9a_0
- tbb =2021.5.0=hd09550d_0
- tk =8.6.11=h1ccaba5_0
- tornado =6.1=py39h27cfd23_0
- tzdata =2021e=hda174b7_0
- wheel =0.37.1=pyhd3eb1b0_0
- xz =5.2.5=h7b6447c_0
- yaml =0.2.5=h7b6447c_0
- zlib =1.2.11=h7f8727e_4
- zstd =1.4.9=haebb681_0