PARP Research Group University of Murcia, Spain


src/qvcuda/qvcudautils.cpp

00001 /*
00002  *      Copyright (C) 2007, 2008, 2009. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
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 }



QVision framework. PARP research group, copyright 2007, 2008.