From 90dda9022688a9c7543404ca8f11835a3912b567 Mon Sep 17 00:00:00 2001 From: Kevin Stratford Date: Fri, 4 Oct 2024 12:52:57 +0000 Subject: [PATCH] Check all tdp return values --- src/advection.c | 34 +-- src/blue_phase.c | 4 +- src/blue_phase_beris_edwards.c | 4 +- src/brazovskii.c | 26 +- src/cahn_hilliard.c | 4 +- src/cahn_hilliard_stats.c | 2 +- src/colloids.c | 6 +- src/coords.c | 12 +- src/distribution_rt.c | 2 +- src/fe_electro.c | 8 +- src/fe_electro_symmetric.c | 12 +- src/fe_null.c | 8 +- src/fe_ternary.c | 6 +- src/field.c | 59 ++--- src/field_grad.c | 111 ++++----- src/gradient_3d_7pt_solid.c | 12 +- src/gradient_s7_anchoring.c | 16 +- src/halo_swap.c | 382 +++++++++++++++--------------- src/hydro.c | 8 +- src/lb_data.c | 64 ++--- src/lc_droplet.c | 23 +- src/leesedwards.c | 17 +- src/ludwig.c | 4 +- src/map.c | 14 +- src/noise.c | 6 +- src/pe.c | 4 +- src/phi_cahn_hilliard.c | 2 +- src/phi_force_colloid.c | 8 +- src/phi_force_stress.c | 36 +-- src/phi_stats.c | 2 +- src/polar_active.c | 24 +- src/propagation.c | 2 +- src/stats_distribution.c | 4 +- src/surfactant.c | 14 +- src/symmetric.c | 28 +-- src/wall.c | 103 ++++---- target/target_x86.c | 8 +- tests/unit/test_blue_phase.c | 2 +- tests/unit/test_ch.c | 4 +- tests/unit/test_coords.c | 5 +- tests/unit/test_fe_electro.c | 2 +- tests/unit/test_fe_electro_symm.c | 3 +- tests/unit/test_fe_surfactant1.c | 4 +- tests/unit/test_fe_ternary.c | 4 +- tests/unit/test_field.c | 3 +- tests/unit/test_halo.c | 4 +- tests/unit/test_hydro.c | 2 +- tests/unit/test_polar_active.c | 4 +- tests/unit/test_prop.c | 4 +- tests/unit/test_visc_arrhenius.c | 4 +- 50 files changed, 570 insertions(+), 554 deletions(-) diff --git a/src/advection.c b/src/advection.c index aae9cc88f..a3ef32813 100644 --- a/src/advection.c +++ b/src/advection.c @@ -191,7 +191,7 @@ __host__ int advflux_create(pe_t * pe, cs_t * cs, lees_edw_t * le, int nf, /* Allocate target copy of structure (or alias) */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { obj->target = obj; @@ -260,24 +260,30 @@ __host__ int advflux_free(advflux_t * obj) { assert(obj); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) { if (obj->le == NULL) { - tdpMemcpy(&tmp, &obj->target->fx, sizeof(double *), tdpMemcpyDeviceToHost); - tdpFree(tmp); + tdpAssert( tdpMemcpy(&tmp, &obj->target->fx, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); } else { - tdpMemcpy(&tmp, &obj->target->fe, sizeof(double *), tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &obj->target->fw, sizeof(double *), tdpMemcpyDeviceToHost); - tdpFree(tmp); + tdpAssert( tdpMemcpy(&tmp, &obj->target->fe, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &obj->target->fw, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); } - tdpMemcpy(&tmp, &obj->target->fy, sizeof(double *), tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &obj->target->fz, sizeof(double *), tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpFree(obj->target); + + tdpAssert( tdpMemcpy(&tmp, &obj->target->fy, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &obj->target->fz, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpFree(obj->target) ); } if (obj->le == NULL) { @@ -373,7 +379,7 @@ __host__ int advflux_memcpy(advflux_t * adv, tdpMemcpyKind flag) { assert(adv); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { /* Ensure we alias */ diff --git a/src/blue_phase.c b/src/blue_phase.c index de6b1fbf9..3b2f3a786 100644 --- a/src/blue_phase.c +++ b/src/blue_phase.c @@ -118,7 +118,7 @@ __host__ int fe_lc_create(pe_t * pe, cs_t * cs, lees_edw_t * le, /* Allocate device memory, or alias */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { fe->target = fe; @@ -167,7 +167,7 @@ __host__ int fe_lc_free(fe_lc_t * fe) { assert(fe); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) tdpAssert(tdpFree(fe->target)); diff --git a/src/blue_phase_beris_edwards.c b/src/blue_phase_beris_edwards.c index 00cf15f33..b6b9a0fae 100644 --- a/src/blue_phase_beris_edwards.c +++ b/src/blue_phase_beris_edwards.c @@ -144,7 +144,7 @@ __host__ int beris_edw_create(pe_t * pe, cs_t * cs, lees_edw_t * le, /* Allocate a target copy, or alias */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { obj->target = obj; @@ -190,7 +190,7 @@ __host__ int beris_edw_free(beris_edw_t * be) { assert(be); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) { double * htmp; diff --git a/src/brazovskii.c b/src/brazovskii.c index 97c090c68..1ecead098 100644 --- a/src/brazovskii.c +++ b/src/brazovskii.c @@ -125,7 +125,7 @@ __host__ int fe_brazovskii_create(pe_t * pe, cs_t * cs, field_t * phi, /* Allocate device memory, or alias */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { obj->target = obj; @@ -133,19 +133,19 @@ __host__ int fe_brazovskii_create(pe_t * pe, cs_t * cs, field_t * phi, else { fe_brazovskii_param_t * tmp; fe_vt_t * vt; - tdpMalloc((void **) &obj->target, sizeof(fe_brazovskii_t)); - tdpMemset(obj->target, 0, sizeof(fe_brazovskii_t)); + tdpAssert( tdpMalloc((void **) &obj->target, sizeof(fe_brazovskii_t)) ); + tdpAssert( tdpMemset(obj->target, 0, sizeof(fe_brazovskii_t)) ); tdpGetSymbolAddress((void **) &tmp, tdpSymbol(const_param)); - tdpMemcpy(&obj->target->param, &tmp, sizeof(fe_brazovskii_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&obj->target->param, &tmp, sizeof(fe_brazovskii_t *), + tdpMemcpyHostToDevice) ); tdpGetSymbolAddress((void **) &vt, tdpSymbol(fe_braz_dvt)); - tdpMemcpy(&obj->target->super.func, &vt, sizeof(fe_vt_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&obj->target->super.func, &vt, sizeof(fe_vt_t *), + tdpMemcpyHostToDevice) ); - tdpMemcpy(&obj->target->phi, &phi->target, sizeof(field_t *), - tdpMemcpyHostToDevice); - tdpMemcpy(&obj->target->dphi, &dphi->target, sizeof(field_grad_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&obj->target->phi, &phi->target, sizeof(field_t *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMemcpy(&obj->target->dphi, &dphi->target, + sizeof(field_grad_t *), tdpMemcpyHostToDevice) ); } *p = obj; @@ -165,8 +165,8 @@ __host__ int fe_brazovskii_free(fe_brazovskii_t * fe) { assert(fe); - tdpGetDeviceCount(&ndevice); - if (ndevice > 0) tdpFree(fe->target); + tdpAssert( tdpGetDeviceCount(&ndevice) ); + if (ndevice > 0) tdpAssert( tdpFree(fe->target) ); free(fe->param); free(fe); diff --git a/src/cahn_hilliard.c b/src/cahn_hilliard.c index 2a95191e8..0ef1ec475 100644 --- a/src/cahn_hilliard.c +++ b/src/cahn_hilliard.c @@ -71,7 +71,7 @@ __host__ int ch_create(pe_t * pe, cs_t * cs, ch_info_t info, ch_t ** ch) { advflux_cs_create(pe, cs, info.nfield, &obj->flux); assert(obj->flux); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { obj->target = obj; @@ -109,7 +109,7 @@ __host__ int ch_free(ch_t * ch) { { int ndevice = 0; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) tdpAssert(tdpFree(ch->target)); } diff --git a/src/cahn_hilliard_stats.c b/src/cahn_hilliard_stats.c index 3d2c981a7..d5da6c932 100644 --- a/src/cahn_hilliard_stats.c +++ b/src/cahn_hilliard_stats.c @@ -209,7 +209,7 @@ __host__ int cahn_stats_reduce(phi_ch_t * pch, field_t * phi, MPI_Reduce(&local.max, &stats->max, 1, MPI_DOUBLE, MPI_MAX, root, comm); MPI_Reduce(&local.vol, &stats->vol, 1, MPI_DOUBLE, MPI_SUM, root, comm); - tdpFree(stats_d); + tdpAssert( tdpFree(stats_d) ); return 0; } diff --git a/src/colloids.c b/src/colloids.c index b85d069d4..cc72f5011 100644 --- a/src/colloids.c +++ b/src/colloids.c @@ -81,7 +81,7 @@ __host__ int colloids_info_create(pe_t * pe, cs_t * cs, int ncell[3], obj->rho0 = RHO_DEFAULT; obj->drmax = DRMAX_DEFAULT; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { obj->target = obj; @@ -184,7 +184,7 @@ __host__ int colloids_memcpy(colloids_info_t * info, int flag) { assert(info); assert(info->map_new); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { /* Bare pointer equality causes HIPCC to choke, hence explicit (()) */ @@ -284,7 +284,7 @@ __host__ int colloids_info_map_init(colloids_info_t * info) { /* Allocate data space on target */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) { void * tmp; diff --git a/src/coords.c b/src/coords.c index 5422d0a8a..70919e9dd 100644 --- a/src/coords.c +++ b/src/coords.c @@ -7,7 +7,7 @@ * Edinburgh Soft Matter and Statistical Physics and * Edinburgh Parallel Computing Centre * - * (c) 2010-2022 The University of Edinburgh + * (c) 2010-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -216,18 +216,18 @@ __host__ int cs_init(cs_t * cs) { /* Device side */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { cs->target = cs; } else { cs_param_t * tmp; - tdpMalloc((void **) &cs->target, sizeof(cs_t)); - tdpMemset(cs->target, 0, sizeof(cs_t)); + tdpAssert( tdpMalloc((void **) &cs->target, sizeof(cs_t)) ); + tdpAssert( tdpMemset(cs->target, 0, sizeof(cs_t)) ); tdpGetSymbolAddress((void **) &tmp, tdpSymbol(const_param)); - tdpMemcpy(&cs->target->param, (const void *) &tmp, sizeof(cs_param_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&cs->target->param, (const void *) &tmp, + sizeof(cs_param_t *), tdpMemcpyHostToDevice) ); cs_commit(cs); } diff --git a/src/distribution_rt.c b/src/distribution_rt.c index fcaf451fd..ec129963f 100644 --- a/src/distribution_rt.c +++ b/src/distribution_rt.c @@ -179,7 +179,7 @@ int lb_run_time_prev(pe_t * pe, cs_t * cs, rt_t * rt, lb_t ** lb) { * not as to disrupt the regression tests. */ { int ndevice = 0; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) options.halo = LB_HALO_TARGET; } diff --git a/src/fe_electro.c b/src/fe_electro.c index b4e475aaf..4f5ffa819 100644 --- a/src/fe_electro.c +++ b/src/fe_electro.c @@ -27,7 +27,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: * Oliver Henrich (ohenrich@epcc.ed.ac.uk) @@ -120,7 +120,7 @@ __host__ int fe_electro_create(pe_t * pe, psi_t * psi, fe_electro_t ** pobj) { fe->super.func = &fe_electro_hvt; fe->super.id = FE_ELECTRO; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { fe->target = fe; @@ -131,7 +131,7 @@ __host__ int fe_electro_create(pe_t * pe, psi_t * psi, fe_electro_t ** pobj) { fe_vt_t * vt = NULL; tdpAssert(tdpMalloc((void **) &fe->target, sizeof(fe_electro_t))); - tdpMemset(fe->target, 0, sizeof(fe_electro_t)); + tdpAssert( tdpMemset(fe->target, 0, sizeof(fe_electro_t)) ); tdpGetSymbolAddress((void **) &vt, tdpSymbol(fe_electro_dvt)); tdpAssert(tdpMemcpy(&fe->target->super.func, &vt, sizeof(fe_vt_t *), @@ -155,7 +155,7 @@ __host__ int fe_electro_free(fe_electro_t * fe) { assert(fe); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) tdpAssert(tdpFree(fe->target)); if (fe->mu_ref) free(fe->mu_ref); diff --git a/src/fe_electro_symmetric.c b/src/fe_electro_symmetric.c index 9e2917431..4575ae186 100644 --- a/src/fe_electro_symmetric.c +++ b/src/fe_electro_symmetric.c @@ -30,7 +30,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2013-2018 The University of Edinburgh + * (c) 2013-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -138,7 +138,7 @@ __host__ int fe_es_create(pe_t * pe, cs_t * cs, fe_symm_t * symm, psi_nk(psi, &fe->param->nk); fe_es_epsilon_set(fe, psi->epsilon, psi->epsilon2); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { fe->target = fe; @@ -147,10 +147,10 @@ __host__ int fe_es_create(pe_t * pe, cs_t * cs, fe_symm_t * symm, fe_vt_t * vt; fe_es_param_t * tmp; - tdpMalloc((void **) &fe->target, sizeof(fe_es_t)); + tdpAssert( tdpMalloc((void **) &fe->target, sizeof(fe_es_t)) ); tdpGetSymbolAddress((void **) &tmp, tdpSymbol(const_param)); - tdpMemcpy(&fe->target->param, tmp, sizeof(fe_es_param_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&fe->target->param, tmp, sizeof(fe_es_param_t *), + tdpMemcpyHostToDevice) ); tdpGetSymbolAddress((void **) &vt, tdpSymbol(fe_es_dvt)); } @@ -169,7 +169,7 @@ __host__ int fe_es_free(fe_es_t * fe) { assert(fe); - if (fe->target != fe) tdpFree(fe->target); + if (fe->target != fe) tdpAssert( tdpFree(fe->target) ); free(fe->param); free(fe); diff --git a/src/fe_null.c b/src/fe_null.c index 7d6fe8285..3cc48639d 100644 --- a/src/fe_null.c +++ b/src/fe_null.c @@ -8,7 +8,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 * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -79,7 +79,7 @@ __host__ int fe_null_create(pe_t * pe, fe_null_t ** p) { /* Allocate target memory, or alias */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { fe->target = fe; @@ -112,9 +112,9 @@ __host__ int fe_null_free(fe_null_t * fe) { assert(fe); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); - if (ndevice > 0) tdpFree(fe->target); + if (ndevice > 0) tdpAssert( tdpFree(fe->target) ); free(fe); return 0; diff --git a/src/fe_ternary.c b/src/fe_ternary.c index d4aa8a104..0bd5f7477 100644 --- a/src/fe_ternary.c +++ b/src/fe_ternary.c @@ -17,7 +17,7 @@ * Edinburgh Soft Matter and Statistical Physics Group * and Edinburgh Parallel Computing Centre * - * (c) 2019-2021 The University of Edinburgh + * (c) 2019-2024 The University of Edinburgh * * Contributing authors: * Shan Chen (shan.chen@epfl.ch) @@ -111,7 +111,7 @@ int fe_ternary_create(pe_t * pe, cs_t * cs, field_t * phi, /* Allocate target memory, or alias */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { obj->target = obj; @@ -163,7 +163,7 @@ __host__ int fe_ternary_free(fe_ternary_t * fe) { assert(fe); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) tdpAssert(tdpFree(fe->target)); free(fe->param); diff --git a/src/field.c b/src/field.c index bb216f232..a312dc297 100644 --- a/src/field.c +++ b/src/field.c @@ -48,7 +48,7 @@ __host__ int field_init(field_t * obj, int nhcomm, lees_edw_t * le); #include "mpi-ext.h" #endif -#ifdef __NVCC__ +#ifdef __HIPCC__ /* There are two file-scope switches here, which need to be generalised * via some suitable interface; they are separate, but both relate to * GPU execution. */ @@ -168,13 +168,13 @@ __host__ int field_free(field_t * obj) { assert(obj); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) { - tdpMemcpy(&tmp, &obj->target->data, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpFree(obj->target); + tdpAssert( tdpMemcpy(&tmp, &obj->target->data, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpFree(obj->target) ); } if (obj->data) free(obj->data); @@ -239,7 +239,7 @@ __host__ int field_init(field_t * obj, int nhcomm, lees_edw_t * le) { /* Allocate target copy of structure (or alias) */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { obj->target = obj; @@ -247,17 +247,17 @@ __host__ int field_init(field_t * obj, int nhcomm, lees_edw_t * le) { else { cs_t * cstarget = NULL; lees_edw_t * letarget = NULL; - tdpMalloc((void **) &obj->target, sizeof(field_t)); - tdpMalloc((void **) &tmp, nfsz*sizeof(double)); - tdpMemcpy(&obj->target->data, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &obj->target, sizeof(field_t)) ); + tdpAssert( tdpMalloc((void **) &tmp, nfsz*sizeof(double)) ); + tdpAssert( tdpMemcpy(&obj->target->data, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); cs_target(obj->cs, &cstarget); if (le) lees_edw_target(obj->le, &letarget); - tdpMemcpy(&obj->target->cs, &cstarget, sizeof(cs_t *), - tdpMemcpyHostToDevice); - tdpMemcpy(&obj->target->le, &letarget, sizeof(lees_edw_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&obj->target->cs, &cstarget, sizeof(cs_t *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMemcpy(&obj->target->le, &letarget, sizeof(lees_edw_t *), + tdpMemcpyHostToDevice) ); field_memcpy(obj, tdpMemcpyHostToDevice); } @@ -276,7 +276,7 @@ __host__ int field_memcpy(field_t * obj, tdpMemcpyKind flag) { size_t nfsz; double * tmp; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { /* Ensure we alias */ @@ -285,18 +285,18 @@ __host__ int field_memcpy(field_t * obj, tdpMemcpyKind flag) { else { nfsz = (size_t) obj->nf*obj->nsites; - tdpMemcpy(&tmp, &obj->target->data, sizeof(double *), - tdpMemcpyDeviceToHost); + tdpAssert( tdpMemcpy(&tmp, &obj->target->data, sizeof(double *), + tdpMemcpyDeviceToHost) ); switch (flag) { case tdpMemcpyHostToDevice: - tdpMemcpy(&obj->target->nf, &obj->nf, sizeof(int), flag); - tdpMemcpy(&obj->target->nhcomm, &obj->nhcomm, sizeof(int), flag); - tdpMemcpy(&obj->target->nsites, &obj->nsites, sizeof(int), flag); - tdpMemcpy(tmp, obj->data, nfsz*sizeof(double), flag); + tdpAssert( tdpMemcpy(&obj->target->nf, &obj->nf, sizeof(int), flag) ); + tdpAssert( tdpMemcpy(&obj->target->nhcomm, &obj->nhcomm, sizeof(int), flag) ); + tdpAssert( tdpMemcpy(&obj->target->nsites, &obj->nsites, sizeof(int), flag) ); + tdpAssert( tdpMemcpy(tmp, obj->data, nfsz*sizeof(double), flag) ); break; case tdpMemcpyDeviceToHost: - tdpMemcpy(obj->data, tmp, nfsz*sizeof(double), flag); + tdpAssert( tdpMemcpy(obj->data, tmp, nfsz*sizeof(double), flag) ); break; default: pe_fatal(obj->pe, "Bad flag in field_memcpy\n"); @@ -1393,8 +1393,8 @@ int field_halo_create(const field_t * field, field_halo_t * h) { /* Device */ - tdpGetDeviceCount(&ndevice); - tdpStreamCreate(&h->stream); + tdpAssert( tdpGetDeviceCount(&ndevice) ); + tdpAssert( tdpStreamCreate(&h->stream) ); if (ndevice == 0) { h->target = h; @@ -1608,7 +1608,8 @@ int field_halo_free(field_halo_t * h) { assert(h); int ndevice = 0; - tdpGetDeviceCount(&ndevice); + + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) { tdpAssert( tdpMemcpy(h->send_d, h->target->send, 27*sizeof(double *), @@ -1616,10 +1617,10 @@ int field_halo_free(field_halo_t * h) { tdpAssert( tdpMemcpy(h->recv_d, h->target->recv, 27*sizeof(double *), tdpMemcpyDeviceToHost) ); for (int p = 1; p < h->nvel; p++) { - tdpFree(h->send_d[p]); - tdpFree(h->recv_d[p]); + tdpAssert( tdpFree(h->send_d[p]) ); + tdpAssert( tdpFree(h->recv_d[p]) ); } - tdpFree(h->target); + tdpAssert( tdpFree(h->target) ); } for (int p = 1; p < h->nvel; p++) { diff --git a/src/field_grad.c b/src/field_grad.c index 27e553e08..8382a9441 100644 --- a/src/field_grad.c +++ b/src/field_grad.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) @@ -86,19 +86,20 @@ static int field_grad_init(field_grad_t * obj) { /* Failure in int32_t indexing ... */ if (INT_MAX < nfsz || nfsz < 1) return -1; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { obj->target = obj; } else { - tdpMalloc((void **) &obj->target, sizeof(field_grad_t)); - tdpMemset(obj->target, 0, sizeof(field_grad_t)); - tdpMemcpy(&obj->target->nf, &obj->nf, sizeof(int), tdpMemcpyHostToDevice); - tdpMemcpy(&obj->target->nsite, &obj->nsite, sizeof(int), - tdpMemcpyHostToDevice); - tdpMemcpy(&obj->target->field, &obj->field->target, sizeof(field_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &obj->target, sizeof(field_grad_t)) ); + tdpAssert( tdpMemset(obj->target, 0, sizeof(field_grad_t)) ); + tdpAssert( tdpMemcpy(&obj->target->nf, &obj->nf, sizeof(int), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMemcpy(&obj->target->nsite, &obj->nsite, sizeof(int), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMemcpy(&obj->target->field, &obj->field->target, + sizeof(field_t *), tdpMemcpyHostToDevice) ); } if (obj->level >= 2) { @@ -112,13 +113,13 @@ static int field_grad_init(field_grad_t * obj) { /* Allocate data space on target (or alias) */ if (ndevice > 0) { - tdpMalloc((void **) &tmp, nfsz*NVECTOR*sizeof(double)); - tdpMemcpy(&obj->target->grad, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, nfsz*NVECTOR*sizeof(double)) ); + tdpAssert( tdpMemcpy(&obj->target->grad, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); - tdpMalloc((void **) &tmp, nfsz*sizeof(double)); - tdpMemcpy(&obj->target->delsq, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, nfsz*sizeof(double)) ); + tdpAssert( tdpMemcpy(&obj->target->delsq, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); } } @@ -128,9 +129,9 @@ static int field_grad_init(field_grad_t * obj) { if (obj->d_ab == NULL) pe_fatal(obj->pe, "calloc(fieldgrad->d_ab) failed\n"); if (ndevice > 0) { - tdpMalloc((void **) &tmp, NSYMM*nfsz*sizeof(double)); - tdpMemcpy(&obj->target->d_ab, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, NSYMM*nfsz*sizeof(double)) ); + tdpAssert( tdpMemcpy(&obj->target->d_ab, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); } } @@ -141,13 +142,13 @@ static int field_grad_init(field_grad_t * obj) { if (obj->delsq_delsq == NULL) pe_fatal(obj->pe, "calloc(grad->delsq_delsq) failed"); if (ndevice > 0) { - tdpMalloc((void **) &tmp, NVECTOR*nfsz*sizeof(double)); - tdpMemcpy(&obj->target->grad_delsq, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, NVECTOR*nfsz*sizeof(double)) ); + tdpAssert( tdpMemcpy(&obj->target->grad_delsq, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); - tdpMalloc((void **) &tmp, nfsz*sizeof(double)); - tdpMemcpy(&obj->target->delsq_delsq, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, nfsz*sizeof(double)) ); + tdpAssert( tdpMemcpy(&obj->target->delsq_delsq, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); } } @@ -168,7 +169,7 @@ __host__ int field_grad_memcpy(field_grad_t * obj, tdpMemcpyKind flag) { assert(obj); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { /* Ensure we alias */ @@ -195,21 +196,23 @@ __host__ int field_grad_memcpy(field_grad_t * obj, tdpMemcpyKind flag) { switch (flag) { case tdpMemcpyHostToDevice: - tdpMemcpy(&obj->target->nf, &obj->nf, sizeof(int), - tdpMemcpyHostToDevice); - tdpMemcpy(&obj->target->nsite, &obj->nsite, sizeof(int), - tdpMemcpyHostToDevice); - - tdpMemcpy(grad, obj->grad, NVECTOR*nsz, tdpMemcpyHostToDevice); - tdpMemcpy(delsq, obj->delsq, nsz, tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&obj->target->nf, &obj->nf, sizeof(int), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMemcpy(&obj->target->nsite, &obj->nsite, sizeof(int), + tdpMemcpyHostToDevice) ); + + tdpAssert( tdpMemcpy(grad, obj->grad, NVECTOR*nsz, + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMemcpy(delsq, obj->delsq, nsz, tdpMemcpyHostToDevice) ); if (obj->level >= 4) { - tdpMemcpy(grad_delsq, obj->grad_delsq, NVECTOR*nsz, flag); - tdpMemcpy(delsq_delsq, obj->delsq_delsq, nsz, flag); + tdpAssert( tdpMemcpy(grad_delsq, obj->grad_delsq, NVECTOR*nsz, flag) ); + tdpAssert( tdpMemcpy(delsq_delsq, obj->delsq_delsq, nsz, flag) ); } break; case tdpMemcpyDeviceToHost: - tdpMemcpy(obj->grad, grad, NVECTOR*nsz, tdpMemcpyDeviceToHost); - tdpMemcpy(obj->delsq, delsq, nsz, tdpMemcpyDeviceToHost); + tdpAssert( tdpMemcpy(obj->grad, grad, NVECTOR*nsz, + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpy(obj->delsq, delsq, nsz, tdpMemcpyDeviceToHost) ); if (obj->level >= 4) { tdpAssert(tdpMemcpy(obj->grad_delsq, grad_delsq, nsz*NVECTOR, flag)); tdpAssert(tdpMemcpy(obj->delsq_delsq, delsq_delsq, nsz, flag)); @@ -273,26 +276,26 @@ __host__ void field_grad_free(field_grad_t * obj) { assert(obj); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) { - tdpMemcpy(&tmp, &obj->target->grad, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &obj->target->delsq, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &obj->target->d_ab, sizeof(double *), - tdpMemcpyDeviceToHost); - if (tmp) tdpFree(tmp); - tdpMemcpy(&tmp, &obj->target->grad_delsq, sizeof(double *), - tdpMemcpyDeviceToHost); - if (tmp) tdpFree(tmp); - tdpMemcpy(&tmp, &obj->target->delsq_delsq, sizeof(double *), - tdpMemcpyDeviceToHost); - if (tmp) tdpFree(tmp); - - tdpFree(obj->target); + tdpAssert( tdpMemcpy(&tmp, &obj->target->grad, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &obj->target->delsq, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &obj->target->d_ab, sizeof(double *), + tdpMemcpyDeviceToHost) ); + if (tmp) tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &obj->target->grad_delsq, sizeof(double *), + tdpMemcpyDeviceToHost) ); + if (tmp) tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &obj->target->delsq_delsq, sizeof(double *), + tdpMemcpyDeviceToHost) ); + if (tmp) tdpAssert( tdpFree(tmp) ); + + tdpAssert( tdpFree(obj->target) ); } if (obj->grad) free(obj->grad); diff --git a/src/gradient_3d_7pt_solid.c b/src/gradient_3d_7pt_solid.c index e5d07f6fc..680ad8d63 100644 --- a/src/gradient_3d_7pt_solid.c +++ b/src/gradient_3d_7pt_solid.c @@ -43,7 +43,7 @@ * Edinburgh Soft Matter and Statistical Physics Group 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) @@ -132,7 +132,7 @@ __host__ int grad_lc_anch_create(pe_t * pe, cs_t * cs, map_t * map, lc_anchoring_matrices(fep.kappa0, fep.kappa1, &obj->bc); } - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { obj->target = obj; @@ -140,7 +140,7 @@ __host__ int grad_lc_anch_create(pe_t * pe, cs_t * cs, map_t * map, else { /* Copy required entities over ... */ cs_t * tcs = NULL; - tdpMalloc((void **) &obj->target, sizeof(grad_lc_anch_t)); + tdpAssert( tdpMalloc((void **) &obj->target, sizeof(grad_lc_anch_t)) ); cs_target(obj->cs, &tcs); tdpAssert(tdpMemcpy(&obj->target->cs, &tcs, sizeof(cs_t *), @@ -172,7 +172,7 @@ __host__ int grad_lc_anch_free(grad_lc_anch_t * grad) { assert(grad); - if (grad->target != grad) tdpFree(grad->target); + if (grad->target != grad) tdpAssert( tdpFree(grad->target) ); free(grad); return 0; @@ -194,7 +194,7 @@ __host__ int grad_3d_7pt_solid_set(map_t * map, colloids_info_t * cinfo) { static_grad->map = map; static_grad->cinfo = cinfo; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice) { tdpAssert(tdpMemcpy(&static_grad->target->cinfo, &cinfo->target, sizeof(colloids_info_t *), tdpMemcpyHostToDevice)); @@ -271,7 +271,7 @@ int gradient_6x6(grad_lc_anch_t * anch, field_grad_t * fg, int nextra) { k3d, cstarget, anch->target, anch->fe->target, fg->target, anch->map->target); - tdpDeviceSynchronize(); + tdpAssert( tdpDeviceSynchronize() ); } return 0; diff --git a/src/gradient_s7_anchoring.c b/src/gradient_s7_anchoring.c index 3e9c7bb2c..2e5344b58 100644 --- a/src/gradient_s7_anchoring.c +++ b/src/gradient_s7_anchoring.c @@ -39,7 +39,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 * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -121,19 +121,19 @@ __host__ int grad_s7_anchoring_create(pe_t * pe, cs_t * cs, map_t * map, lc_anchoring_matrices(fep.kappa0, fep.kappa1, &obj->bc); } - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { obj->target = obj; } else { cs_t * cstarget = NULL; - tdpMalloc((void **) &obj->target, sizeof(grad_s7_anch_t)); - tdpMemset(obj->target, 0, sizeof(grad_s7_anch_t)); + tdpAssert( tdpMalloc((void **) &obj->target, sizeof(grad_s7_anch_t)) ); + tdpAssert( tdpMemset(obj->target, 0, sizeof(grad_s7_anch_t)) ); cs_target(obj->cs, &cstarget); - tdpMemcpy(&obj->target->cs, &cstarget, sizeof(cs_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&obj->target->cs, &cstarget, sizeof(cs_t *), + tdpMemcpyHostToDevice) ); tdpAssert(tdpMemcpy(&obj->target->bc, &obj->bc, sizeof(lc_anchoring_matrices_t), @@ -160,7 +160,7 @@ __host__ int grad_s7_anchoring_cinfo_set(colloids_info_t * cinfo) { static_grad->cinfo = cinfo; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) { tdpAssert(tdpMemcpy(&static_grad->target->cinfo, &cinfo->target, @@ -212,7 +212,7 @@ __host__ int grad_s7_anchoring_free(grad_s7_anch_t * grad) { assert(grad); - if (grad->target != grad) tdpFree(grad->target); + if (grad->target != grad) tdpAssert( tdpFree(grad->target) ); free(grad); diff --git a/src/halo_swap.c b/src/halo_swap.c index 4c10d3092..b0a789c61 100644 --- a/src/halo_swap.c +++ b/src/halo_swap.c @@ -7,7 +7,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2016-2020 The University of Edinburgh + * (c) 2016-2024 The University of Edinburgh * * Contributing authors: * Alan Gray (alang@epcc.ed.ac.uk) @@ -167,30 +167,30 @@ __host__ int halo_swap_create(pe_t * pe, cs_t * cs, int nhcomm, int naddr, /* Host buffers, actual and halo regions */ sz = (size_t) halo->param->hsz[X]*na*nb*sizeof(double); - tdpHostAlloc((void **) &halo->fxlo, sz, mflag); - tdpHostAlloc((void **) &halo->fxhi, sz, mflag); - tdpHostAlloc((void **) &halo->hxlo, sz, mflag); - tdpHostAlloc((void **) &halo->hxhi, sz, mflag); + tdpAssert( tdpHostAlloc((void **) &halo->fxlo, sz, mflag) ); + tdpAssert( tdpHostAlloc((void **) &halo->fxhi, sz, mflag) ); + tdpAssert( tdpHostAlloc((void **) &halo->hxlo, sz, mflag) ); + tdpAssert( tdpHostAlloc((void **) &halo->hxhi, sz, mflag) ); sz = (size_t) halo->param->hsz[Y]*na*nb*sizeof(double); - tdpHostAlloc((void **) &halo->fylo, sz, mflag); - tdpHostAlloc((void **) &halo->fyhi, sz, mflag); - tdpHostAlloc((void **) &halo->hylo, sz, mflag); - tdpHostAlloc((void **) &halo->hyhi, sz, mflag); + tdpAssert( tdpHostAlloc((void **) &halo->fylo, sz, mflag) ); + tdpAssert( tdpHostAlloc((void **) &halo->fyhi, sz, mflag) ); + tdpAssert( tdpHostAlloc((void **) &halo->hylo, sz, mflag) ); + tdpAssert( tdpHostAlloc((void **) &halo->hyhi, sz, mflag) ); sz = (size_t) halo->param->hsz[Z]*na*nb*sizeof(double); - tdpHostAlloc((void **) &halo->fzlo, sz, mflag); - tdpHostAlloc((void **) &halo->fzhi, sz, mflag); - tdpHostAlloc((void **) &halo->hzlo, sz, mflag); - tdpHostAlloc((void **) &halo->hzhi, sz, mflag); + tdpAssert( tdpHostAlloc((void **) &halo->fzlo, sz, mflag) ); + tdpAssert( tdpHostAlloc((void **) &halo->fzhi, sz, mflag) ); + tdpAssert( tdpHostAlloc((void **) &halo->hzlo, sz, mflag) ); + tdpAssert( tdpHostAlloc((void **) &halo->hzhi, sz, mflag) ); - tdpStreamCreate(&halo->stream[X]); - tdpStreamCreate(&halo->stream[Y]); - tdpStreamCreate(&halo->stream[Z]); + tdpAssert( tdpStreamCreate(&halo->stream[X]) ); + tdpAssert( tdpStreamCreate(&halo->stream[Y]) ); + tdpAssert( tdpStreamCreate(&halo->stream[Z]) ); /* Device buffers: allocate or alias */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { halo->target = halo; @@ -200,61 +200,61 @@ __host__ int halo_swap_create(pe_t * pe, cs_t * cs, int nhcomm, int naddr, halo_swap_param_t * tmpp; /* Target structure */ - tdpMalloc((void **) &halo->target, sizeof(halo_swap_t)); - tdpMemset(halo->target, 0, sizeof(halo_swap_t)); + tdpAssert( tdpMalloc((void **) &halo->target, sizeof(halo_swap_t)) ); + tdpAssert( tdpMemset(halo->target, 0, sizeof(halo_swap_t)) ); /* Buffers */ sz = (size_t) halo->param->hsz[X]*na*nb*sizeof(double); - tdpMalloc((void **) &tmp, sz); - tdpMemcpy(&halo->target->fxlo, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); - tdpMalloc((void **) &tmp, sz); - tdpMemcpy(&halo->target->fxhi, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, sz) ); + tdpAssert( tdpMemcpy(&halo->target->fxlo, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMalloc((void **) &tmp, sz) ); + tdpAssert( tdpMemcpy(&halo->target->fxhi, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); - tdpMalloc((void **) &tmp, sz); - tdpMemcpy(&halo->target->hxlo, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); - tdpMalloc((void **) & tmp, sz); - tdpMemcpy(&halo->target->hxhi, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, sz) ); + tdpAssert( tdpMemcpy(&halo->target->hxlo, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMalloc((void **) & tmp, sz) ); + tdpAssert( tdpMemcpy(&halo->target->hxhi, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); sz = (size_t) halo->param->hsz[Y]*na*nb*sizeof(double); - tdpMalloc((void ** ) &tmp, sz); - tdpMemcpy(&halo->target->fylo, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); - tdpMalloc((void **) &tmp, sz); - tdpMemcpy(&halo->target->fyhi, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void ** ) &tmp, sz) ); + tdpAssert( tdpMemcpy(&halo->target->fylo, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMalloc((void **) &tmp, sz) ); + tdpAssert( tdpMemcpy(&halo->target->fyhi, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); - tdpMalloc((void **) &tmp, sz); - tdpMemcpy(&halo->target->hylo, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); - tdpMalloc((void **) &tmp, sz); - tdpMemcpy(&halo->target->hyhi, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, sz) ); + tdpAssert( tdpMemcpy(&halo->target->hylo, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMalloc((void **) &tmp, sz) ); + tdpAssert( tdpMemcpy(&halo->target->hyhi, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); sz = (size_t) halo->param->hsz[Z]*na*nb*sizeof(double); - tdpMalloc((void **) &tmp, sz); - tdpMemcpy(&halo->target->fzlo, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); - tdpMalloc((void **) &tmp, sz); - tdpMemcpy(&halo->target->fzhi, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, sz) ); + tdpAssert( tdpMemcpy(&halo->target->fzlo, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMalloc((void **) &tmp, sz) ); + tdpAssert( tdpMemcpy(&halo->target->fzhi, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); - tdpMalloc((void **) &tmp, sz); - tdpMemcpy(&halo->target->hzlo, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); - tdpMalloc((void **) &tmp, sz); - tdpMemcpy(&halo->target->hzhi, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, sz) ); + tdpAssert( tdpMemcpy(&halo->target->hzlo, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMalloc((void **) &tmp, sz) ); + tdpAssert( tdpMemcpy(&halo->target->hzhi, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); tdpGetSymbolAddress((void **) &tmpp, tdpSymbol(const_param)); - tdpMemcpy(&halo->target->param, &tmpp, sizeof(halo_swap_param_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&halo->target->param, &tmpp, + sizeof(halo_swap_param_t *), tdpMemcpyHostToDevice) ); /* Device constants */ halo_swap_commit(halo); @@ -277,69 +277,69 @@ __host__ int halo_swap_free(halo_swap_t * halo) { assert(halo); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) { double * tmp; - tdpMemcpy(&tmp, &halo->target->fxlo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &halo->target->fxhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &halo->target->fylo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &halo->target->fyhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &halo->target->fzlo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &halo->target->fzhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - - tdpMemcpy(&tmp, &halo->target->hxlo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &halo->target->hxhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &halo->target->hylo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &halo->target->hyhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &halo->target->hzlo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &halo->target->hzhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - - tdpFree(halo->target); + tdpAssert( tdpMemcpy(&tmp, &halo->target->fxlo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &halo->target->fxhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &halo->target->fylo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &halo->target->fyhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &halo->target->fzlo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &halo->target->fzhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + + tdpAssert( tdpMemcpy(&tmp, &halo->target->hxlo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hxhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hylo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hyhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hzlo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hzhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + + tdpAssert( tdpFree(halo->target) ); } - tdpFreeHost(halo->fxlo); - tdpFreeHost(halo->fxhi); - tdpFreeHost(halo->fylo); - tdpFreeHost(halo->fyhi); - tdpFreeHost(halo->fzlo); - tdpFreeHost(halo->fzhi); + tdpAssert( tdpFreeHost(halo->fxlo) ); + tdpAssert( tdpFreeHost(halo->fxhi) ); + tdpAssert( tdpFreeHost(halo->fylo) ); + tdpAssert( tdpFreeHost(halo->fyhi) ); + tdpAssert( tdpFreeHost(halo->fzlo) ); + tdpAssert( tdpFreeHost(halo->fzhi) ); - tdpFreeHost(halo->hxlo); - tdpFreeHost(halo->hxhi); - tdpFreeHost(halo->hylo); - tdpFreeHost(halo->hyhi); - tdpFreeHost(halo->hzlo); - tdpFreeHost(halo->hzhi); + tdpAssert( tdpFreeHost(halo->hxlo) ); + tdpAssert( tdpFreeHost(halo->hxhi) ); + tdpAssert( tdpFreeHost(halo->hylo) ); + tdpAssert( tdpFreeHost(halo->hyhi) ); + tdpAssert( tdpFreeHost(halo->hzlo) ); + tdpAssert( tdpFreeHost(halo->hzhi) ); - tdpStreamDestroy(halo->stream[X]); - tdpStreamDestroy(halo->stream[Y]); - tdpStreamDestroy(halo->stream[Z]); + tdpAssert( tdpStreamDestroy(halo->stream[X]) ); + tdpAssert( tdpStreamDestroy(halo->stream[Y]) ); + tdpAssert( tdpStreamDestroy(halo->stream[Z]) ); free(halo->param); free(halo); @@ -736,7 +736,7 @@ __host__ int halo_swap_packed(halo_swap_t * halo, double * data) { /* 2D systems require fix... in the meantime...*/ assert(halo->param->nlocal[Z] >= halo->param->nswap); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); halo_swap_commit(halo); cs_cart_comm(halo->cs, &comm); @@ -791,14 +791,14 @@ __host__ int halo_swap_packed(halo_swap_t * halo, double * data) { if (ndevice > 0) { ncount = hsz[X]*halo->param->nfel; - tdpMemcpy(&tmp, &halo->target->fxlo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(halo->fxlo, tmp, ncount*sizeof(double), - tdpMemcpyDeviceToHost, halo->stream[X]); - tdpMemcpy(&tmp, &halo->target->fxhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(halo->fxhi, tmp, ncount*sizeof(double), - tdpMemcpyDeviceToHost, halo->stream[X]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->fxlo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(halo->fxlo, tmp, ncount*sizeof(double), + tdpMemcpyDeviceToHost, halo->stream[X]) ); + tdpAssert( tdpMemcpy(&tmp, &halo->target->fxhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(halo->fxhi, tmp, ncount*sizeof(double), + tdpMemcpyDeviceToHost, halo->stream[X]) ); } /* pack Y edges on accelerator */ @@ -809,14 +809,14 @@ __host__ int halo_swap_packed(halo_swap_t * halo, double * data) { if (ndevice > 0) { ncount = hsz[Y]*halo->param->nfel; - tdpMemcpy(&tmp, &halo->target->fylo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(halo->fylo, tmp, ncount*sizeof(double), - tdpMemcpyDeviceToHost, halo->stream[Y]); - tdpMemcpy(&tmp, &halo->target->fyhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(halo->fyhi, tmp, ncount*sizeof(double), - tdpMemcpyDeviceToHost, halo->stream[Y]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->fylo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(halo->fylo, tmp, ncount*sizeof(double), + tdpMemcpyDeviceToHost, halo->stream[Y]) ); + tdpAssert( tdpMemcpy(&tmp, &halo->target->fyhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(halo->fyhi, tmp, ncount*sizeof(double), + tdpMemcpyDeviceToHost, halo->stream[Y]) ); } /* pack Z edges on accelerator */ @@ -827,36 +827,36 @@ __host__ int halo_swap_packed(halo_swap_t * halo, double * data) { if (ndevice > 0) { ncount = hsz[Z]*halo->param->nfel; - tdpMemcpy(&tmp, &halo->target->fzlo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(halo->fzlo, tmp, ncount*sizeof(double), - tdpMemcpyDeviceToHost, halo->stream[Z]); - tdpMemcpy(&tmp, &halo->target->fzhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(halo->fzhi, tmp, ncount*sizeof(double), - tdpMemcpyDeviceToHost, halo->stream[Z]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->fzlo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(halo->fzlo, tmp, ncount*sizeof(double), + tdpMemcpyDeviceToHost, halo->stream[Z]) ); + tdpAssert( tdpMemcpy(&tmp, &halo->target->fzhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(halo->fzhi, tmp, ncount*sizeof(double), + tdpMemcpyDeviceToHost, halo->stream[Z]) ); } /* Wait for X; copy or MPI recvs; put X halos back on device, and unpack */ - tdpStreamSynchronize(halo->stream[X]); + tdpAssert( tdpStreamSynchronize(halo->stream[X]) ); ncount = hsz[X]*halo->param->nfel; if (mpicartsz[X] == 1) { /* note these copies do not alias for ndevice == 1 */ /* fxhi -> hxlo */ memcpy(halo->hxlo, halo->fxhi, ncount*sizeof(double)); - tdpMemcpy(&tmp, &halo->target->hxlo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(tmp, halo->fxhi, ncount*sizeof(double), - tdpMemcpyHostToDevice, halo->stream[X]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hxlo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(tmp, halo->fxhi, ncount*sizeof(double), + tdpMemcpyHostToDevice, halo->stream[X]) ); /* fxlo -> hxhi */ memcpy(halo->hxhi, halo->fxlo, ncount*sizeof(double)); - tdpMemcpy(&tmp, &halo->target->hxhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(tmp, halo->fxlo, ncount*sizeof(double), - tdpMemcpyHostToDevice, halo->stream[X]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hxhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(tmp, halo->fxlo, ncount*sizeof(double), + tdpMemcpyHostToDevice, halo->stream[X]) ); } else { MPI_Isend(halo->fxhi, ncount, MPI_DOUBLE, @@ -867,16 +867,16 @@ __host__ int halo_swap_packed(halo_swap_t * halo, double * data) { for (m = 0; m < 4; m++) { MPI_Waitany(4, req_x, &mc, status); if (mc == 0 && ndevice > 0) { - tdpMemcpy(&tmp, &halo->target->hxlo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(tmp, halo->hxlo, ncount*sizeof(double), - tdpMemcpyHostToDevice, halo->stream[X]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hxlo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(tmp, halo->hxlo, ncount*sizeof(double), + tdpMemcpyHostToDevice, halo->stream[X]) ); } if (mc == 1 && ndevice > 0) { - tdpMemcpy(&tmp, &halo->target->hxhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(tmp, halo->hxhi, ncount*sizeof(double), - tdpMemcpyHostToDevice, halo->stream[X]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hxhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(tmp, halo->hxhi, ncount*sizeof(double), + tdpMemcpyHostToDevice, halo->stream[X]) ); } } } @@ -888,7 +888,7 @@ __host__ int halo_swap_packed(halo_swap_t * halo, double * data) { /* Now wait for Y data to arrive from device */ /* Fill in 4 corners of Y edge data from X halo */ - tdpStreamSynchronize(halo->stream[Y]); + tdpAssert( tdpStreamSynchronize(halo->stream[Y]) ); ih = halo->param->hext[Y][X] - nh; jh = halo->param->hext[X][Y] - nh - halo->param->nswap; @@ -921,16 +921,16 @@ __host__ int halo_swap_packed(halo_swap_t * halo, double * data) { if (mpicartsz[Y] == 1) { /* fyhi -> hylo */ memcpy(halo->hylo, halo->fyhi, ncount*sizeof(double)); - tdpMemcpy(&tmp, &halo->target->hylo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(tmp, halo->fyhi, ncount*sizeof(double), - tdpMemcpyHostToDevice, halo->stream[Y]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hylo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(tmp, halo->fyhi, ncount*sizeof(double), + tdpMemcpyHostToDevice, halo->stream[Y]) ); /* fylo -> hyhi */ memcpy(halo->hyhi, halo->fylo, ncount*sizeof(double)); - tdpMemcpy(&tmp, &halo->target->hyhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(tmp, halo->fylo,ncount*sizeof(double), - tdpMemcpyHostToDevice, halo->stream[Y]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hyhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(tmp, halo->fylo,ncount*sizeof(double), + tdpMemcpyHostToDevice, halo->stream[Y]) ); } else { MPI_Isend(halo->fyhi, ncount, MPI_DOUBLE, @@ -941,16 +941,16 @@ __host__ int halo_swap_packed(halo_swap_t * halo, double * data) { for (m = 0; m < 4; m++) { MPI_Waitany(4, req_y, &mc, status); if (mc == 0 && ndevice > 0) { - tdpMemcpy(&tmp, &halo->target->hylo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(tmp, halo->hylo, ncount*sizeof(double), - tdpMemcpyHostToDevice, halo->stream[Y]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hylo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(tmp, halo->hylo, ncount*sizeof(double), + tdpMemcpyHostToDevice, halo->stream[Y]) ); } if (mc == 1 && ndevice > 0) { - tdpMemcpy(&tmp, &halo->target->hyhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(tmp, halo->hyhi, ncount*sizeof(double), - tdpMemcpyHostToDevice, halo->stream[Y]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hyhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(tmp, halo->hyhi, ncount*sizeof(double), + tdpMemcpyHostToDevice, halo->stream[Y]) ); } } } @@ -963,7 +963,7 @@ __host__ int halo_swap_packed(halo_swap_t * halo, double * data) { /* Wait for Z data from device */ /* Fill in 4 corners of Z edge data from X halo */ - tdpStreamSynchronize(halo->stream[Z]); + tdpAssert( tdpStreamSynchronize(halo->stream[Z]) ); ih = halo->param->hext[Z][X] - nh; kh = halo->param->hext[X][Z] - nh - halo->param->nswap; @@ -1018,15 +1018,15 @@ __host__ int halo_swap_packed(halo_swap_t * halo, double * data) { if (mpicartsz[Z] == 1) { /* fzhi -> hzlo */ - tdpMemcpy(&tmp, &halo->target->hzlo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(tmp, halo->fzhi, ncount*sizeof(double), - tdpMemcpyHostToDevice, halo->stream[Z]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hzlo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(tmp, halo->fzhi, ncount*sizeof(double), + tdpMemcpyHostToDevice, halo->stream[Z]) ); /* fzlo -> hzhi */ - tdpMemcpy(&tmp, &halo->target->hzhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(tmp, halo->fzlo, ncount*sizeof(double), - tdpMemcpyHostToDevice, halo->stream[Z]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hzhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(tmp, halo->fzlo, ncount*sizeof(double), + tdpMemcpyHostToDevice, halo->stream[Z]) ); } else { MPI_Isend(halo->fzhi, ncount, MPI_DOUBLE, @@ -1037,16 +1037,16 @@ __host__ int halo_swap_packed(halo_swap_t * halo, double * data) { for (m = 0; m < 4; m++) { MPI_Waitany(4, req_z, &mc, status); if (mc == 0 && ndevice > 0) { - tdpMemcpy(&tmp, &halo->target->hzlo, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(tmp, halo->hzlo, ncount*sizeof(double), - tdpMemcpyHostToDevice, halo->stream[Z]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hzlo, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(tmp, halo->hzlo, ncount*sizeof(double), + tdpMemcpyHostToDevice, halo->stream[Z]) ); } if (mc == 1 && ndevice > 0) { - tdpMemcpy(&tmp, &halo->target->hzhi, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpMemcpyAsync(tmp, halo->hzhi, ncount*sizeof(double), - tdpMemcpyHostToDevice, halo->stream[Z]); + tdpAssert( tdpMemcpy(&tmp, &halo->target->hzhi, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpMemcpyAsync(tmp, halo->hzhi, ncount*sizeof(double), + tdpMemcpyHostToDevice, halo->stream[Z]) ); } } } @@ -1055,9 +1055,9 @@ __host__ int halo_swap_packed(halo_swap_t * halo, double * data) { tdpLaunchKernel(halo->data_unpack, nblk, ntpb, 0, halo->stream[Z], halo->target, Z, data); - tdpStreamSynchronize(halo->stream[X]); - tdpStreamSynchronize(halo->stream[Y]); - tdpStreamSynchronize(halo->stream[Z]); + tdpAssert( tdpStreamSynchronize(halo->stream[X]) ); + tdpAssert( tdpStreamSynchronize(halo->stream[Y]) ); + tdpAssert( tdpStreamSynchronize(halo->stream[Z]) ); return 0; } diff --git a/src/hydro.c b/src/hydro.c index 6e3c40d83..65fd9e908 100644 --- a/src/hydro.c +++ b/src/hydro.c @@ -85,7 +85,7 @@ __host__ int hydro_create(pe_t * pe, cs_t * cs, lees_edw_t * le, /* Allocate target copy of structure (or alias) */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { obj->target = obj; @@ -126,7 +126,7 @@ __host__ int hydro_free(hydro_t * obj) { assert(obj); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) tdpAssert(tdpFree(obj->target)); @@ -152,7 +152,7 @@ __host__ int hydro_memcpy(hydro_t * obj, tdpMemcpyKind flag) { assert(obj); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { /* Ensure we alias */ @@ -722,7 +722,7 @@ __host__ int hydro_correct_momentum(hydro_t * hydro) { /* Apply correction and finish */ - tdpMemcpy(fnetd, fnet, 3*sizeof(double), tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(fnetd, fnet, 3*sizeof(double), tdpMemcpyHostToDevice) ); { dim3 nblk = {}; diff --git a/src/lb_data.c b/src/lb_data.c index 15e33486e..c7ba18f8a 100644 --- a/src/lb_data.c +++ b/src/lb_data.c @@ -196,20 +196,21 @@ int lb_data_create(pe_t * pe, cs_t * cs, const lb_data_options_t * options, __host__ int lb_free(lb_t * lb) { int ndevice; - double * tmp; assert(lb); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) { - tdpMemcpy(&tmp, &lb->target->f, sizeof(double *), tdpMemcpyDeviceToHost); - tdpFree(tmp); - - tdpMemcpy(&tmp, &lb->target->fprime, sizeof(double *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpFree(lb->target); + double * tmp = NULL; + tdpAssert( tdpMemcpy(&tmp, &lb->target->f, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + + tdpAssert( tdpMemcpy(&tmp, &lb->target->fprime, sizeof(double *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpFree(lb->target) ); } io_metadata_finalise(&lb->input); @@ -241,7 +242,7 @@ __host__ int lb_memcpy(lb_t * lb, tdpMemcpyKind flag) { assert(lb); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { /* Make sure we alias */ @@ -253,18 +254,19 @@ __host__ int lb_memcpy(lb_t * lb, tdpMemcpyKind flag) { assert(lb->target); - tdpMemcpy(&tmpf, &lb->target->f, sizeof(double *), tdpMemcpyDeviceToHost); + tdpAssert( tdpMemcpy(&tmpf, &lb->target->f, sizeof(double *), + tdpMemcpyDeviceToHost) ); switch (flag) { case tdpMemcpyHostToDevice: - tdpMemcpy(&lb->target->ndim, &lb->ndim, sizeof(int), flag); - tdpMemcpy(&lb->target->nvel, &lb->nvel, sizeof(int), flag); - tdpMemcpy(&lb->target->ndist, &lb->ndist, sizeof(int), flag); - tdpMemcpy(&lb->target->nsite, &lb->nsite, sizeof(int), flag); - tdpMemcpy(tmpf, lb->f, nsz, flag); + tdpAssert( tdpMemcpy(&lb->target->ndim, &lb->ndim, sizeof(int), flag) ); + tdpAssert( tdpMemcpy(&lb->target->nvel, &lb->nvel, sizeof(int), flag) ); + tdpAssert( tdpMemcpy(&lb->target->ndist, &lb->ndist, sizeof(int), flag) ); + tdpAssert( tdpMemcpy(&lb->target->nsite, &lb->nsite, sizeof(int), flag) ); + tdpAssert( tdpMemcpy(tmpf, lb->f, nsz, flag) ); break; case tdpMemcpyDeviceToHost: - tdpMemcpy(lb->f, tmpf, nsz, flag); + tdpAssert( tdpMemcpy(lb->f, tmpf, nsz, flag) ); break; default: pe_fatal(lb->pe, "Bad flag in lb_memcpy\n"); @@ -307,7 +309,7 @@ static int lb_init(lb_t * lb) { ndata = lb->nsite*lb->ndist*lb->model.nvel; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { lb->target = lb; @@ -315,21 +317,22 @@ static int lb_init(lb_t * lb) { else { lb_collide_param_t * ptmp = NULL; - tdpMalloc((void **) &lb->target, sizeof(lb_t)); - tdpMemset(lb->target, 0, sizeof(lb_t)); + tdpAssert( tdpMalloc((void **) &lb->target, sizeof(lb_t)) ); + tdpAssert( tdpMemset(lb->target, 0, sizeof(lb_t)) ); - tdpMalloc((void **) &tmp, ndata*sizeof(double)); - tdpMemset(tmp, 0, ndata*sizeof(double)); - tdpMemcpy(&lb->target->f, &tmp, sizeof(double *), tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, ndata*sizeof(double)) ); + tdpAssert( tdpMemset(tmp, 0, ndata*sizeof(double)) ); + tdpAssert( tdpMemcpy(&lb->target->f, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); - tdpMalloc((void **) &tmp, ndata*sizeof(double)); - tdpMemset(tmp, 0, ndata*sizeof(double)); - tdpMemcpy(&lb->target->fprime, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, ndata*sizeof(double)) ); + tdpAssert( tdpMemset(tmp, 0, ndata*sizeof(double)) ); + tdpAssert( tdpMemcpy(&lb->target->fprime, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); tdpGetSymbolAddress((void **) &ptmp, tdpSymbol(static_param)); - tdpMemcpy(&lb->target->param, &ptmp, sizeof(lb_collide_param_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&lb->target->param, &ptmp, + sizeof(lb_collide_param_t *), tdpMemcpyHostToDevice)); } lb_mpi_init(lb); @@ -539,7 +542,8 @@ __host__ int lb_halo_swap(lb_t * lb, lb_halo_enum_t flag) { switch (flag) { case LB_HALO_TARGET: - tdpMemcpy(&data, &lb->target->f, sizeof(double *), tdpMemcpyDeviceToHost); + tdpAssert( tdpMemcpy(&data, &lb->target->f, sizeof(double *), + tdpMemcpyDeviceToHost) ); halo_swap_packed(lb->halo, data); break; case LB_HALO_OPENMP_FULL: diff --git a/src/lc_droplet.c b/src/lc_droplet.c index 1359cdff1..76e31f3f4 100644 --- a/src/lc_droplet.c +++ b/src/lc_droplet.c @@ -123,7 +123,7 @@ __host__ int fe_lc_droplet_create(pe_t * pe, cs_t * cs, fe_lc_t * lc, fe->super.func = &fe_drop_hvt; fe->super.id = FE_LC_DROPLET; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { fe->target = fe; @@ -131,19 +131,20 @@ __host__ int fe_lc_droplet_create(pe_t * pe, cs_t * cs, fe_lc_t * lc, else { fe_lc_droplet_param_t * tmp; fe_vt_t * vt; - tdpMalloc((void **) &fe->target, sizeof(fe_lc_droplet_t)); - tdpMemset(fe->target, 0, sizeof(fe_lc_droplet_t)); + tdpAssert( tdpMalloc((void **) &fe->target, sizeof(fe_lc_droplet_t)) ); + tdpAssert( tdpMemset(fe->target, 0, sizeof(fe_lc_droplet_t)) ); tdpGetSymbolAddress((void **) &tmp, tdpSymbol(const_param)); - tdpMemcpy(&fe->target->param, &tmp, sizeof(fe_lc_droplet_param_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&fe->target->param, &tmp, + sizeof(fe_lc_droplet_param_t *), + tdpMemcpyHostToDevice) ); tdpGetSymbolAddress((void **) &vt, tdpSymbol(fe_drop_dvt)); - tdpMemcpy(&fe->target->super.func, &vt, sizeof(fe_vt_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&fe->target->super.func, &vt, sizeof(fe_vt_t *), + tdpMemcpyHostToDevice) ); - tdpMemcpy(&fe->target->lc, &lc->target, sizeof(fe_lc_t *), - tdpMemcpyHostToDevice); - tdpMemcpy(&fe->target->symm, &symm->target, sizeof(fe_symm_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&fe->target->lc, &lc->target, sizeof(fe_lc_t *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMemcpy(&fe->target->symm, &symm->target, sizeof(fe_symm_t *), + tdpMemcpyHostToDevice) ); { /* Provide constant memory for lc parameters */ diff --git a/src/leesedwards.c b/src/leesedwards.c index f7b7d1a28..a5577aad6 100644 --- a/src/leesedwards.c +++ b/src/leesedwards.c @@ -9,7 +9,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2010-2023 The University of Edinburgh + * (c) 2010-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -106,7 +106,7 @@ __host__ int lees_edw_create(pe_t * pe, cs_t * cs, lees_edw_init_tables(le); le->nref = 1; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { le->target = le; @@ -115,14 +115,15 @@ __host__ int lees_edw_create(pe_t * pe, cs_t * cs, lees_edw_param_t * tmp; cs_t * cst; - tdpMalloc((void **) &le->target, sizeof(lees_edw_t)); - tdpMemset(le->target, 0, sizeof(lees_edw_t)); + tdpAssert( tdpMalloc((void **) &le->target, sizeof(lees_edw_t)) ); + tdpAssert( tdpMemset(le->target, 0, sizeof(lees_edw_t)) ); tdpGetSymbolAddress((void **) &tmp, tdpSymbol(static_param)); - tdpMemcpy(&le->target->param, (const void *) &tmp, - sizeof(lees_edw_param_t *), tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&le->target->param, (const void *) &tmp, + sizeof(lees_edw_param_t *), tdpMemcpyHostToDevice) ); cs_target(cs, &cst); - tdpMemcpy(&le->target->cs, &cst, sizeof(cs_t *), tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&le->target->cs, &cst, sizeof(cs_t *), + tdpMemcpyHostToDevice) ); lees_edw_commit(le); } @@ -161,7 +162,7 @@ __host__ int lees_edw_free(lees_edw_t * le) { if (le->nref <= 0) { - if (le->target != le) tdpFree(le->target); + if (le->target != le) tdpAssert( tdpFree(le->target) ); pe_free(le->pe); cs_free(le->cs); diff --git a/src/ludwig.c b/src/ludwig.c index b2d80e050..c17dd1be3 100644 --- a/src/ludwig.c +++ b/src/ludwig.c @@ -468,7 +468,7 @@ void ludwig_run(const char * inputfile) { MPI_Comm_rank(node_comm, &node_rank); MPI_Comm_size(node_comm, &node_size); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0 && ndevice < node_size) { pe_info(ludwig->pe, "MPI tasks per node: %d\n", node_size); @@ -2136,7 +2136,7 @@ int ludwig_colloids_update(ludwig_t * ludwig) { colloids_info_ntotal(ludwig->collinfo, &ncolloid); if (ncolloid == 0) return 0; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); lb_ndist(ludwig->lb, &ndist); iconserve = (ludwig->psi || (ludwig->phi && ndist == 1)); diff --git a/src/map.c b/src/map.c index fe4514f94..ff30a96ab 100644 --- a/src/map.c +++ b/src/map.c @@ -175,7 +175,7 @@ int map_initialise(pe_t * pe, cs_t * cs, const map_options_t * options, /* Allocate target copy of structure (or alias) */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { map->target = map; @@ -236,7 +236,7 @@ int map_finalise(map_t * map) { int ndevice = 0; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) { char * status = NULL; @@ -278,22 +278,22 @@ int map_memcpy(map_t * map, tdpMemcpyKind flag) { assert(map); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { /* Ensure we alias */ assert(map->target == map); } else { - tdpMemcpy(&tmp, &map->target->status, sizeof(char *), - tdpMemcpyDeviceToHost); + tdpAssert( tdpMemcpy(&tmp, &map->target->status, sizeof(char *), + tdpMemcpyDeviceToHost) ); switch (flag) { case tdpMemcpyHostToDevice: - tdpMemcpy(tmp, map->status, map->nsite*sizeof(char), flag); + tdpAssert( tdpMemcpy(tmp, map->status, map->nsite*sizeof(char), flag) ); break; case tdpMemcpyDeviceToHost: - tdpMemcpy(map->status, tmp, map->nsite*sizeof(char), flag); + tdpAssert( tdpMemcpy(map->status, tmp, map->nsite*sizeof(char), flag) ); break; default: pe_fatal(map->pe, "Bad flag in map_memcpy()\n"); diff --git a/src/noise.c b/src/noise.c index bcb26b9b8..1bb58df1a 100644 --- a/src/noise.c +++ b/src/noise.c @@ -206,7 +206,7 @@ int noise_initialise(pe_t * pe, cs_t * cs, const noise_options_t * options, /* Device allocations */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { ns->target = ns; @@ -245,7 +245,7 @@ int noise_finalise(noise_t * ns) { assert(ns); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) { unsigned int * state = NULL; @@ -356,7 +356,7 @@ int noise_memcpy(noise_t * ns, tdpMemcpyKind flag) { assert(ns); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { assert(ns->target == ns); diff --git a/src/pe.c b/src/pe.c index 517a7d950..4b137be72 100644 --- a/src/pe.c +++ b/src/pe.c @@ -15,7 +15,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2010-2023 The University of Edinburgh + * (c) 2010-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -185,7 +185,7 @@ __host__ int pe_message(pe_t * pe) { assert(printf("Note assertions via standard C assert() are on.\n\n")); /* Thread model */ - tdpThreadModelInfo(stdout); + tdpAssert( tdpThreadModelInfo(stdout) ); printf("\n"); } diff --git a/src/phi_cahn_hilliard.c b/src/phi_cahn_hilliard.c index f1122b286..f8cb99f9b 100644 --- a/src/phi_cahn_hilliard.c +++ b/src/phi_cahn_hilliard.c @@ -1163,7 +1163,7 @@ static int phi_ch_subtract_sum_phi_after_forward_step(phi_ch_t * pch, field_t * tdpAssert(tdpDeviceSynchronize()); } - tdpFree(local_d); + tdpAssert( tdpFree(local_d) ); return 0; } diff --git a/src/phi_force_colloid.c b/src/phi_force_colloid.c index c356ef524..40d40a4f2 100644 --- a/src/phi_force_colloid.c +++ b/src/phi_force_colloid.c @@ -146,7 +146,7 @@ __host__ int pth_force_driver(pth_t * pth, colloids_info_t * cinfo, kernel_3d_launch_param(k3d.kiterations, &nblk, &ntpb); tdpAssert( tdpMalloc((void **) &fwd, 3*sizeof(double)) ); - tdpMemcpy(fwd, fw, 3*sizeof(double), tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(fwd, fw, 3*sizeof(double), tdpMemcpyHostToDevice) ); TIMER_start(TIMER_PHI_FORCE_CALC); @@ -155,10 +155,10 @@ __host__ int pth_force_driver(pth_t * pth, colloids_info_t * cinfo, tdpLaunchKernel(pth_force_wall_kernel, nblk, ntpb, 0, 0, k3d, pth->target, map->target, wallt, fwd); - tdpDeviceSynchronize(); + tdpAssert( tdpDeviceSynchronize() ); } - tdpMemcpy(fw, fwd, 3*sizeof(double), tdpMemcpyDeviceToHost); + tdpAssert( tdpMemcpy(fw, fwd, 3*sizeof(double), tdpMemcpyDeviceToHost) ); wall_momentum_add(wall, fw); tdpAssert( tdpFree(fwd) ); @@ -257,7 +257,7 @@ __host__ int pth_force_fluid_wall_driver(pth_t * pth, hydro_t * hydro, tdpAssert( tdpDeviceSynchronize() ); } - tdpMemcpy(fw, fwd, 3*sizeof(double), tdpMemcpyDeviceToHost); + tdpAssert( tdpMemcpy(fw, fwd, 3*sizeof(double), tdpMemcpyDeviceToHost) ); wall_momentum_add(wall, fw); return 0; diff --git a/src/phi_force_stress.c b/src/phi_force_stress.c index 629bb5e6d..b67ce7902 100644 --- a/src/phi_force_stress.c +++ b/src/phi_force_stress.c @@ -63,7 +63,7 @@ __host__ int pth_create(pe_t * pe, cs_t * cs, int method, pth_t ** pobj) { /* Allocate target memory, or alias */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { obj->target = obj; @@ -73,15 +73,15 @@ __host__ int pth_create(pe_t * pe, cs_t * cs, int method, pth_t ** pobj) { int imem = (method == FE_FORCE_METHOD_STRESS_DIVERGENCE) || (method == FE_FORCE_METHOD_RELAXATION_ANTI); - tdpMalloc((void **) &obj->target, sizeof(pth_t)); - tdpMemset(obj->target, 0, sizeof(pth_t)); - tdpMemcpy(&obj->target->nsites, &obj->nsites, sizeof(int), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &obj->target, sizeof(pth_t)) ); + tdpAssert( tdpMemset(obj->target, 0, sizeof(pth_t)) ); + tdpAssert( tdpMemcpy(&obj->target->nsites, &obj->nsites, sizeof(int), + tdpMemcpyHostToDevice) ); if (imem) { - tdpMalloc((void **) &tmp, 3*3*obj->nsites*sizeof(double)); - tdpMemcpy(&obj->target->str, &tmp, sizeof(double *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, 3*3*obj->nsites*sizeof(double)) ); + tdpAssert( tdpMemcpy(&obj->target->str, &tmp, sizeof(double *), + tdpMemcpyHostToDevice) ); } } @@ -103,13 +103,13 @@ __host__ int pth_free(pth_t * pth) { assert(pth); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) { - tdpMemcpy(&tmp, &pth->target->str, sizeof(double *), - tdpMemcpyDeviceToHost); - if (tmp) tdpFree(tmp); - tdpFree(pth->target); + tdpAssert( tdpMemcpy(&tmp, &pth->target->str, sizeof(double *), + tdpMemcpyDeviceToHost) ); + if (tmp) tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpFree(pth->target) ); } if (pth->str) free(pth->str); @@ -131,7 +131,7 @@ __host__ int pth_memcpy(pth_t * pth, tdpMemcpyKind flag) { assert(pth); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { /* Ensure we alias */ @@ -141,15 +141,15 @@ __host__ int pth_memcpy(pth_t * pth, tdpMemcpyKind flag) { double * tmp = NULL; nsz = 9*pth->nsites*sizeof(double); - tdpMemcpy(&tmp, &pth->target->str, sizeof(double *), - tdpMemcpyDeviceToHost); + tdpAssert( tdpMemcpy(&tmp, &pth->target->str, sizeof(double *), + tdpMemcpyDeviceToHost) ); switch (flag) { case tdpMemcpyHostToDevice: - tdpMemcpy(tmp, pth->str, nsz, flag); + tdpAssert( tdpMemcpy(tmp, pth->str, nsz, flag) ); break; case tdpMemcpyDeviceToHost: - tdpMemcpy(pth->str, tmp, nsz, flag); + tdpAssert( tdpMemcpy(pth->str, tmp, nsz, flag) ); break; default: pe_fatal(pth->pe, "Bad flag in pth_memcpy\n"); diff --git a/src/phi_stats.c b/src/phi_stats.c index 00daa7e36..01b12c676 100644 --- a/src/phi_stats.c +++ b/src/phi_stats.c @@ -195,7 +195,7 @@ int stats_field_q_reduce(field_t * field, map_t * map, int nxx, sum_t * sum, MPI_Type_free(&dt); } - tdpFree(dsum); + tdpAssert( tdpFree(dsum) ); return 0; } diff --git a/src/polar_active.c b/src/polar_active.c index 296911e39..37cb10bea 100644 --- a/src/polar_active.c +++ b/src/polar_active.c @@ -34,7 +34,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2011-2018 The University of Edinburgh + * (c) 2011-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -118,7 +118,7 @@ __host__ int fe_polar_create(pe_t * pe, cs_t * cs, field_t * p, obj->super.func = &fe_polar_hvt; obj->super.id = FE_POLAR; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { obj->target = obj; @@ -126,19 +126,19 @@ __host__ int fe_polar_create(pe_t * pe, cs_t * cs, field_t * p, else { fe_polar_param_t * tmp; fe_vt_t * vt; - tdpMalloc((void **) &obj->target, sizeof(fe_polar_t)); - tdpMemset(obj->target, 0, sizeof(fe_polar_t)); + tdpAssert( tdpMalloc((void **) &obj->target, sizeof(fe_polar_t)) ); + tdpAssert( tdpMemset(obj->target, 0, sizeof(fe_polar_t)) ); tdpGetSymbolAddress((void **) &tmp, tdpSymbol(const_param)); - tdpMemcpy(&obj->target->param, &tmp, sizeof(fe_polar_param_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&obj->target->param, &tmp, sizeof(fe_polar_param_t *), + tdpMemcpyHostToDevice) ); tdpGetSymbolAddress((void **) &vt, tdpSymbol(fe_polar_dvt)); - tdpMemcpy(&obj->target->super.func, &vt, sizeof(fe_vt_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&obj->target->super.func, &vt, sizeof(fe_vt_t *), + tdpMemcpyHostToDevice) ); - tdpMemcpy(&obj->target->p, &p->target, sizeof(field_t *), - tdpMemcpyHostToDevice); - tdpMemcpy(&obj->target->dp, &dp->target, sizeof(field_grad_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&obj->target->p, &p->target, sizeof(field_t *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMemcpy(&obj->target->dp, &dp->target, sizeof(field_grad_t *), + tdpMemcpyHostToDevice) ); } *fe = obj; diff --git a/src/propagation.c b/src/propagation.c index 8d9dc1329..05a57ded2 100644 --- a/src/propagation.c +++ b/src/propagation.c @@ -217,7 +217,7 @@ __host__ int lb_model_swapf(lb_t * lb) { assert(lb); assert(lb->target); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { tmp1 = lb->f; diff --git a/src/stats_distribution.c b/src/stats_distribution.c index 82c81698b..d49185b12 100644 --- a/src/stats_distribution.c +++ b/src/stats_distribution.c @@ -11,7 +11,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2010-2023 The University of Edinburgh + * (c) 2010-2024 The University of Edinburgh * * Kevin Stratford (kevin@epcc.ed.ac.uk) * @@ -263,7 +263,7 @@ int distribution_stats_momentum(lb_t * lb, map_t * map, int root, MPI_Type_free(&dt); } - tdpFree(sum_d); + tdpAssert( tdpFree(sum_d) ); return 0; } diff --git a/src/surfactant.c b/src/surfactant.c index 197b9370f..10b5e2a09 100644 --- a/src/surfactant.c +++ b/src/surfactant.c @@ -28,7 +28,7 @@ * Edinburgh Soft Matter and Statistical Physics Group * and Edinburgh Parallel Computing Centre * - * (c) 2010-2021 The University of Edinburgh + * (c) 2010-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -111,7 +111,7 @@ int fe_surf_create(pe_t * pe, cs_t * cs, field_t * phi, /* Allocate target memory, or alias */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { fe_surf_param_set(obj, param); @@ -119,10 +119,10 @@ int fe_surf_create(pe_t * pe, cs_t * cs, field_t * phi, } else { fe_surf_param_t * tmp; - tdpMalloc((void **) &obj->target, sizeof(fe_surf_t)); + tdpAssert( tdpMalloc((void **) &obj->target, sizeof(fe_surf_t)) ); tdpGetSymbolAddress((void **) &tmp, tdpSymbol(const_param)); - tdpMemcpy(&obj->target->param, tmp, sizeof(fe_surf_param_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&obj->target->param, tmp, sizeof(fe_surf_param_t *), + tdpMemcpyHostToDevice) ); /* Now copy. */ assert(0); /* No implementation */ } @@ -144,8 +144,8 @@ __host__ int fe_surf_free(fe_surf_t * fe) { assert(fe); - tdpGetDeviceCount(&ndevice); - if (ndevice > 0) tdpFree(fe->target); + tdpAssert( tdpGetDeviceCount(&ndevice) ); + if (ndevice > 0) tdpAssert( tdpFree(fe->target) ); free(fe->param); free(fe); diff --git a/src/symmetric.c b/src/symmetric.c index 4dfecbb06..734525c24 100644 --- a/src/symmetric.c +++ b/src/symmetric.c @@ -16,7 +16,7 @@ * Edinburgh Soft Matter and Statistical Physics Group * and Edinburgh Parallel Computing Centre * - * (c) 2011-2021 The University of Edinburgh + * (c) 2011-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -113,7 +113,7 @@ __host__ int fe_symm_create(pe_t * pe, cs_t * cs, field_t * phi, /* Allocate target memory, or alias */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { obj->target = obj; @@ -121,19 +121,19 @@ __host__ int fe_symm_create(pe_t * pe, cs_t * cs, field_t * phi, else { fe_symm_param_t * tmp = NULL; fe_vt_t * vt; - tdpMalloc((void **) &obj->target, sizeof(fe_symm_t)); - tdpMemset(obj->target, 0, sizeof(fe_symm_t)); + tdpAssert( tdpMalloc((void **) &obj->target, sizeof(fe_symm_t)) ); + tdpAssert( tdpMemset(obj->target, 0, sizeof(fe_symm_t)) ); tdpGetSymbolAddress((void **) &tmp, tdpSymbol(const_param)); - tdpMemcpy(&obj->target->param, &tmp, sizeof(fe_symm_param_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&obj->target->param, &tmp, sizeof(fe_symm_param_t *), + tdpMemcpyHostToDevice) ); tdpGetSymbolAddress((void **) &vt, tdpSymbol(fe_symm_dvt)); - tdpMemcpy(&obj->target->super.func, &vt, sizeof(fe_vt_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&obj->target->super.func, &vt, sizeof(fe_vt_t *), + tdpMemcpyHostToDevice) ); - tdpMemcpy(&obj->target->phi, &phi->target, sizeof(field_t *), - tdpMemcpyHostToDevice); - tdpMemcpy(&obj->target->dphi, &dphi->target, sizeof(field_grad_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&obj->target->phi, &phi->target, sizeof(field_t *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMemcpy(&obj->target->dphi, &dphi->target, + sizeof(field_grad_t *), tdpMemcpyHostToDevice) ); } *p = obj; @@ -153,9 +153,9 @@ __host__ int fe_symm_free(fe_symm_t * fe) { assert(fe); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); - if (ndevice > 0) tdpFree(fe->target); + if (ndevice > 0) tdpAssert( tdpFree(fe->target) ); free(fe->param); free(fe); diff --git a/src/wall.c b/src/wall.c index 51083103e..70b945d5a 100644 --- a/src/wall.c +++ b/src/wall.c @@ -86,7 +86,7 @@ __host__ int wall_create(pe_t * pe, cs_t * cs, map_t * map, lb_t * lb, /* Target copy */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { wall->target = wall; @@ -94,11 +94,11 @@ __host__ int wall_create(pe_t * pe, cs_t * cs, map_t * map, lb_t * lb, else { wall_param_t * tmp = NULL; - tdpMalloc((void **) &wall->target, sizeof(wall_t)); - tdpMemset(wall->target, 0, sizeof(wall_t)); + tdpAssert( tdpMalloc((void **) &wall->target, sizeof(wall_t)) ); + tdpAssert( tdpMemset(wall->target, 0, sizeof(wall_t)) ); tdpGetSymbolAddress((void **) &tmp, tdpSymbol(static_param)); - tdpMemcpy(&wall->target->param, &tmp, sizeof(wall_param_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(&wall->target->param, &tmp, sizeof(wall_param_t *), + tdpMemcpyHostToDevice) ); } *p = wall; @@ -119,36 +119,36 @@ __host__ int wall_free(wall_t * wall) { if (wall->target != wall) { { int * tmp = NULL; - tdpMemcpy(&tmp, &wall->target->linki, sizeof(int *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &wall->target->linkj, sizeof(int *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &wall->target->linkp, sizeof(int *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); - tdpMemcpy(&tmp, &wall->target->linku, sizeof(int *), - tdpMemcpyDeviceToHost); - tdpFree(tmp); + tdpAssert( tdpMemcpy(&tmp, &wall->target->linki, sizeof(int *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &wall->target->linkj, sizeof(int *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &wall->target->linkp, sizeof(int *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); + tdpAssert( tdpMemcpy(&tmp, &wall->target->linku, sizeof(int *), + tdpMemcpyDeviceToHost) ); + tdpAssert( tdpFree(tmp) ); } /* Release slip stuff */ if (wall->param->slip.active) { int * tmp = NULL; tdpAssert(tdpMemcpy(&tmp, &wall->target->linkk, sizeof(int *), tdpMemcpyDeviceToHost)); - tdpFree(tmp); + tdpAssert( tdpFree(tmp) ); } if (wall->param->slip.active) { int8_t * tmp = NULL; tdpAssert(tdpMemcpy(&tmp, &wall->target->linkq, sizeof(int8_t *), tdpMemcpyDeviceToHost)); - tdpFree(tmp); + tdpAssert( tdpFree(tmp) ); tdpAssert(tdpMemcpy(&tmp, &wall->target->links, sizeof(int8_t *), tdpMemcpyDeviceToHost)); - tdpFree(tmp); + tdpAssert( tdpFree(tmp) ); } - tdpFree(wall->target); + tdpAssert( tdpFree(wall->target) ); } cs_free(wall->cs); @@ -402,7 +402,7 @@ __host__ int wall_init_boundaries(wall_t * wall, wall_init_enum_t init) { assert(wall); assert(wall->lb); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (init == WALL_INIT_ALLOCATE) { nlink = imax(1, wall->nlink); /* Avoid zero-sized allocations */ @@ -421,18 +421,18 @@ __host__ int wall_init_boundaries(wall_t * wall, wall_init_enum_t init) { if (wall->linku == NULL) pe_fatal(wall->pe,"calloc(wall->linku) failed\n"); if (ndevice > 0) { int tmp; - tdpMalloc((void **) &tmp, wall->nlink*sizeof(int)); - tdpMemcpy(&wall->target->linki, &tmp, sizeof(int *), - tdpMemcpyHostToDevice); - tdpMalloc((void **) &tmp, wall->nlink*sizeof(int)); - tdpMemcpy(&wall->target->linkj, &tmp, sizeof(int *), - tdpMemcpyHostToDevice); - tdpMalloc((void **) &tmp, wall->nlink*sizeof(int)); - tdpMemcpy(&wall->target->linkp, &tmp, sizeof(int *), - tdpMemcpyHostToDevice); - tdpMalloc((void **) &tmp, wall->nlink*sizeof(int)); - tdpMemcpy(&wall->target->linku, &tmp, sizeof(int *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, wall->nlink*sizeof(int)) ); + tdpAssert( tdpMemcpy(&wall->target->linki, &tmp, sizeof(int *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMalloc((void **) &tmp, wall->nlink*sizeof(int)) ); + tdpAssert( tdpMemcpy(&wall->target->linkj, &tmp, sizeof(int *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMalloc((void **) &tmp, wall->nlink*sizeof(int)) ); + tdpAssert( tdpMemcpy(&wall->target->linkp, &tmp, sizeof(int *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMalloc((void **) &tmp, wall->nlink*sizeof(int)) ); + tdpAssert( tdpMemcpy(&wall->target->linku, &tmp, sizeof(int *), + tdpMemcpyHostToDevice) ); } } @@ -504,7 +504,7 @@ __host__ int wall_init_boundaries_slip(wall_t * wall) { assert(wall->cs); assert(wall->map); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (wall->param->slip.active) { @@ -525,18 +525,18 @@ __host__ int wall_init_boundaries_slip(wall_t * wall) { /* Allocate device memory */ if (ndevice > 0) { int tmp; - tdpMalloc((void **) &tmp, nlink*sizeof(int)); - tdpMemcpy(&wall->target->linkk, &tmp, sizeof(int *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, nlink*sizeof(int)) ); + tdpAssert (tdpMemcpy(&wall->target->linkk, &tmp, sizeof(int *), + tdpMemcpyHostToDevice) ); } if (ndevice > 0) { int8_t tmp; - tdpMalloc((void **) &tmp, nlink*sizeof(int8_t)); - tdpMemcpy(&wall->target->linkq, &tmp, sizeof(int8_t *), - tdpMemcpyHostToDevice); - tdpMalloc((void **) &tmp, nlink*sizeof(int8_t)); - tdpMemcpy(&wall->target->links, &tmp, sizeof(int8_t *), - tdpMemcpyHostToDevice); + tdpAssert( tdpMalloc((void **) &tmp, nlink*sizeof(int8_t)) ); + tdpAssert( tdpMemcpy(&wall->target->linkq, &tmp, sizeof(int8_t *), + tdpMemcpyHostToDevice) ); + tdpAssert( tdpMalloc((void **) &tmp, nlink*sizeof(int8_t)) ); + tdpAssert( tdpMemcpy(&wall->target->links, &tmp, sizeof(int8_t *), + tdpMemcpyHostToDevice) ); } /* For each existing fluid-to-solid link i->j with cv[p] ... */ @@ -777,7 +777,7 @@ __host__ int wall_memcpy(wall_t * wall, tdpMemcpyKind flag) { assert(wall); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice == 0) { assert(wall->target == wall); @@ -922,7 +922,8 @@ __host__ int wall_set_wall_distributions(wall_t * wall) { tdpLaunchKernel(wall_setu_kernel, nblk, ntpb, 0, 0, wall->target, wall->lb->target); - tdpDeviceSynchronize(); + tdpAssert( tdpPeekAtLastError() ); + tdpAssert( tdpDeviceSynchronize() ); return 0; } @@ -1321,17 +1322,17 @@ __host__ int wall_momentum(wall_t * wall, double f[3]) { * the host via wall_momentum_add() and others are on the * device. */ - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice > 0) { - tdpMemcpy(ftmp, wall->target->fnet, 3*sizeof(double), - tdpMemcpyDeviceToHost); + tdpAssert( tdpMemcpy(ftmp, wall->target->fnet, 3*sizeof(double), + tdpMemcpyDeviceToHost) ); wall->fnet[X] += ftmp[X]; wall->fnet[Y] += ftmp[Y]; wall->fnet[Z] += ftmp[Z]; ftmp[X] = 0.0; ftmp[Y] = 0.0; ftmp[Z] = 0.0; - tdpMemcpy(wall->target->fnet, ftmp, 3*sizeof(double), - tdpMemcpyHostToDevice); + tdpAssert( tdpMemcpy(wall->target->fnet, ftmp, 3*sizeof(double), + tdpMemcpyHostToDevice) ); } /* Return the current net */ diff --git a/target/target_x86.c b/target/target_x86.c index e130c52f2..82e5f485a 100644 --- a/target/target_x86.c +++ b/target/target_x86.c @@ -7,7 +7,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2018-2023 The University of Edinburgh + * (c) 2018-2024 The University of Edinburgh * * Contributing authors: * Alan Gray (Late of this parish) @@ -251,13 +251,9 @@ tdpError_t tdpGetDeviceCount(int * device) { *device = 0; -#ifdef FAKE_DEVICE /* "Fake" device */ - *device = 1; -#endif - /* Strictly, we should return tdpErrorInsufficientDriver or ... */ - return tdpErrorNoDevice; + return tdpSuccess; } /***************************************************************************** diff --git a/tests/unit/test_blue_phase.c b/tests/unit/test_blue_phase.c index 49c8340a0..dac5fdf1c 100644 --- a/tests/unit/test_blue_phase.c +++ b/tests/unit/test_blue_phase.c @@ -970,7 +970,7 @@ __host__ int do_test_fe_lc_device1(pe_t * pe, cs_t * cs, fe_lc_t * fe) { tdpAssert(tdpMemcpy(p, ¶m, sizeof(fe_lc_param_t), tdpMemcpyHostToDevice)); tdpLaunchKernel(do_test_fe_lc_kernel1, nblk, ntpb, 0, 0, fetarget, p); - tdpDeviceSynchronize(); + tdpAssert( tdpDeviceSynchronize() ); tdpAssert(tdpFree(p)); } diff --git a/tests/unit/test_ch.c b/tests/unit/test_ch.c index d76ac9344..558d6007a 100644 --- a/tests/unit/test_ch.c +++ b/tests/unit/test_ch.c @@ -7,7 +7,7 @@ * Edinburgh Soft Matter and Statistics Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2019 The University of Edinburgh + * (c) 2019-2024 The University of Edinburgh * *****************************************************************************/ @@ -33,7 +33,7 @@ int test_ch_suite(void) { int ndevice; pe_t * pe = NULL; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); pe_create(MPI_COMM_WORLD, PE_QUIET, &pe); diff --git a/tests/unit/test_coords.c b/tests/unit/test_coords.c index 6475d4292..b1ecbf579 100644 --- a/tests/unit/test_coords.c +++ b/tests/unit/test_coords.c @@ -7,7 +7,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2009-2022 The University of Edinburgh + * (c) 2009-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -538,7 +538,8 @@ __host__ int do_test_coords_device1(pe_t * pe) { ntpb.x = 1; tdpLaunchKernel(do_test_coords_kernel1, nblk, ntpb, 0, 0, cstarget); - tdpDeviceSynchronize(); + tdpAssert( tdpPeekAtLastError() ); + tdpAssert( tdpDeviceSynchronize() ); cs_free(cs); diff --git a/tests/unit/test_fe_electro.c b/tests/unit/test_fe_electro.c index 0dac0171d..790e3a973 100644 --- a/tests/unit/test_fe_electro.c +++ b/tests/unit/test_fe_electro.c @@ -43,7 +43,7 @@ int test_fe_electro_suite(void) { cs_t * cs = NULL; physics_t * phys = NULL; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); pe_create(MPI_COMM_WORLD, PE_QUIET, &pe); diff --git a/tests/unit/test_fe_electro_symm.c b/tests/unit/test_fe_electro_symm.c index b66700c08..4dcf2bd2e 100644 --- a/tests/unit/test_fe_electro_symm.c +++ b/tests/unit/test_fe_electro_symm.c @@ -39,7 +39,8 @@ int test_fe_electro_symm_suite(void) { pe_t * pe = NULL; pe_create(MPI_COMM_WORLD, PE_QUIET, &pe); - tdpGetDeviceCount(&ndevice); + + tdpAssert( tdpGetDeviceCount(&ndevice) ); if (ndevice) { pe_info(pe, "SKIP ./unit/test_fe_electro_symm\n"); diff --git a/tests/unit/test_fe_surfactant1.c b/tests/unit/test_fe_surfactant1.c index 7a00737af..1f7c61c83 100644 --- a/tests/unit/test_fe_surfactant1.c +++ b/tests/unit/test_fe_surfactant1.c @@ -7,7 +7,7 @@ * Edinburgh Soft Matter and Statistical Phsyics Group and * Edinburgh Parallel Computing Centre * - * (c) 2019-2023 The University of Edinburgh + * (c) 2019-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -57,7 +57,7 @@ __host__ int test_fe_surfactant1_suite(void) { cs_t * cs = NULL; field_t * phi = NULL; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); pe_create(MPI_COMM_WORLD, PE_QUIET, &pe); diff --git a/tests/unit/test_fe_ternary.c b/tests/unit/test_fe_ternary.c index 84c08cc69..f2003cc6d 100644 --- a/tests/unit/test_fe_ternary.c +++ b/tests/unit/test_fe_ternary.c @@ -7,7 +7,7 @@ * Edinburgh Soft Matter and Statistical Phsyics Group and * Edinburgh Parallel Computing Centre * - * (c) 2019-2022 The University of Edinburgh + * (c) 2019-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -48,7 +48,7 @@ __host__ int test_fe_ternary_suite(void) { cs_t * cs = NULL; field_t * phi = NULL; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); pe_create(MPI_COMM_WORLD, PE_QUIET, &pe); diff --git a/tests/unit/test_field.c b/tests/unit/test_field.c index 02cb93e76..f80c2e7a2 100644 --- a/tests/unit/test_field.c +++ b/tests/unit/test_field.c @@ -260,7 +260,8 @@ int do_test_device1(pe_t * pe) { ntpb.x = 1; tdpLaunchKernel(do_test_field_kernel1, nblk, ntpb, 0, 0, phi->target); - tdpDeviceSynchronize(); + tdpAssert( tdpPeekAtLastError() ); + tdpAssert( tdpDeviceSynchronize() ); field_free(phi); cs_free(cs); diff --git a/tests/unit/test_halo.c b/tests/unit/test_halo.c index 3cf825563..ccd317921 100644 --- a/tests/unit/test_halo.c +++ b/tests/unit/test_halo.c @@ -8,7 +8,7 @@ * Edinburgh Soft Matter and Statistical Physics Group * Edinburgh Parallel Computing Centre * - * (c) 2010-2022 The University of Edinburgh + * (c) 2010-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -232,7 +232,7 @@ int do_test_halo(pe_t * pe, cs_t * cs, int dim, const lb_data_options_t * opts) assert(dim == X || dim == Y || dim == Z); assert(opts); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); lb_data_create(pe, cs, opts, &lb); diff --git a/tests/unit/test_hydro.c b/tests/unit/test_hydro.c index 409b46f5d..945b6354b 100644 --- a/tests/unit/test_hydro.c +++ b/tests/unit/test_hydro.c @@ -48,7 +48,7 @@ int test_hydro_suite(void) { pe_create(MPI_COMM_WORLD, PE_QUIET, &pe); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); do_test1(pe); do_test_halo1(pe, 1, 1, FIELD_HALO_TARGET); diff --git a/tests/unit/test_polar_active.c b/tests/unit/test_polar_active.c index 60a3bacf8..205f63b49 100644 --- a/tests/unit/test_polar_active.c +++ b/tests/unit/test_polar_active.c @@ -10,7 +10,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2010-2017 The University of Edinbrugh + * (c) 2010-2024 The University of Edinbrugh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -60,7 +60,7 @@ int test_polar_active_suite(void) { field_options_t opts = field_options_ndata_nhalo(nf, nhalo); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); pe_create(MPI_COMM_WORLD, PE_QUIET, &pe); diff --git a/tests/unit/test_prop.c b/tests/unit/test_prop.c index 4f52b48ab..075cf7945 100644 --- a/tests/unit/test_prop.c +++ b/tests/unit/test_prop.c @@ -7,7 +7,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2010-2022 Ths University of Edinburgh + * (c) 2010-2024 Ths University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -46,7 +46,7 @@ int test_lb_prop_suite(void) { cs_create(pe, &cs); cs_init(cs); - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); do_test_velocity(pe, cs, 1, LB_HALO_TARGET); do_test_velocity(pe, cs, 2, LB_HALO_TARGET); diff --git a/tests/unit/test_visc_arrhenius.c b/tests/unit/test_visc_arrhenius.c index aa080c8d5..fe90b831f 100644 --- a/tests/unit/test_visc_arrhenius.c +++ b/tests/unit/test_visc_arrhenius.c @@ -7,7 +7,7 @@ * Edinburgh Soft Matter and Statistical Phsyics Group and * Edinburgh Parallel Computing Centre * - * (c) 2020-2022 The University of Edinburgh + * (c) 2020-2024 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -46,7 +46,7 @@ __host__ int test_visc_arrhenius_suite(void) { cs_t * cs = NULL; field_t * phi = NULL; - tdpGetDeviceCount(&ndevice); + tdpAssert( tdpGetDeviceCount(&ndevice) ); pe_create(MPI_COMM_WORLD, PE_QUIET, &pe);