chiark / gitweb /
do not bother with barriers and stuff if nprocessors=1
authorIan Jackson <ian@davenant.relativity.greenend.org.uk>
Sun, 28 Sep 2008 23:13:52 +0000 (00:13 +0100)
committerIan Jackson <ian@davenant.relativity.greenend.org.uk>
Sun, 28 Sep 2008 23:13:52 +0000 (00:13 +0100)
parallel.c

index d9782df..f5841ee 100644 (file)
@@ -54,7 +54,7 @@ void inparallel(const struct Vertices *vertices,
 
   int s, r;
 
-  if (!threads_started) {
+  if (NSECTIONS>1 && !threads_started) {
     r= pthread_barrier_init(&threads_barrier, 0, NSECTIONS);
     if (r) { errno=r; diee("pthread_barrier_init"); }
 
@@ -82,8 +82,10 @@ void inparallel(const struct Vertices *vertices,
 }
 
 void inparallel_barrier(void) {
-  int r;
-  r= pthread_barrier_wait(&threads_barrier);
-  if (r && r!=PTHREAD_BARRIER_SERIAL_THREAD)
-    { errno=r; diee("pthread_barrier_wait"); }
+  if (NSECTIONS>1) {
+    int r;
+    r= pthread_barrier_wait(&threads_barrier);
+    if (r && r!=PTHREAD_BARRIER_SERIAL_THREAD)
+      { errno=r; diee("pthread_barrier_wait"); }
+  }
 }