Re: C/C++ call to detect cpu?
On Saturday 21 January 2006 15:33, John Levine wrote: Other than 'grep'ing dmesg, is there a way to know the current cpu such as a struct with the machine's cpu and cpu feature (kinda like a time_t struct)? $ sysctl hw.model hw.model: AMD Athlon(tm) 64 Processor 3000+ If you want more details write a tiny assembler routine that does a CPUID instruction and decode the result. Intel has a detailed application note about it at http://developer.intel.ru/design/xeon/applnots/241618.htm R's, John Thanks, that was great help, I was able to get the Processor Name string using info from that pdf. Using asm instead of sysctl will ensure a bit more portability. Unfortunatly, getting the actual processor speed (in Mhz) is more complicated according to that pdf, would you have any suggestions? Thanks, Nicolas. -- FreeBSD 7.0-CURRENT #0: Sat Jan 21 11:33:22 EST 2006 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/CLK01A PGP? (updated 16 Nov 05) : http://www.clkroot.net/security/nb_root.asc pgp0D90kwoQcw.pgp Description: PGP signature
Re: C/C++ call to detect cpu?
Nicolas, I have commented assembler code for the intel family of CPU's. This code goes back to the i386 and also takes into account the CPU string, and will calculate the clock speed. I do call this as a library function from c/c++ programs. Unfortunately this is written for Microsoft's MASM, and I have never ported it to gas. If you want a copy I can send you the assembler source code and/or the commented listing as well. -Derek At 05:50 PM 1/22/2006, Nicolas Blais wrote: On Saturday 21 January 2006 15:33, John Levine wrote: Other than 'grep'ing dmesg, is there a way to know the current cpu such as a struct with the machine's cpu and cpu feature (kinda like a time_t struct)? $ sysctl hw.model hw.model: AMD Athlon(tm) 64 Processor 3000+ If you want more details write a tiny assembler routine that does a CPUID instruction and decode the result. Intel has a detailed application note about it at http://developer.intel.ru/design/xeon/applnots/241618.htm R's, John Thanks, that was great help, I was able to get the Processor Name string using info from that pdf. Using asm instead of sysctl will ensure a bit more portability. Unfortunatly, getting the actual processor speed (in Mhz) is more complicated according to that pdf, would you have any suggestions? Thanks, Nicolas. -- FreeBSD 7.0-CURRENT #0: Sat Jan 21 11:33:22 EST 2006 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/CLK01A PGP? (updated 16 Nov 05) : http://www.clkroot.net/security/nb_root.asc ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: C/C++ call to detect cpu?
On Sunday 22 January 2006 19:53, Derek Ragona wrote: Nicolas, I have commented assembler code for the intel family of CPU's. This code goes back to the i386 and also takes into account the CPU string, and will calculate the clock speed. I do call this as a library function from c/c++ programs. Unfortunately this is written for Microsoft's MASM, and I have never ported it to gas. If you want a copy I can send you the assembler source code and/or the commented listing as well. -Derek Certainly, that would be of great help! Under what license would you be releasing the source ? :) Nicolas. -- FreeBSD 7.0-CURRENT #0: Sat Jan 21 11:33:22 EST 2006 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/CLK01A PGP? (updated 16 Nov 05) : http://www.clkroot.net/security/nb_root.asc pgpilr8wlaw2e.pgp Description: PGP signature
Re: C/C++ call to detect cpu?
Other than 'grep'ing dmesg, is there a way to know the current cpu such as a struct with the machine's cpu and cpu feature (kinda like a time_t struct)? $ sysctl hw.model hw.model: AMD Athlon(tm) 64 Processor 3000+ If you want more details write a tiny assembler routine that does a CPUID instruction and decode the result. Intel has a detailed application note about it at http://developer.intel.ru/design/xeon/applnots/241618.htm R's, John ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: C/C++ call to detect cpu?
On Jan 21, 2006, at 12:33 PM, John Levine wrote: Other than 'grep'ing dmesg, is there a way to know the current cpu such as a struct with the machine's cpu and cpu feature (kinda like a time_t struct)? $ sysctl hw.model hw.model: AMD Athlon(tm) 64 Processor 3000+ If you want more details write a tiny assembler routine that does a CPUID instruction and decode the result. Intel has a detailed application note about it at http://developer.intel.ru/design/xeon/applnots/241618.htm R's, John As for gcc, CFLAGS and CXXFLAGS, doing some searching on google for -march gcc will prove to help you in finding out what is and is not supported by your processor. There's also a link from the Gentoo Linux docs somewhere in the handbook, but you will have to hunt that down on your own ;). There's also a better (or perhaps, just more relevant) doc somewhere on FreeBSD's site about CFLAGS and CXXFLAGS which also addresses gcc variables and architectures I think. -Garrett ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: C/C++ call to detect cpu?
On Jan 21, 2006, at 12:33 PM, John Levine wrote: Other than 'grep'ing dmesg, is there a way to know the current cpu such as a struct with the machine's cpu and cpu feature (kinda like a time_t struct)? $ sysctl hw.model hw.model: AMD Athlon(tm) 64 Processor 3000+ If you want more details write a tiny assembler routine that does a CPUID instruction and decode the result. Intel has a detailed application note about it at http://developer.intel.ru/design/xeon/applnots/241618.htm R's, John Erm. Nevermind. I just misunderstood your question =\... -Garrett ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]