我有兩個文件。浮動值變化。不知道爲什麼
- 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