Instalasi MPJExpress di Netbeans
December 21, 2017
Kali ini, kita akan menggunakan Netbeans IDE untuk pemrograman paralel. Penulis menggunakan Netbeans versi 8.2 dengan spesifikasi sebagai berikut:
- Product Version: NetBeans IDE 8.2 (Build 201609300101)
Updates: Updates available to version NetBeans 8.2 Patch 2
Java: 1.8.0_112; Java HotSpot(TM) 64-Bit Server VM 25.112-b15
Runtime: Java(TM) SE Runtime Environment 1.8.0_112-b15
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
User directory: C:\Users\Toshiba\AppData\Roaming\NetBeans\8.2
Cache directory: C:\Users\Toshiba\AppData\Local\NetBeans\Cache\8.2
Langkah-langkah instalasi sebagai berikut:
Buat project baru: Pada contoh berikut ini, project diberi nama MPJExpress
Tambahkan library. Klik kanan pada paket Libraries sehingga muncul tampilan berikut:
Pilih JAR/Folder. Cari folder C:\mpj\lib; pilih file mpj.jar seperti pada gambar berikut ini:
Tekan tombol open. Pastikan library mpj.jar sudah ditambahkan ke paket libraries seperti pada gambar berikut ini:
Siapkan lingkungan virtual machine untuk MPJExpress sebagai berikut:
Customisasi configurasi seperti pada gambar berikut ini:
Sehingga muncul tampilan berikut ini. Lakukan pemilihan New Confif seperti pada gambar berikut ini:
Isilah configurasi baru tersebut, beri nama MPJExpress seperti pada gambar berikut ini:
Tekan tombol OK. Lalu lengkapi isian Working Directory dan VM Option sebagai berikut:
- Working Directory: C:\mpj\mpj-user
- VM Option:-jar C:\mpj\lib\starter.jar -np 4
(empat menunjukkan banyaknya pemroses yang digunakan sebagai virtual machine). Configurasi akhir menjadi sebagai berikut:
Tekan tombol OK.
Gunakan configurasi MPJExpress ini sebagai configurasi utama ketika mengcompile dan running program Paralel.
Berikut contoh program parallel HelloWorld dan hasil eksekusinya di Netbeans IDE:
Demikian instalasi MPJExpress di Netbeans IDE dan contoh program HelloWorld dengan 4 elemen pemroses.
Getting Started with MPJ Express
December 21, 2017
This section shows how MPJ Express programs can be executed in the multicore, cluster and hybrid configuration
Pre-requisites
- Java 1.6 (stable) or higher (Mandatory).
- Apache ant 1.6.2 or higher (Optional): ant is required for compiling MPJ Express source code.
- Perl (Optional): MPJ Express needs Perl for compiling source code because some of the Java code is generated from Perl templates. The build file will generate Java files from Perl templates if it detects perl on the machine. It is a good idea to install Perl if you want to do some development with MPJ Express.
- A native MPI library (Optional): Native MPI library such as MS-MPI is required for running MPJ Express in cluster configuration with native device.
- Visual Studio (Optional): MPJ Express needs Visual Studio to build JNI wrapper library for the native device
Installing MPJ Express
This section outlines steps to download and install MPJ Express software.
- Download MPJ Express and unpack it
- Assuming unpacked ‘mpj express’ is in ‘c:\mpj’, Right-click My ComputeràPropertiesàAdvanced tabàEnvironment Variables and export the following system variables (user variables are not enough)
- Set the value of variable MPJ_HOME as c:\mpj
- Append the value of variable Path as c:\mpj\bin
Compiling and Running User Applications
This section shows how to compile a simple Hello World parallel Java program.
- Write Hello World MPJ Express program and save it as HelloWorld.java
import mpi.MPI;
/**
*
* @author pbasari
*/
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(“Hi from <“+me+”>”);
MPI.Finalize();
}
}
- Compile: javac -cp .;%MPJ_HOME%/lib/mpj.jar HelloWorld.java
- Running (Multi-core Configuration): mpjrun.bat -np 2 HelloWorld
Example:
C:\mpj\mpj-user>javac -cp .;%MPJ_HOME%/lib/mpj.jar HelloWorld.java
C:\mpj\mpj-user>mpjrun.bat -np 2 HelloWorld
MPJ Express (0.40) is started in the multicore configuration
Hi from <1>
Hi from <0>