1.编译问题
mpi1.6会有hang up 的情况。
使用 1.4.5
https://bbs.archlinux.org/viewtopic.php?id=145518
gcc 必须大于 4.2
2.sample运行问题
bool line_parser
bool line_parser
#include <graphlab.hpp>
#include <iostream>
using namespace std;
struct web_page {
std::string pagename;
double pagerank;
web_page():pagerank(0.0) { }
explicit web_page(std::string name):pagename(name),pagerank(0.0){ }
void save(graphlab::oarchive& oarc) const {
oarc << pagename << pagerank;
}
void load(graphlab::iarchive& iarc) {
iarc >> pagename >> pagerank;
}
};
typedef graphlab::distributed_graph<web_page, graphlab::empty> graph_type;
bool line_parser(graph_type& graph, const std::string& filename, const std::string& textline) {
std::cout << "fname : '" << filename << "' and textline : '" << textline << "'\n";
std::stringstream strm(textline);
graphlab::vertex_id_type vid;
std::string pagename;
// first entry in the line is a vertex ID
strm >> vid;
strm >> pagename;
// insert this web page
graph.add_vertex(vid, web_page(pagename));
// while there are elements in the line, continue to read until we fail
while(1){
graphlab::vertex_id_type other_vid;
strm >> other_vid;
if (strm.fail()){
break;
}
graph.add_edge(vid, other_vid);
}
return 1;
}
int main(int argc, char** argv) {
graphlab::mpi_tools::init(argc, argv);
graphlab::distributed_control dc;
graph_type graph(dc);
graph.load("/workshop/graphlab/graphlabapi/debug/apps/mytest/graph.txt", line_parser);
graphlab::mpi_tools::finalize();
}
需要注意:官方示例里面是没有返回值的,这样会在执行时刻报错,
因为:
const bool success = line_parser(*this, filename, line);
if (!success) {
logstream(LOG_WARNING)
<< "Error parsing line " << linecount << " in "
<< filename << ": " << std::endl
<< "\t\"" << line << "\"" << std::endl;
return false;
}