Using memory without cache for benchmark?

Posted on 2004-09-23
Last Modified: 2010-04-15
I'm writing a crossplaform bechmark in c. It's meanth to test the effects that some bios settings have on you're overall system. For nom it only has a FPU test but the next test i want to write a memory bandwith test. I' don't need to know the exact value of the memory bandwith but just a relative value to see how you're sistem improves or doesn't.

I wanted to test this by copying data of memory into another place in the memory but is there any way i can make make shure i'm not reading or writing to the cache by clearing it or something else? How do i best do this? If possible a crossplatform (linux / windows) would be the best but if it's not possible two different  way's to do this(one for linux one for windows ) are no problem.
Any other suggenstions on doing this test are also more than welcome.
Question by:neushoorn
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 45

Accepted Solution

Kent Olsen earned 125 total points
ID: 12143008

Without hacking into the BIOs and disabling the cache your options are somewhat limited.  But you do have options.

I'd run several tests with data transfers of different sizes so that the tests show the effects of copying withing the cache and with repeated cache voiding.

#define XFER1 256
#define XFER2 1024
#define XFER3 4096
#define XFER4 16384
#define XFER5 65536
#define XFER6 262144
#define XFER7 1048576
#define XFER8 4194304
#define XFER9 16777216

#define XFER_LIMIT 2147483647

unisgned int TransferSize[10] = {XFER1, XFER2, XFER3, XFER4, XFER5, XFER6, XFER7, XFER8, XFER9, 0};

int Method;
char *ibuf = 0;
char *obuf = 0;
int XferSize;
int PassCount;
int idx;

for (Method = 0; TransferSize[Method]; Method++)
  XferSize = TransferSize[Method];
  PassCount = XFER_LIMIT / XferSize;
  ibuf = (char *)realloc (ibuf);
  obuf = (char *)realloc (obuf);
  for (idx = 0; idx < PassCount; idx++)
    memcpy (obuf, ibuf, XferSize);

Just insert your timing controls around the inner for() loop and you'll get an idea of how long it takes to move 2GB in chunks of varying sizes.  The smaller blocks will void the cache once, at most.  The larger blocks will repeated void the cache.

This doesn't give you the answer that you're looking for, but it will give you an idea of relative performance based on "cache only" and "cache voiding".

Good Luck,

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question