From 86ddb3ceb361f37904f48d14b28d8497d89c8022 Mon Sep 17 00:00:00 2001 From: Kevin Stratford Date: Wed, 12 Jun 2024 09:09:00 +0100 Subject: [PATCH 1/2] Replace run-time vector length --- tests/unit/test_kernel_3d.c | 2 ++ tests/unit/test_kernel_3d_v.c | 28 +++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/tests/unit/test_kernel_3d.c b/tests/unit/test_kernel_3d.c index 8af06ba3..152e3d74 100644 --- a/tests/unit/test_kernel_3d.c +++ b/tests/unit/test_kernel_3d.c @@ -277,6 +277,8 @@ int test_kernel_3d_cs_index(pe_t * pe) { tdpAssert( tdpDeviceSynchronize() ); } + cs_free(cs); + return ifail; } diff --git a/tests/unit/test_kernel_3d_v.c b/tests/unit/test_kernel_3d_v.c index 2e08e1b6..3c5baf19 100644 --- a/tests/unit/test_kernel_3d_v.c +++ b/tests/unit/test_kernel_3d_v.c @@ -269,10 +269,12 @@ __global__ void test_kernel_3d_v_coords_kernel(kernel_3d_v_t k3v, cs_t * cs) { int kindex = 0; + assert(k3v.nsimdvl == NSIMDVL); + for_simt_parallel(kindex, k3v.kiterations, k3v.nsimdvl) { - int icv[k3v.nsimdvl]; - int jcv[k3v.nsimdvl]; - int kcv[k3v.nsimdvl]; + int icv[NSIMDVL]; + int jcv[NSIMDVL]; + int kcv[NSIMDVL]; kernel_3d_v_coords(&k3v, kindex, icv, jcv, kcv); for (int iv = 0; iv < k3v.nsimdvl; iv++) { int ic = icv[iv]; @@ -295,11 +297,13 @@ __global__ void test_kernel_3d_v_mask_kernel(kernel_3d_v_t k3v) { int kindex = 0; + assert(k3v.nsimdvl == NSIMDVL); + for_simt_parallel(kindex, k3v.kiterations, k3v.nsimdvl) { - int icv[k3v.nsimdvl]; - int jcv[k3v.nsimdvl]; - int kcv[k3v.nsimdvl]; - int maskv[k3v.nsimdvl]; + int icv[NSIMDVL]; + int jcv[NSIMDVL]; + int kcv[NSIMDVL]; + int maskv[NSIMDVL]; kernel_3d_v_coords(&k3v, kindex, icv, jcv, kcv); kernel_3d_v_mask(&k3v, icv, jcv, kcv, maskv); @@ -340,11 +344,13 @@ __global__ void test_kernel_3d_v_cs_index_kernel(kernel_3d_v_t k3v, cs_t *cs) { int kindex = 0; + assert(k3v.nsimdvl == NSIMDVL); + for_simt_parallel(kindex, k3v.kiterations, k3v.nsimdvl) { - int icv[k3v.nsimdvl]; - int jcv[k3v.nsimdvl]; - int kcv[k3v.nsimdvl]; - int indexv[k3v.nsimdvl]; + int icv[NSIMDVL]; + int jcv[NSIMDVL]; + int kcv[NSIMDVL]; + int indexv[NSIMDVL]; kernel_3d_v_coords(&k3v, kindex, icv, jcv, kcv); kernel_3d_v_cs_index(&k3v, icv, jcv, kcv, indexv); From aae6cf87d818032556953dce3cbb5277d18660ee Mon Sep 17 00:00:00 2001 From: Kevin Stratford Date: Wed, 12 Jun 2024 09:09:32 +0100 Subject: [PATCH 2/2] Release memory correction --- src/advection.c | 16 ++++++++++++---- src/ewald.c | 8 +++++++- src/io_impl_mpio.c | 3 ++- src/wall.c | 9 ++++++++- tests/unit/test_fe_electro.c | 4 +++- tests/unit/test_fe_electro_symm.c | 4 +++- tests/unit/test_lb_bc_outflow_rhou.c | 4 +++- tests/unit/test_psi_solver_options.c | 4 +++- tests/unit/test_psi_sor.c | 8 +++++++- 9 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/advection.c b/src/advection.c index 8af26904..aae9cc88 100644 --- a/src/advection.c +++ b/src/advection.c @@ -280,10 +280,18 @@ __host__ int advflux_free(advflux_t * obj) { tdpFree(obj->target); } - free(obj->fe); - free(obj->fw); - free(obj->fy); - free(obj->fz); + if (obj->le == NULL) { + free(obj->fx); + free(obj->fy); + free(obj->fz); + } + else { + free(obj->fe); + free(obj->fw); + free(obj->fy); + free(obj->fz); + } + free(obj); return 0; diff --git a/src/ewald.c b/src/ewald.c index a66d70c8..aa6ecff5 100644 --- a/src/ewald.c +++ b/src/ewald.c @@ -10,7 +10,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2007-2023 The University of Edinburgh. + * (c) 2007-2024 The University of Edinburgh. * * Contributing authors: * Grace Kim @@ -135,6 +135,12 @@ int ewald_create(pe_t * pe, cs_t * cs, double mu_input, double rc_input, int ewald_free(ewald_t * ewald) { assert(ewald); + + free(sinx_); + free(cosx_); + free(sinkr_); + free(coskr_); + free(ewald); return 0; diff --git a/src/io_impl_mpio.c b/src/io_impl_mpio.c index 5da3c765..9ffe9406 100644 --- a/src/io_impl_mpio.c +++ b/src/io_impl_mpio.c @@ -13,7 +13,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2022 The University of Edinburgh + * (c) 2022-2024 The University of Edinburgh * * Kevin Stratford (kevin@epcc.ed.ac.uk) * @@ -274,6 +274,7 @@ int io_impl_mpio_write_end(io_impl_mpio_t * io) { assert(io); MPI_File_write_all_end(io->fh, io->super.aggr->buf, &io->status); + MPI_File_close(&io->fh); return 0; } diff --git a/src/wall.c b/src/wall.c index 8e562763..6050e89c 100644 --- a/src/wall.c +++ b/src/wall.c @@ -9,7 +9,7 @@ * Edinburgh Soft Matter and Statistical Physics and * Edinburgh Parallel Computing Centre * - * (c) 2011-2023 The University of Edinburgh + * (c) 2011-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -150,10 +150,17 @@ __host__ int wall_free(wall_t * wall) { cs_free(wall->cs); free(wall->param); + + /* slip quantities */ + if (wall->linkk) free(wall->linkk); + if (wall->linkq) free(wall->linkq); + if (wall->links) free(wall->links); + if (wall->linki) free(wall->linki); if (wall->linkj) free(wall->linkj); if (wall->linkp) free(wall->linkp); if (wall->linku) free(wall->linku); + free(wall); return 0; diff --git a/tests/unit/test_fe_electro.c b/tests/unit/test_fe_electro.c index 0c3094c6..0dac0171 100644 --- a/tests/unit/test_fe_electro.c +++ b/tests/unit/test_fe_electro.c @@ -7,7 +7,7 @@ * Edinburgh Soft Matter and Statistical Phsyics Group and * Edinburgh Parallel Computing Centre * - * (c) 2014-2023 The University of Edinburgh + * (c) 2014-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -183,6 +183,7 @@ int do_test2(pe_t * pe, cs_t * cs, physics_t * phys) { assert(cs); assert(phys); + /* We need a slightly better way to construct nk /= 2 case */ { int nhalo = 0; cs_nhalo(cs, &nhalo); @@ -194,6 +195,7 @@ int do_test2(pe_t * pe, cs_t * cs, physics_t * phys) { opts.valency[0] = valency[0]; opts.valency[1] = valency[1]; opts.valency[2] = valency[2]; + opts.rho = field_options_ndata_nhalo(3, nhalo); psi_create(pe, cs, &opts, &psi); } } diff --git a/tests/unit/test_fe_electro_symm.c b/tests/unit/test_fe_electro_symm.c index f2d28be5..b66700c0 100644 --- a/tests/unit/test_fe_electro_symm.c +++ b/tests/unit/test_fe_electro_symm.c @@ -7,7 +7,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2013-2023 The University of Edinburgh + * (c) 2013-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -145,6 +145,8 @@ static int do_test1(pe_t * pe) { /* Finish. */ fe_es_free(fe); + fe_symm_free(fe_symm); + fe_electro_free(fe_elec); field_grad_free(dphi); field_free(phi); psi_free(&psi); diff --git a/tests/unit/test_lb_bc_outflow_rhou.c b/tests/unit/test_lb_bc_outflow_rhou.c index 30063daa..e193ce42 100644 --- a/tests/unit/test_lb_bc_outflow_rhou.c +++ b/tests/unit/test_lb_bc_outflow_rhou.c @@ -6,7 +6,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2021-2022 The University of Edinburgh + * (c) 2021-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -82,6 +82,8 @@ __host__ int test_lb_bc_outflow_rhou_create(pe_t * pe, cs_t * cs) { assert(outflow->linki); assert(outflow->linkj); + lb_bc_outflow_rhou_free(outflow); + return 0; } diff --git a/tests/unit/test_psi_solver_options.c b/tests/unit/test_psi_solver_options.c index 54b36e01..7d7b4282 100644 --- a/tests/unit/test_psi_solver_options.c +++ b/tests/unit/test_psi_solver_options.c @@ -6,7 +6,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2023 The University of Edinburgh + * (c) 2023-2024 The University of Edinburgh * * Kevin Stratford (kevin@epcc.ed.ac.uk) * @@ -292,6 +292,8 @@ int test_psi_solver_options_from_json(void) { assert(fabs(pso.abstol - 0.02) < DBL_EPSILON); } + cJSON_Delete(json); + return ifail; } diff --git a/tests/unit/test_psi_sor.c b/tests/unit/test_psi_sor.c index a97f874d..79dd4748 100644 --- a/tests/unit/test_psi_sor.c +++ b/tests/unit/test_psi_sor.c @@ -7,7 +7,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2012-2023 The University of Edinburgh + * (c) 2012-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -96,6 +96,9 @@ int test_psi_solver_sor_create(pe_t * pe) { assert(sor == NULL); } + psi_free(&psi); + cs_free(cs); + return ifail; } @@ -192,6 +195,9 @@ int test_psi_solver_sor_var_epsilon_create(pe_t * pe) { assert(sor == NULL); } + psi_free(&psi); + cs_free(cs); + return ifail; }