{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ctest - return 1 printf"Starting ctest stride%d\n"...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * Performance test from former 161 prof. Brad Chen * Stresses VM. * * Intended for the VM assignment. This should run successfully on a * variety of strides when the VM system is complete. Strides that are * not a multiple of 2 work better; see below. */ #include <stdio.h> #include <stdlib.h> /* * SIZE is the amount of memory used. * DEFAULT is the default stride. * Note that SIZE and DEFAULT should be relatively prime. */ #define SIZE (1024*1024/sizeof(struct entry)) #define DEFAULT 477 struct entry { struct entry *e; }; struct entry array[SIZE]; int main(int argc, char **argv) { volatile struct entry *e; unsigned i, stride; stride = DEFAULT; if (argc == 2) { stride = atoi(argv[1]); } if (stride <= 0 || argc > 2) { printf("Usage: ctest [stridesize]\n"); printf(" stridesize should not be a multiple of 2.\n");
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: return 1; } printf("Starting ctest: stride %d\n", stride); /* * Generate a huge linked list, with each entry pointing to * the slot STRIDE entries above it. As long as STRIDE and SIZE * are relatively prime, this will put all the entries on one * list. Otherwise you will get multiple disjoint lists. (All * these lists will be circular.) */ for (i=0; i<SIZE; i++) { array[i].e = &array[(i+stride) % SIZE]; } /* * Traverse the list. We stop after hitting each element once. * * (If STRIDE was even, this will hit some elements more than * once and others not at all.) */ e = &array[0]; for (i=0; i<SIZE; i++) { if (i % stride == 0) { putchar('.'); } e = e->e; } printf("\nDone!\n"); return 0; }...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern