Solved

Using memory without cache for benchmark?

Posted on 2004-09-23
3
165 Views
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.
0
Comment
Question by:neushoorn
3 Comments
 
LVL 45

Accepted Solution

by:
Kdo 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,
Kent
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

762 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now