Revised processor-specific hints for back-off
authorkhizmax <libcds.dev@gmail.com>
Wed, 8 Mar 2017 09:53:00 +0000 (12:53 +0300)
committerkhizmax <libcds.dev@gmail.com>
Wed, 8 Mar 2017 09:53:00 +0000 (12:53 +0300)
16 files changed:
cds/algo/backoff_strategy.h
cds/compiler/backoff.h
cds/compiler/clang/defs.h
cds/compiler/gcc/amd64/backoff.h
cds/compiler/gcc/arm7/backoff.h [new file with mode: 0644]
cds/compiler/gcc/arm8/backoff.h [new file with mode: 0644]
cds/compiler/gcc/ia64/backoff.h
cds/compiler/gcc/ppc64/backoff.h
cds/compiler/gcc/sparc/backoff.h
cds/compiler/gcc/x86/backoff.h
cds/compiler/vc/amd64/backoff.h
cds/compiler/vc/x86/backoff.h
projects/Win/vc14/cds.vcxproj
projects/Win/vc14/cds.vcxproj.filters
projects/Win/vc141/cds.vcxproj
projects/Win/vc141/cds.vcxproj.filters

index 62cf5a5df0c07ddc7e4b7ea1b44c99e5f6ceffc4..0e0711b3d08dd4a49e9dfd020f585dbc9f9e2551 100644 (file)
@@ -129,8 +129,8 @@ namespace cds {
             //@cond
             void operator ()() const CDS_NOEXCEPT
             {
-#            ifdef CDS_backoff_pause_defined
-                platform::backoff_pause();
+#            ifdef CDS_backoff_hint_defined
+                platform::backoff_hint();
 #            endif
             }
 
index 9cfce783d8ca2973a9112e21aba7798eed9be2fb..cdb51fd70b670d286fcbb5ca3a99aefde0727d5f 100644 (file)
 #       include <cds/compiler/gcc/sparc/backoff.h>
 #   elif CDS_PROCESSOR_ARCH == CDS_PROCESSOR_PPC64
 #       include <cds/compiler/gcc/ppc64/backoff.h>
-//#   elif CDS_PROCESSOR_ARCH == CDS_PROCESSOR_ARM7
-//#       include <cds/compiler/gcc/arm7/backoff.h>
+#   elif CDS_PROCESSOR_ARCH == CDS_PROCESSOR_ARM7
+#       include <cds/compiler/gcc/arm7/backoff.h>
+#   elif CDS_PROCESSOR_ARCH == CDS_PROCESSOR_ARM8
+#       include <cds/compiler/gcc/arm8/backoff.h>
 #   endif
 #else
 #   error "Undefined compiler"
index 49723b2b89c92fbd94a1c2125e8c8a25f88f0667..018981692c2f59a51be9b429df35571c32c02212 100644 (file)
 #ifndef CDSLIB_COMPILER_CLANG_DEFS_H
 #define CDSLIB_COMPILER_CLANG_DEFS_H
 
-/*
-    Known issues:
-        Error compiling 64bit boost.atomic on clang 3.4 - 3.5, see https://svn.boost.org/trac/boost/ticket/9610
-        Solution: use boost 1.56 +
-*/
-
 // Compiler version
 #define CDS_COMPILER_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
 
@@ -44,8 +38,8 @@
 #define  CDS_COMPILER__NAME    ("clang " __clang_version__)
 #define  CDS_COMPILER__NICK    "clang"
 
-#if CDS_COMPILER_VERSION < 30300
-#   error "Compiler version error. Clang version 3.3.0 and above is supported"
+#if CDS_COMPILER_VERSION < 30600
+#   error "Compiler version error. Clang version 3.6.0 and above is supported"
 #endif
 
 #if defined(_LIBCPP_VERSION) && !defined(CDS_USE_BOOST_ATOMIC) && CDS_COMPILER_VERSION < 30700
index 6ee6bc4f01b21c2b1e80e4847c3f07a97cbe8378..9896260c9ecc673bb6f3e2b0133374f5e4b22d66 100644 (file)
 namespace cds { namespace backoff {
     namespace gcc { namespace amd64 {
 
-#       define CDS_backoff_pause_defined
-        static inline void backoff_pause( unsigned int nLoop = 0x000003FF )
-        {
-            asm volatile (
-                "andl %[nLoop], %%ecx;      \n\t"
-                "cmovzl %[nLoop], %%ecx;    \n\t"
-                "rep; "
-                "nop;   \n\t"
-                : /*no output*/
-                : [nLoop] "r" (nLoop)
-                : "ecx", "cc"
-                );
-        }
-
 #       define CDS_backoff_nop_defined
         static inline void backoff_nop()
         {
             asm volatile ( "nop;" );
         }
 
+#       define CDS_backoff_hint_defined
+        static inline void backoff_hint()
+        {
+            asm volatile ( "pause;" );
+        }
+
+
     }} // namespace gcc::amd64
 
     namespace platform {
diff --git a/cds/compiler/gcc/arm7/backoff.h b/cds/compiler/gcc/arm7/backoff.h
new file mode 100644 (file)
index 0000000..c5e3a57
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
+
+    Source code repo: http://github.com/khizmax/libcds/
+    Download: http://sourceforge.net/projects/libcds/files/
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef CDSLIB_COMPILER_GCC_ARM7_BACKOFF_H
+#define CDSLIB_COMPILER_GCC_ARM7_BACKOFF_H
+
+//@cond none
+
+namespace cds { namespace backoff {
+    namespace gcc { namespace arm7 {
+
+#       define CDS_backoff_hint_defined
+        static inline void backoff_hint()
+        {
+            asm volatile( "yield" ::: "memory" );
+        }
+    }} // namespace gcc::arm7
+
+    namespace platform {
+        using namespace gcc::arm7;
+    }
+}}  // namespace cds::backoff
+
+//@endcond
+#endif  // #ifndef CDSLIB_COMPILER_GCC_ARM7_BACKOFF_H
diff --git a/cds/compiler/gcc/arm8/backoff.h b/cds/compiler/gcc/arm8/backoff.h
new file mode 100644 (file)
index 0000000..72a6083
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
+
+    Source code repo: http://github.com/khizmax/libcds/
+    Download: http://sourceforge.net/projects/libcds/files/
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef CDSLIB_COMPILER_GCC_ARM8_BACKOFF_H
+#define CDSLIB_COMPILER_GCC_ARM8_BACKOFF_H
+
+//@cond none
+
+namespace cds { namespace backoff {
+    namespace gcc { namespace arm8 {
+
+#       define CDS_backoff_hint_defined
+        static inline void backoff_hint()
+        {
+            asm volatile( "yield" ::: "memory" );
+        }
+    }} // namespace gcc::arm8
+
+    namespace platform {
+        using namespace gcc::arm8;
+    }
+}}  // namespace cds::backoff
+
+//@endcond
+#endif  // #ifndef CDSLIB_COMPILER_GCC_ARM8_BACKOFF_H
index ecc6eb16f883e855d4a5efc7d4235025c597de16..5a0304ed3088b1317b67ad16e7b9097a93d9b88f 100644 (file)
 namespace cds { namespace backoff {
     namespace gcc { namespace ia64 {
 
-#       define CDS_backoff_pause_defined
-        static inline void backoff_pause( unsigned int nLoop = 0x000003FF )
-        {
-            asm volatile ( "hint @pause" );
-        }
-
 #       define CDS_backoff_hint_defined
         static inline void backoff_hint()
         {
index f1bf7fd26a2b28f1179633a7a64bad613ed5f834..75e45741f064b4924f68354a8bbcb7aebb79e420 100644 (file)
 namespace cds { namespace backoff {
     namespace gcc { namespace ppc64 {
 
+#       define CDS_backoff_hint_defined
+        static inline void backoff_hint()
+        {
+            // Provide a hint that performance will probably be improved
+            // if shared resources dedicated to the executing processor are released for use by other processors
+            asm volatile( "or 27,27,27   # yield" );
+        }
     }} // namespace gcc::ppc64
 
     namespace platform {
index 76fb9c457e07b903af37062b0ede17ee13c71a49..41f7ac97cf639451e27b9f170f461960710b4662 100644 (file)
 namespace cds { namespace backoff {
     namespace gcc { namespace Sparc {
 
-#       define CDS_backoff_pause_defined
-        static inline void backoff_pause( unsigned int nLoop = 0x000003FF )
-        {}
-
 #       define CDS_backoff_nop_defined
         static inline void backoff_nop()
         {
index 777bac049bed90fd922a48f40560d4ba363f4b00..30324066493e8d945e19b55e69967887b6b693c0 100644 (file)
 namespace cds { namespace backoff {
     namespace gcc { namespace x86 {
 
-#       define CDS_backoff_pause_defined
-        static inline void backoff_pause( unsigned int nLoop = 0x000003FF )
-        {
-            asm volatile (
-                "andl %[nLoop], %%ecx;      \n\t"
-                "cmovzl %[nLoop], %%ecx;    \n\t"
-                "rep; "
-                "nop;   \n\t"
-                : /*no output*/
-                : [nLoop] "r" (nLoop)
-                : "ecx", "cc"
-                );
-        }
-
 #       define CDS_backoff_nop_defined
         static inline void backoff_nop()
         {
             asm volatile ( "nop;" );
         }
 
+#       define CDS_backoff_hint_defined
+        static inline void backoff_hint()
+        {
+            asm volatile ( "pause;" );
+        }
+
+
     }} // namespace gcc::x86
 
     namespace platform {
index a26b0a0579d7f5bcd9f4baed7c9be325a4192a12..87eec6a5c805e28898232cbd32c5167cf107ac3a 100644 (file)
 #define CDSLIB_COMPILER_VC_AMD64_BACKOFF_H
 
 //@cond none
+#include <intrin.h>
 
 namespace cds { namespace backoff {
     namespace vc { namespace amd64 {
 
-#       define CDS_backoff_pause_defined
-        static inline void backoff_pause( unsigned int nLoop = 0x000003FF )
+#       define CDS_backoff_hint_defined
+        static inline void backoff_hint()
         {
-            for ( unsigned int i = 0; i < nLoop; i++ )
-                __nop();
+            _mm_pause();
         }
 
 #       define CDS_backoff_nop_defined
index 8545104dbc0348e8804dc016b9b32d536d8ddbeb..e2113e954c56e5bd74c4efb5c1dc2952a4c5770e 100644 (file)
 #define CDSLIB_COMPILER_VC_X86_BACKOFF_H
 
 //@cond none
+#include <intrin.h>
 
 namespace cds { namespace backoff {
     namespace vc { namespace x86 {
 
-#       define CDS_backoff_pause_defined
-        static inline void backoff_pause( unsigned int nLoop = 0x000003FF )
+#       define CDS_backoff_hint_defined
+        static inline void backoff_hint()
         {
-            __asm {
-                and ecx, nLoop;
-                cmovz ecx, nLoop;
-                rep nop;
-            }
+            _mm_pause();
         }
 
 #       define CDS_backoff_nop_defined
index a0d0f66a66c47dca48e24cdc612a1a86097c170d..ada6ba795c5e28082decf0f43afedeb70bea5305 100644 (file)
     <ClInclude Include="..\..\..\cds\compiler\cxx11_atomic.h" />\r
     <ClInclude Include="..\..\..\cds\compiler\feature_tsan.h" />\r
     <ClInclude Include="..\..\..\cds\compiler\gcc\amd64\cxx11_atomic.h" />\r
+    <ClInclude Include="..\..\..\cds\compiler\gcc\arm7\backoff.h" />\r
+    <ClInclude Include="..\..\..\cds\compiler\gcc\arm8\backoff.h" />\r
     <ClInclude Include="..\..\..\cds\compiler\gcc\compiler_macro.h" />\r
     <ClInclude Include="..\..\..\cds\compiler\gcc\ia64\cxx11_atomic.h" />\r
     <ClInclude Include="..\..\..\cds\compiler\gcc\sparc\cxx11_atomic.h" />\r
index c54484928e0a4a3b474765e040e7b1d2617ff3a6..82017a5f3236d931fc0b84a3cc7aa86986f4ff9b 100644 (file)
     <Filter Include="Header Files\cds\container\impl">\r
       <UniqueIdentifier>{0a2328b4-ff6f-4afb-8de0-9884ae172fa9}</UniqueIdentifier>\r
     </Filter>\r
+    <Filter Include="Header Files\cds\compiler\gcc\arm7">\r
+      <UniqueIdentifier>{8f1fe8df-3837-42fd-a2f7-581aaf653c53}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Header Files\cds\compiler\gcc\arm8">\r
+      <UniqueIdentifier>{fb32845c-1b47-49d0-8065-4a0aa4b55d6d}</UniqueIdentifier>\r
+    </Filter>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClCompile Include="..\..\..\src\dllmain.cpp">\r
     <ClInclude Include="..\..\..\cds\details\throw_exception.h">\r
       <Filter>Header Files\cds\details</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="..\..\..\cds\compiler\gcc\arm7\backoff.h">\r
+      <Filter>Header Files\cds\compiler\gcc\arm7</Filter>\r
+    </ClInclude>\r
+    <ClInclude Include="..\..\..\cds\compiler\gcc\arm8\backoff.h">\r
+      <Filter>Header Files\cds\compiler\gcc\arm8</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file
index 02cdd5dba56e26b9adf4823b9d9e51e29ff0c5b4..2079d4cfda94fa2f641977e8adef91c0bc4f71f0 100644 (file)
     <ClInclude Include="..\..\..\cds\compiler\cxx11_atomic.h" />
     <ClInclude Include="..\..\..\cds\compiler\feature_tsan.h" />
     <ClInclude Include="..\..\..\cds\compiler\gcc\amd64\cxx11_atomic.h" />
+    <ClInclude Include="..\..\..\cds\compiler\gcc\arm7\backoff.h" />
+    <ClInclude Include="..\..\..\cds\compiler\gcc\arm8\backoff.h" />
     <ClInclude Include="..\..\..\cds\compiler\gcc\compiler_macro.h" />
     <ClInclude Include="..\..\..\cds\compiler\gcc\ia64\cxx11_atomic.h" />
     <ClInclude Include="..\..\..\cds\compiler\gcc\sparc\cxx11_atomic.h" />
index 2b0de7cb1d71eb9f31c25e8d26d4b5a87775b912..3b28674f35a625b7b24d06ae2eb007ff3e8904c5 100644 (file)
     <Filter Include="Header Files\cds\container\impl">
       <UniqueIdentifier>{0a2328b4-ff6f-4afb-8de0-9884ae172fa9}</UniqueIdentifier>
     </Filter>
+    <Filter Include="Header Files\cds\compiler\gcc\arm8">
+      <UniqueIdentifier>{151e21e7-1535-430a-a7d1-676b93d8162c}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\cds\compiler\gcc\arm7">
+      <UniqueIdentifier>{754f330c-8443-4012-b05b-41b3eba647f9}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\..\src\dllmain.cpp">
     <ClInclude Include="..\..\..\cds\details\throw_exception.h">
       <Filter>Header Files\cds\details</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\..\cds\compiler\gcc\arm8\backoff.h">
+      <Filter>Header Files\cds\compiler\gcc\arm8</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\cds\compiler\gcc\arm7\backoff.h">
+      <Filter>Header Files\cds\compiler\gcc\arm7</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>
\ No newline at end of file