I'm trying to get parfor_all_vertices to run only on specified subsets of the vertices of a graph. As I read the docs, it looks like I can do that by specifying a vertex_set, but I think I must not be doing something correctly because my code always runs on all vertices, even if the vertex_set is graph.empty_set().
Here's some sample code. I create a vertex_set that contains only the vertex w/ id==0, and then run the parfor.
#include <graphlab/engine/warp_engine.hpp>
#include <graphlab/engine/warp_parfor_all_vertices.hpp>
typedef graphlab::empty edge_data_type;
typedef graphlab::empty vertex_data_type;
typedef graphlab::distributed_graph<vertex_data_type,
edge_data_type> graph_type;
bool find_zero(const graph_type::vertex_type& v){
}
void compute(graph_type::vertex_type& v){
// we should only have one node here.
std::cout<<"working node with id "<<
v.id()<<std::endl;
}
int main(int argc, char** argv) {
graphlab::distributed_control dc;
graphlab::command_line_options clopts("Louvain modularity maximization");
std::string prefix;
std::string format="tsv";
clopts.attach_option("graph", prefix,
"Graph input. reads all graphs matching prefix*");
clopts.attach_option("format", format,
"The graph format");
if(!clopts.parse(argc, argv)) return EXIT_FAILURE;
graph_type graph(dc, clopts);
graph.load_format(prefix, format);
graph.finalize();
graphlab::warp::warp_engine<graph_type> no_engine(dc,graph,clopts);
graphlab::vertex_set ZERO = graph.select(find_zero);
std::cout<<"Size of active set: "<<graph.vertex_set_size(ZERO)<<std::endl;
graphlab::warp::parfor_all_vertices(graph,compute,ZERO);
}
./warpset --graph K4 --format tsv
INFO: dc.cpp(init:573): Cluster of 1 instances created.
INFO: distributed_graph.hpp(set_ingress_method:3200): Automatically determine ingress method: grid
INFO: distributed_graph.hpp(load_from_posixfs:2189): Loading graph from file: ./K4
INFO: distributed_ingress_base.hpp(finalize:185): Finalizing Graph...
WARNING: memory_info.cpp(log_usage:96): Unable to print memory info for: Post Flush. No memory extensions api available.
INFO: distributed_ingress_base.hpp(exchange_global_info:532): Graph info:
nverts: 4
nedges: 12
nreplicas: 4
replication factor: 1
INFO: distributed_ingress_base.hpp(finalize:185): Finalizing Graph...
Size of active set: 1
working node with id 0
working node with id 1
working node with id 2
working node with id 3
So it appears that the vertex_set is being properly created (or at least its cardinality is!) but the parfor still runs the compute() over all nodes. Replacing ZERO with graph.empty_set() does the same thing.