java - Intellij IDEA 中运行的 MPJ Express(Java MPI)

标签 java intellij-idea mpi mpj-express

我下载了mpj-v0_44并将其提取到 C:\mpj

放Windows系统环境。变量 MPJ_HOMEC:\mpj 并在 PATH 中添加值 C:\mpj\bin

我在项目结构->库中添加了mpi.jarmpj.jar

enter image description here

并编写了简单的 helloworld mpi 程序:

import mpi.MPI;

public class Main {

    public static void main(String[] args) {
        MPI.Init(args);
        int me = MPI.COMM_WORLD.Rank();
        int size = MPI.COMM_WORLD.Size();
        System.out.println("Hello world from <"+me+"> of <"+size+">");
        MPI.Finalize();
    }
}

我创建了图片上描述的运行配置: enter image description here

但是我得到以下错误:

MPJ Express (0.44) is started in the multicore configuration
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at runtime.starter.MulticoreStarter$1.run(MulticoreStarter.java:281)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: 0
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)
    ... 6 more

我在 eclipse 中发现了类似的问题,但没有一个解决方案有效:

java.io.FileNotFoundException: null\conf\wrapper.conf (The system cannot find the path specified)

"Unresolved compilation problems" from running MPJ express in Eclipse Indigo

在 Eclipse 中一切正常,但我需要 Intellij IDEA!

附言: (如果你需要 javadoc 添加整个 C:\mpj\lib 文件夹和 C:\mpj\src 库源文件夹)

最佳答案

你需要把主类改成

"runtime.starter.MPJRun"

和 VM 选项以包含您的主类

"-jar $MPJ_HOME$\lib\starter.jar nz.geek.colin.mpj.Main -np 4"

这是因为 MPJExpress 运行然后加载您的程序以创建多个进程。

如果 IntelliJ 提示找不到 runtime.starter.MPJRun,您可以忽略它,但如果警告困扰您,您可以将 starter.jar 添加到项目中。

关于java - Intellij IDEA 中运行的 MPJ Express(Java MPI),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36356408/

相关文章:

c - MPI 通信中出现奇怪的 double 值 - 内存问题?

c - 使用 MPI_Put 的异步有限差分方案

java - 计算两个十六进制整数值的混合

java - 基于 Maven 的代码生成器

grails - 迁移Grails 2.4 MultipleCompilationErrorsException

intellij-idea - IntelliJ IDEA 10.5 如何处理 Tomcat

intellij-idea - 无法更改配置的依赖项

mpi - 在消息传递接口(interface)中使用共享数组

java - 当我们使用引用类型和对象类型时

java - 使用 sax 解析器实现的设计问题