dijkstra_shortest_paths performance problem

Hello, all We are doing a algorithm based on the graph boost library. Actually, it will be a Dinamic Link Library(dll). Our problem is when we execute it in console mode, it costs 12 seconds to finish, while it costs 120 seconds more or less when we are calling it as a DLL from Visual Basic. We have traced into the source code and found that is the dijkstra_shortest_paths function from the boost library which costs us 10 times more in the dll than the console mode. We call the dijkstra_shortest_paths like this: dijkstra_shortest_paths(g,s,predecessor_map(&p[0]).distance_map(&d[0]). visitor(make_dijkstra_visitor(_buscaVia(g,on_finish_vertex(),vinfo,edge_comp,via,p) ))); ///////below is the codes for visitor template <class Graph, class Tag> struct buscaVia : public boost::base_visitor<buscaVia<Graph, Tag> > { typedef Tag event_filter; buscaVia(typename property_map<Graph, vertex_info_t>::type & vinfo_, property_map<UGraph, edge_component_t>::type & ecomp,Vertex & _via,vector<Vertex> &p) :vinfo(vinfo_),encontrada(false),_ecomp(ecomp),via(_via),_p(p){} template <class Vertex, class Graph> void operator() (Vertex v, Graph& g){ bool hay_comp=false; Vertex a=v; if( vinfo[v].is_via && ! encontrada ){ while(_p[a]!=a){// mientras no hayamos llegado al origen if( _ecomp[edge(a,_p[a],g).first]->isComponentCaerTension() ){hay_comp=true; break;} else a=_p[a]; //pasamos al anterior } if(hay_comp==false){ // encontramos la via de la bobina DEBUG_CODE(cout << " via encontrada: " << vinfo[v].vertex_name << endl;) via = v; encontrada=true; } } DEBUG_CODE(else cout << "pasamos por vertice: " << vinfo[v].vertex_name << endl;) } private: typename property_map<Graph, vertex_info_t>::type & vinfo; property_map<UGraph, edge_component_t>::type & _ecomp; bool encontrada; Vertex & via; vector<Vertex> &_p; }; template<class Graph, class Tag> inline buscaVia<Graph,Tag> _buscaVia(Graph &g, Tag,typename property_map<Graph, vertex_info_t>::type & vinfo, property_map<UGraph, edge_component_t>::type & ecomp, Vertex & _via, vector<Vertex> &p){ return buscaVia<Graph,Tag>(vinfo,ecomp,_via,p); } ///////end of codes for visitor We appreciate your kind help! Yang ---------------------------------

Gustavo S?ffffe1nchez wrote:
Hello, all We are doing a algorithm based on the graph boost library. Actually, it will be a Dinamic Link Library(dll). Our problem is when we execute it in console mode, it costs 12 seconds to finish, while it costs 120 seconds more or less when we are calling it as a DLL from Visual Basic. We have traced into the source code and found that is the dijkstra_shortest_paths function from the boost library which costs us 10 times more in the dll than the console mode. We call the dijkstra_shortest_paths like this: dijkstra_shortest_paths(g,s,predecessor_map(&p[0]).distance_map(&d[0]).
visitor(make_dijkstra_visitor(_buscaVia(g,on_finish_vertex(),vinfo,edge_comp,via,p)
)));
To begin with, are you sure DLL and console app are compiled with the same optimization settings. BGL is very template heavy, so 10x speed difference due to optimization would not be surprising. Another idea is to drop the use of visitor and check if performance diffence is still there. - Volodya
participants (2)
-
Gustavo Sÿffffe1nchez
-
Vladimir Prus