flann-lib / flann

Fast Library for Approximate Nearest Neighbors
http://people.cs.ubc.ca/~mariusm/flann
Other
2.25k stars 647 forks source link

Compilation error under Win7 VS2012 x64 Cuda 5.5RC for Cuda static #133

Open frmir opened 11 years ago

frmir commented 11 years ago

Hi Marius,

I get two types of error when compiling the flann_cuda_s project:

Error 10 error : no operator "+" matches these operands C:\Users\id\Documents\Code\flann-1.8.4-src\src\cpp\flann\util\params.h 114

Error 20 error : calling a device function("SingleResultSet") from a host function("knnSearchGpu") is not allowed C:\Users\id\Documents\Code\flann-1.8.4-src\src\cpp\flann\algorithms\kdtree_cuda_3d_index.cu 323

The first appears only once, the second appears 47 times. I wonder more about the second error. Do you have any idea ?

mya1114 commented 11 years ago

I've got the same setting with frmir, and am facing the same problem. I've looked into the kdtree_cuda_3d_index.cu file, and it seems there should be no issue unless Nvidia has made some changes in the way to call a device function in their new Cuda release. Can anybody help to resovle this issues please?

rob100 commented 11 years ago

NVidia changed the default behavior with CUDA 5. The problem is, that the methods in result_set.h are used on device as well as on host. You can fix this with declaring all methods in result_set.h from device to device host. Then the methods will be compiled twice, once for device usage, once for host usage. For example:

__device__
SingleResultSet( DistanceType eps ) : bestIndex(-1),bestDist(INFINITY), epsError(eps){ }
// change to:
__device__ __host__
SingleResultSet( DistanceType eps ) : bestIndex(-1),bestDist(INFINITY), epsError(eps){ }

Additionally you need to change the infinity() method because ___int_asfloat is device only:

__device__ __host__ __forceinline__
float infinity()
{
     //return __int_as_float(0x7f800000);
    return 2139095040.f;
     // This seems either way to be a better solution, because infinity is a constant
}

This is not the best solution, but it will work until somebody will rebuild the architecture.

mya1114 commented 11 years ago

Thank you so much, rob100. Additionally I had to change all the search functions (i.e., knnSearch() and radisuSearch()) in nn_index.h to virtual functions otherwise those functions of CUDA implementation in kdtree_cuda_3d_index.cuh are not called with the KdTreeCuda3dIndex index type. This might be only my case, but I thought I should mention it anyway.

Ryosaji commented 7 years ago

Hi, there, I have the same problems of flann_cuda_s project under Win7 VS2010 x64 Cuda 7.5. Thanks to your explanation, I fixed the two problems in "result_set.h" which are changed from device to device host and the infinity() method. However, I still have the problem in "param.h", which has : ..\flann-master\src\cpp\flann/util/params.h(114): error : no operator "+" matches these operands operand types are: std::string + std::string

The cod "params.h(114)" is: throw FLANNException(std::string("Missing parameter '")name+std::string("' in the parameters given")); Have you fixed the problem mentioned above? Could you please let me know how to fix it?

Thank you in advance.

razieh90 commented 7 years ago

You can solve this problem "..\flann-master\src\cpp\flann/util/params.h(114): error : no operator "+" matches these operands", by doing two following modifications in param.h 1- by changing this line:

include "iostream" into

include < iostream >

2- and adding srings as:

include < string >