Text archives Help
- From: boulos@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r2021 - trunk/Core/Thread
- Date: Tue, 29 Jan 2008 15:48:14 -0700 (MST)
Author: boulos
Date: Tue Jan 29 15:48:13 2008
New Revision: 2021
Modified:
trunk/Core/Thread/AtomicCounter_x86.cc
trunk/Core/Thread/Thread_pthreads.cc
Log:
Core/Thread/AtomicCounter_x86.cc
Changing volatile to register and adding an additional movl and
__volatile__ for set.
The atomic counter now works on Leopard for Release and Debug for
32-bits and 64-bits. Please test on Linux and Win32.
bin/atomic_counter 4 100 also seems to match the manta behavior. If
the program produces correct output (and returns 0) then Manta
works. Otherwise, the atomic counter is busted on your system.
Core/Thread/Thread_pthreads.cc
Enabling the x86 AtomicCounter as long as you're not using the Intel
Compiler (which I can't test).
Modified: trunk/Core/Thread/AtomicCounter_x86.cc
==============================================================================
--- trunk/Core/Thread/AtomicCounter_x86.cc (original)
+++ trunk/Core/Thread/AtomicCounter_x86.cc Tue Jan 29 15:48:13 2008
@@ -66,7 +66,7 @@
int
AtomicCounter::operator++() {
- volatile int return_val = 1;
+ register int return_val = 1;
__asm__ __volatile__(
"lock;\n"
@@ -80,7 +80,7 @@
int
AtomicCounter::operator++(int) {
- volatile int return_val = 1;
+ register int return_val = 1;
__asm__ __volatile__(
"lock;\n"
@@ -94,7 +94,7 @@
int
AtomicCounter::operator--() {
- volatile int return_val = -1;
+ register int return_val = -1;
__asm__ __volatile__(
"lock;\n"
"xaddl %1, %0;\n" :
@@ -107,7 +107,7 @@
int
AtomicCounter::operator--(int) {
- volatile int return_val = -1;
+ register int return_val = -1;
__asm__ __volatile__(
"lock;\n"
"xaddl %1, %0;\n" :
@@ -121,12 +121,13 @@
void
AtomicCounter::set(int v) {
- volatile int copy_val = v;
+ __volatile__ register int copy_val = v;
__asm__ __volatile__(
+ "movl %1, %2;\n"
"lock;\n"
"xchgl %1, %0\n" :
"=m" (value), "=r" (copy_val) :
- "m" (value), "r" (copy_val) :
+ "m" (value), "r" (copy_val), "r" (v) :
/* no unknown clobbers */
);
}
Modified: trunk/Core/Thread/Thread_pthreads.cc
==============================================================================
--- trunk/Core/Thread/Thread_pthreads.cc (original)
+++ trunk/Core/Thread/Thread_pthreads.cc Tue Jan 29 15:48:13 2008
@@ -162,10 +162,13 @@
#include <Core/Thread/Barrier_default.cc>
#ifdef MANTA_X86
-#include <Core/Thread/AtomicCounter_default.cc>
-//AtomicCounter_x86 is currently broken.
-//#include <Core/Thread/AtomicCounter_x86.cc>
-#else
+# if !defined(__INTEL_COMPILER)
+# include <Core/Thread/AtomicCounter_x86.cc>
+# else
+//AtomicCounter_x86 is currently broken for ICC.
+# include <Core/Thread/AtomicCounter_default.cc>
+# endif // intel compiler or not
+#else // manta_x86 or not
#include <Core/Thread/AtomicCounter_default.cc>
#endif
#endif
- [Manta] r2021 - trunk/Core/Thread, boulos, 01/29/2008
Archive powered by MHonArc 2.6.16.