Opteron-based nodes benchmarks: RDTSC

Mikhail Kuzminsky kus at free.net
Mon Jul 23 12:44:16 EDT 2012


I'm testing some fortran benchmarks on 2-CPUs Opteron 1.6 Hhz
server we want to use in Beowulf cluster. In particular, I need to measure
small time intervals, for which I want to use RDTSC-based "function"
(for example I attach below one - published by T.Prince). But it requires
some minor modifications, I beleive, to work properly on x86-64. 
 
 I use gcc-3.2 under SuSE SLES8 and call this function from
 the source compilated by pgf90-5.0beta2 (64-bit mode). The original
 source version of function by T.Prince gives assembler
errors because i386 is not pre-defined. I simple defined
 both i386 and _M_IX86, gcc -c is now OK, it create 64-bit object
 module, but after linking and runs of test the time measured
 is wrong :-( (negative in some cases). 
 
 I'll be very appreciate for any ideas what should I modify
 in the source (applied below) to resolve the problem.
 
 Mikhail Kuzminsky
 Zelinsky Institute of Organic Chemistry
 Moscow
 kus at free.net
> ===================================================
> #define _IFC 1
> 
> #define CLOCK_RATE 1600000000
> /* SET THIS AND RECOMPILE FOR TARGET MACHINE */
> #undef _WIN32
> /* set not to use API calls even on Windows */
>  #ifdef _WIN32
>  #include <windows.h>
>      #endif
> unsigned long long int rdtsc( )
> {
> #ifdef _M_IA64
> 
> unsigned __int64 __getReg(int whichReg);
> #pragma intrinsic(__getReg);
> #define INL_REGID_APITC 3116
> 
>   return  __getReg(INL_REGID_APITC);
> #elif defined(_WIN32)
>  unsigned long long int qpc;
>  (void)QueryPerformanceCounter((LARGE_INTEGER *)&qpc);
>  return qpc;
> #elif defined(__GNUC__)
> #ifdef i386
>    long long a;
>    asm volatile("rdtsc":"=A" (a));
>    return a;
> #else
>  unsigned long result;
> /* gcc-IA64 version */
>  __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
>  while (__builtin_expect ((int) result == -1, 0))
>   __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) ::
> "memory");
>  return result;
> 
> #endif
> #elif defined(_M_IX86)
>   _asm
>   {
>    _emit 0x0f /* rdtsc */
>    _emit 0x31
> 
>   }
> return;
> #else
> #error "only supports IA64,IX86,GNUC"
> #endif
> }
> 
> #ifdef _G77
> double g77_etime_0__ (float tarray[2])
> #elif defined (_IFC)
> double g77_etime_0_  (float tarray[2])
> #else
> double g77_etime_0   (float tarray[2])
> #endif
> 
> {
>    static int win32_platform = -1;
>    double usertime, systime;
> 
>      {
>        static double clock_per=1./(long long)CLOCK_RATE;
>        static unsigned long long int old_count;
>        unsigned long long count;
>        if(!old_count){
>  #ifdef _WIN32
>  unsigned long long int qpf;
>  if(QueryPerformanceFrequency((LARGE_INTEGER *)&qpf))
>      clock_per=1./(long long)qpf;
>      #endif
>  old_count=rdtsc();
>  }
> 
>        count = rdtsc();
>        tarray[0] = usertime = (long long)(count - old_count) * clock_per;
>        tarray[1] = 0;
>      }
>    return usertime ;
> 
> }
> 
> #ifdef _G77
> void f90_cputime4__(float *time){ // Intel Fortran call
> #elif defined (_IFC)
> void f90_cputime4_(float *time){
> #else
> void f90_cputime4  (float *time){
> #endif
>   float tarray[2];
> #ifdef _G77
>   *time=(float)g77_etime_0__ (tarray);
> #else
>   *time=(float)g77_etime_0_  (tarray);
> #endif
> }
> 

_______________________________________________
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf



More information about the Beowulf mailing list