mersenneforum.org  

Go Back   mersenneforum.org > Factoring Projects > Msieve

Reply
 
Thread Tools
Old 2010-10-25, 08:09   #1
10metreh
 
10metreh's Avatar
 
Nov 2008

2·33·43 Posts
Default Msieve not detecting L3 cache

I've just noticed that msieve doesn't detect the L3 cache on my Core i5. It seems to have only detected the L2:

Code:
using block size 10922 for processor cache size 256 kB
I knew that the code used not to be able to detect L3 cache, but I thought that had been fixed. (This is with 1.47.)
10metreh is offline   Reply With Quote
Old 2010-10-25, 10:52   #2
jasonp
Tribal Bullet
 
jasonp's Avatar
 
Oct 2004

3,541 Posts
Default

Grrr. The problem is Intel's scheme for reporting cache sizes; basically every new processor that comes out has its own code for its cache size, although the L2 size is also reported in a standard way. That basically means that your cache size detection code has to be updated about once a year to account for new Intel processors.

Edit: OK, fixed in SVN now. It turns out that Intel moved to a more general architecture for reporting cache sizes around last year, and this should hopefully avoid having to touch the code over and over again.

@Brian Gladman: Does MSVC have an intrinsic that runs the CPUID instruction with *both* EAX and ECX specified? The one you used in the current code only specifies EAX, and so the cache size is still misreported when compiling with MSVC.

Last fiddled with by jasonp on 2010-10-25 at 12:21
jasonp is offline   Reply With Quote
Old 2010-10-25, 12:30   #3
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

22·5·373 Posts
Default

Quote:
Originally Posted by jasonp View Post
Grrr. The problem is Intel's scheme for reporting cache sizes; basically every new processor that comes out has its own code for its cache size, although the L2 size is also reported in a standard way. That basically means that your cache size detection code has to be updated about once a year to account for new Intel processors.

Edit: OK, fixed in SVN now. It turns out that Intel moved to a more general architecture for reporting cache sizes around last year, and this should hopefully avoid having to touch the code over and over again.

@Brian Gladman: Does MSVC have an intrinsic that runs the CPUID instruction with *both* EAX and ECX specified? The one you used in the current code only specifies EAX, and so the cache size is still misreported when compiling with MSVC.
Actually, a generic, algorithmic solution is possible.

Take a small array. Time how long it takes to fill/empty it. Keep increasing
the size of the array until the fill/empty time jumps suddenly. You've now
exceeded the cache....
R.D. Silverman is offline   Reply With Quote
Old 2010-10-25, 13:08   #4
Prime95
P90 years forever!
 
Prime95's Avatar
 
Aug 2002
Yeehaw, FL

1D6616 Posts
Default

Quote:
Originally Posted by R.D. Silverman View Post
Keep increasing
the size of the array until the fill/empty time jumps suddenly. You've now exceeded the cache....
...or discovered when some other CPU intensive program has grabbed a time slice.
Prime95 is offline   Reply With Quote
Old 2010-10-25, 13:10   #5
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

22·5·373 Posts
Default

Quote:
Originally Posted by Prime95 View Post
...or discovered when some other CPU intensive program has grabbed a time slice.
Yep. It works only if nothing else is running........
R.D. Silverman is offline   Reply With Quote
Old 2010-10-25, 15:57   #6
jasonp
Tribal Bullet
 
jasonp's Avatar
 
Oct 2004

3,541 Posts
Default

No matter how complex it is to read the Intel cache codes, that has to be better than figuring out the size dynamically. Look at the source for LMBench if you don't believe me; you need to fool the hardware prefetch mechanism, get timing information that is portable enough and accurate enough (and multiprocessor safe, which the x86 cycle counter is not), then time for long enough to get a robust answer, which is guaranteed to be longer than an entire small QS job takes.

Plus the machine has to be idle :)
jasonp is offline   Reply With Quote
Old 2010-10-25, 17:07   #7
Robert Holmes
 
Robert Holmes's Avatar
 
Oct 2007

1528 Posts
Default

Quote:
Originally Posted by jasonp View Post
@Brian Gladman: Does MSVC have an intrinsic that runs the CPUID instruction with *both* EAX and ECX specified? The one you used in the current code only specifies EAX, and so the cache size is still misreported when compiling with MSVC.
Yes, __cpuidex.
Robert Holmes is offline   Reply With Quote
Old 2010-10-25, 19:11   #8
Brian Gladman
 
Brian Gladman's Avatar
 
May 2008
Worcester, United Kingdom

22×7×19 Posts
Default

Quote:
Originally Posted by jasonp View Post
Grrr. The problem is Intel's scheme for reporting cache sizes; basically every new processor that comes out has its own code for its cache size, although the L2 size is also reported in a standard way. That basically means that your cache size detection code has to be updated about once a year to account for new Intel processors.

Edit: OK, fixed in SVN now. It turns out that Intel moved to a more general architecture for reporting cache sizes around last year, and this should hopefully avoid having to touch the code over and over again.

@Brian Gladman: Does MSVC have an intrinsic that runs the CPUID instruction with *both* EAX and ECX specified? The one you used in the current code only specifies EAX, and so the cache size is still misreported when compiling with MSVC.
Yes - I have now added it in the SVN version.

Brian
Brian Gladman is offline   Reply With Quote
Old 2010-10-26, 01:42   #9
jasonp
Tribal Bullet
 
jasonp's Avatar
 
Oct 2004

3,541 Posts
Default

Thanks everybody.
jasonp is offline   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting bigInt roots mathPuzzles Computer Science & Computational Number Theory 9 2017-07-01 03:35
Problem detecting GPU VoltsNCodes Msieve 13 2013-06-14 15:14
8k fft and L2 cache pman Information & Answers 1 2012-05-23 14:00
Detecting arithmetic progressions grandpascorpion Math 18 2007-03-28 15:08
L3 cache. What could it buy us? nomadicus Hardware 3 2003-08-09 22:23

All times are UTC. The time now is 00:48.


Sat Jul 17 00:48:23 UTC 2021 up 49 days, 22:35, 1 user, load averages: 1.69, 1.54, 1.40

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.