DFS algorithm not working with ArBB

DFS algorithm not working with ArBB

I'm using intel ArBB to implement the DFS algorithm on an adjacency matrix to compare the performance with the usual c++ language, however there seems to be a problem and the algorithm is not working.
When i run it without using the call function it works fine, however when i use the call it enters an infinite loop.

This is the algorithm i implemented:

#include
#include
#define UNVISITED 0
#define VISITED 1
using namespace arbb;
using namespace std;

dense Matrix;
dense Mark;

void
DFS(i32 vertex, i32 numVertex)
{
_if (Mark[vertex] == VISITED) {
} _else {
Mark[vertex]=VISITED;
std::cout<<"v "<< std::endl;
i32 w=0;
i32 i=0;
////////////////////////// finding first neighbor
_for(i=0, i _if(Matrix(vertex,i) != 0) {
_break;
}_end_if;
}_end_for;

//////////////////////////// DFS algorithm
_for(w=i,w#if _CALL
call(DFS)(w, numVertex);
#else
DFS(w, numVertex);
#endif
_for(w=w+1, w _if(Matrix(vertex,w) != 0) {
_break;
}_end_if;
}_end_for;
}_end_for;
} _end_if
}

And here is the main:

int main()
{
i32 start=0;
i32 n=8;
Matrix = dense::dense(VERTICES,VERTICES);
Mark = dense::dense(VERTICES);
_for(i32 i=0,i {
Mark[i]=0;
_for(i32 j=0,j {
Matrix(i,j)=0;
}_end_for;
}_end_for;
//call(Matrix_Fill)(Matrix,n);
#if _CALL
call(DFS)(0, VERTICES);
#else
DFS(0, VERTICES);
#endif
return 0;
}

publicaciones de 2 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

The arbb::call() operator is always necessary in the main. Without it, the runtime won't create a closure for the function DFS, and DFS is executed just like a regular C++ function. The recursive call inside DFS do not need the arbb::call() operator, but it is not an error to use it either. A direct call (without using arbb::call() operator) is always inlined. A call via arbb::call() may or may not be inlined.

Please refer to the Function Invocation chapter in the Intel ArBB API reference manual to learn how to use arbb::call().

A bigger problem with this code is that it cannot be parallelized. The code expresses a sequential algorithm. It does not use any ArBB parallel constructs to express parallelism. Even we can get it run, it will run sequentially and much slower than equivalent C/C++ code because of the overhead introduced by the ArBB types and constructs. You may want to review the ArBB Code Tips webinar we did recently to learn more about expressing parallelism in ArBB.

Inicie sesión para dejar un comentario.