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 <<CPUID>> writes to, as the
; optimiser doesn't know about <<CPUID>>, and so doesn't expect
; these registers to change.
push eax
push ebx
push ecx
push edx
; eax = 0x80000002 --> eax, ebx, ecx, edx: get processor name
string (part 1)
mov eax,0x80000002
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 = 0x80000003 --> eax, ebx, ecx, edx: get processor name
string (part 2)
mov eax,0x80000003
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 = 0x80000004 --> eax, ebx, ecx, edx: get processor name
string (part 3)
mov eax,0x80000004
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