mirror of
https://github.com/smyalygames/FiniteVolumeGPU_HIP.git
synced 2025-12-24 13:29:17 +01:00
Compare commits
5 Commits
main
...
aa21733806
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa21733806 | ||
|
|
5a27445de8 | ||
|
|
cd69f69080 | ||
|
|
9761ff4924 | ||
|
|
5931cee93f |
@@ -35,6 +35,8 @@ import gc
|
|||||||
import netCDF4
|
import netCDF4
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from tqdm import trange
|
||||||
|
|
||||||
#import pycuda.compiler as cuda_compiler
|
#import pycuda.compiler as cuda_compiler
|
||||||
#import pycuda.gpuarray
|
#import pycuda.gpuarray
|
||||||
#import pycuda.driver as cuda
|
#import pycuda.driver as cuda
|
||||||
@@ -178,8 +180,8 @@ def runSimulation(simulator, simulator_args, outfile, save_times, save_var_names
|
|||||||
profiling_data_sim_runner["end"]["t_sim_init"] = time.time()
|
profiling_data_sim_runner["end"]["t_sim_init"] = time.time()
|
||||||
|
|
||||||
#Start simulation loop
|
#Start simulation loop
|
||||||
progress_printer = ProgressPrinter(save_times[-1], print_every=10)
|
# progress_printer = ProgressPrinter(save_times[-1], print_every=10)
|
||||||
for k in range(len(save_times)):
|
for k in trange(len(save_times)):
|
||||||
#Get target time and step size there
|
#Get target time and step size there
|
||||||
t_step = t_steps[k]
|
t_step = t_steps[k]
|
||||||
t_end = save_times[k]
|
t_end = save_times[k]
|
||||||
@@ -211,9 +213,9 @@ def runSimulation(simulator, simulator_args, outfile, save_times, save_var_names
|
|||||||
profiling_data_sim_runner["end"]["t_nc_write"] += time.time()
|
profiling_data_sim_runner["end"]["t_nc_write"] += time.time()
|
||||||
|
|
||||||
#Write progress to screen
|
#Write progress to screen
|
||||||
print_string = progress_printer.getPrintString(t_end)
|
# print_string = progress_printer.getPrintString(t_end)
|
||||||
if (print_string):
|
# if (print_string):
|
||||||
logger.debug(print_string)
|
# logger.debug(print_string)
|
||||||
|
|
||||||
logger.debug("Simulated to t={:f} in {:d} timesteps (average dt={:f})".format(t_end, sim.simSteps(), sim.simTime() / sim.simSteps()))
|
logger.debug("Simulated to t={:f} in {:d} timesteps (average dt={:f})".format(t_end, sim.simSteps(), sim.simTime() / sim.simSteps()))
|
||||||
|
|
||||||
@@ -433,58 +435,58 @@ class DataDumper(object):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ProgressPrinter(object):
|
# class ProgressPrinter(object):
|
||||||
"""
|
# """
|
||||||
Small helper class for
|
# Small helper class for
|
||||||
"""
|
# """
|
||||||
def __init__(self, total_steps, print_every=5):
|
# def __init__(self, total_steps, print_every=5):
|
||||||
self.logger = logging.getLogger(__name__)
|
# self.logger = logging.getLogger(__name__)
|
||||||
self.start = time.time()
|
# self.start = time.time()
|
||||||
self.total_steps = total_steps
|
# self.total_steps = total_steps
|
||||||
self.print_every = print_every
|
# self.print_every = print_every
|
||||||
self.next_print_time = self.print_every
|
# self.next_print_time = self.print_every
|
||||||
self.last_step = 0
|
# self.last_step = 0
|
||||||
self.secs_per_iter = None
|
# self.secs_per_iter = None
|
||||||
|
|
||||||
def getPrintString(self, step):
|
# def getPrintString(self, step):
|
||||||
elapsed = time.time() - self.start
|
# elapsed = time.time() - self.start
|
||||||
if (elapsed > self.next_print_time):
|
# if (elapsed > self.next_print_time):
|
||||||
dt = elapsed - (self.next_print_time - self.print_every)
|
# dt = elapsed - (self.next_print_time - self.print_every)
|
||||||
dsteps = step - self.last_step
|
# dsteps = step - self.last_step
|
||||||
steps_remaining = self.total_steps - step
|
# steps_remaining = self.total_steps - step
|
||||||
|
|
||||||
if (dsteps == 0):
|
# if (dsteps == 0):
|
||||||
return
|
# return
|
||||||
|
|
||||||
self.last_step = step
|
# self.last_step = step
|
||||||
self.next_print_time = elapsed + self.print_every
|
# self.next_print_time = elapsed + self.print_every
|
||||||
|
|
||||||
if not self.secs_per_iter:
|
# if not self.secs_per_iter:
|
||||||
self.secs_per_iter = dt / dsteps
|
# self.secs_per_iter = dt / dsteps
|
||||||
self.secs_per_iter = 0.2*self.secs_per_iter + 0.8*(dt / dsteps)
|
# self.secs_per_iter = 0.2*self.secs_per_iter + 0.8*(dt / dsteps)
|
||||||
|
|
||||||
remaining_time = steps_remaining * self.secs_per_iter
|
# remaining_time = steps_remaining * self.secs_per_iter
|
||||||
|
|
||||||
return "{:s}. Total: {:s}, elapsed: {:s}, remaining: {:s}".format(
|
# return "{:s}. Total: {:s}, elapsed: {:s}, remaining: {:s}".format(
|
||||||
ProgressPrinter.progressBar(step, self.total_steps),
|
# ProgressPrinter.progressBar(step, self.total_steps),
|
||||||
ProgressPrinter.timeString(elapsed + remaining_time),
|
# ProgressPrinter.timeString(elapsed + remaining_time),
|
||||||
ProgressPrinter.timeString(elapsed),
|
# ProgressPrinter.timeString(elapsed),
|
||||||
ProgressPrinter.timeString(remaining_time))
|
# ProgressPrinter.timeString(remaining_time))
|
||||||
|
|
||||||
def timeString(seconds):
|
# def timeString(seconds):
|
||||||
seconds = int(max(seconds, 1))
|
# seconds = int(max(seconds, 1))
|
||||||
minutes, seconds = divmod(seconds, 60)
|
# minutes, seconds = divmod(seconds, 60)
|
||||||
hours, minutes = divmod(minutes, 60)
|
# hours, minutes = divmod(minutes, 60)
|
||||||
periods = [('h', hours), ('m', minutes), ('s', seconds)]
|
# periods = [('h', hours), ('m', minutes), ('s', seconds)]
|
||||||
time_string = ' '.join('{}{}'.format(value, name)
|
# time_string = ' '.join('{}{}'.format(value, name)
|
||||||
for name, value in periods
|
# for name, value in periods
|
||||||
if value)
|
# if value)
|
||||||
return time_string
|
# return time_string
|
||||||
|
|
||||||
def progressBar(step, total_steps, width=30):
|
# def progressBar(step, total_steps, width=30):
|
||||||
progress = np.round(width * step / total_steps).astype(np.int32)
|
# progress = np.round(width * step / total_steps).astype(np.int32)
|
||||||
progressbar = "0% [" + "#"*(progress) + "="*(width-progress) + "] 100%"
|
# progressbar = "0% [" + "#"*(progress) + "="*(width-progress) + "] 100%"
|
||||||
return progressbar
|
# return progressbar
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import numpy as np
|
|||||||
import math
|
import math
|
||||||
import logging
|
import logging
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
|
from tqdm import tqdm
|
||||||
|
|
||||||
#import pycuda.compiler as cuda_compiler
|
#import pycuda.compiler as cuda_compiler
|
||||||
#import pycuda.gpuarray
|
#import pycuda.gpuarray
|
||||||
@@ -156,7 +157,7 @@ class BaseSimulator(object):
|
|||||||
self.num_substeps = num_substeps
|
self.num_substeps = num_substeps
|
||||||
|
|
||||||
#Handle autotuning block size
|
#Handle autotuning block size
|
||||||
if (self.context.autotuner):
|
if self.context.autotuner:
|
||||||
peak_configuration = self.context.autotuner.get_peak_performance(self.__class__)
|
peak_configuration = self.context.autotuner.get_peak_performance(self.__class__)
|
||||||
block_width = int(peak_configuration["block_width"])
|
block_width = int(peak_configuration["block_width"])
|
||||||
block_height = int(peak_configuration["block_height"])
|
block_height = int(peak_configuration["block_height"])
|
||||||
@@ -195,42 +196,45 @@ class BaseSimulator(object):
|
|||||||
Requires that the step() function is implemented in the subclasses
|
Requires that the step() function is implemented in the subclasses
|
||||||
"""
|
"""
|
||||||
|
|
||||||
printer = Common.ProgressPrinter(t)
|
# printer = Common.ProgressPrinter(t)
|
||||||
|
|
||||||
t_start = self.simTime()
|
t_start = self.simTime()
|
||||||
t_end = t_start + t
|
t_end = t_start + t
|
||||||
|
|
||||||
update_dt = True
|
update_dt = True
|
||||||
if (dt is not None):
|
if dt is not None:
|
||||||
update_dt = False
|
update_dt = False
|
||||||
self.dt = dt
|
self.dt = dt
|
||||||
|
|
||||||
while(self.simTime() < t_end):
|
for _ in tqdm(range(math.ceil(t_end / self.dt))):
|
||||||
# Update dt every 100 timesteps and cross your fingers it works
|
# Update dt every 100 timesteps and cross your fingers it works
|
||||||
# for the next 100
|
# for the next 100
|
||||||
if (update_dt and (self.simSteps() % 100 == 0)):
|
# TODO this is probably broken now after fixing the "infinite" loop
|
||||||
|
if update_dt and (self.simSteps() % 100 == 0):
|
||||||
self.dt = self.computeDt()*self.cfl_scale
|
self.dt = self.computeDt()*self.cfl_scale
|
||||||
|
|
||||||
# Compute timestep for "this" iteration (i.e., shorten last timestep)
|
# Compute timestep for "this" iteration (i.e., shorten last timestep)
|
||||||
current_dt = np.float32(min(self.dt, t_end-self.simTime()))
|
current_dt = np.float32(min(self.dt, t_end-self.simTime()))
|
||||||
|
|
||||||
# Stop if end reached (should not happen)
|
# Stop if end reached (should not happen)
|
||||||
if (current_dt <= 0.0):
|
if current_dt <= 0.0:
|
||||||
self.logger.warning("Timestep size {:d} is less than or equal to zero!".format(self.simSteps()))
|
self.logger.warning("Timestep size {:d} is less than or equal to zero!".format(self.simSteps()))
|
||||||
break
|
break
|
||||||
|
|
||||||
# Step forward in time
|
# Step forward in time
|
||||||
self.step(current_dt)
|
self.step(current_dt)
|
||||||
|
|
||||||
#Print info
|
#Print info
|
||||||
print_string = printer.getPrintString(self.simTime() - t_start)
|
# print_string = printer.getPrintString(self.simTime() - t_start)
|
||||||
if (print_string):
|
# if (print_string):
|
||||||
self.logger.info("%s: %s", self, print_string)
|
# self.logger.info("%s: %s", self, print_string)
|
||||||
try:
|
# try:
|
||||||
self.check()
|
# self.check()
|
||||||
except AssertionError as e:
|
# except AssertionError as e:
|
||||||
e.args += ("Step={:d}, time={:f}".format(self.simSteps(), self.simTime()),)
|
# e.args += ("Step={:d}, time={:f}".format(self.simSteps(), self.simTime()),)
|
||||||
raise
|
# raise
|
||||||
|
|
||||||
|
print("Done")
|
||||||
|
|
||||||
|
|
||||||
def step(self, dt):
|
def step(self, dt):
|
||||||
|
|||||||
@@ -19,18 +19,18 @@ Mydir=/project/project_4650000xx
|
|||||||
Myapplication=${Mydir}/FiniteVolumeGPU_hip/mpiTesting.py
|
Myapplication=${Mydir}/FiniteVolumeGPU_hip/mpiTesting.py
|
||||||
|
|
||||||
#modules
|
#modules
|
||||||
ml LUMI/23.03 partition/G
|
ml LUMI/24.03 partition/G
|
||||||
ml lumi-container-wrapper
|
ml lumi-container-wrapper
|
||||||
ml cray-python/3.9.13.1
|
ml cray-python/3.11.7
|
||||||
ml rocm/5.2.3
|
ml rocm/6.2.2
|
||||||
|
|
||||||
ml craype-accel-amd-gfx90a
|
ml craype-accel-amd-gfx90a
|
||||||
ml cray-mpich/8.1.27
|
ml cray-mpich/8.1.29
|
||||||
|
|
||||||
export PATH="/project/project_4650000xx/FiniteVolumeGPU_hip/MyCondaEnv/bin:$PATH"
|
export PATH="/project/project_4650000xx/FiniteVolumeGPU_hip/MyCondaEnv/bin:$PATH"
|
||||||
|
|
||||||
#missing library
|
#missing library
|
||||||
export LD_LIBRARY_PATH=/opt/cray/pe/mpich/8.1.27/ofi/cray/14.0/lib-abi-mpich:$LD_LIBRARY_PATH
|
export LD_LIBRARY_PATH=/opt/cray/pe/mpich/8.1.29/ofi/cray/17.0/lib-abi-mpich:$LD_LIBRARY_PATH
|
||||||
|
|
||||||
#Binding mask
|
#Binding mask
|
||||||
bind_mask="0x${fe}000000000000,0x${fe}00000000000000,0x${fe}0000,0x${fe}000000,0x${fe},0x${fe}00,0x${fe}00000000,0x${fe}0000000000"
|
bind_mask="0x${fe}000000000000,0x${fe}00000000000000,0x${fe}0000,0x${fe}000000,0x${fe},0x${fe}00,0x${fe}00000000,0x${fe}0000000000"
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ This is a HIP version of the [FiniteVolume code](https://github.com/babrodtk/Fin
|
|||||||
## Setup on LUMI-G
|
## Setup on LUMI-G
|
||||||
Here is a step-by-step guide on installing packages on LUMI-G
|
Here is a step-by-step guide on installing packages on LUMI-G
|
||||||
|
|
||||||
### Step 1: Install rocm-5.2.5 with Easybuild
|
### Step 1: Install rocm-5.4.6 with Easybuild
|
||||||
```
|
```
|
||||||
export EBU_USER_PREFIX=/project/project_xxxxxx/EasyBuild
|
export EBU_USER_PREFIX=/project/project_xxxxxx/EasyBuild
|
||||||
ml LUMI/24.03 partition/G
|
ml LUMI/24.03 partition/G
|
||||||
ml EasyBuild-user
|
ml EasyBuild-user
|
||||||
export PYTHONIOENCODING=utf-8
|
export PYTHONIOENCODING=utf-8
|
||||||
eb rocm-5.2.5.eb -r
|
eb rocm-5.4.6.eb -r
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 2: run conda-container
|
### Step 2: run conda-container
|
||||||
|
|||||||
@@ -5,15 +5,17 @@ channels:
|
|||||||
- conda-forge
|
- conda-forge
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- python=3.9.13
|
- python=3.11.7
|
||||||
|
- pip
|
||||||
- numpy
|
- numpy
|
||||||
- mpi4py
|
- mpi4py
|
||||||
- six
|
- six
|
||||||
- pytools
|
- pytools
|
||||||
- netcdf4
|
- netcdf4
|
||||||
- scipy
|
- scipy
|
||||||
|
- tqdm
|
||||||
- pip:
|
- pip:
|
||||||
- hip-python==5.4.3.470.16
|
- hip-python==6.2.0.499.16
|
||||||
- -i https://test.pypi.org/simple/
|
- -i https://test.pypi.org/simple/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ def genSim(grid, **kwargs):
|
|||||||
return sim
|
return sim
|
||||||
|
|
||||||
|
|
||||||
outfile, sim_runner_profiling_data, sim_profiling_data = Common.runSimulation(
|
(outfile, sim_runner_profiling_data, sim_profiling_data) = Common.runSimulation(
|
||||||
genSim, arguments, outfile, save_times, save_var_names, dt)
|
genSim, arguments, outfile, save_times, save_var_names, dt)
|
||||||
|
|
||||||
if(args.profile):
|
if(args.profile):
|
||||||
|
|||||||
Reference in New Issue
Block a user