--- stream-one-gethuge.orig	2008-12-03 11:18:19.000000000 +0000
+++ stream-one-gethuge.c	2008-12-03 11:28:47.000000000 +0000
@@ -46,6 +46,7 @@
 # include <limits.h>
 # include <sys/time.h>
 # include <stdlib.h>
+# include <hugetlbfs.h>
 
 /* INSTRUCTIONS:
  *
@@ -122,9 +123,15 @@
     int			BytesPerWord;
     register int	j, k;
     double		scalar, t, times[4][NTIMES];
+    size_t		bufsize;
+
+    /* Calculate and hugepage-align the size of the arrays */
+    bufsize = sizeof(double) * (N + OFFSET) * 3;
+    bufsize = (bufsize + gethugepagesize() - 1) & ~(gethugepagesize() - 1);
+    printf("Allocating buffer size %zd\n", bufsize);
 
     /* --- SETUP --- determine precision and check timing --- */
-    a = malloc(sizeof(double) * (N + OFFSET) * 3);
+    a = get_huge_pages(bufsize, GHP_DEFAULT);
     b = a + N + OFFSET;
     c = b + N + OFFSET;
     if (a == NULL) {
@@ -137,7 +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("The work arrays are allocated with get_huge_pages()\n");
 
     printf(HLINE);
     printf("Array size = %d, Offset = %d\n" , N, OFFSET);
@@ -276,7 +283,7 @@
     checkSTREAMresults();
     printf(HLINE);
 
-    free(a);
+    free_huge_pages(a);
     return 0;
 }
 

