getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] r5474 - /trunk/getfem/src/getfem_generic_assembly.cc


From: andriy . andreykiv
Subject: [Getfem-commits] r5474 - /trunk/getfem/src/getfem_generic_assembly.cc
Date: Wed, 09 Nov 2016 15:48:48 -0000

Author: andrico
Date: Wed Nov  9 16:48:47 2016
New Revision: 5474

URL: http://svn.gna.org/viewcvs/getfem?rev=5474&view=rev
Log:
defining new assembly functions is made thread-safe and allowed in parallel.
Repeated definition of the same function is allowed, the second definition is 
skipped.

Modified:
    trunk/getfem/src/getfem_generic_assembly.cc

Modified: trunk/getfem/src/getfem_generic_assembly.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_generic_assembly.cc?rev=5474&r1=5473&r2=5474&view=diff
==============================================================================
--- trunk/getfem/src/getfem_generic_assembly.cc (original)
+++ trunk/getfem/src/getfem_generic_assembly.cc Wed Nov  9 16:48:47 2016
@@ -2691,6 +2691,10 @@
   void ga_define_function(const std::string &name, size_type nbargs,
                           const std::string &expr, const std::string &der1,
                           const std::string &der2) {
+    auto guard = omp_guard{};
+
+    auto &PREDEF_FUNCTIONS = 
dal::singleton<ga_predef_function_tab>::instance(0);
+    if(PREDEF_FUNCTIONS.find(name) != PREDEF_FUNCTIONS.end()) return;
     GMM_ASSERT1(nbargs >= 1 && nbargs <= 2, "Generic assembly only allows "
                 "the definition of scalar function with one or two arguments");
     { // Only for syntax analysis
@@ -2702,14 +2706,8 @@
       workspace.add_function_expression(expr);
     }
 
-    ga_predef_function_tab &PREDEF_FUNCTIONS
-      = dal::singleton<ga_predef_function_tab>::instance(0);
-    GMM_ASSERT1(PREDEF_FUNCTIONS.find(name) == PREDEF_FUNCTIONS.end(),
-                "Already defined function " << name);
     PREDEF_FUNCTIONS[name] = ga_predef_function(expr);
     ga_predef_function &F = PREDEF_FUNCTIONS[name];
-    GMM_ASSERT1(!me_is_multithreaded_now(),
-                "functions should not be defined in multi-threaded code");
     F.gis = std::make_unique<instruction_set>();
     for (size_type thread = 0; thread < num_threads(); ++thread)
     {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]