我有两个文件。浮动值变化。不知道为什么
- TreeSearch.cpp
- TreeSearchCUDA.cu
在TreeSearch.cpp我:
int* searchTree(vector<TreeNode> &tree, vector<ImageFeature> featureList)
{
float** features = makeMatrix(featureList, CHILDREN);
float* featuresArray = makeArray(features, featureList.size());
float* centroidNodes = convertTree(tree);
int numFeatures = featureList.size();
for(int j = 0; j < 10; j++)
{
cout << "C++ " << centroidNodes[j] << endl;
}
cout << "" << endl;
int* votes = startSearch(centroidNodes, tree.size(), featuresArray, numFeatures);
return votes;
}
开始搜索存在于TreeSearchCUDA.cu看起来像这样:
int* startSearch(float* centroids, int nodesCount, float* features, int featuresCount)
{
for(int j = 0; j < 10; j++)
{
printf("CUDA %f \n", centroids[j]);
}
...
}
现在我f我们看看它的输出如下:
C++ 0
C++ 2.52435e-29
C++ 0
C++ 2.52435e-29
C++ 6.72623e-44
C++ 1.26117e-44
C++ 2.03982e+12
C++ 4.58477e-41
C++ 0
C++ 1.26117e-44
CUDA 0.000000
CUDA 0.000000
CUDA 0.000000
CUDA 0.000000
CUDA 0.000000
CUDA 0.000000
CUDA 2039820058624.000000
CUDA 0.000000
CUDA 0.000000
CUDA 0.000000
结果是不一样的。有没有人有任何想法? :) 我有一个想法,这是因为代码的某些部分是用-m64编译的,而有些部分则不是。但是不可能改变这一点。链接我使用-m64的对象时。
我希望有人从你的输出CUDA是接近真正的小浮0
溶液或解释:)
你能解释哪部分代码是用64bit编译的,哪部分是32bit的? – shibumi 2011-12-14 06:06:42