Changeset 2838

Show
Ignore:
Timestamp:
02/15/07 17:12:45 (6 years ago)
Author:
ttsou
Message:

Added assembly call rdtsc option

Location:
experimental/components/TimingSrc1/trunk/TimingSrc1
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • experimental/components/TimingSrc1/trunk/TimingSrc1/TimingSrc1.cpp

    r2808 r2838  
    2727#include <sys/time.h> 
    2828#include "TimingSrc1.h" 
     29 
     30#define USE_RDTSC 
     31//#define USE_GTOD 
    2932 
    3033TimingSrc1_i::TimingSrc1_i(const char *uuid, omni_condition *condition) : Resource_impl(uuid), component_running(condition)  
     
    110113    Q_out_0.length(packetLength);  
    111114 
    112     struct timeval tv; 
    113  
    114115    std::ofstream outputFile; 
    115116    outputFile.open("/media/hda1/sent.dat"); 
     
    122123    */ 
    123124    int length = 10000; 
    124     unsigned long timeStamp_I_sent[length]; 
    125     unsigned long timeStamp_Q_sent[length]; 
     125    unsigned long long timeStamp_I_sent[length]; 
     126    unsigned long long timeStamp_Q_sent[length]; 
    126127 
    127128    // Rough sample rate setting 
    128129    unsigned int samplerate = 64000; 
    129130    unsigned int timespacing = (unsigned int) (packetLength * 1e6 / samplerate); 
     131 
     132#ifdef USE_GTOD 
     133    struct timeval tv; 
    130134 
    131135    int count = 0; 
     
    138142                std::cerr << "error: gettimeofday()" << std::endl; 
    139143            } 
    140  
    141144            // Push random data 
    142145            Class_instance_name->dataOut_0->pushPacket(I_out_0, Q_out_0); 
     
    150153        usleep(timespacing); 
    151154    } 
     155#else 
     156#ifdef USE_RDTSC 
     157    unsigned long long int tc; 
    152158 
     159    int count = 0; 
     160    while (count < length) 
     161    { 
     162        if (Class_instance_name->isRunning) 
     163        { 
     164            // Mark timestamp 
     165            tc = Class_instance_name->get_rdtsc(); 
     166 
     167            // Push random data 
     168            Class_instance_name->dataOut_0->pushPacket(I_out_0, Q_out_0); 
     169 
     170            // Store timestamps 
     171            timeStamp_I_sent[count] = 0; 
     172            timeStamp_Q_sent[count] = tc; 
     173 
     174            count++; 
     175        } 
     176        usleep(timespacing); 
     177    } 
     178#endif 
     179#endif 
    153180    // Rest when finished 
    154181    sleep(5); 
  • experimental/components/TimingSrc1/trunk/TimingSrc1/TimingSrc1.h

    r2468 r2838  
    6969        //list components provides and uses ports 
    7070        standardInterfaces_i::complexLong_u *dataOut_0; 
    71          
     71     
     72        __inline__ unsigned long long int get_rdtsc() 
     73        { 
     74            unsigned long long int tc; 
     75            __asm__ volatile (".byte 0x0f, 0x31" : "=A"(tc)); 
     76            return tc; 
     77        }  
     78     
    7279}; 
    7380#endif