Solved

Using memory without cache for benchmark?

Posted on 2004-09-23
3
169 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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 (http://en.wikipedia.org/wiki/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 and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

803 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