This is an example for Sending and Receiving Program in MPJExpress. Overview about  sending and receiving with MPI will be added later 🙂

package MPJExpress;
import mpi.MPI;
* @author pbasari
public class SendReceive {
      public static void main (String args[]) {
          int rank = MPI.COMM_WORLD.Rank();
          int size = MPI.COMM_WORLD.Size();
        // sending
        if (rank == 0) {
        int data [] = {1, 2, 3, 4};
               for (int i = 1; i < size; i++) {
                      System.out.println(“From 0 Send to ” +i);
                      MPI.COMM_WORLD.Send(data, 0, data.length, MPI.INT, i, 0);
       else { // receiving
             int data [] = new int[4];
             System.out.println(“Received From 0 “);
             MPI.COMM_WORLD.Recv(data, 0, data.length, MPI.INT, 0, 0);
             for (int i = 0; i < data.length; i++)
                    System.out.println(“Rank:” + rank + “; ” + data[i]);


MPJExpress Tutorials

December 21, 2017


Welcome to the MPIExpress tutorials! In these tutorials, you will learn a wide array of concepts about MPI (Message Passing Interface) from Wes Kendall and its implementation using Java, MPJExpress. Below are the available lessons, each of which contain example code.

The tutorials assume that the reader has a basic knowledge of Java Programming Language.

Introduction and MPI installation


    Blocking point-to-point communication

    • Sending and receiving with MPI.COMM_WORLD.Send and MPI.COMM_WORLD.Recv
    • Point-to-point communication application

    Basic collective communication

    • Collective communication introduction with MPI.COMM_WORLD.Bcast
    • Common collectives – MPI.COMM_WORLD.Scatter, MPI.COMM_WORLD.Gather, and MPI.COMM_WORLD.Allgather
    • Application example – Performing parallel rank computation with basic collectives

    Advanced collective communication

    • Using MPI.COMM_WORLD.Reduce and MPI.COMM_WORLD.Allreduce for parallel number reduction

    Groups and communicators

    • Introduction to groups and communicator



© 2017 MPJExpress Tutorial. All rights reserved.

MPI Tutorial Introduction

December 21, 2017

MPI Tutorial Introduction From

Brief introduction to MPI, short but clear enough!. I hope you can enjoy it. Thanks for this tutorial, Wes.

MPI Tutorial Introduction

Author: Wes Kendall

Parallel computing is now as much a part of everyone’s life as personal computers, smart phones, and other technologies are. You obviously understand this, because you have embarked upon the MPI Tutorial website. Whether you are taking a class about parallel programming, learning for work, or simply learning it because it’s fun, you have chosen to learn a skill that will remain incredibly valuable for years to come. In my opinion, you have also taken the right path to expanding your knowledge about parallel programming – by learning the Message Passing Interface (MPI). Although MPI is lower level than most parallel programming libraries (for example, Hadoop), it is a great foundation on which to build your knowledge of parallel programming.

Before I dive into MPI, I want to explain why I made this resource. When I was in graduate school, I worked extensively with MPI. I was fortunate enough to work with important figures in the MPI community during my internships at Argonne National Laboratory and to use MPI on large supercomputing resources to do crazy things in my doctoral research. However, even with access to all of these resources and knowledgeable people, I still found that learning MPI was a difficult process.

Learning MPI was difficult for me because of three main reasons. First of all, the online resources for learning MPI were mostly outdated or not that thorough. Second, it was hard to find any resources that detailed how I could easily build or access my own cluster. And finally, the cheapest MPI book at the time of my graduate studies was a whopping 60 dollars – a hefty price for a graduate student to pay. Given how important parallel programming is in our day and time, I feel it is equally important for people to have access to better information about one of the fundamental interfaces for writing parallel applications.

Although I am by no means an MPI expert, I decided that it would be useful for me to expel all of the information I learned about MPI during graduate school in the form of easy tutorials with example code that can be executed on your very own cluster! I hope this resource will be a valuable tool for your career, studies, or life – because parallel programming is not only the present, it is the future.

A brief history of MPI

Before the 1990’s, programmers weren’t as lucky as us. Writing parallel applications for different computing architectures was a difficult and tedious task. At that time, many libraries could facilitate building parallel applications, but there was not a standard accepted way of doing it.

During this time, most parallel applications were in the science and research domains. The model most commonly adopted by the libraries was the message passing model. What is the message passing model? All it means is that an application passes messages among processes in order to perform a task. This model works out quite well in practice for parallel applications. For example, a master process might assign work to slave processes by passing them a message that describes the work. Another example is a parallel merge sorting application that sorts data locally on processes and passes results to neighboring processes to merge sorted lists. Almost any parallel application can be expressed with the message passing model.

Since most libraries at this time used the same message passing model with only minor feature differences among them, the authors of the libraries and others came together at the Supercomputing 1992 conference to define a standard interface for performing message passing – the Message Passing Interface. This standard interface would allow programmers to write parallel applications that were portable to all major parallel architectures. It would also allow them to use the features and models they were already used to using in the current popular libraries.

By 1994, a complete interface and standard was defined (MPI-1). Keep in mind that MPI is only a definition for an interface. It was then up to developers to create implementations of the interface for their respective architectures. Luckily, it only took another year for complete implementations of MPI to become available. After its first implementations were created, MPI was widely adopted and still continues to be the de-facto method of writing message-passing applications.

An accurate representation of the first MPI programmers.

An accurate representation of the first MPI programmers.

MPI’s design for the message passing model

Before starting the tutorial, I will cover a couple of the classic concepts behind MPI’s design of the message passing model of parallel programming. The first concept is the notion of a communicator. A communicator defines a group of processes that have the ability to communicate with one another. In this group of processes, each is assigned a unique rank, and they explicitly communicate with one another by their ranks.

The foundation of communication is built upon send and receive operations among processes. A process may send a message to another process by providing the rank of the process and a unique tag to identify the message. The receiver can then post a receive for a message with a given tag (or it may not even care about the tag), and then handle the data accordingly. Communications such as this which involve one sender and receiver are known as point-to-point communications.

There are many cases where processes may need to communicate with everyone else. For example, when a master process needs to broadcast information to all of its worker processes. In this case, it would be cumbersome to write code that does all of the sends and receives. In fact, it would often not use the network in an optimal manner. MPI can handle a wide variety of these types of collective communications that involve all processes.

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:

8-AddWorkingDirTekan 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.


This section shows how MPJ Express programs can be executed in the multicore, cluster and hybrid configuration


  • 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.

  1. Download MPJ Express and unpack it
  2. 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.

  1. Write Hello World MPJ Express program and save it as

import mpi.MPI;

* @author pbasari

public class HelloWorld {
     public static void main(String args[]) throws Exception {
         int me = MPI.COMM_WORLD.Rank();
         int size = MPI.COMM_WORLD.Size();
         System.out.println(“Hi from <“+me+”>”);

  1. Compile: javac -cp .;%MPJ_HOME%/lib/mpj.jar
  2. Running  (Multi-core Configuration): mpjrun.bat -np 2 HelloWorld


C:\mpj\mpj-user>javac -cp .;%MPJ_HOME%/lib/mpj.jar
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>

Python in NetBeans IDE 8.0.2

November 21, 2016

Manja 😤 . Iyya sih..  😜

Programming yang bisa dilakukan dengan editor biasa dan dijalankan melalu command prompt; saya tetap gunakan IDE untuk mempermudahnya. Kurang cool ya? 😈

Meskipun saya bukan fanatik, tapi saya ini kalo sudah suka (Java) ya suka; ga tertarik lagi untuk melihat yang lain. Da aku mah gitu orangnya. Tapi berhubung Python ini terus digembar gembor sebagai bahasa kekinian, minimal menurut (5 besar), menurut (ranking 3), dan menurut (dia ranking 2!). Mau ga mau, suka tidak suka, saya harus sekedar tahu dan bisa say “Hello World!” Dengan python ini. Literate ya 😄

Meskipun bahasa ini sudah lama rilisnya, 20 February 1991; 25 years ago, oleh Guido van Rossum , Python semakin popular belakangan ini. Eh penasaran bagaimana menghitung popularitas suatu bahasa? Bisa dicek di sini Atau mungkin dia pake buzzer robot sehingga indeks popularitasnya menaik 😂😂

Hush 🙊

Kembali ke Python. Semua resource ada di versi stabil bisa diambil di; saya lebih suka versi 2.7.x don’t ask ya, kenapa dia ada keluarga 3.5.x sementara 2.7.x pun tetap dikembangkan. Bedanya apa? Tanya mas Guildo aja ya. Atau baca-baca di sini.

Berhubung ini bahasa scripting dengan interpreter, nah loh; dulu saya tahunya script ya script; ga bisa dibilang bahasa. Jadi kalo saya bilang “bahasa scripting” koq jadi tampak suka suka saya ya? Ya jadi kita bisa jalankan kodingan kita (nah loh, ada kodingan dan skriptingan) langsung dengan interpreter melalui command prompt.

Di situlah saya merasa malas 😴😴 . Manja! Saya mau pake IDE. Manja ya 😚😚. Sterotipe kodingan line of code itu kayaknya sok keren banget ya (apalagi kalo dia hitam putih), dibandingkan pake IDE yang warna warni centil dan dilengkapi autocomplete. Biarin. Ini masalah preferensi 💆.

Dari sekian pilihan IDE for python (baca sendiri di sini saya akhirnya memilih.. Netbeans 😏. Don’t ask why, itu krn udah ada aja di komputer aku 🐣. dan diam-diam aku mempelajari “How to porting Python to Java”, vice versa 😎. Begitulah. Sekalinya Java tetap Java! #sikap. Oh ya. Sebetulnya orang-orang menggunakan PyCharm, sepertinya lebih mudah.

Nah. Ketika memilih Netbeans IDE itu; saya menyimak video ini.

Ga susah koq. Caranya:

  • Siapkan netbeans (8.0.2). jangan lupakan JRE dan JDK sudah include; silahkan cek di situs Netbeans atau di situs Java. Pokoknya, please Get the Correct Version of NetBeans IDE.
  • Siapkan python (download dan ekstrak); ambil di situs python, bisa juga di Pastikan, Get the Python Plugin for NetBeans IDE 8.0.2.
  • Add sebagai plug in, buka plug in manager (dari menu Tools, pilih sub menu Plugins, pilih tab Downloaded, Tekan tombol Add Plugins; add seluruh file Python Plugin for Netbeans yang telah diekstrak)


  • Buat projek baru dg Python
  • Siapkan program Hello World!


Ini contoh program “Hello World!”

__author__ = "pbasari"
__date__ = "$Nov 15, 2016 12:06:21 PM$"

f __name__ == "__main__":
   print "Hello World"

Untuk menjalankannya, cukup tekan tombol Run. Easy. Dan cukup mudah untuk koder Malas Manis Manja seperti saya.

Oh ya. Python tidak mengenal Begin – End; tapi dia menggunakan indentasi untuk setiap blok pemrogramannya. Saya sih senang, karena membuat programmer mau ga mau, harus tertib indentasi!

Selanjutnya. Belajar Python, bisa dicek di (sebenernya saya nonton X Factor; Astaga! Honey G masih bertahan!!). Ups. Kembali ke video tutorial; dia menggunakan PyCharm sebagai IDE. Gampang banget lho.

Untuk Dokumentasi Python tutorial lengkap bisa dilihat di Ke depan, saya akan membuatkan Tutorial OOP dengan Python. Tentu tetap dengan IDE Netbeans😚.





Berdasarkan situs TIOBE yang berisi Tiobe Index bulanan untuk bahasa paling popular digunakan, Java menempati urutan kedua, setelah sekian lama tergusur kembali oleh bahasa C. RIP Dennis Ritchie, with smile :). Indeks Tiobe Walau demikian, saya tetap setia kepada bahasa Java ini (selagi tidak ada programming dengan bahasa Sunda). 255px-Wave.svg Hidup James Gosling dan kopi Java-nya!

Banyak yang belajar bahasa Java, langsung kepada teknis pemrograman. Padahal, seharusnya seseorang belajar bahasa pemrograman itu berangkat dari paradigma  pemrograman itu sendiri, dalam hal berorientasi objek. Buku idola saya, Grady Booch: Object Oriented Analysis and Design bisa digunakan untuk pemula yang ingin belajar pemrograman berorientasi objek. Buku tersebut sangat saya sukai karena dilengkapi dengan ilustrasi yang lucu-lucu.

Lihat contoh gambar lucu pada buku tersebut :). Menjelaskan tentang prinsip abstraksi: Abstraction focuses upon the essential characteristics of some object, relative to the perspective of the viewer.


sumber gambar:

Buku tersebut banyak berbicara di level analisis dan desain berorientasi objek, dengan contoh penggunaan dengan bahasa C++, tidak menggunakan bahasa Java. Nah. Untuk belajar bahasa Java sesuai konsep berorientasi objek, saya menggunakan buku dari JACQUIE BARKER  berjudul Beginning Java Objects From Concepts to Code, Second Edition. Buku yang bagus, karena mengurai konsep terlebih dahulu sebelum masuk ke teknis pemrograman Java. Buku ini juga disertai ilustrasi yang memudahkan pemahaman konsep, meski tidak selucu gambaran pada buku Grady Booch di atas. Buku ini saya jadikan referensi utama mata kuliah yang saya ampu: Konstruksi Perangkat Lunak Berorientasi Objek.

Rangkuman buku dalam bentuk slide materi perkuliahan, bisa dilihat di url ini. Semoga bermanfaat 🙂