Re: [Slightly Off Topic] processor speed
I admit this is slightly Meaningless Numbers Calculus, but I have to measure a certain computational task, and come up with a number per architecture. I could use total process time, but dividing it with the processor speed to acquire a measure of total cpu cycles seems more appropriate. Returning to my problem, I can use /proc/cpuinfo (in fact, I am). However, on Sun/Alpha the best I can do is run psrinfo, but it is problematic since those systems are in some cases assymetric - and I cannot tell on which cpu my proccess is running. Any other ideas? Dan. On Tue, Dec 04, 2001, Dan Kenigsberg wrote about [Slightly Off Topic] processor speed: I would like to tell the speed of the processor I'm using, via a system call, on ... Please assume I cannot open the computer or afraid of screwdrivers, and cannot parse the lovely Linux /proc/cpuinfo, nor parse the output of Sun's I'll answer only about Linux (I don't remember how to do this on Solaris). On Linux, it is an official decision that instead of having dozens of system calls, or weird non-standard system calls returning even weirder data structures, or weird special kernel interfaces (routing sockets anyone?) that simple kernel information like that will only be available through the /proc/cpuinfo interface. What's wrong with that - how hard is to open this file and look for a newline followed by cpu MHz? The format of this file might changed in some future Linux release (the linux-kernel mailing list is always filled with fights on how to change /proc), but CPU speed is very non-portable anyway, so I don't see what problems this can cause you. Of course, it's possible to access the CPU directly and find the CPU's version string, but this is definitely not recommended (if at all possible) to do outside the kernel. Check the Linux kernel on how they do it, if you're interested. P.S. Obviously, with today's complicated CPUs, it is not at all certain how exactly the MHz or bogomips figures in /proc/cpuinfo are relevant to the speed of an actual program that you intend to run... = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: [Slightly Off Topic] processor speed
On Wed, 5 Dec 2001, Dan Kenigsberg wrote: I admit this is slightly Meaningless Numbers Calculus, but I have to measure a certain computational task, and come up with a number per architecture. I could use total process time, but dividing it with the processor speed to acquire a measure of total cpu cycles seems more appropriate. as for process time, you can use getrusage() to get the total user time and system time. Returning to my problem, I can use /proc/cpuinfo (in fact, I am). However, on Sun/Alpha the best I can do is run psrinfo, but it is problematic since those systems are in some cases assymetric - and I cannot tell on which cpu my proccess is running. use inline asm to get cpu speed? i would think that all cpus have an instruction to get this information. you can look at the kernel's arch/ subdir to see how it's calculated for the different architectures. note that this is most likely a can of worms, unless you only need to support a limited subset of processors architectures. -- mulix http://www.pointer.co.il/~mulix/ http://syscalltrack.sf.net/ = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: [Slightly Off Topic] processor speed
On Wed, Dec 05, 2001, Dan Kenigsberg wrote about Re: [Slightly Off Topic] processor speed: ... However, on Sun/Alpha the best I can do is run psrinfo, but it is problematic since those systems are in some cases assymetric - and I cannot tell on which cpu my proccess is running. Assymetric in the sense that you have two or more CPUs of different speeds? This is weird... Anyway, on Solaris you can do ps -P to see which CPU your process is bound to. If it is not bound to a specific CPU it might constantly (on every context switch) be assigned to a different CPU, so you'd have no idea what effective CPU speed your program is getting. So, see pbind(1) on how to bind your process to a specific CPU (for which psrinfo will give you its MHz value, whatever that means...). [not that this has anything to do with Linux...] -- Nadav Har'El| Wednesday, Dec 5 2001, 20 Kislev 5762 [EMAIL PROTECTED] |- Phone: +972-53-245868, ICQ 13349191 |Boat: A hole in the water surrounded by http://nadav.harel.org.il |wood into which one pours money. = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
[Slightly Off Topic] processor speed
I would like to tell the speed of the processor I'm using, via a system call, on various unices (linux, solaris and alpha). any idea? Please assume I cannot open the computer or afraid of screwdrivers, and cannot parse the lovely Linux /proc/cpuinfo, nor parse the output of Sun's and alpha's psrinfo Dan. = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: [Slightly Off Topic] processor speed
On Tue, Dec 04, 2001, Dan Kenigsberg wrote about [Slightly Off Topic] processor speed: I would like to tell the speed of the processor I'm using, via a system call, on ... Please assume I cannot open the computer or afraid of screwdrivers, and cannot parse the lovely Linux /proc/cpuinfo, nor parse the output of Sun's I'll answer only about Linux (I don't remember how to do this on Solaris). On Linux, it is an official decision that instead of having dozens of system calls, or weird non-standard system calls returning even weirder data structures, or weird special kernel interfaces (routing sockets anyone?) that simple kernel information like that will only be available through the /proc/cpuinfo interface. What's wrong with that - how hard is to open this file and look for a newline followed by cpu MHz? The format of this file might changed in some future Linux release (the linux-kernel mailing list is always filled with fights on how to change /proc), but CPU speed is very non-portable anyway, so I don't see what problems this can cause you. Of course, it's possible to access the CPU directly and find the CPU's version string, but this is definitely not recommended (if at all possible) to do outside the kernel. Check the Linux kernel on how they do it, if you're interested. P.S. Obviously, with today's complicated CPUs, it is not at all certain how exactly the MHz or bogomips figures in /proc/cpuinfo are relevant to the speed of an actual program that you intend to run... -- Nadav Har'El| Tuesday, Dec 4 2001, 20 Kislev 5762 [EMAIL PROTECTED] |- Phone: +972-53-245868, ICQ 13349191 |I couldn't think of an interesting http://nadav.harel.org.il |signature to put here... Maybe next time. = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]