public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* cpuinfo cache size
@ 2015-06-23 13:39 Marco Atzeri
  2015-06-23 14:17 ` Corinna Vinschen
  2015-08-29 11:35 ` Corinna Vinschen
  0 siblings, 2 replies; 6+ messages in thread
From: Marco Atzeri @ 2015-06-23 13:39 UTC (permalink / raw)
  To: cygwin

Hi Corinna,

for a porting of a math lib to cygwin we are trying to obtain
the same information of

sysconf(_SC_LEVEL1_DCACHE_SIZE)
sysconf(_SC_LEVEL2_CACHE_SIZE)
sysconf(_SC_LEVEL3_CACHE_SIZE)
sysconf(_SC_LEVEL4_CACHE_SIZE)

but of course none of them is implemented in cygwin.

The /proc/cpuinfo contains :
------------------------------------------------------------------
processor       : same 0 to 3
vendor_id       : GenuineIntel
cpu family      : 6
model           : 58
model name      : Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz
stepping        : 9
cpu MHz         : 2594.000
cache size      : 256 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge 
mca cmov                    pat pse36 clflush dts acpi mmx fxsr sse sse2 
ss ht tm pbe pni dtes64 monitor ds_                   cpl vmx smx est 
tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 x2apic popcnt aes xsave o 
            sxsave avx f16c rdrand lahf_lm ida arat epb xsaveopt pln pts 
dtherm fsgsbase sme                   p erms
TLB size        : 0 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:
------------------------------------------------------------------

Looking on the code it seems that for
   maxe >= 0x80000006

cache_size reported on cpuinfo is calculated using L1
and immediately after overwritten with L2 value.

--------- winsup/cygwin/fhandler_proc.cc --------------------

               if (maxe >= 0x80000005) /* L1 Cache and TLB Identifiers. */
                 {
                   uint32_t data_cache, inst_cache;
                   cpuid (&unused, &unused, &data_cache, &inst_cache,
                          0x80000005);

->                cache_size = (inst_cache >> 24) + (data_cache >> 24);
                   tlb_size = 0;
                 }
               if (maxe >= 0x80000006) /* L2 Cache and L2 TLB 
Identifiers. */
                 {
                   uint32_t tlb, l2;
                   cpuid (&unused, &tlb, &l2, &unused, 0x80000006);

->                cache_size = l2 >> 16;
                   tlb_size = ((tlb >> 16) & 0xfff) + (tlb & 0xfff);
                 }
-----------------------------------------------------------------

Should be possible to have both info available ?
Any idea how to obtain the other cache infos ?


Using a third part tool
    CPU-Z version                   1.72.1.x64
I know that my architecture should be:

Number of processors            1
Number of threads               4

Processor 0
         -- Core 0
                 -- Thread 0     0
                 -- Thread 1     1
         -- Core 1
                 -- Thread 0     2
                 -- Thread 1     3

L1 Data cache           2 x 32 KBytes, 8-way set associative, 64-byte 
line size
L1 Instruction cache    2 x 32 KBytes, 8-way set associative, 64-byte 
line size
L2 cache                2 x 256 KBytes, 8-way set associative, 64-byte 
line size
L3 cache                3 MBytes, 12-way set associative, 64-byte line size

Thanks in advance
Marco

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cpuinfo cache size
  2015-06-23 13:39 cpuinfo cache size Marco Atzeri
@ 2015-06-23 14:17 ` Corinna Vinschen
  2015-08-03 10:15   ` Achim Gratz
  2015-08-29 11:35 ` Corinna Vinschen
  1 sibling, 1 reply; 6+ messages in thread
From: Corinna Vinschen @ 2015-06-23 14:17 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1965 bytes --]

On Jun 23 15:39, Marco Atzeri wrote:
> Hi Corinna,
> 
> for a porting of a math lib to cygwin we are trying to obtain
> the same information of
> 
> sysconf(_SC_LEVEL1_DCACHE_SIZE)
> sysconf(_SC_LEVEL2_CACHE_SIZE)
> sysconf(_SC_LEVEL3_CACHE_SIZE)
> sysconf(_SC_LEVEL4_CACHE_SIZE)
> 
> but of course none of them is implemented in cygwin.
> 
> The /proc/cpuinfo contains :
> ------------------------------------------------------------------
> [...]
> cache size      : 256 KB
> [...]
> ------------------------------------------------------------------
> 
> Looking on the code it seems that for
>   maxe >= 0x80000006
> 
> cache_size reported on cpuinfo is calculated using L1
> and immediately after overwritten with L2 value.

This seems to be right, at least partially.  Linux /proc/cpuinfo
appears to report only the size of the outmost available cache.
So if you have L1 and L2 caches, Linux reports the L2 cache size.

The problem is that the L2 cache isn't the outmost available
cache anymore these days.  On my CPU Cygwin reports 256K, which
is the size of the per-core L2 caches.  However, the shared L3 cache
has a size of 15Megs, and that's what Linux reports:

  $ grep 'cache size' /proc/cpuinfo | head -1
  cache size	: 15360 KB

Cygwin is lacking the code to fetch L3 caches and afaics, it's not
overly simple.  At least calling cpuid as for L1 and L2 caches is not
sufficient, apparently.

> Should be possible to have both info available ?
> Any idea how to obtain the other cache infos ?

Not completely.  You have to use different cpuid codes for AMD and Intel
CPUs, and you have to call cpuid multiple times to get the full info
for all L3 caches of the system's CPUs, but I'm fuzzy on the details.

Patches are certainly welcome.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cpuinfo cache size
  2015-06-23 14:17 ` Corinna Vinschen
