Commits

Anonymous committed dc43d99

current OpenMP complaints about return from critical blocks, also removed nested criticial blocks

  • Participants
  • Parent commits c2cd215

Comments (0)

Files changed (2)

 
 /* void m4ri_mm_free(void *condemned, ...); */
 static inline void m4ri_mm_free(void *condemned, ...) { 
-#ifdef HAVE_OPENMP
-#pragma omp critical
-{
-#endif
 #ifdef HAVE_MM_MALLOC
   _mm_free(condemned); 
 #else
   free(condemned);
-#endif  
-#ifdef HAVE_OPENMP
- }
 #endif
 }
 
  */
 
 static inline void *m4ri_mmc_malloc(size_t size) {
+
+#ifdef ENABLE_MMC
+  void *ret = NULL;
+#endif
+
 #ifdef HAVE_OPENMP
 #pragma omp critical
 {
 #endif
+
 #ifdef ENABLE_MMC
   mmb_t *mm = m4ri_mmc_handle();
   if (size <= M4RI_MMC_THRESHOLD) {
     size_t i;
     for (i=0; i<M4RI_MMC_NBLOCKS; i++) {
       if(mm[i].size == size) {
-        void *ret = mm[i].data;
+        ret = mm[i].data;
         mm[i].data = NULL;
         mm[i].size = 0;
-        return ret;
+        break;
       }
     }
   }
 #endif //ENABLE_MMC
+
 #ifdef HAVE_OPENMP
  }
 #endif
-  return m4ri_mm_malloc(size);
+
+#ifdef ENABLE_MMC
+ if (ret)
+   return ret;
+ else
+   return m4ri_mm_malloc(size);
+#else 
+ return m4ri_mm_malloc(size);
+#endif
 }
 
 /**
 #pragma omp critical
 {
 #endif
-#ifdef ENABLE_MMC
+#ifdef ENABLE_MMC  
   static size_t j = 0;
   mmb_t *mm = m4ri_mmc_handle();
   if (size < M4RI_MMC_THRESHOLD) {
       if(mm[i].size == 0) {
         mm[i].size = size;
         mm[i].data = condemned;
-        return;
+        break;
       }
     }
-    m4ri_mm_free(mm[j].data);
-    mm[j].size = size;
-    mm[j].data = condemned;
-    j = (j+1) % M4RI_MMC_NBLOCKS;
-    return;
+    if (i == M4RI_MMC_NBLOCKS) {
+      m4ri_mm_free(mm[j].data);
+      mm[j].size = size;
+      mm[j].data = condemned;
+      j = (j+1) % M4RI_MMC_NBLOCKS;
+    }
+  } else {
+    m4ri_mm_free(condemned);
   }
+#else
+  m4ri_mm_free(condemned);
 #endif //ENABLE_MMC
 #ifdef HAVE_OPENMP
  }
 #endif
-  m4ri_mm_free(condemned);
 }
 
 /**

testsuite/Makefile

 CFLAGS=-I.. -std=c99
-LDFLAGS=-L../.libs/ -lm4ri 
+LDFLAGS=-L../.libs/ -lm4ri
 DEBUG=-ggdb
 
 TEST_PRGS=test_elimination test_multiplication test_trsm test_lqup test_solve test_kernel