User: Password:
|
|
Subscribe / Log in / New account

Patch for STREAM to use malloc()

This patch goes with Huge pages part 5: A deeper look at TLBs and costs.

--- stream.c	2009-08-13 17:19:35.000000000 +0100
+++ stream-malloc.c	2009-08-13 17:19:21.000000000 +0100
@@ -45,6 +45,7 @@
 # include <float.h>
 # include <limits.h>
 # include <sys/time.h>
+# include <stdlib.h>
 
 /* INSTRUCTIONS:
  *
@@ -94,9 +95,7 @@
 # define MAX(x,y) ((x)>(y)?(x):(y))
 # endif
 
-static double	a[N+OFFSET],
-		b[N+OFFSET],
-		c[N+OFFSET];
+static double	*a, *b, *c;
 
 static double	avgtime[4] = {0}, maxtime[4] = {0},
 		mintime[4] = {FLT_MAX,FLT_MAX,FLT_MAX,FLT_MAX};
@@ -131,6 +130,13 @@
     double		scalar, t, times[4][NTIMES];
 
     /* --- SETUP --- determine precision and check timing --- */
+    a = (double *)malloc(sizeof(double) * (N + OFFSET) * 3);
+    b = a + N + OFFSET;
+    c = b + N + OFFSET;
+    if (a == NULL) {
+        printf("Failed to alloc arrays\n");
+        exit(-1);
+    }
 
     printf(HLINE);
     printf("STREAM version $Revision: 5.9 $\n");
@@ -138,6 +144,7 @@
     BytesPerWord = sizeof(double);
     printf("This system uses %d bytes per DOUBLE PRECISION word.\\n",
 	BytesPerWord);
+    printf("The work arrays are allocated with malloc()\\n");
 
     printf(HLINE);
 #ifdef NO_LONG_LONG

(Log in to post comments)


Copyright © 2010, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds