Commit fbda20d67b3343a07c88088da6b603d744c1027f

Authored by boolli
1 parent f58d41a3

Get rid of useless code

openbr/plugins/cuda/MatManager.cu
... ... @@ -19,20 +19,11 @@ namespace br { namespace cuda {
19 19  
20 20 for (int i=0; i < num; i++) {
21 21 cudaMalloc(&_mats[i], 1 * sizeof(uint8_t));
22   - //_mats[i] = new GpuMat();
23 22  
24 23 // initialize matTaken
25   - /*
26   - _matTaken[i] = new bool;
27   - (*_matTaken[i]) = false;
28   - */
29 24 _matTaken[i] = false;
30 25  
31 26 // initialize all mat dimensions to be 1
32   - /*
33   - _matsDimension[i] = new int;
34   - (*_matsDimension[i]) = 1;
35   - */
36 27 _matsDimension[i] = 1;
37 28 }
38 29  
... ... @@ -49,7 +40,6 @@ namespace br { namespace cuda {
49 40  
50 41 MatManager::matindex MatManager::reserve(Mat &mat) {
51 42 int reservedMatIndex = 0;
52   - //std::cout << "Reserving" << std::endl << std::flush;
53 43  
54 44 sem_wait(_matSemaphore);
55 45 pthread_mutex_lock(_matTakenLock);
... ... @@ -58,7 +48,6 @@ namespace br { namespace cuda {
58 48 if ( !_matTaken[i] ) {
59 49 _matTaken[i] = true;
60 50 reservedMatIndex = i;
61   - //std::cout << "Taking " << i << std::endl << std::flush;
62 51 break;
63 52 }
64 53 }
... ... @@ -66,8 +55,6 @@ namespace br { namespace cuda {
66 55 std::cout << "Cannot reserve a mat. Not enough GpuMat resourses\n" << std::endl << std::flush;
67 56 }
68 57  
69   - //printMats();
70   - //printSemValue();
71 58 pthread_mutex_unlock(_matTakenLock);
72 59  
73 60 // reallocate if size does not match
... ... @@ -84,25 +71,12 @@ namespace br { namespace cuda {
84 71 }
85 72  
86 73 void MatManager::upload(MatManager::matindex reservedMatIndex, Mat& mat) {
87   - // upload the image
88   - /*
89   - pthread_mutex_lock(_matsDimensionLock);
90   - reservedMat->upload(mat);
91   - pthread_mutex_unlock(_matsDimensionLock);
92   - */
93   -
94 74 // copy the content of the Mat to GPU
95 75 uint8_t* reservedMat = _mats[reservedMatIndex];
96 76 cudaMemcpy(reservedMat, mat.ptr<uint8_t>(), mat.rows * mat.cols, cudaMemcpyHostToDevice);
97 77 }
98 78  
99 79 void MatManager::download(MatManager::matindex reservedMatIndex, Mat& dstMat) {
100   - /*
101   - pthread_mutex_lock(_matsDimensionLock);
102   - reservedMat->download(dstMat);
103   - pthread_mutex_unlock(_matsDimensionLock);
104   - */
105   -
106 80 // copy the mat data back
107 81 int dimension = dstMat.rows * dstMat.cols;
108 82 uint8_t* reservedMat = _mats[reservedMatIndex];
... ... @@ -126,19 +100,6 @@ namespace br { namespace cuda {
126 100 std::cout << "Reservedmat is not in the _mats array" << std::endl << std::flush;
127 101 return;
128 102 }
129   - /*
130   - printReleasingMat(reservedMat);
131   - pthread_mutex_lock(_matsDimensionLock);
132   - Size size = reservedMat->size();
133   - int type = reservedMat->type();
134   - reservedMat->release();
135   - reservedMat->create(size, type);
136   -
137   -
138   -
139   - pthread_mutex_unlock(_matsDimensionLock);
140   - */
141   -
142 103 sem_post(_matSemaphore);
143 104 }
144 105  
... ... @@ -148,44 +109,6 @@ namespace br { namespace cuda {
148 109 //std::cout << "Start to destroy.." << std::endl << std::flush;
149 110 }
150 111  
151   - /*
152   - void MatManager::printMats() {
153   - for (int i = 0; i < _numMats; i++) {
154   - if ((*_matTaken[i]) == true) {
155   - std::cout << i << ": Taken, " << _mats[i]->size() << std::endl << std::flush;
156   - } else {
157   - std::cout << i << ": Not taken, " << _mats[i]->size() << std::endl << std::flush;
158   - }
159   - }
160   - std::cout << std::endl << std::flush;
161   - }
162   -
163   - void MatManager::printSemValue() {
164   - int semValue;
165   - sem_getvalue(_matSemaphore, &semValue);
166   - std::cout << "Sem value: " << semValue << std::endl << std::flush;
167   - }
168   -
169   - void MatManager::printSizeChangingMat(GpuMat* gpuMat) {
170   - for (int i=0; i < _numMats; i++) {
171   - if (gpuMat == _mats[i]) {
172   - std::cout << "changing is size of" << i << " at " << gpuMat << std::endl << std::flush;
173   - return;
174   - }
175   - }
176   - std::cout << "can't change size of mat at address: " << gpuMat << std::endl << std::flush;
177   - }
178   -
179   - void MatManager::printReleasingMat(GpuMat* gpuMat) {
180   - for (int i=0; i < _numMats; i++) {
181   - if (gpuMat == _mats[i]) {
182   - std::cout << "releasing mat" << i << " at " << gpuMat << std::endl << std::flush;
183   - return;
184   - }
185   - }
186   - std::cout << "can't release mat at address: " << gpuMat << std::endl << std::flush;
187   - }
188   -*/
189 112 uint8_t* MatManager::get_mat_pointer_from_index(MatManager::matindex matIndex) {
190 113 return _mats[matIndex];
191 114 }
... ...
openbr/plugins/cuda/MatManager.hpp
... ... @@ -21,7 +21,7 @@ namespace br { namespace cuda {
21 21 int* _matsDimension; // holds the dimension of the Mats
22 22  
23 23 pthread_mutex_t* _matTakenLock; // lock for matTaken table
24   - pthread_mutex_t* _matsDimensionLock; // lock for OpenCV upload/download/realloc operations
  24 + pthread_mutex_t* _matsDimensionLock; // lock for _matsDimension table and _mats table
25 25 sem_t* _matSemaphore;
26 26  
27 27 public:
... ... @@ -35,9 +35,5 @@ namespace br { namespace cuda {
35 35 uint8_t* get_mat_pointer_from_index(matindex matIndex);
36 36  
37 37 ~MatManager();
38   - //void printMats();
39   - //void printSemValue();
40   - //void printSizeChangingMat(uint8_t* gpuMat);
41   - //void printReleasingMat(uint8_t* gpuMat);
42 38 };
43 39 }}
... ...
openbr/plugins/cuda/cudalbp.cpp
... ... @@ -157,28 +157,20 @@ class CUDALBPTransform : public UntrainableTransform
157 157 cuda::MatManager::matindex a;
158 158 cuda::MatManager::matindex b;
159 159 a = matManager->reserve(m);
160   -// std::cout << "m: " << m.size() << ", " << m.type() << std::endl << std::flush;
161   -// std::cout << "a: " << a->size() << ", " << a->type() << std::endl << std::flush;
162 160 matManager->upload(a, m);
163 161  
164 162 // reserve the second mat and check the dimensiosn
165 163 b = matManager->reserve(m);
166   - //matManager->matchDimensions(b, a);
167 164  
168   - //std::cout << "Coming to here" << std::endl << std::flush;
169 165 uint8_t* srcMatPtr = matManager->get_mat_pointer_from_index(a);
170 166 uint8_t* dstMatPtr = matManager->get_mat_pointer_from_index(b);
171 167 br::cuda::cudalbp_wrapper(srcMatPtr, dstMatPtr, lutGpuPtr, m.cols, m.rows, m.step1());
172   - //std::cout << "Coming out of here" << std::endl << std::flush;
173 168  
174   - //std::cout << "Start to download" << std::endl << std::flush;
175 169 matManager->download(b, dst);
176   - //std::cout << "finish download" << std::endl << std::flush;
177 170  
178 171 // release both the mats
179 172 matManager->release(a);
180 173 matManager->release(b);
181   - //std::cout << "finish release" << std::endl << std::flush;
182 174 }
183 175 };
184 176  
... ...