• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

Using memory without cache for benchmark?

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.
0
neushoorn
Asked:
neushoorn
1 Solution
 
Kent OlsenData Warehouse Architect / DBACommented:

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,
Kent
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Worried about phishing attacks?

90% of attacks start with a phish. It’s critical that IT admins and MSSPs have the right security in place to protect their end users from these phishing attacks. Check out our latest feature brief for tips and tricks to keep your employees off a hackers line!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now