Openmpi perform Java MPI job __java

Source: Internet
Author: User
Openmpi perform Java MPI jobs

Next blog (set up open MPI cluster environment) Install java environment

sudo yum install-y java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64
Compile and install Openmpi
$./configure--prefix=/opt/openmpi--enable-mpi-java
$ make
$ sudo make install

* Note: To use the "–enable-mpi-java" option * Install validation

After the installation is complete, check that the/opt/openmpi/bin/mpijavac file exists and that the installation is successful if the file exists. performing Java MPI jobs Hello.java File

Import java.net.InetAddress;
Import mpi.*;

Class Hello {
    static public void main (string[] args) throws Exception {

    MPI. Init (args);
    String hostname = Inetaddress.getlocalhost (). GetHostName ();
    int myrank = MPI.COMM_WORLD.getRank ();
    int size = MPI.COMM_WORLD.getSize ();
    System.out.println ("<" + hostname + "": "+" Hello World from Rank "+ Myrank +" of "+ size);

    Mpi. Finalize ();
    }
Hosts file
Test1    slots=2
test2    slots=2
compiling Java code
$ Mpijavac Hello.java
running Java Classes
$ mpiexec--hostfile hosts-np 4 java Hello
<test1>: Hello World from rank 0 of 4
<test1>: Hello wor LD from rank 1 of 4
<test2>: Hello World from rank 2 of 4
<test2>: Hello World from rank 3 of 4

Reprint please link the form to indicate this article link
This article link: http://blog.csdn.net/kongxx/article/details/52237416

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.