Re: [hwloc-users] How do I access CPUModel info string

2012-10-25 Thread Robin Scher


On 10/25/2012 3:06 PM, Samuel Thibault wrote:

Robin Scher, le Thu 25 Oct 2012 23:57:38 +0200, a écrit :

Do you think those could be added to hwloc?

Yes: we already use cpuid for the x86 backend. That will only work on
x86 hosts of course.


Windows being x86 only for the time being, I'm OK with that.

I would love to get this by my next release, say in the next 3-6 months. 
Is that something that would be possible? Is there anything I can do to 
help?


Thanks,
-robin

--
*Robin Scher* Uberware
ro...@uberware.net
+1 (213) 448-0443




Re: [hwloc-users] How do I access CPUModel info string

2012-10-25 Thread Samuel Thibault
Robin Scher, le Thu 25 Oct 2012 23:57:38 +0200, a écrit :
> ; eax = 0x8002 --> eax, ebx, ecx, edx: get processor name string
> (part 1)
> mov eax,0x8002
> cpuid

Oh, this is indeed *exactly* the model name string. I only knew about
the vendor_id string.

> I don't know if that would work on Win64, though.

It should: cpuid is not a privileged instruction.

> Do you think those could be added to hwloc?

Yes: we already use cpuid for the x86 backend. That will only work on
x86 hosts of course.

Brice, that actually brings another piece to the plugin engine: on
Windows ideally we should still get the topology from the OS, but take
the cpu string from the x86 backend...

Samuel


Re: [hwloc-users] How do I access CPUModel info string

2012-10-25 Thread Brice Goglin
Le 25/10/2012 23:57, Robin Scher a écrit :
> On OS-X, you can get this string from the sysctlbyname() call:
>
> const char *name = "machdep.cpu.brand_string";
> char buffer[ 64 ];
> size_t size = 64;
> if( !sysctlbyname( name, buffer, &size, NULL, 0 ) )
> memcpy( cpu_model, buffer, 12 * sizeof( int ) );

Thanks.

> if That doesn't work, you can get it from calling system_profiler and
> parsing the output.

I'd rather not do that from inside the hwloc library :)

> On Widows (32 bit), the only way I've found is to actually use the
> cpuid assembly call:

Good to know, that's likely similar to the Linux code I cited in my
other mail.
I'll see if I can put that in some sort of common code.

> I don't know if that would work on Win64, though. Do you think those
> could be added to hwloc?

If we can make this work without too much pain, sure.

Brice



Re: [hwloc-users] How do I access CPUModel info string

