📜 ⬆️ ⬇️

Java as a language for parallel computing. Installation, configuration, first program

Hello,

I have never seen people writing parallel programs in Java for a certain period of their work with HPC. He himself wrote something on C, looked at Fortran, but the soul always stretched to Java. In the end, he sat down and tried to figure it out.

Content:
1) MPI for Java implementation; What is it? Where to get?
2) How to install all this? How to setup?
3) Write your most simple program. How to run it?
')

For introductory parallel technologies, you can refer to my previous post .

1) MPI for Java implementation; What is it? Where to get?

For Java MPI implementations, there are two - mpiJava , as far as I know, already dropped by the author, and MPJ Express , which has the author mpiJava and several other talented developers in its team. The implementation natively supports two technologies - NIO and Myrinet. Since Myrinet was not at my fingertips, it was tested with NIO. The implementation works like MPICH — on the right nodes, processes of demons are created that talk to each other.

Site implementation. Pretty scarce, not enough examples.

2) How to install all this? How to setup?

Go. Site: SuSe 10.3 64-bit on 4 nodes; Java HotSpot (TM) 64-Bit Server VM (build 1.5.0_16-b02, mixed mode).

// download the 0.35 version because 0.36 is still not enough run-in and glitches occur, which // resulted in a three-day correspondence with the developer :-). Warning: it is necessary that the JVM of the same version is installed on all // nodes!

wget " sourceforge.net/projects/mpjexpress/files/releases/mpj-v0_35.tar.gz/download "
tar xvf mpj-v0_35.tar.gz
cd mpj-v0_35
ant (if ant is not installed, you need to install it)


It would be best if the MPJ Express folder is shared on all nodes in any way, so that there is no need to place it along the same path manually.

Now you need to fix the way. I use ZSH, it differs from Bash only in the file name.
The following should be added to the / etc / zshenv file:
export JAVA_HOME = path_to_java
export MPJ_HOME = path_to_MPJ
export PATH = $ PATH: $ MPJ_HOME / bin


Just in /.zshrc does not roll - you need to give out the paths and execute the SSH command.
Of course, this must be done on all nodes.

For convenience, we put the most needed library (/path_k_mpj/lib/mpj.jar) in / ext / lib. On all nodes!

You can try to run demons. Create the machines file, where we specify the necessary nodes:
node-1
node-2
node-3

and run / path_to_mpj / bin / mpjboot machines — our demons. You can check the functionality right here - if you have created * .pid files, one for each daemon, then everything is OK. If you created and disappeared in a couple of seconds - it means problems with the JVM. Not created - no JVM at all. :-) You can diagnose all the problems with the help of the utility, which is right there in the bin - mpjdaemon_linux_x86_64 with the console key.

Is done.

3) Write your most simple program. How to run it?

The program - is never easier.
import mpi.*; public class HelloWorld { public static void main(String args[]) throws Exception { MPI.Init(args); int me = MPI.COMM_WORLD.Rank(); int size = MPI.COMM_WORLD.Size(); System.out.println("Hello world from <"+me+"> from <"+size); MPI.Finalize(); } } 


Explanations:
We initialize the parallel section (.Init), create two me & size primitives (node ​​ID and the number of nodes in the pool), display “Hello world!” And close the parallel section.

That's all. There will be achievements - I will share. In the meantime, maybe this post has interested someone and inspired to greater accomplishments.

Source: https://habr.com/ru/post/105021/


All Articles