Commit 728e43f51e3b073a79c0c3dcd0d2be3e366c3f72

Authored by boolli
1 parent 4efed3e0

Change input parameter of MatManager::reserve from Mat* to Mat&

openbr/plugins/cuda/MatManager.cu
... ... @@ -41,7 +41,7 @@ namespace br { namespace cuda {
41 41 sem_init(_matSemaphore, 0, _numMats);
42 42 }
43 43  
44   - MatManager::matindex MatManager::reserve(Mat *mat) {
  44 + MatManager::matindex MatManager::reserve(Mat &mat) {
45 45 int reservedMatIndex = 0;
46 46 //std::cout << "Reserving" << std::endl << std::flush;
47 47  
... ... @@ -66,16 +66,11 @@ namespace br { namespace cuda {
66 66  
67 67 // reallocate if size does not match
68 68 pthread_mutex_lock(_matsDimensionLock);
69   - if (*_matsDimension[reservedMatIndex] != mat->rows * mat->cols) {
70   - //printSizeChangingMat(reservedMat);
71   - //reservedMat->release();
72   - //reservedMat->create(mat->size(), mat->type());
73   - //std::cout << "Size mismatch" << std::endl << std::flush;
74   - // re malloc
  69 + if (*_matsDimension[reservedMatIndex] != mat.rows * mat.cols) {
75 70 cudaFree(_mats[reservedMatIndex]); // free the previous memory first
76   - cudaMalloc(&_mats[reservedMatIndex], mat->rows * mat->cols * sizeof(uint8_t));
  71 + cudaMalloc(&_mats[reservedMatIndex], mat.rows * mat.cols * sizeof(uint8_t));
77 72 // change the dimension of that matrix
78   - *_matsDimension[reservedMatIndex] = mat->rows * mat->cols;
  73 + *_matsDimension[reservedMatIndex] = mat.rows * mat.cols;
79 74  
80 75 }
81 76 pthread_mutex_unlock(_matsDimensionLock);
... ...
openbr/plugins/cuda/MatManager.hpp
... ... @@ -28,7 +28,7 @@ namespace br { namespace cuda {
28 28 typedef int matindex;
29 29 MatManager(int num);
30 30  
31   - int reserve(Mat *mat);
  31 + int reserve(Mat &mat);
32 32 void upload(matindex reservedMatIndex, Mat& mat);
33 33 void download(matindex reservedMatIndex, Mat& dstMat);
34 34 void release(matindex matIndex);
... ...
openbr/plugins/cuda/cudalbp.cpp
... ... @@ -156,13 +156,13 @@ class CUDALBPTransform : public UntrainableTransform
156 156 Mat& m = (Mat&)src.m();
157 157 cuda::MatManager::matindex a;
158 158 cuda::MatManager::matindex b;
159   - a = matManager->reserve(&m);
  159 + a = matManager->reserve(m);
160 160 // std::cout << "m: " << m.size() << ", " << m.type() << std::endl << std::flush;
161 161 // std::cout << "a: " << a->size() << ", " << a->type() << std::endl << std::flush;
162 162 matManager->upload(a, m);
163 163  
164 164 // reserve the second mat and check the dimensiosn
165   - b = matManager->reserve(&m);
  165 + b = matManager->reserve(m);
166 166 //matManager->matchDimensions(b, a);
167 167  
168 168 //std::cout << "Coming to here" << std::endl << std::flush;
... ...