diff --git a/parcels/kernel_benchmark.py b/parcels/kernel_benchmark.py index 52ea86ff25..efdabfa03c 100644 --- a/parcels/kernel_benchmark.py +++ b/parcels/kernel_benchmark.py @@ -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() diff --git a/parcels/particleset_benchmark.py b/parcels/particleset_benchmark.py index 87460f4c78..57992bfe18 100644 --- a/parcels/particleset_benchmark.py +++ b/parcels/particleset_benchmark.py @@ -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) diff --git a/parcels/tools/performance_logger.py b/parcels/tools/performance_logger.py index a5ccf05874..421aa31e0a 100644 --- a/parcels/tools/performance_logger.py +++ b/parcels/tools/performance_logger.py @@ -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 \ No newline at end of file diff --git a/performance/benchmark_CMEMS.py b/performance/benchmark_CMEMS.py index 50dad75fa8..004e9d29d0 100644 --- a/performance/benchmark_CMEMS.py +++ b/performance/benchmark_CMEMS.py @@ -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: diff --git a/performance/benchmark_deep_migration_NPacific.py b/performance/benchmark_deep_migration_NPacific.py index 22b9c56815..c872973c9e 100644 --- a/performance/benchmark_deep_migration_NPacific.py +++ b/performance/benchmark_deep_migration_NPacific.py @@ -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 @@ -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: diff --git a/performance/benchmark_galapagos_backwards.py b/performance/benchmark_galapagos_backwards.py index ab55302d6b..c30452080a 100644 --- a/performance/benchmark_galapagos_backwards.py +++ b/performance/benchmark_galapagos_backwards.py @@ -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: diff --git a/performance/benchmark_palaeo_Y2K.py b/performance/benchmark_palaeo_Y2K.py index 415ff69bc4..32e3a93e6b 100644 --- a/performance/benchmark_palaeo_Y2K.py +++ b/performance/benchmark_palaeo_Y2K.py @@ -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: diff --git a/performance/benchmark_perlin.py b/performance/benchmark_perlin.py index 3b09723ccf..8752319251 100644 --- a/performance/benchmark_perlin.py +++ b/performance/benchmark_perlin.py @@ -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: @@ -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: diff --git a/performance/benchmark_stommel.py b/performance/benchmark_stommel.py index f6304c80cd..54af7fdb86 100644 --- a/performance/benchmark_stommel.py +++ b/performance/benchmark_stommel.py @@ -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 @@ -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: @@ -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: @@ -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: