inline assembly in C++

fragusmaximus

Member
Sep 8, 2002
40
0
0


I'm writting a little class that has a function to count the number of clock cycles that elapse on an Intel Pentium. I have got preliminary implementation done, but I wanted to ask the good folks here if they knew of a way to direct my inline assembly to either the primary or secondary (or nth) processor.

See if there are multiple processors, I want to call all of them and get each one's clock cycles to get the *total* number of cycles passed. Does anyone know if there's a way of "directing" your inline assembly code to a particular processor?

I'm sure someone has already done this and made the product commercially available. VTune comes to mind. However, I don't have a budget to buy commercially. Besides, this kind of research is fun for me.

Thanks in advance.
 

glugglug

Diamond Member
Jun 9, 2002
5,340
1
81
You can give the thread the inline assembly is running in a processor affinity.

Note: in theory, you are going to get the same count from all processors in the system. I don't think there is any x86 multi-CPU system where the CPUs can run at different speeds than each other.