From fd9f90bbbf890b13db7e57c3fc7b7fae7b308aa2 Mon Sep 17 00:00:00 2001 From: Jean-Paul Pelteret Date: Thu, 7 May 2020 23:58:07 +0200 Subject: [PATCH] Disable a fallback option in the BatchOptimizer This is what is promised in the documentation, and I forgot to change the behaviour everywhere. --- .../differentiation/sd/symengine_optimizer.h | 24 +++++++++++++++++++ .../differentiation/sd/symengine_optimizer.cc | 18 +++++--------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/include/deal.II/differentiation/sd/symengine_optimizer.h b/include/deal.II/differentiation/sd/symengine_optimizer.h index e9e12dfa5f..36d8229f8e 100644 --- a/include/deal.II/differentiation/sd/symengine_optimizer.h +++ b/include/deal.II/differentiation/sd/symengine_optimizer.h @@ -35,6 +35,7 @@ DEAL_II_DISABLE_EXTRA_DIAGNOSTICS # endif DEAL_II_ENABLE_EXTRA_DIAGNOSTICS +# include # include # include @@ -62,6 +63,29 @@ namespace Differentiation { namespace SD { + /** + * @addtogroup Exceptions + * @{ + */ + + /** + * An exception to indicate that the SymEngine library has not been built + * against the LLVM compiler. + */ + DeclExceptionMsg(ExcSymEngineLLVMNotAvailable, + "SymEngine has not been built with LLVM support."); + + /** + * An exception to indicate that SymEngine's LLVM optimizer doesn't work + * with the desired return type. + */ + DeclExceptionMsg(ExcSymEngineLLVMReturnTypeNotSupported, + "The SymEngine LLVM optimizer does not (yet) support the " + "selected return type."); + + //@} + + // Forward declarations template class BatchOptimizer; diff --git a/source/differentiation/sd/symengine_optimizer.cc b/source/differentiation/sd/symengine_optimizer.cc index c7449d3b21..474e0828a1 100644 --- a/source/differentiation/sd/symengine_optimizer.cc +++ b/source/differentiation/sd/symengine_optimizer.cc @@ -78,18 +78,14 @@ namespace Differentiation ExcMessage( "Cannot call set_optimization_method() once the optimizer is finalized.")); - method = optimization_method; # ifndef HAVE_SYMENGINE_LLVM - if (this->optimization_method() == OptimizerType::llvm) + if (optimization_method == OptimizerType::llvm) { - // Fall-back if the LLVM JIT compiler is not available - deallog - << "Warning: The LLVM is not available, so the batch optimizer " - << "is using a lambda optimizer instead." << std::endl; - method = OptimizerType::lambda; + AssertThrow(false, ExcSymEngineLLVMNotAvailable()); } # endif - flags = optimization_flags; + method = optimization_method; + flags = optimization_flags; } @@ -774,12 +770,10 @@ namespace Differentiation } else { - AssertThrow(false, - ExcMessage("The SymEngine LLVM optimizer does not " - "(yet) support the selected ReturnType.")); + AssertThrow(false, ExcSymEngineLLVMReturnTypeNotSupported()); } # else - AssertThrow(false, ExcMessage("The LLVM compiler is not available.")); + AssertThrow(false, ExcSymEngineLLVMNotAvailable()); # endif } else -- 2.39.5