在CPU上实现了一个多关键字多节点的树
然后把树拷贝到GPU
然后GPU启动一个线程遍历
我的遍历代码如下
global static void TreeTest(Treenode* droot,char * word,int * num)
{
int i=0,branch=0;
while(word[i])
{
branch=word[i]-‘a’; //最多26个子结点
if(!droot->next[branch]) {
num[0]=0;
break;
}
droot=droot->next[branch]; //继续寻找分支结点。
i++;
num[i]=droot->count;
num[0]=droot->count;
}
}
树已拷贝到GPU,树经过从GPU拷回cpu验证是没有错误的。
在遍历时,droot=droot->next[branch]; //继续寻找分支结点。
程序不能正常运行。
去掉droot=droot->next[branch]; 可以运行,但逻辑不对!