Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gpu #30

Merged
merged 90 commits into from
Mar 26, 2021
Merged

Gpu #30

Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
585b8ed
changing cpu to use same example as gpu in Project folder. Changing g…
aniabrown Jul 14, 2020
175cdad
only for now
AlexJamesWright Aug 5, 2020
02e258b
Merged with master
AlexJamesWright Aug 5, 2020
eb8bb9e
GPU should now be match CPU
AlexJamesWright Aug 5, 2020
ba80bd0
Ready
AlexJamesWright Aug 5, 2020
b0df337
Outline HDF5- created files, began to edit Makefile.
smangham Aug 20, 2020
c2951d0
updated makefile to compile gtest with std=c++11 to work on more cuda…
Aug 24, 2020
0ab3cae
added FlowKHSingleFluid unit test. Changed project to use KHSingleFlu…
Aug 24, 2020
1c5ff45
updated main functions in Project/CPU and Project/GPU to simulate the…
aniabrown Aug 25, 2020
6c89018
switching back to Project/main with implemented model etc, to better …
aniabrown Aug 25, 2020
aa84670
adding platformEnv files
aniabrown Aug 25, 2020
f984cb4
adding platformEnv to Data
aniabrown Aug 25, 2020
86cd8be
added env to Simulation
aniabrown Aug 25, 2020
6b265a7
Update the initFunc for KHI (also some stuff related to interactive p…
AlexJamesWright Aug 25, 2020
0568b6f
added new API for saving data
aniabrown Aug 26, 2020
e879fb8
split out compiling and final linking into nvcc/g++, to prepare for a…
aniabrown Sep 1, 2020
30ff577
adding parallel BCS files
aniabrown Sep 1, 2020
de65862
attempt at building with mpicc, not yet working
aniabrown Sep 1, 2020
a62c51e
changed build strategy -- build everything with nvcc and link MPI lib…
aniabrown Sep 1, 2020
9c248d1
merged fix to KHInstability from gpu_alex
aniabrown Sep 1, 2020
e9c5b24
fix to bcs for parallel version
aniabrown Sep 1, 2020
ee4992a
shortening time. Comparison to CPU version passes at this reduced end…
aniabrown Sep 1, 2020
aa04e14
Added serial HDF5 content, parallel HDF5 outlines, examples for both.…
smangham Sep 16, 2020
4671878
tweaking srmhd.cu so that it matches the CPU version (both versions r…
aniabrown Sep 21, 2020
425beae
Some documentation changes, edits to parallel example file, added MPI…
smangham Sep 21, 2020
849d285
debugging tweaks. Reverse later
aniabrown Sep 22, 2020
e247098
debugging tweaks. Reverse later
aniabrown Sep 22, 2020
6812845
moving SRMHD::getPrimitiveVars to GPU. In progress, needs debugging
aniabrown Sep 22, 2020
dbdaf55
gpu version no longer failing to converge in getPrims but still gives…
aniabrown Sep 22, 2020
ac37273
reversing changes made for debugging
aniabrown Sep 23, 2020
3ee82f2
fixing typo that was causing bug in getPrimitiveVars
aniabrown Sep 23, 2020
adf419b
cleaning up makefile
aniabrown Sep 28, 2020
192749e
updated getPrimitiveVars on SRMHD to only send prims and aux required…
aniabrown Sep 30, 2020
d83af68
adding back multiple streams to GPU version
aniabrown Sep 30, 2020
d27bac2
Refactor to use HDF5 C interface, added scripts to compare serial and…
smangham Oct 2, 2020
f735f3f
Merge branch 'master' of https://github.com/AlexJamesWright/METHOD in…
smangham Oct 2, 2020
768aa18
Commented out HDF5 for Travis purposes.
smangham Oct 2, 2020
72ed1e6
adding hdf5 tests
aniabrown Oct 21, 2020
acd9f72
adding hdf5 unit tests
aniabrown Oct 21, 2020
48258a5
fixed typo in srrmhd related to printing var names
aniabrown Oct 21, 2020
0cfb51a
updating hdf5 tests to run through pytest
aniabrown Oct 26, 2020
4d0c6a4
small cleanup
aniabrown Oct 26, 2020
a059940
fixed bugs that were causing hdf5 tests to not run
aniabrown Oct 26, 2020
01c5801
converted half of non-MPI GPU tests to use platformEnv API
aniabrown Oct 28, 2020
ccf9704
finished converting serial GPU tests to use platformEnv object
aniabrown Nov 3, 2020
e1880d9
Store the order of the variables in cons prims and aux for use in int…
AlexJamesWright Nov 11, 2020
284ab54
allow for use of h5py when storing in .h5 format
AlexJamesWright Nov 11, 2020
d2b9bed
Ignore h5 test executables
AlexJamesWright Nov 11, 2020
2b59afe
adding instructions and submission files for running CPU tests on Iri…
aniabrown Nov 16, 2020
ce60a7a
forgot to git commit script to convert text to hdf5 for all text outp…
aniabrown Nov 16, 2020
058dd07
added module loads to iridis python venv setup
aniabrown Nov 17, 2020
f3cb108
Merging those commits from hdf5_alex into dev_hdf5 that don't break o…
aniabrown Nov 17, 2020
b067ac0
adding directories for hdf5 testing
aniabrown Nov 17, 2020
de0228e
adding more directories to makePaths
aniabrown Nov 17, 2020
3a3437a
simplifying makefile to hopefully run locally
aniabrown Nov 17, 2020
7aecf2b
adding tests to compare gpu with and without MPI
aniabrown Nov 17, 2020
709359e
added instructions for running gpu tests on iridis 5
aniabrown Nov 17, 2020
bed02a7
splitting tests into non-python and python to make setting up module …
aniabrown Nov 23, 2020
7a0cfb3
updating BrioWuSingleFluid for MPI; adding parallel tests
aniabrown Nov 30, 2020
5dab772
forgetting to add files to git
aniabrown Nov 30, 2020
33768e4
added non-MPI restart from checkpoint file
aniabrown Dec 9, 2020
5637202
adding initial files for mpi-based checkpoint restart
aniabrown Dec 16, 2020
2395f22
changing mpi cartesian comm to always be periodic regardless of bcs, …
aniabrown Jan 5, 2021
79a6bb5
adding example code for MPI checkpoint restart
aniabrown Jan 6, 2021
e7cf548
git repo fix -- adding include files for mpi checkpoint restart
aniabrown Jan 6, 2021
a3c115c
putting cpu and gpu iridis instructions in the same place
aniabrown Jan 6, 2021
9fd16ee
small fix to main file
aniabrown Jan 8, 2021
0ece0d6
resolving merge conflicts
aniabrown Jan 8, 2021
e7b5062
adding initial files for hdf5 and checkpoint restart, copying from cp…
aniabrown Jan 8, 2021
490764b
continuing to modify gpu version for hdf5 and checkpoint restart
aniabrown Jan 11, 2021
478fa06
updating project makefile for checkpoint restart
aniabrown Jan 11, 2021
60957c1
small bug fix to serial checkpoint restart
aniabrown Jan 12, 2021
919f483
small fix to project makefile with checkpoint restart
aniabrown Jan 12, 2021
ad3492b
removing hard coded value from example codes
aniabrown Jan 12, 2021
de16673
adding example checkpoint file; cleaning up makefile
aniabrown Jan 14, 2021
7bd3cc1
Merge branch 'dev_hdf5' into gpu
aniabrown Jan 18, 2021
d89ce8b
updating tests makefile to use mpicc rather than hard code mpi librar…
aniabrown Jan 19, 2021
8e623a3
adding serial hdf5 to gpu tests
aniabrown Jan 19, 2021
a19f45a
adding serial hdf5 to gpu tests
aniabrown Jan 19, 2021
ea5548e
updating test makefile to run hdf5 on ubuntu
aniabrown Jan 19, 2021
d8af18d
use hdf5 comparison script in gpu tests
aniabrown Jan 19, 2021
d87d993
adding parallel HDF5 to gpu tests
aniabrown Jan 20, 2021
6e6f5c7
fixing a typo which lead to the latest cpu and gpu instructions for i…
aniabrown Jan 22, 2021
3a03cbf
fixing a typo which lead to the latest cpu and gpu instructions for i…
aniabrown Jan 22, 2021
59a0809
standardising gpu project and test makefile
aniabrown Jan 22, 2021
0920b8c
add Scripts to gpu test python path
aniabrown Jan 22, 2021
7717aee
Merge branch 'gpu_dev' into gpu
aniabrown Jan 25, 2021
8827b78
remove unecessary line from makefile
aniabrown Jan 29, 2021
ce306cd
fixing small error in Project makefile
aniabrown Feb 18, 2021
5f5fa1a
removing hard coded path from iridis scripts
aniabrown Mar 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ test_parallel_rk2
test_parallel_rkSplit
test_rkSplit
test_weno
test_hdf5_parallel_rk2
test_hdf5_rk2

test_*.o
!test_*.cc
gtest_main.a
gtest.a

*.dat
*.hdf5

Doxumentation/html/*

Expand All @@ -37,11 +40,21 @@ runMultipleSims.sh
cleanData.sh

.cache

ProfileParallel.nvvp

slurm*

# Don't track the data files!
Data
Tests/TestData
Examples/Data*
Scripts/Data*

# Ignore the build directories
build

# Don't track files from the docker mount
dockermount
# Don't track files from the virtual environment or IDE
venv
.idea
193 changes: 193 additions & 0 deletions Examples/KelvinHelmholtz/SingleFluidIdealRandomMPIHDF5/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
# Make file for the main function. Builds all modules
# and links for main.cc

# Compiler
CC = mpic++
##CC = g++

USE_MPI = 1
USE_OMP = 1
USE_HDF = 1

PROJECT_TYPE = CPU

# Module directory
MODULE_DIR = ./../../../Project/${PROJECT_TYPE}/Src

# Rootfinder directory
RTFIND_DIR = ./../../../Project/${PROJECT_TYPE}/CminpackLibrary

# Include directory
INC_DIR = ./../../../Project/${PROJECT_TYPE}/Include

# Cminpack include directory
RTFIND_INC_DIR = ./../../../Project/${PROJECT_TYPE}/CminpackLibrary/Include

# Cminpack source directory
RTFIND_SRC_DIR = ./../../../Project/${PROJECT_TYPE}//CminpackLibrary/Src

ifeq ($(USE_OMP), 1)
OMP_FLAGS = -fopenmp
endif

# C++ compiler flags
CXXFLAGS = -Wall -std=c++11 -O3 $(OMP_FLAGS) -Wno-unknown-pragmas

# Sources
SRCS = simulation.cc \
srmhd.cc \
initFunc.cc \
simData.cc \
wenoUpwinds.cc \
weno.cc \
RK2.cc \
rkSplit.cc \
boundaryConds.cc \
fluxVectorSplitting.cc \

SERIAL_SRCS = serialSaveData.cc \
serialEnv.cc

ifeq ($(USE_HDF), 1)
SERIAL_SRCS += serialSaveDataHDF5.cc
endif

PARALLEL_SRCS = parallelSaveData.cc \
parallelBoundaryConds.cc \
parallelEnv.cc

ifeq ($(USE_HDF), 1)
PARALLEL_SRCS += parallelSaveDataHDF5.cc
endif

ifeq ($(USE_MPI), 1)
SRCS += ${PARALLEL_SRCS}
else
SRCS += ${SERIAL_SRCS}
endif

ifeq ($(USE_HDF), 1)
export HDF5_CXX := $(CC)
export HDF5_CLINKER := $(CC)

ifeq ($(USE_OMP), 1)
CC = h5pcc.openmpi
else
CC = h5c++
endif
endif

# Headers
HDRS = ${SRCS:.cc=.h} cudaErrorCheck.h

# Objects
OBJS = ${SRCS:.cc=.o}

# Rootfinder objects
RTFIND_OBJS = $(RTFIND_SRC_DIR)/dogleg.o \
$(RTFIND_SRC_DIR)/dpmpar.o \
$(RTFIND_SRC_DIR)/enorm.o \
$(RTFIND_SRC_DIR)/fdjac1.o \
$(RTFIND_SRC_DIR)/hybrd.o \
$(RTFIND_SRC_DIR)/hybrd1.o \
$(RTFIND_SRC_DIR)/qform.o \
$(RTFIND_SRC_DIR)/qrfac.o \
$(RTFIND_SRC_DIR)/r1mpyq.o \
$(RTFIND_SRC_DIR)/r1updt.o

# Programmes
PROGS = ${SRCS:.cc=}

# Main programme executable
EXEC = main

# Rootfinder executables
RTFIND = buildRootfinder


# Build everything
build : $(RTFIND) $(EXEC)

# Make and run all tests on simulation scripts and run main
all : $(RTFIND) $(EXEC)
cd $(TEST_DIR) && $(MAKE) test
@$(MAKE) run

# Build and run main (does not run any tests if called explicitly)
run : $(RTFIND) $(EXEC)
@echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
@echo ''
@echo ''
@echo '######################################################'
@echo '# Executing main programme #'
@echo '######################################################'
@./$(EXEC)

clean :
rm -f $(EXEC) *.o *.gch


#################
# Build objects #
#################

simData.o : $(MODULE_DIR)/simData.cc $(INC_DIR)/simData.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

initFunc.o : $(MODULE_DIR)/initFunc.cc $(INC_DIR)/initFunc.h $(INC_DIR)/simData.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

srmhd.o : $(MODULE_DIR)/srmhd.cc $(INC_DIR)/srmhd.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR) -I$(RTFIND_INC_DIR)

simulation.o : $(MODULE_DIR)/simulation.cc $(INC_DIR)/simulation.h $(INC_DIR)/model.h $(INC_DIR)/simData.h $(INC_DIR)/saveData.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

main.o : ./main.cc $(INC_DIR)/simulation.h $(INC_DIR)/model.h $(INC_DIR)/simData.h $(INC_DIR)/initFunc.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR) -I$(RTFIND_INC_DIR) $(CXXFLAGS)

wenoUpwinds.o : $(MODULE_DIR)/wenoUpwinds.cc $(INC_DIR)/wenoUpwinds.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

weno.o : $(MODULE_DIR)/weno.cc $(INC_DIR)/weno.h $(INC_DIR)/wenoUpwinds.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

RK2.o : $(MODULE_DIR)/RK2.cc $(INC_DIR)/RK2.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

rkSplit.o : $(MODULE_DIR)/rkSplit.cc $(INC_DIR)/rkSplit.h $(INC_DIR)/RK2.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

boundaryConds.o : $(MODULE_DIR)/boundaryConds.cc $(INC_DIR)/boundaryConds.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

parallelBoundaryConds.o : $(MODULE_DIR)/parallelBoundaryConds.cc $(INC_DIR)/parallelBoundaryConds.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

serialSaveData.o : $(MODULE_DIR)/serialSaveData.cc $(INC_DIR)/serialSaveData.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

serialSaveDataHDF5.o : $(MODULE_DIR)/serialSaveDataHDF5.cc $(INC_DIR)/serialSaveDataHDF5.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

parallelSaveData.o : $(MODULE_DIR)/parallelSaveData.cc $(INC_DIR)/parallelSaveData.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

parallelSaveDataHDF5.o : $(MODULE_DIR)/parallelSaveDataHDF5.cc $(INC_DIR)/parallelSaveDataHDF5.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

fluxVectorSplitting.o : $(MODULE_DIR)/fluxVectorSplitting.cc $(INC_DIR)/fluxVectorSplitting.h $(INC_DIR)/weno.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

serialEnv.o : $(MODULE_DIR)/serialEnv.cc $(INC_DIR)/serialEnv.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

parallelEnv.o : $(MODULE_DIR)/parallelEnv.cc $(INC_DIR)/parallelEnv.h
$(CC) $< -c $(CXXFLAGS) -I$(INC_DIR)

# Executable
main : main.o $(OBJS) $(RTFIND_OBJS)
$(CC) $^ -o $@ $(CXXFLAGS) $(CXXFLAGS)

buildRootfinder:
@cd $(RTFIND_DIR) && $(MAKE) objects
56 changes: 56 additions & 0 deletions Examples/KelvinHelmholtz/SingleFluidIdealRandomMPIHDF5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Model
-----
- Ideal MHD



Initial data
------------
- Kelvin-Helmholtz instability with random perturbation



InteractivePlot help
--------------------
- This is a 2D problem, so we want to plot heatmaps. After running
interactivePlot.py, use

`Plot.plotHeatMaps()`

to plot the primitive variables as heatmaps.

- Use

`help(Plot.plotHeatMaps)`

for more information about plotting heatmaps.



Animation help
--------------
- This is a great simulations to generate animations with. Running animation.py
as main will save a gif of the density evolution in the Examples/ directory.



Notes
-----
- As this is a 2D simulation, it will take significantly longer to run. Expect
this to take five minutes or so to generate the timeseries data.

- If you have the time, I recommend running a higher resolution simulation of
this. It is aesthetically pleasing!

- This simulation should be run using `make main` and then `./main seed` where
`seed` is some integar seed for the random perturbation on the layer.


Parallel version -- current limitations
---------------------------------------
- Save data gathers all state vectors to proc0 so while this version will be faster, it doesn't currently allow a larger problem to be simulated than will fit on one node
- nx, ny, nz must currently be even multiple of nxRanks, nyRanks, nzRanks, and these must be specified as args to PlatformEnv manually.
- nxRanks x nyRanks x nzRanks must match the total number of processes launched
- Save data does not include boundary cells


89 changes: 89 additions & 0 deletions Examples/KelvinHelmholtz/SingleFluidIdealRandomMPIHDF5/main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Serial main
#include "simData.h"
#include "simulation.h"
#include "initFunc.h"
#include "srmhd.h"
#include "parallelBoundaryConds.h"
#include "rkSplit.h"
#include "fluxVectorSplitting.h"
#include "parallelSaveDataHDF5.h"
#include "platformEnv.h"
#include "weno.h"
#include <cstring>

using namespace std;

int main(int argc, char *argv[]) {


// Set up domain
int Ng(4);
int nx(64);
int ny(64);
int nz(0);
double xmin(0.0);
double xmax(1.0);
double ymin(0.0);
double ymax(1.0);
double zmin(0.0);
double zmax(1.0);
double endTime(3.0);
double cfl(0.6);
double gamma(4.0/3.0);
double sigma(10);
double cp(1.0);
double mu1(-100);
double mu2(100);
int frameSkip(10);
bool output(false);
if (argc != 2) throw std::invalid_argument("Expected ./main seed!\n");
int seed(atoi(argv[1]));

double nxRanks(2);
double nyRanks(2);
double nzRanks(1);

ParallelEnv env(&argc, &argv, nxRanks, nyRanks, nzRanks);

Data data(nx, ny, nz, xmin, xmax, ymin, ymax, zmin, zmax, endTime, &env,
cfl, Ng, gamma, sigma, cp, mu1, mu2, frameSkip);

// Choose particulars of simulation
SRMHD model(&data);

Weno3 weno(&data);

FVS fluxMethod(&data, &weno, &model);

ParallelPeriodic bcs(&data, &env);

Simulation sim(&data, &env);

if (env.rank==0){
printf("Seed: %d\n", seed);
}

KHRandomInstabilitySingleFluid init(&data, 1, seed);

RKSplit timeInt(&data, &model, &bcs, &fluxMethod);

ParallelSaveDataHDF5 save(&data, &env, "data_parallel", ParallelSaveDataHDF5::OUTPUT_ALL);

// Now objects have been created, set up the simulation
sim.set(&init, &model, &timeInt, &bcs, &fluxMethod, &save);

// Time execution of programme
//double startTime(omp_get_wtime());

// Run until end time and save results
sim.evolve(output);

//double timeTaken(omp_get_wtime() - startTime);

save.saveAll();
//printf("\nRuntime: %.5fs\nCompleted %d iterations.\n", timeTaken, data.iters);
if(env.rank==0) printf("\nCompleted %d iterations.\n", data.iters);

return 0;

}
Loading