Skip to content

Commit

Permalink
Merged with benchmark rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
CKehl committed Nov 20, 2020
1 parent b51fb3f commit 041147d
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 40 deletions.
12 changes: 8 additions & 4 deletions parcels/kernel_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,17 @@ def execute_jit(self, pset, endtime, dt):
g.load_chunk = np.where(g.load_chunk == 1, 2, g.load_chunk)
if len(g.load_chunk) > 0: # not the case if a field in not called in the kernel
if not g.load_chunk.flags.c_contiguous:
g.load_chunk = g.load_chunk.copy()
# g.load_chunk = g.load_chunk.copy()
g.load_chunk = np.array(g.load_chunk, order='C')
if not g.depth.flags.c_contiguous:
g.depth = g.depth.copy()
# g.depth = g.depth.copy()
g.depth = np.array(g.depth, order='C')
if not g.lon.flags.c_contiguous:
g.lon = g.lon.copy()
# g.lon = g.lon.copy()
g.lon = np.array(g.lon, order='C')
if not g.lat.flags.c_contiguous:
g.lat = g.lat.copy()
# g.lat = g.lat.copy()
g.lat = np.array(g.lat, order='C')
self._mem_io_timings.stop_timing()
self._mem_io_timings.accumulate_timing()

Expand Down
6 changes: 0 additions & 6 deletions parcels/particleset_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,6 @@ def execute(self, pyfunc=AdvectionRK4, endtime=None, runtime=None, dt=1.,
self.total_log.stop_timing()
self.total_log.accumulate_timing()
mem_B_used_total = 0
# if MPI:
# mpi_comm = MPI.COMM_WORLD
# mem_B_used = self.process.memory_info().rss
# mem_B_used_total = mpi_comm.reduce(mem_B_used, op=MPI.SUM, root=0)
# else:
# mem_B_used_total = self.process.memory_info().rss
mem_B_used_total = self.process.memory_info().rss
self.mem_log.advance_iteration(mem_B_used_total)

Expand Down
2 changes: 1 addition & 1 deletion parcels/tools/performance_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@ def advance_iteration(self, param):
else:
self._params.append(param)
self._samples.append(self._iter)
self._iter += 1
self._iter += 1
1 change: 0 additions & 1 deletion performance/benchmark_CMEMS.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ def perIterGC():

if MPI:
mpi_comm = MPI.COMM_WORLD
# mpi_comm.Barrier()
Nparticles = mpi_comm.reduce(np.array(pset.nparticle_log.get_params()), op=MPI.SUM, root=0)
Nmem = mpi_comm.reduce(np.array(pset.mem_log.get_params()), op=MPI.SUM, root=0)
if mpi_comm.Get_rank() == 0:
Expand Down
3 changes: 1 addition & 2 deletions performance/benchmark_deep_migration_NPacific.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def DeleteParticle(particle, fieldset, time):
def perIterGC():
gc.collect()

def getclosest_ij(lats,lons,latpt,lonpt):
def getclosest_ij(lats,lons,latpt,lonpt):
"""Function to find the index of the closest point to a certain lon/lat value."""
dist_sq = (lats-latpt)**2 + (lons-lonpt)**2 # find squared distance of every point on grid
minindex_flattened = dist_sq.argmin() # 1D index of minimum dist_sq element
Expand Down Expand Up @@ -436,7 +436,6 @@ def Profiles(particle, fieldset, time):

if MPI:
mpi_comm = MPI.COMM_WORLD
# mpi_comm.Barrier()
Nparticles = mpi_comm.reduce(np.array(pset.nparticle_log.get_params()), op=MPI.SUM, root=0)
Nmem = mpi_comm.reduce(np.array(pset.mem_log.get_params()), op=MPI.SUM, root=0)
if mpi_comm.Get_rank() == 0:
Expand Down
1 change: 0 additions & 1 deletion performance/benchmark_galapagos_backwards.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def periodicBC(particle, fieldSet, time):

if MPI:
mpi_comm = MPI.COMM_WORLD
# mpi_comm.Barrier()
Nparticles = mpi_comm.reduce(np.array(pset.nparticle_log.get_params()), op=MPI.SUM, root=0)
Nmem = mpi_comm.reduce(np.array(pset.mem_log.get_params()), op=MPI.SUM, root=0)
if mpi_comm.Get_rank() == 0:
Expand Down
1 change: 0 additions & 1 deletion performance/benchmark_palaeo_Y2K.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ class DinoParticle(JITParticle):

if MPI:
mpi_comm = MPI.COMM_WORLD
# mpi_comm.Barrier()
Nparticles = mpi_comm.reduce(np.array(pset.nparticle_log.get_params()), op=MPI.SUM, root=0)
Nmem = mpi_comm.reduce(np.array(pset.mem_log.get_params()), op=MPI.SUM, root=0)
if mpi_comm.Get_rank() == 0:
Expand Down
16 changes: 0 additions & 16 deletions performance/benchmark_perlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,15 @@ def perlin_fieldset_from_numpy(periodic_wrap=False):

# Coordinates of the test fieldset (on A-grid in deg)
lon = np.linspace(-a*0.5, a*0.5, img_shape[0], dtype=np.float32)
# sys.stdout.write("lon field: {}\n".format(lon.size))
lat = np.linspace(-b*0.5, b*0.5, img_shape[1], dtype=np.float32)
# sys.stdout.write("lat field: {}\n".format(lat.size))
totime = tsteps*tscale*24.0*60.0*60.0
time = np.linspace(0., totime, tsteps, dtype=np.float64)
# sys.stdout.write("time field: {}\n".format(time.size))

# Define arrays U (zonal), V (meridional)
U = perlin2d.generate_fractal_noise_temporal2d(img_shape, tsteps, (perlinres[1], perlinres[2]), noctaves, perlin_persistence, max_shift=((-1, 2), (-1, 2)))
U = np.transpose(U, (0,2,1))
# U = np.swapaxes(U, 1, 2)
# print("U-statistics - min: {:10.7f}; max: {:10.7f}; avg. {:10.7f}; std_dev: {:10.7f}".format(U.min(initial=0), U.max(initial=0), U.mean(), U.std()))
V = perlin2d.generate_fractal_noise_temporal2d(img_shape, tsteps, (perlinres[1], perlinres[2]), noctaves, perlin_persistence, max_shift=((-1, 2), (-1, 2)))
V = np.transpose(V, (0,2,1))
# V = np.swapaxes(V, 1, 2)
# print("V-statistics - min: {:10.7f}; max: {:10.7f}; avg. {:10.7f}; std_dev: {:10.7f}".format(V.min(initial=0), V.max(initial=0), V.mean(), V.std()))

# U = perlin3d.generate_fractal_noise_3d(img_shape, perlinres, noctaves, perlin_persistence) * scalefac
# U = np.transpose(U, (0,2,1))
# sys.stdout.write("U field shape: {} - [tdim][ydim][xdim]=[{}][{}][{}]\n".format(U.shape, time.shape[0], lat.shape[0], lon.shape[0]))
# V = perlin3d.generate_fractal_noise_3d(img_shape, perlinres, noctaves, perlin_persistence) * scalefac
# V = np.transpose(V, (0,2,1))
# sys.stdout.write("V field shape: {} - [tdim][ydim][xdim]=[{}][{}][{}]\n".format(V.shape, time.shape[0], lat.shape[0], lon.shape[0]))

data = {'U': U, 'V': V}
dimensions = {'time': time, 'lon': lon, 'lat': lat}
if periodic_wrap:
Expand Down Expand Up @@ -419,7 +404,6 @@ def Age(particle, fieldset, time):

if MPI:
mpi_comm = MPI.COMM_WORLD
# mpi_comm.Barrier()
Nparticles = mpi_comm.reduce(np.array(pset.nparticle_log.get_params()), op=MPI.SUM, root=0)
Nmem = mpi_comm.reduce(np.array(pset.mem_log.get_params()), op=MPI.SUM, root=0)
if mpi_comm.Get_rank() == 0:
Expand Down
9 changes: 1 addition & 8 deletions performance/benchmark_stommel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from parcels import AdvectionEE, AdvectionRK45, AdvectionRK4
from parcels import FieldSet, ScipyParticle, JITParticle, Variable, AdvectionRK4, ErrorCode
from parcels.particleset_benchmark import ParticleSet_Benchmark as ParticleSet
# from parcels.kernel_benchmark import Kernel_Benchmark as Kernel
from parcels.field import VectorField, NestedField, SummedField
# from parcels.kernel_benchmark import Kernel_Benchmark as Kernel
# from parcels import plotTrajectoriesFile_loadedField
from datetime import timedelta as delta
import math
Expand Down Expand Up @@ -388,11 +388,8 @@ def Age(particle, fieldset, time):
mpi_comm = MPI.COMM_WORLD
mpi_rank = mpi_comm.Get_rank()
if mpi_rank==0:
# starttime = ostime.time()
# starttime = MPI.Wtime()
starttime = ostime.process_time()
else:
# starttime = ostime.time()
starttime = ostime.process_time()
kernels = pset.Kernel(AdvectionRK4,delete_cfiles=True)
if agingParticles:
Expand All @@ -416,11 +413,8 @@ def Age(particle, fieldset, time):
mpi_comm = MPI.COMM_WORLD
mpi_rank = mpi_comm.Get_rank()
if mpi_rank==0:
# endtime = ostime.time()
# endtime = MPI.Wtime()
endtime = ostime.process_time()
else:
#endtime = ostime.time()
endtime = ostime.process_time()

if MPI:
Expand Down Expand Up @@ -456,7 +450,6 @@ def Age(particle, fieldset, time):

if MPI:
mpi_comm = MPI.COMM_WORLD
# mpi_comm.Barrier()
Nparticles = mpi_comm.reduce(np.array(pset.nparticle_log.get_params()), op=MPI.SUM, root=0)
Nmem = mpi_comm.reduce(np.array(pset.mem_log.get_params()), op=MPI.SUM, root=0)
if mpi_comm.Get_rank() == 0:
Expand Down

0 comments on commit 041147d

Please sign in to comment.