Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

RDTSC instructions implementation.

srimks
New Contributor II
634 Views

Hi All.

Normally, any instructions are implemenented either in their MD or .h or .c file of config folder within GCC (gcc/config/i386 or /gcc/config/ia64). Can anyone suggest - Where and How is RDSTC instructions being implemented within this file for GCC v-4.4 or it's earlier versions?

Here, I mean to refer it's back-end or middle -end files related with Intel C++ Compiler RDTSC inst. implementation in .h, .md or .c with GCC.

I did referred RDTSC instruction in "Intel-64 & IA-32 Arch. Software Developer's Manual - Vol-2B" for understanding RDSTC inst. implementations.

~BR

MKS

0 Kudos
3 Replies
TimP
Honored Contributor III
634 Views
Why are you asking about gcc here?
As you appear to be stretching your definition of gcc, you might grep your kernel source, in particular the /include/asm-i386/ and /asm-x86_64/ directories. Then, check the quality of code generated by those macros in comparison with icc __rdtsc(), if that's what you're getting at.
0 Kudos
srimks
New Contributor II
634 Views
Quoting - tim18
Why are you asking about gcc here?
As you appear to be stretching your definition of gcc, you might grep your kernel source, in particular the /include/asm-i386/ and /asm-x86_64/ directories. Then, check the quality of code generated by those macros in comparison with icc __rdtsc(), if that's what you're getting at.
Hi Tim.

I think I meant, how Intel instruction RDTSC has been implemented within GCC. The impl. of this instruction would help to understand RDTSC much better.

I did check within gcc/config/i386 & /gcc/config/ia64 about RDTSC, but didn't found anything.

Since, Intel C++ Compiler doesn't make it's Compiler source or it's COMPILER INTERNALS to public, so implementation of Intel instructions can be understood through GCC where Intel ports it's instructions. Probably, Intel only provides "Applications towards it's instructions" to public, but may be it's IPR policy for them.

Any instruction behaviour is better understood through it's implementation either in it's MD or .h or .c file of /gcc/config/i386[ia64) folder.

No worries, TX

~BR
0 Kudos
kfsone
New Contributor I
634 Views
It's not very clear what you mean. RDTSC "instructions" are provided by the chip and you either access them with some assembler, e.g.
[cpp]static inline void rdtsc(unsigned long long& destination)
{
 __asm__ volatile (".byte 0x0f, 0x31" : "=A" (destination)) ;
}

int main(int argc, char* argv[])
{
  unsigned long long startTick, endTick ;
  char buffer[65] ;
  rdtsc(startTick) ;
  for ( unsigned int i = 0 ; i < 150000 ; ++i )
  {
    unsigned int dummy = (rand() % 32767) ;
    snprintf(buffer, sizeof(buffer)-1, "%u", dummy) ;
  }
  rdtsc(endTick) ;

  std::cout << "Took " << (endTick - startTick) << " ticks" << endl ;
}

[/cpp]
Or are you talking about the __rdtsc() intrinsic?
0 Kudos
Reply