From bbefc3dad687f4370afd5bc85386d983201cb321 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Mon, 24 Feb 2020 15:54:50 -0800 Subject: Profiler wrapper to allow for cudaDeviceSynchronize (#738) * add warpx profiler wrapper * call WX profiler wrapper instead of BL * EOL and cleaning * add doc on profile syncs * do not use PROFILE macros in .H files * replace WX_PROFILE with WARPX_PROFILE and use bool instead of int * typo * this file shouldn't be there --- Source/Utils/WarpXProfilerWrapper.H | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Source/Utils/WarpXProfilerWrapper.H (limited to 'Source/Utils/WarpXProfilerWrapper.H') diff --git a/Source/Utils/WarpXProfilerWrapper.H b/Source/Utils/WarpXProfilerWrapper.H new file mode 100644 index 000000000..6d18e22ba --- /dev/null +++ b/Source/Utils/WarpXProfilerWrapper.H @@ -0,0 +1,27 @@ +/* Copyright 2020 Axel Huebl, Maxence Thevenet + * + * This file is part of WarpX. + * + * License: BSD-3-Clause-LBNL + */ + +#ifndef WARPX_PROFILERWRAPPER_H_ +#define WARPX_PROFILERWRAPPER_H_ + +#include "AMReX_BLProfiler.H" +#include "AMReX_GpuDevice.H" + +static void doDeviceSynchronize(int do_device_synchronize) +{ + if ( do_device_synchronize ) + amrex::Gpu::synchronize(); +} + +#define WARPX_PROFILE(fname) doDeviceSynchronize(WarpX::do_device_synchronize_before_profile); BL_PROFILE(fname) +#define WARPX_PROFILE_VAR(fname, vname) doDeviceSynchronize(WarpX::do_device_synchronize_before_profile); BL_PROFILE_VAR(fname, vname) +#define WARPX_PROFILE_VAR_NS(fname, vname) doDeviceSynchronize(WarpX::do_device_synchronize_before_profile); BL_PROFILE_VAR_NS(fname, vname) +#define WARPX_PROFILE_VAR_START(vname) doDeviceSynchronize(WarpX::do_device_synchronize_before_profile); BL_PROFILE_VAR_START(vname) +#define WARPX_PROFILE_VAR_STOP(vname) doDeviceSynchronize(WarpX::do_device_synchronize_before_profile); BL_PROFILE_VAR_STOP(vname) +#define WARPX_PROFILE_REGION(rname) doDeviceSynchronize(WarpX::do_device_synchronize_before_profile); BL_PROFILE_REGION(rname) + +#endif // WARPX_PROFILERWRAPPER_H_ -- cgit v1.2.3