我正在尝试在 OpenCL 上实现 A-Star 搜索算法,但无法找到为其实现优先级队列的方法。这是我在 .cl 文件中尝试执行的操作的总体思路
//HOW TO IMPLEMENT THESE??
void extractFromPriorityQueue();
void insertIntoPriorityQueue();
//HOW TO IMPLEMENT THESE??
__kernel void startAStar(//necessary inputs) {
int id = get_global_id(0);
int currentNode = extractFromPriorityQueue(priorityQueueArray,id);
if(currentNode==0){
return;
}
int earliest_edge = vertexArray[currentNode-1];
int next_vertex_edge = vertexArray[currentNode];
for(int i=earliest_edge;i<next_vertex_edge;i++){
int child = edgeArray[i];
float weight = weightArray[i];
gCostArray[child-1] = gCostArray[currentNode] + weight;
hCostArray[child-1] = computeHeuristic(currentNode,child,coordinateArray);
fCostArray[child-1] = gCostArray[child-1] + hCostArray[child-1];
insertIntoPriorityQueue(priorityQueueArray,child);
}
}
另外,在这种情况下是否必须同步优先级队列?