I
I
igorsap132018-12-01 13:07:17
C++ / C#
igorsap13, 2018-12-01 13:07:17

How to manage cpu cache?

There is a program - it performs mathematical operations. RAM takes up a lot. More than 25 GB. But there is a spare RAM.
When data is loaded into the processor cache, operations are performed quickly. But if you do not perform operations for some time (30 seconds), and then start again, they begin to be performed 10 times slower. (Because it loads into the processor cache again). Then the speed returns to normal again.
Question - is it possible to manage the processor cache somehow?
Prevent him from clearing the cache himself? Somehow write it yourself and delete it if necessary?
How to calculate how much cache the processor needs for such an array (more than 25 GB - data is stored in (float *a = new float[5 000 000 000];))?
No other operations are performed on the server.
I am using Windows Server 2012 R2. Visual Studio 2015 (c++). Intel Xeon e5-2660 v4 (35 MB cache per processor).
PS The operations themselves are optimized. Question - what to do with the cache?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
J
jcmvbkbc, 2018-12-01
@jcmvbkbc

There is a program - it performs mathematical operations. RAM takes up a lot. More than 25 GB. But there is a spare RAM.
When data is loaded into the processor cache, operations are performed quickly.

I also want a processor cache greater than 25GB, but in your case, the processor cache has nothing to do with it.
To begin with, understand what a "processor cache" is, how much it is and how it works. Then understand how physical memory is allocated to the application, where it comes from and where it goes if it is not used.
If you want to stake an array in physical memory -- look at VirtualLock .

R
res2001, 2018-12-01
@res2001

It looks like your gigabytes manage to be swapped during the pause, hence the brakes until the OS gets them out of there.
You cannot directly manage the cache in any way, you can only indirectly structure the code and data accordingly. You cannot increase the cache size either, except to put a percentage with a larger cache.
For now, try adding memory to the computer, so that your entire array would fit there (and even the reserve was for other tasks and OS).
By the way, you did not give the amount of RAM on your computer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question