【问题标题】:Caused by: mpi.MPIException: java.lang.ClassCastException: cannot be cast to [Ljava.lang.Object;原因:mpi.MPIException: java.lang.ClassCastException: 无法转换为 [Ljava.lang.Object;
【发布时间】:2015-09-22 13:31:22
【问题描述】:

我一直在尝试使用 MPJExpress 发送对象:-

StateP randomState = HeuristicSolverUtility.createRandom(Constants.DIMENSION , Constants.w1);

MPI.COMM_WORLD.Isend(randomState , 0 , 1 , MPI.OBJECT , 3 , Constants.STARTOPERATION);

或者使用,从这个答案here,以这种形式

StateP[] stateArray = new StateP[1];
stateArray[0] = randomState;
MPI.COMM_WORLD.Isend(stateArray , 0 , 1 , MPI.OBJECT , 3 , Constants.STARTOPERATION);

当上面的代码行被执行时,我得到了这个异常:-

java.lang.reflect.InvocationTargetException

Caused by: mpi.MPIException: mpi.MPIException: java.lang.ClassCastException: common.model.StateP cannot be cast to [Ljava.lang.Object;
    at mpi.Comm$9.handleCompletion(Comm.java:1678)

StateP 类是可序列化的

public class StateP implements State , Serializable
{

这里没有可接受的解决方案:- Send objects with MPJ express

投票最多的答案对我不起作用。 我该如何纠正这个,我做错了什么?

如果需要,这是我的 MPJ.IReceive 函数

StateP startingState = HeuristicSolverUtility.generateGoalState(Constants.DIMENSION, Constants.w1);
        Request request = MPI.COMM_WORLD.Irecv(startingState, 0, 1, MPI.OBJECT, 0, Constants.STARTOPERATION);
        request.Wait();

【问题讨论】:

  • 你能试试那个帖子的第二个答案吗?在我看来,它应该可以解决您的问题。

标签: java debugging mpi mpj-express


【解决方案1】:

试一试!

 Object[] sendArr = new Object[1];
 sendArr[0] = (Object) randomState;
 MPI.COMM_WORLD.Isend(sendArr , 0 , 1 , MPI.OBJECT , 3 , Constants.STARTOPERATION);

【讨论】:

    猜你喜欢
    • 2014-07-08
    • 2012-08-07
    • 1970-01-01
    • 1970-01-01
    • 2016-05-01
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多