From c1043e58f9011028e43fe86ef73dee44b05f746e Mon Sep 17 00:00:00 2001 From: eschnett Date: Thu, 20 Feb 2014 20:04:20 +0000 Subject: Do not call LinearCombination unless the evolved variable lives on the device git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/MoL/trunk@211 578cdeb0-5ea1-4b81-8215-5a3b8777ee0b --- interface.ccl | 4 ++++ src/Operators.c | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/interface.ccl b/interface.ccl index f12606b..ccafdbb 100644 --- a/interface.ccl +++ b/interface.ccl @@ -215,6 +215,10 @@ CCTK_INT FUNCTION GetRefinementLevel \ (CCTK_POINTER_TO_CONST IN cctkGH) USES FUNCTION GetRefinementLevel +CCTK_INT FUNCTION Device_GetDevice \ + (CCTK_POINTER_TO_CONST IN cctkGH) +USES FUNCTION Device_GetDevice + # Computes: # var = scale * var + \sum_i^nsrcs facts[i] * scrcs[i][tls[i]] CCTK_INT FUNCTION LinearCombination \ diff --git a/src/Operators.c b/src/Operators.c index 2cbde16..01947b4 100644 --- a/src/Operators.c +++ b/src/Operators.c @@ -226,10 +226,18 @@ MoL_LinearCombination(cGH const *const cctkGH, { DECLARE_CCTK_PARAMETERS; - // Forward call to aliased function, if it is defined + // Forward call to aliased function, if it is defined and if we are + // using the device (accelerator) static int is_aliased = -1; if (is_aliased < 0) { - is_aliased = CCTK_IsFunctionAliased("LinearCombination"); + int is_device = 0; + if (CCTK_IsFunctionAliased("Device_GetDevice")) { + is_device = Device_GetDevice(cctkGH) >= 0; + } + is_aliased = 0; + if (is_device) { + is_aliased = CCTK_IsFunctionAliased("LinearCombination"); + } } if (is_aliased) { return -- cgit v1.2.3