Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
c9db05de
Commit
c9db05de
authored
Mar 12, 2016
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6137 from dtmoodie:thrust_allocator
parents
bad09e5f
95608b1b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
0 deletions
+50
-0
utility.hpp
modules/core/include/opencv2/core/cuda/utility.hpp
+9
-0
gpu_mat.cu
modules/core/src/cuda/gpu_mat.cu
+41
-0
No files found.
modules/core/include/opencv2/core/cuda/utility.hpp
View file @
c9db05de
...
@@ -54,6 +54,15 @@
...
@@ -54,6 +54,15 @@
namespace
cv
{
namespace
cuda
{
namespace
device
namespace
cv
{
namespace
cuda
{
namespace
device
{
{
struct
CV_EXPORTS
ThrustAllocator
{
typedef
uchar
value_type
;
virtual
__device__
__host__
uchar
*
allocate
(
size_t
numBytes
)
=
0
;
virtual
__device__
__host__
void
deallocate
(
uchar
*
ptr
,
size_t
numBytes
)
=
0
;
static
ThrustAllocator
&
getAllocator
();
static
void
setAllocator
(
ThrustAllocator
*
allocator
);
};
#define OPENCV_CUDA_LOG_WARP_SIZE (5)
#define OPENCV_CUDA_LOG_WARP_SIZE (5)
#define OPENCV_CUDA_WARP_SIZE (1 << OPENCV_CUDA_LOG_WARP_SIZE)
#define OPENCV_CUDA_WARP_SIZE (1 << OPENCV_CUDA_LOG_WARP_SIZE)
#define OPENCV_CUDA_LOG_MEM_BANKS ((__CUDA_ARCH__ >= 200) ? 5 : 4) // 32 banks on fermi, 16 on tesla
#define OPENCV_CUDA_LOG_MEM_BANKS ((__CUDA_ARCH__ >= 200) ? 5 : 4) // 32 banks on fermi, 16 on tesla
...
...
modules/core/src/cuda/gpu_mat.cu
View file @
c9db05de
...
@@ -50,11 +50,52 @@
...
@@ -50,11 +50,52 @@
#include "opencv2/core/cuda.hpp"
#include "opencv2/core/cuda.hpp"
#include "opencv2/cudev.hpp"
#include "opencv2/cudev.hpp"
#include "opencv2/core/cuda/utility.hpp"
using namespace cv;
using namespace cv;
using namespace cv::cuda;
using namespace cv::cuda;
using namespace cv::cudev;
using namespace cv::cudev;
namespace
{
class DefaultThrustAllocator: public cv::cuda::device::ThrustAllocator
{
public:
__device__ __host__ uchar* allocate(size_t numBytes)
{
#ifndef __CUDA_ARCH__
uchar* ptr;
CV_CUDEV_SAFE_CALL(cudaMalloc(&ptr, numBytes));
return ptr;
#else
return NULL;
#endif
}
__device__ __host__ void deallocate(uchar* ptr, size_t numBytes)
{
#ifndef __CUDA_ARCH__
CV_CUDEV_SAFE_CALL(cudaFree(ptr));
#endif
}
};
DefaultThrustAllocator defaultThrustAllocator;
cv::cuda::device::ThrustAllocator* g_thrustAllocator = &defaultThrustAllocator;
}
cv::cuda::device::ThrustAllocator& cv::cuda::device::ThrustAllocator::getAllocator()
{
return *g_thrustAllocator;
}
void cv::cuda::device::ThrustAllocator::setAllocator(cv::cuda::device::ThrustAllocator* allocator)
{
if(allocator == NULL)
g_thrustAllocator = &defaultThrustAllocator;
else
g_thrustAllocator = allocator;
}
namespace
namespace
{
{
class DefaultAllocator : public GpuMat::Allocator
class DefaultAllocator : public GpuMat::Allocator
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment