00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #include <cstdio>
00026 #include <cstdlib>
00027
00028 #include <cuda.h>
00029 #include <cuda_runtime.h>
00030
00031 #include "cutil.h"
00032
00033 #include "qvcudautils.h"
00034
00035 void InitCuda(int argc, char **argv) { CUT_DEVICE_INIT(argc,argv); }
00036
00037 int iDivUp(int a, int b) { return (a % b != 0) ? (a / b + 1) : (a / b); };
00038
00039 int iDivDown(int a, int b) { return a / b; };
00040
00041 int iAlignUp(int a, int b) { return (a % b != 0) ? (a - a % b + b) : a; };
00042
00043 int iAlignDown(int a, int b) { return a - a % b; };
00044
00045 void StartTimer(unsigned int *hTimer)
00046 {
00047 CUT_SAFE_CALL(cutCreateTimer(hTimer));
00048 CUT_SAFE_CALL(cutResetTimer(*hTimer));
00049 CUT_SAFE_CALL(cutStartTimer(*hTimer));
00050 }
00051
00052 double StopTimer(unsigned int hTimer)
00053 {
00054 CUT_SAFE_CALL(cutStopTimer(hTimer));
00055 double gpuTime = cutGetTimerValue(hTimer);
00056 CUT_SAFE_CALL(cutDeleteTimer(hTimer));
00057 return gpuTime;
00058 }