gpt4 book ai didi

c++ - 多台机器执行失败

转载 作者:太空宇宙 更新时间:2023-11-04 12:11:43 25 4
gpt4 key购买 nike

与我的工作相关(此处为 Using a generic type with an adjacency_list)我现在正在测试执行以下操作的简单代码的执行情况:

  • 初始化 boost-mpi 环境
  • 将文件中的图加载到分布式 adjacency_list
  • 最后在每台机器上对其执行 2 个简单操作:计算边的数量并计算聚类系数。

代码如下:

#include "Common.h"
#include "GraphFileReader.h"
#include "GraphNeighbors.h"
#include <boost/graph/metis.hpp>
#include <boost/mpi/environment.hpp>
#include <boost/mpi/communicator.hpp>
#include <time.h>

int main(int argc, char *argv []){

// Start mpi enviroment
boost::mpi::environment env(argc, argv);
boost::mpi::communicator world;

// Create the graph
GraphFileReader *graphFileReader;
undirectedAdjacencyList graph;

if(process_id(graph.process_group()) == 0){
// Load the graph's path
graphFileReader = new GraphFileReader(argv[1]);
// Read the graph file and adds the vertices and edges
graphFileReader->loadGraph(graph);
}

// Wait until the process 0 has finished loading the graph
world.barrier();
synchronize(graph.process_group());

GraphNeighbors graphNeighbors;

// Now each machine should process it's own graph piece
graphNeighbors.countEdges(graph);
graphNeighbors.clusteringCoefficient(graph);

// Wait for the other processes before finishing
world.barrier();
synchronize(graph.process_group());
cout << "\n process: " << world.rank() <<" finishing\n" << std::endl;

结果如下:

graphs: /usr/include/boost/graph/distributed/adjacency_list.hpp:2679: 
std::pair<typename boost::adjacency_list<OutEdgeListS, boost::distributedS<ProcessGroup,
InVertexListS, InDistribution>, DirectedS, VertexProperty, EdgeProperty, GraphProperty,
EdgeListS>::out_edge_iterator, typename boost::adjacency_list<OutEdgeListS,
boost::distributedS<ProcessGroup, InVertexListS, InDistribution>, DirectedS,
VertexProperty, EdgeProperty, GraphProperty, EdgeListS>::out_edge_iterator>
boost::out_edges(typename boost::adjacency_list<OutEdgeListS,
boost::distributedS<ProcessGroup, InVertexListS, InDistribution>, DirectedS,
VertexProperty, EdgeProperty, GraphProperty, EdgeListS>::vertex_descriptor, const
boost::adjacency_list<OutEdgeListS, boost::distributedS<ProcessGroup, InVertexListS,
InDistribution>, DirectedS, VertexProperty, EdgeProperty, GraphProperty, EdgeListS>&) [with
OutEdgeListS = boost::vecS, ProcessGroup = boost::graph::distributed::mpi_process_group,
InVertexListS = boost::vecS, InDistribution = boost::defaultS, DirectedS =
boost::undirectedS, VertexProperty = Node, EdgeProperty = boost::no_property, GraphProperty
= boost::no_property, EdgeListS = boost::listS]: Assertion `v.owner == g.processor()' failed.

_________________________________________________________________

I'm process: 0
I'm process: 1

Number of edges: 4
0.37694 milliseconds
Number of edges: 2
0.16284 milliseconds
rank 1 in job 1 compute-1-4_49342 caused collective abort of all ranks
exit status of rank 1: killed by signal 6
_________________________________________________________________
Epilogue Args:
Job ID: 138573.tucan
User ID: ***
Group ID: ***
Job Name: mpiGraphs.job
Resource List: 5746
Queue Name: ncpus=1,neednodes=2:ppn=2,nodes=2:ppn=2
Account String: cput=00:00:00,mem=420kb,vmem=13444kb,walltime=00:00:02
Date: Thu Mar 1 14:28:19 CET 2012
_________________________________________________________________

另一方面,只有一台机器的执行效果很好:

I'm process: 0

Number of edges: 6
8.46696 milliseconds
The network average clustering coefficient is: 0.53333
0.12708 milliseconds


process: 0 finishing

我的导师和我认为这可能是因为一台机器结束了而另一台机器仍在执行它的操作,所以我们添加了同步和障碍(我实际上不知道两者之间的区别,所以我测试了一些结果相同的组合)。

如果您需要其余的代码(Common.h、GraphFileReader 或 GraphNeighbors),我可以上传它并在此处发布链接以避免发布大量帖子。

最佳答案

由于您正在考虑同步错误,我将简化您收到的错误消息:

graphs: (boost)adjacency_list.hpp:2679: boost::out_edges(vertex_descriptor v, adjacency_list& g): Assertion `v.owner == g.processor()' failed.

exit status of rank 1: killed by signal 6

信号 6 由 abort() 触发,后者又由上述断言失败触发。

我对这个图形库一无所知,但根据 adjacency_list.hpp似乎您的处理器 1 正在调用 out_edges 并传递属于处理器 0 的顶点 v

关于c++ - 多台机器执行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9517306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com