00001
00002 #include <moc.h>
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if defined(MOC_SPU_TIMESOURCE_TIMEOFDAY)
00012 #undef MOC_SPU_TIMESOURCE_SPUTIME
00013
00014 #include <time.h>
00015 #include <sys/time.h>
00016
00017 double MOC_Wtime(void)
00018 {
00019 struct timeval time;
00020 gettimeofday(&time, NULL);
00021 return ((double) time.tv_sec) + ((double) time.tv_usec)
00022 / ((double) 1000000.0);
00023 }
00024
00025
00026
00027
00028
00029 #elif defined(MOC_SPU_TIMESOURCE_SPUTIME)
00030 #undef MOC_SPU_TIMESOURCE_TIMEOFDAY
00031
00032 #include <spu_mfcio.h>
00033 #include <spu_timer.h>
00034
00035 #define IMOC_TIMEBASE 79800000
00036
00037 char isTimerRunning = 0;
00038
00039 double MOC_Wtime(void)
00040 {
00041 if (!isTimerRunning)
00042 {
00043 spu_slih_register (MFC_DECREMENTER_EVENT, spu_clock_slih);
00044 spu_clock_start ();
00045 isTimerRunning = 1;
00046 }
00047 return ((double)spu_clock_read()/((double)IMOC_TIMEBASE));
00048 }
00049
00050
00051
00052 #else
00053
00054 double MOC_Wtime(void)
00055 {
00056 return 0;
00057 }
00058
00059 #endif
00060