WL#4963: Fix prefetch when using SunStudio with InnoDB

Affects: Server-5.4   —   Status: Complete   —   Priority: Medium

Fixing prefetch when using SunStudio with InnoDB
In MySQL 5.4.0
Memory prefetching with SunStudio does not work. IFDEFs in the code that apply
only to Linux must be changed to include SunStudio with proper use of macros
from SunStudio to implement prefetching.
Sparc prefetch patch
      Compile fixes, sun_prefetch.h only available on Sun Studio
  Use sun_prefetch_read_many() and friends, instead of sparc_prefetch_read_many(),
  etc.  The sparc_* are defined only for sparc, but the sun_* are generic for x86
  and sparc (and are defined empty for any other platform). 


=== modified file 'storage/innobase/include/univ.i'
--- storage/innobase/include/univ.i	2008-03-27 01:40:45 +0000
+++ storage/innobase/include/univ.i	2008-10-13 19:46:29 +0000
@@ -9,6 +9,10 @@ Created 1/20/1994 Heikki Tuuri
 #ifndef univ_i
 #define univ_i
 
+#if ( defined(sun) || defined(__sun) )
+# include <sun_prefetch.h>
+#endif
+
 #if (defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)) &&
!defined(MYSQL_SERVER) && !defined(__WIN__)
 # undef __WIN__
 # define __WIN__
@@ -274,6 +278,11 @@ it is read. */
 /* Minimize cache-miss latency by moving data at addr into a cache before
 it is read or written. */
 # define UNIV_PREFETCH_RW(addr) __builtin_prefetch(addr, 1, 3)
+#elif ( defined(sun) || defined(__sun) )
+# define UNIV_EXPECT(expr,value) (expr)
+# define UNIV_LIKELY_NULL(expr) (expr)
+# define UNIV_PREFETCH_R(addr) sparc_prefetch_read_many(addr)
+# define UNIV_PREFETCH_RW(addr) sparc_prefetch_write_many(addr)
 #else
 /* Dummy versions of the macros */
 # define UNIV_EXPECT(expr,value) (expr)


=== modified file 'storage/innobase/include/univ.i'
--- storage/innobase/include/univ.i	2008-10-13 19:46:29 +0000
+++ storage/innobase/include/univ.i	2008-10-16 15:06:48 +0000
@@ -9,7 +9,7 @@ Created 1/20/1994 Heikki Tuuri
 #ifndef univ_i
 #define univ_i
 
-#if ( defined(sun) || defined(__sun) )
+#ifdef __SUNPRO_C
 # include <sun_prefetch.h>
 #endif
 
@@ -278,7 +278,7 @@ it is read. */
 /* Minimize cache-miss latency by moving data at addr into a cache before
 it is read or written. */
 # define UNIV_PREFETCH_RW(addr) __builtin_prefetch(addr, 1, 3)
-#elif ( defined(sun) || defined(__sun) )
+#elif defined(__SUNPRO_C)
 # define UNIV_EXPECT(expr,value) (expr)
 # define UNIV_LIKELY_NULL(expr) (expr)
 # define UNIV_PREFETCH_R(addr) sparc_prefetch_read_many(addr)



=== modified file 'storage/innobase/include/univ.i'
--- storage/innobase/include/univ.i	2008-10-30 09:23:36 +0000
+++ storage/innobase/include/univ.i	2009-01-28 21:17:20 +0000
@@ -291,8 +291,8 @@ it is read or written. */
 #elif defined(__SUNPRO_C)
 # define UNIV_EXPECT(expr,value) (expr)
 # define UNIV_LIKELY_NULL(expr) (expr)
-# define UNIV_PREFETCH_R(addr) sparc_prefetch_read_many(addr)
-# define UNIV_PREFETCH_RW(addr) sparc_prefetch_write_many(addr)
+# define UNIV_PREFETCH_R(addr) sun_prefetch_read_many(addr)
+# define UNIV_PREFETCH_RW(addr) sun_prefetch_write_many(addr)
 #else
 /* Dummy versions of the macros */
 # define UNIV_EXPECT(expr,value) (expr)

=== modified file 'storage/ndb/include/portlib/prefetch.h'
--- storage/ndb/include/portlib/prefetch.h	2006-12-23 19:20:40 +0000
+++ storage/ndb/include/portlib/prefetch.h	2009-01-28 21:17:20 +0000
@@ -43,7 +43,7 @@ inline void prefetch(void* p)
    __asm(" ldl r31,0(a0);", p);
 #endif /* NDB_ALPHA */
 #ifdef NDB_FORTE6
-  sparc_prefetch_read_once(p);
+  sun_prefetch_read_once(p);
 #else 
   (void)p;
 #endif
@@ -55,7 +55,7 @@ inline void writehint(void* p)
    __asm(" wh64 (a0);", p);
 #endif /* NDB_ALPHA */
 #ifdef NDB_FORTE6
-  sparc_prefetch_write_once(p);
+  sun_prefetch_write_once(p);
 #else
   (void)p;
 #endif