commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 01/01: volk: make volk's get_machine thread


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/01: volk: make volk's get_machine thread safe.
Date: Wed, 29 Jan 2014 00:04:15 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch maint
in repository gnuradio.

commit e2acdc57d1b0ccb3fc9e91add8d141118cf78e3d
Author: Roy Thompson <address@hidden>
Date:   Tue Jan 28 16:11:00 2014 -0500

    volk: make volk's get_machine thread safe.
    
    Sets a local struct instead of the global while searching. When found, then 
sets the machine.
    
    This assumes that the pointer assignment is atomic, which it probably is on 
almost any platform.
---
 volk/tmpl/volk.tmpl.c | 44 ++++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/volk/tmpl/volk.tmpl.c b/volk/tmpl/volk.tmpl.c
index f915f15..eb22435 100644
--- a/volk/tmpl/volk.tmpl.c
+++ b/volk/tmpl/volk.tmpl.c
@@ -32,28 +32,32 @@
 static size_t __alignment = 0;
 static intptr_t __alignment_mask = 0;
 
-struct volk_machine *get_machine(void) {
-    extern struct volk_machine *volk_machines[];
-    extern unsigned int n_volk_machines;
-    static struct volk_machine *machine = NULL;
-    
-    if(machine != NULL) return machine;
-    else {
-        unsigned int max_score = 0;
-        unsigned int i;
-        for(i=0; i<n_volk_machines; i++) {
-            if(!(volk_machines[i]->caps & (~volk_get_lvarch()))) {
-                if(volk_machines[i]->caps > max_score) {
-                    max_score = volk_machines[i]->caps;
-                    machine = volk_machines[i];
-                }
-            }
+struct volk_machine *get_machine(void)
+{
+  extern struct volk_machine *volk_machines[];
+  extern unsigned int n_volk_machines;
+  static struct volk_machine *machine = NULL;
+
+  if(machine != NULL)
+    return machine;
+  else {
+    unsigned int max_score = 0;
+    unsigned int i;
+    struct volk_machine *max_machine = NULL;
+    for(i=0; i<n_volk_machines; i++) {
+      if(!(volk_machines[i]->caps & (~volk_get_lvarch()))) {
+        if(volk_machines[i]->caps > max_score) {
+          max_score = volk_machines[i]->caps;
+          max_machine = volk_machines[i];
         }
-        printf("Using Volk machine: %s\n", machine->name);
-        __alignment = machine->alignment;
-        __alignment_mask = (intptr_t)(__alignment-1);
-        return machine;
+      }
     }
+    machine = max_machine;
+    printf("Using Volk machine: %s\n", machine->name);
+    __alignment = machine->alignment;
+    __alignment_mask = (intptr_t)(__alignment-1);
+    return machine;
+  }
 }
 
 size_t volk_get_alignment(void)



reply via email to

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