Pass query type T into kernel
This commit is contained in:
parent
63813e83ae
commit
fd1528795e
@ -64,6 +64,8 @@ namespace cv
|
||||
|
||||
static const int OPT_SIZE = 100;
|
||||
|
||||
static const char * T_ARR [] = {"uchar", "char", "ushort", "short", "int", "float", "double"};
|
||||
|
||||
template < int BLOCK_SIZE, int MAX_DESC_LEN/*, typename Mask*/ >
|
||||
void matchUnrolledCached(const oclMat &query, const oclMat &train, const oclMat &/*mask*/,
|
||||
const oclMat &trainIdx, const oclMat &distance, int distType)
|
||||
@ -78,7 +80,9 @@ void matchUnrolledCached(const oclMat &query, const oclMat &train, const oclMat
|
||||
vector< pair<size_t, const void *> > args;
|
||||
|
||||
char opt [OPT_SIZE] = "";
|
||||
sprintf(opt, "-D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d", distType, block_size, m_size);
|
||||
sprintf(opt,
|
||||
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d",
|
||||
T_ARR[query.depth()], distType, block_size, m_size);
|
||||
|
||||
if(globalSize[0] != 0)
|
||||
{
|
||||
@ -119,7 +123,9 @@ void match(const oclMat &query, const oclMat &train, const oclMat &/*mask*/,
|
||||
vector< pair<size_t, const void *> > args;
|
||||
|
||||
char opt [OPT_SIZE] = "";
|
||||
sprintf(opt, "-D DIST_TYPE=%d -D BLOCK_SIZE=%d", distType, block_size);
|
||||
sprintf(opt,
|
||||
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d",
|
||||
T_ARR[query.depth()], distType, block_size);
|
||||
|
||||
if(globalSize[0] != 0)
|
||||
{
|
||||
@ -162,7 +168,9 @@ void matchUnrolledCached(const oclMat &query, const oclMat &train, float maxDist
|
||||
vector< pair<size_t, const void *> > args;
|
||||
|
||||
char opt [OPT_SIZE] = "";
|
||||
sprintf(opt, "-D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d", distType, block_size, m_size);
|
||||
sprintf(opt,
|
||||
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d",
|
||||
T_ARR[query.depth()], distType, block_size, m_size);
|
||||
|
||||
if(globalSize[0] != 0)
|
||||
{
|
||||
@ -202,7 +210,9 @@ void radius_match(const oclMat &query, const oclMat &train, float maxDistance, c
|
||||
vector< pair<size_t, const void *> > args;
|
||||
|
||||
char opt [OPT_SIZE] = "";
|
||||
sprintf(opt, "-D DIST_TYPE=%d -D BLOCK_SIZE=%d", distType, block_size);
|
||||
sprintf(opt,
|
||||
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d",
|
||||
T_ARR[query.depth()], distType, block_size);
|
||||
|
||||
if(globalSize[0] != 0)
|
||||
{
|
||||
@ -300,7 +310,9 @@ void knn_matchUnrolledCached(const oclMat &query, const oclMat &train, const ocl
|
||||
vector< pair<size_t, const void *> > args;
|
||||
|
||||
char opt [OPT_SIZE] = "";
|
||||
sprintf(opt, "-D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d", distType, block_size, m_size);
|
||||
sprintf(opt,
|
||||
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d",
|
||||
T_ARR[query.depth()], distType, block_size, m_size);
|
||||
|
||||
if(globalSize[0] != 0)
|
||||
{
|
||||
@ -334,7 +346,9 @@ void knn_match(const oclMat &query, const oclMat &train, const oclMat &/*mask*/,
|
||||
vector< pair<size_t, const void *> > args;
|
||||
|
||||
char opt [OPT_SIZE] = "";
|
||||
sprintf(opt, "-D DIST_TYPE=%d -D BLOCK_SIZE=%d", distType, block_size);
|
||||
sprintf(opt,
|
||||
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d",
|
||||
T_ARR[query.depth()], distType, block_size);
|
||||
|
||||
if(globalSize[0] != 0)
|
||||
{
|
||||
@ -368,7 +382,10 @@ void calcDistanceUnrolled(const oclMat &query, const oclMat &train, const oclMat
|
||||
vector< pair<size_t, const void *> > args;
|
||||
|
||||
char opt [OPT_SIZE] = "";
|
||||
sprintf(opt, "-D DIST_TYPE=%d", distType);
|
||||
sprintf(opt,
|
||||
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d",
|
||||
T_ARR[query.depth()], distType, block_size, m_size);
|
||||
|
||||
if(globalSize[0] != 0)
|
||||
{
|
||||
args.push_back( make_pair( sizeof(cl_mem), (void *)&query.data ));
|
||||
@ -401,7 +418,10 @@ void calcDistance(const oclMat &query, const oclMat &train, const oclMat &/*mask
|
||||
vector< pair<size_t, const void *> > args;
|
||||
|
||||
char opt [OPT_SIZE] = "";
|
||||
sprintf(opt, "-D DIST_TYPE=%d", distType);
|
||||
sprintf(opt,
|
||||
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d",
|
||||
T_ARR[query.depth()], distType, block_size);
|
||||
|
||||
if(globalSize[0] != 0)
|
||||
{
|
||||
args.push_back( make_pair( sizeof(cl_mem), (void *)&query.data ));
|
||||
|
@ -47,6 +47,10 @@
|
||||
#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics:enable
|
||||
#define MAX_FLOAT 3.40282e+038f
|
||||
|
||||
#ifndef T
|
||||
#define T float
|
||||
#endif
|
||||
|
||||
#ifndef BLOCK_SIZE
|
||||
#define BLOCK_SIZE 16
|
||||
#endif
|
||||
@ -54,7 +58,11 @@
|
||||
#define MAX_DESC_LEN 64
|
||||
#endif
|
||||
|
||||
int bit1Count(float x)
|
||||
#ifndef DIST_TYPE
|
||||
#define DIST_TYPE 0
|
||||
#endif
|
||||
|
||||
int bit1Count(int x)
|
||||
{
|
||||
int c = 0;
|
||||
int ix = (int)x;
|
||||
@ -63,13 +71,9 @@ int bit1Count(float x)
|
||||
c += ix & 0x1;
|
||||
ix >>= 1;
|
||||
}
|
||||
return (float)c;
|
||||
return c;
|
||||
}
|
||||
|
||||
#ifndef DIST_TYPE
|
||||
#define DIST_TYPE 0
|
||||
#endif
|
||||
|
||||
#if (DIST_TYPE == 0)
|
||||
#define DIST(x, y) fabs((x) - (y))
|
||||
#elif (DIST_TYPE == 1)
|
||||
|
Loading…
Reference in New Issue
Block a user