]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Disable a fallback option in the BatchOptimizer 10066/head
authorJean-Paul Pelteret <jppelteret@gmail.com>
Thu, 7 May 2020 21:58:07 +0000 (23:58 +0200)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Thu, 7 May 2020 21:58:07 +0000 (23:58 +0200)
This is what is promised in the documentation, and I forgot to change the behaviour everywhere.

include/deal.II/differentiation/sd/symengine_optimizer.h
source/differentiation/sd/symengine_optimizer.cc

index e9e12dfa5ff7399a98976edc25881e60498880e5..36d8229f8ed1fa085c6f0e0921ab586a5d6468bf 100644 (file)
@@ -35,6 +35,7 @@ DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
 #  endif
 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
 
+#  include <deal.II/base/exceptions.h>
 #  include <deal.II/base/logstream.h>
 #  include <deal.II/base/utilities.h>
 
@@ -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 <typename ReturnType>
     class BatchOptimizer;
index c7449d3b21946b9068291f5943fe6a2290fe61d1..474e0828a117af64dc4036a2ccf4201edfc49257 100644 (file)
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.