forked from ggtoyon/CudaAssertionFailTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CudaAssertionFailTest.cpp
83 lines (67 loc) · 2.35 KB
/
CudaAssertionFailTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <opencv2/core.hpp>
#include <opencv2/cudaarithm.hpp>
#include <opencv2/xfeatures2d/cuda.hpp>
#include <thread>
using namespace std;
//-----------------------------------------------------------------------------
// PASS
//-----------------------------------------------------------------------------
void RunAdd()
{
cv::cuda::GpuMat Row1(cv::Mat::ones(1, 100, CV_8U));
cv::cuda::GpuMat Row2(cv::Mat::ones(1, 100, CV_8U));
cv::cuda::GpuMat Row3(cv::Mat::ones(1, 100, CV_8U));
cv::cuda::GpuMat Row4(cv::Mat::ones(1, 100, CV_8U));
cv::cuda::add(Row1, Row2, Row3, Row4);
}
//-----------------------------------------------------------------------------
// FAIL
//-----------------------------------------------------------------------------
void RunMinMax()
{
double MaxVal;
cv::cuda::minMax(
cv::cuda::GpuMat(cv::Mat::ones(100, 1, CV_32S)),
0,
&MaxVal);
}
//-----------------------------------------------------------------------------
// FAIL
//-----------------------------------------------------------------------------
void RunSqrSum()
{
cv::cuda::GpuMat Row1(cv::Mat::ones(1, 100, CV_8U));
cv::cuda::GpuMat Row2(cv::Mat::ones(1, 100, CV_8U));
cv::cuda::sqrSum(Row1, Row2);
}
//-----------------------------------------------------------------------------
// FAIL
//-----------------------------------------------------------------------------
void RunSum()
{
cv::cuda::GpuMat dIsMaximalMask(cv::Mat::ones(100, 1, CV_32S));
cv::cuda::sum(dIsMaximalMask);
}
//-----------------------------------------------------------------------------
// PASS
//-----------------------------------------------------------------------------
void RunSurf()
{
cv::cuda::GpuMat Image(cv::Mat::zeros(500, 500, CV_8UC1));
vector<cv::KeyPoint> CurMetaFeatures;
cv::cuda::SURF_CUDA Surf;
Surf(Image, cv::cuda::GpuMat(), CurMetaFeatures, Image);
}
//*****************************************************************************
// The functions above are labeled with PASS or FAIL indicating whether memory
// pool assertion fails when they are called on threads in debug. Replace
// arguments for Thread1 and/or Thread 2 to test.
//*****************************************************************************
int main(int argc, const char** argv)
{
thread Thread1(RunSum);
thread Thread2(RunMinMax);
Thread1.join();
Thread2.join();
return 0;
}