@ 2015-08-03 10:15   ` Achim Gratz
  2015-08-03 10:39     ` Marco Atzeri
  2015-08-03 13:33     ` Corinna Vinschen
  0 siblings, 2 replies; 6+ messages in thread
From: Achim Gratz @ 2015-08-03 10:15 UTC (permalink / raw)
  To: cygwin

Corinna Vinschen <corinna-cygwin <at> cygwin.com> writes:
> Cygwin is lacking the code to fetch L3 caches and afaics, it's not
> overly simple.  At least calling cpuid as for L1 and L2 caches is not
> sufficient, apparently.

If you can use the Windows API, then this
https://msdn.microsoft.com/en-us/library/ms683194.aspx

> > Should be possible to have both info available ?
> > Any idea how to obtain the other cache infos ?
> 
> Not completely.  You have to use different cpuid codes for AMD and Intel
> CPUs, and you have to call cpuid multiple times to get the full info
> for all L3 caches of the system's CPUs, but I'm fuzzy on the details.

I have no patches, but another difference to Linux is that the CPU frequency
reported is the maximum (non-turbo) frequency instead of the actual one
(which could be larger or lower depending on the frequency scaling in
effect).  That seems to require more infrastructure, though.


Regards,
Achim.



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cpuinfo cache size
  2015-08-03 10:15   ` Achim Gratz
@ 2015-08-03 10:39     ` Marco Atzeri
  2015-08-03 13:33     ` Corinna Vinschen
  1 sibling, 0 replies; 6+ messages in thread
From: Marco Atzeri @ 2015-08-03 10:39 UTC (permalink / raw)
  To: cygwin



On 8/3/2015 12:15 PM, Achim Gratz wrote:
> Corinna Vinschen <corinna-cygwin <at> cygwin.com> writes:
>> Cygwin is lacking the code to fetch L3 caches and afaics, it's not
>> overly simple.  At least calling cpuid as for L1 and L2 caches is not
>> sufficient, apparently.
>
> If you can use the Windows API, then this
> https://msdn.microsoft.com/en-us/library/ms683194.aspx
>
>>> Should be possible to have both info available ?
>>> Any idea how to obtain the other cache infos ?
>>
>> Not completely.  You have to use different cpuid codes for AMD and Intel
>> CPUs, and you have to call cpuid multiple times to get the full info
>> for all L3 caches of the system's CPUs, but I'm fuzzy on the details.
>
> I have no patches, but another difference to Linux is that the CPU frequency
> reported is the maximum (non-turbo) frequency instead of the actual one
> (which could be larger or lower depending on the frequency scaling in
> effect).  That seems to require more infrastructure, though.

I solved packing HWLOC

http://www.open-mpi.org/projects/hwloc/

It provide the same info in a simpler way

> Regards,
> Achim.
>

Regards
Marco


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cpuinfo cache size
  2015-08-03 10:15   ` Achim Gratz
  2015-08-03 10:39     ` Marco Atzeri
@ 2015-08-03 13:33     ` Corinna Vinschen
  1 sibling, 0 replies; 6+ messages in thread
From: Corinna Vinschen @ 2015-08-03 13:33 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1085 bytes --]

On Aug  3 10:15, Achim Gratz wrote:
> Corinna Vinschen <corinna-cygwin <at> cygwin.com> writes:
> > Cygwin is lacking the code to fetch L3 caches and afaics, it's not
> > overly simple.  At least calling cpuid as for L1 and L2 caches is not
> > sufficient, apparently.
> 
> If you can use the Windows API, then this
> https://msdn.microsoft.com/en-us/library/ms683194.aspx

Oh, that sounds good.  I wasn't aware of this function.  This and
GetLogicalProcessorInformationEx on newer systems seem to help here.

If nobody beats me to it I'll have a look into it at one point.

> I have no patches, but another difference to Linux is that the CPU frequency
> reported is the maximum (non-turbo) frequency instead of the actual one
> (which could be larger or lower depending on the frequency scaling in
> effect).  That seems to require more infrastructure, though.

Another Windows function? :)


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: cpuinfo cache size
  2015-06-23 13:39 cpuinfo cache size Marco Atzeri
  2015-06-23 14:17 ` Corinna Vinschen
@ 2015-08-29 11:35 ` Corinna Vinschen
  1 sibling, 0 replies; 6+ messages in thread
From: Corinna Vinschen @ 2015-08-29 11:35 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 635 bytes --]

Hi Marco,

On Jun 23 15:39, Marco Atzeri wrote:
> Hi Corinna,
> 
> for a porting of a math lib to cygwin we are trying to obtain
> the same information of
> 
> sysconf(_SC_LEVEL1_DCACHE_SIZE)
> sysconf(_SC_LEVEL2_CACHE_SIZE)
> sysconf(_SC_LEVEL3_CACHE_SIZE)
> sysconf(_SC_LEVEL4_CACHE_SIZE)
> 
> but of course none of them is implemented in cygwin.

They are now.  Please give the latest developer snapshot from
https://cygwin.com/snapshots/ a try.


HTH,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-29  7:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-23 13:39 cpuinfo cache size Marco Atzeri
2015-06-23 14:17 ` Corinna Vinschen
2015-08-03 10:15   ` Achim Gratz
2015-08-03 10:39     ` Marco Atzeri
2015-08-03 13:33     ` Corinna Vinschen
2015-08-29 11:35 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).