device.cpp

Java代码 复制代码 收藏代码

#include "device.h" 
#include <math.h>

//Class Timer member function implementation
int Timer::createTimer()
{
_start = 0;
_clocks = 0;

#ifdef _WIN32
QueryPerformanceFrequency((LARGE_INTEGER* )&_freq);
#else
_freq = (long long)1.0E3;
#endif
return SDK_SUCCESS;
}

//Start the Timer
int Timer::startTimer()
{
#ifdef _WIN32
QueryPerformanceCounter((LARGE_INTEGER*)&_start);
#else
struct timeval s;
gettimeofday(&s,0);
_start = (long long)s.tv_sec * (long long)1.0E3 + (long long)s.tv_usec / (long long)1.0E3;
#endif
return SDK_SUCCESS;
}

//Reset the Timer
int Timer::resetTimer()
{
_start = 0;
_clocks = 0;
return SDK_SUCCESS;
}

//Stop the Timer
int Timer::stopTimer()
{
long long n = 0;
#ifdef _WIN32
QueryPerformanceCounter((LARGE_INTEGER*)&n);
#else
struct timeval s;
gettimeofday(&s,0);
n = (long long)s.tv_sec * (long long)1.0E3 + (long long)s.tv_usec / (long long)1.0E3;
#endif
n -= _start;
_start = 0;
_clocks += n;
return SDK_SUCCESS;
}

//Get the elapsed time between the Timer start and end
double Timer::readTimer()
{
totaltime = double(_clocks);
totaltime = double(totaltime / _freq);
return totaltime;
}


//class Device member function implement

//Construction
Device::Device()
{
globalThreads[0] = WIDTH / 4/GROUP;
globalThreads[1] = HEIGHT;

localThreads[0] = 64;
localThreads[1] = 4;
}

//Deconstruction
Device::~Device()
{
//deconstuctor
}  
posted on 2013-02-16 19:34  蜜雪薇琪  阅读(209)  评论(0编辑  收藏  举报