2012-10-25 Thread Brice Goglin
Le 25/10/2012 23:42, Samuel Thibault a écrit :
> Robin Scher, le Thu 25 Oct 2012 23:39:46 +0200, a écrit :
>> Is there a way to get this string (e.g. "Intel(R) Core(TM) i7 CPU M 620 @
>> 2.67GHz") consistently on Windows, Linux, OS-X and Solaris?
> Currently, no.
>
> hwloc itself does not have a table of such strings, and each OS has its
> own table.
>

Actually there's no table on Linux/x86. It uses cpuid to fill the model
name in the vast majority of cases [1]. We could use that to get
consistent names on non-Linux non-Solaris OS, and in the x86 backend.

Brice

[1] http://lxr.free-electrons.com/source/arch/x86/kernel/cpu/common.c#L389


Re: [hwloc-users] How do I access CPUModel info string

2012-10-25 Thread Robin Scher

On OS-X, you can get this string from the sysctlbyname() call:

const char *name = "machdep.cpu.brand_string";
char buffer[ 64 ];
size_t size = 64;
if( !sysctlbyname( name, buffer, &size, NULL, 0 ) )
memcpy( cpu_model, buffer, 12 * sizeof( int ) );

if That doesn't work, you can get it from calling system_profiler and 
parsing the output.


On Widows (32 bit), the only way I've found is to actually use the cpuid 
assembly call:


int ints[ 12 ];

// Use assembly to detect CPUID information...
_asm
{
; we must push/pop the registers <> writes to, as the
; optimiser doesn't know about <>, and so doesn't expect
; these registers to change.
push eax
push ebx
push ecx
push edx

; eax = 0x8002 --> eax, ebx, ecx, edx: get processor name 
string (part 1)

mov eax,0x8002
cpuid
mov ints[  0 * TYPE int ], eax
mov ints[  1 * TYPE int ], ebx
mov ints[  2 * TYPE int ], ecx
mov ints[  3 * TYPE int ], edx

; eax = 0x8003 --> eax, ebx, ecx, edx: get processor name 
string (part 2)

mov eax,0x8003
cpuid
mov ints[  4 * TYPE int ], eax
mov ints[  5 * TYPE int ], ebx
mov ints[  6 * TYPE int ], ecx
mov ints[  7 * TYPE int ], edx

; eax = 0x8004 --> eax, ebx, ecx, edx: get processor name 
string (part 3)

mov eax,0x8004
cpuid
mov ints[  8 * TYPE int ], eax
mov ints[  9 * TYPE int ], ebx
mov ints[ 10 * TYPE int ], ecx
mov ints[ 11 * TYPE int ], edx

pop edx
pop ecx
pop ebx
pop eax
}
::memcpy( cpu_model, ints, 12 * sizeof( int ) );

I don't know if that would work on Win64, though. Do you think those 
could be added to hwloc?


Thanks
-robin


On 10/25/2012 2:42 PM, Brice Goglin wrote:

Hello,

Assuming you found the socket hwloc object whose name you want, do
hwloc_obj_get_info_by_name(obj, "CPUModel");
you'll get const char * pointing to what you want.

However, this info is only available on Linux and Solaris for now. If 
you have any idea of to discover such info on other OS, please let us 
know.


Brice



Le 25/10/2012 23:39, Robin Scher a écrit :
Is there a way to get this string (e.g. "Intel(R) Core(TM) i7 CPU M 
620 @ 2.67GHz") consistently on Windows, Linux, OS-X and Solaris?


Thanks,
-robin

--
*Robin Scher* Uberware
ro...@uberware.net
+1 (213) 448-0443




___
hwloc-users mailing list
hwloc-us...@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-users




___
hwloc-users mailing list
hwloc-us...@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-users


--
*Robin Scher* Uberware
ro...@uberware.net
+1 (213) 448-0443




Re: [hwloc-users] How do I access CPUModel info string

2012-10-25 Thread Samuel Thibault
Robin Scher, le Thu 25 Oct 2012 23:39:46 +0200, a écrit :
> Is there a way to get this string (e.g. "Intel(R) Core(TM) i7 CPU M 620 @
> 2.67GHz") consistently on Windows, Linux, OS-X and Solaris?

Currently, no.

hwloc itself does not have a table of such strings, and each OS has its
own table.

Samuel


Re: [hwloc-users] How do I access CPUModel info string

2012-10-25 Thread Brice Goglin
Hello,

Assuming you found the socket hwloc object whose name you want, do
hwloc_obj_get_info_by_name(obj, "CPUModel");
you'll get const char * pointing to what you want.

However, this info is only available on Linux and Solaris for now. If
you have any idea of to discover such info on other OS, please let us know.

Brice



Le 25/10/2012 23:39, Robin Scher a écrit :
> Is there a way to get this string (e.g. "Intel(R) Core(TM) i7 CPU M
> 620 @ 2.67GHz") consistently on Windows, Linux, OS-X and Solaris?
>
> Thanks,
> -robin
>
> -- 
> *Robin Scher* Uberware
> ro...@uberware.net
> +1 (213) 448-0443
>
>
>
>
> ___
> hwloc-users mailing list
> hwloc-us...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-users



[hwloc-users] How do I access CPUModel info string

2012-10-25 Thread Robin Scher
Is there a way to get this string (e.g. "Intel(R) Core(TM) i7 CPU M 620 
@ 2.67GHz") consistently on Windows, Linux, OS-X and Solaris?


Thanks,
-robin

--
*Robin Scher* Uberware
ro...@uberware.net
+1 (213) 448-0443