Commit 4efed3e0a0f9992759e4c1b500cb4f5691a35b4c
1 parent
a2742d60
Make maxindex type
Showing
3 changed files
with
12 additions
and
11 deletions
openbr/plugins/cuda/MatManager.cu
| @@ -41,7 +41,7 @@ namespace br { namespace cuda { | @@ -41,7 +41,7 @@ namespace br { namespace cuda { | ||
| 41 | sem_init(_matSemaphore, 0, _numMats); | 41 | sem_init(_matSemaphore, 0, _numMats); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | - int MatManager::reserve(Mat *mat) { | 44 | + MatManager::matindex MatManager::reserve(Mat *mat) { |
| 45 | int reservedMatIndex = 0; | 45 | int reservedMatIndex = 0; |
| 46 | //std::cout << "Reserving" << std::endl << std::flush; | 46 | //std::cout << "Reserving" << std::endl << std::flush; |
| 47 | 47 | ||
| @@ -82,7 +82,7 @@ namespace br { namespace cuda { | @@ -82,7 +82,7 @@ namespace br { namespace cuda { | ||
| 82 | return reservedMatIndex; | 82 | return reservedMatIndex; |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | - void MatManager::upload(int reservedMatIndex, Mat& mat) { | 85 | + void MatManager::upload(MatManager::matindex reservedMatIndex, Mat& mat) { |
| 86 | // upload the image | 86 | // upload the image |
| 87 | /* | 87 | /* |
| 88 | pthread_mutex_lock(_matsDimensionLock); | 88 | pthread_mutex_lock(_matsDimensionLock); |
| @@ -95,7 +95,7 @@ namespace br { namespace cuda { | @@ -95,7 +95,7 @@ namespace br { namespace cuda { | ||
| 95 | cudaMemcpy(reservedMat, mat.ptr<uint8_t>(), mat.rows * mat.cols, cudaMemcpyHostToDevice); | 95 | cudaMemcpy(reservedMat, mat.ptr<uint8_t>(), mat.rows * mat.cols, cudaMemcpyHostToDevice); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | - void MatManager::download(int reservedMatIndex, Mat& dstMat) { | 98 | + void MatManager::download(MatManager::matindex reservedMatIndex, Mat& dstMat) { |
| 99 | /* | 99 | /* |
| 100 | pthread_mutex_lock(_matsDimensionLock); | 100 | pthread_mutex_lock(_matsDimensionLock); |
| 101 | reservedMat->download(dstMat); | 101 | reservedMat->download(dstMat); |
| @@ -108,7 +108,7 @@ namespace br { namespace cuda { | @@ -108,7 +108,7 @@ namespace br { namespace cuda { | ||
| 108 | cudaMemcpy(dstMat.ptr<uint8_t>(), reservedMat, dimension, cudaMemcpyDeviceToHost); | 108 | cudaMemcpy(dstMat.ptr<uint8_t>(), reservedMat, dimension, cudaMemcpyDeviceToHost); |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | - void MatManager::release(int reservedMatIndex) { | 111 | + void MatManager::release(MatManager::matindex reservedMatIndex) { |
| 112 | uint8_t* reservedMat = _mats[reservedMatIndex]; | 112 | uint8_t* reservedMat = _mats[reservedMatIndex]; |
| 113 | pthread_mutex_lock(_matTakenLock); | 113 | pthread_mutex_lock(_matTakenLock); |
| 114 | bool foundMatch = false; | 114 | bool foundMatch = false; |
| @@ -185,7 +185,7 @@ namespace br { namespace cuda { | @@ -185,7 +185,7 @@ namespace br { namespace cuda { | ||
| 185 | std::cout << "can't release mat at address: " << gpuMat << std::endl << std::flush; | 185 | std::cout << "can't release mat at address: " << gpuMat << std::endl << std::flush; |
| 186 | } | 186 | } |
| 187 | */ | 187 | */ |
| 188 | - uint8_t* MatManager::get_mat_pointer_from_index(int matIndex) { | 188 | + uint8_t* MatManager::get_mat_pointer_from_index(MatManager::matindex matIndex) { |
| 189 | return _mats[matIndex]; | 189 | return _mats[matIndex]; |
| 190 | } | 190 | } |
| 191 | 191 |
openbr/plugins/cuda/MatManager.hpp
| @@ -25,13 +25,14 @@ namespace br { namespace cuda { | @@ -25,13 +25,14 @@ namespace br { namespace cuda { | ||
| 25 | sem_t* _matSemaphore; | 25 | sem_t* _matSemaphore; |
| 26 | 26 | ||
| 27 | public: | 27 | public: |
| 28 | + typedef int matindex; | ||
| 28 | MatManager(int num); | 29 | MatManager(int num); |
| 29 | 30 | ||
| 30 | int reserve(Mat *mat); | 31 | int reserve(Mat *mat); |
| 31 | - void upload(int reservedMatIndex, Mat& mat); | ||
| 32 | - void download(int reservedMatIndex, Mat& dstMat); | ||
| 33 | - void release(int matIndex); | ||
| 34 | - uint8_t* get_mat_pointer_from_index(int matIndex); | 32 | + void upload(matindex reservedMatIndex, Mat& mat); |
| 33 | + void download(matindex reservedMatIndex, Mat& dstMat); | ||
| 34 | + void release(matindex matIndex); | ||
| 35 | + uint8_t* get_mat_pointer_from_index(matindex matIndex); | ||
| 35 | 36 | ||
| 36 | ~MatManager(); | 37 | ~MatManager(); |
| 37 | //void printMats(); | 38 | //void printMats(); |
openbr/plugins/cuda/cudalbp.cpp
| @@ -154,8 +154,8 @@ class CUDALBPTransform : public UntrainableTransform | @@ -154,8 +154,8 @@ class CUDALBPTransform : public UntrainableTransform | ||
| 154 | void project(const Template &src, Template &dst) const | 154 | void project(const Template &src, Template &dst) const |
| 155 | { | 155 | { |
| 156 | Mat& m = (Mat&)src.m(); | 156 | Mat& m = (Mat&)src.m(); |
| 157 | - int a; | ||
| 158 | - int b; | 157 | + cuda::MatManager::matindex a; |
| 158 | + cuda::MatManager::matindex b; | ||
| 159 | a = matManager->reserve(&m); | 159 | a = matManager->reserve(&m); |
| 160 | // std::cout << "m: " << m.size() << ", " << m.type() << std::endl << std::flush; | 160 | // std::cout << "m: " << m.size() << ", " << m.type() << std::endl << std::flush; |
| 161 | // std::cout << "a: " << a->size() << ", " << a->type() << std::endl << std::flush; | 161 | // std::cout << "a: " << a->size() << ", " << a->type() << std::endl << std::flush; |