PCJ is a library for Java language that helps to perform parallel and distributed calculations. The current version is able to work on the multicore systems connected with the typical interconnect such as ethernet or infiniband providing users with the uniform view across nodes.

Download PCJ library (jar file of 9.01.2016 ver. 4.1)  New!

Download PCJ manual (pdf)

The PCJ library can be used with no cost at BSD license. It requires Java 8 and no additional tools or comilers.  The PCJ library for Java 7 is available in the dowload section.

The source code is available at GitHub: https://github.com/hpdcj/pcj

Current version (4.1.0) introduces PCJ.cas() method. The PCJ.waitFor() now returns integer value. For detailed description please reffer to the JavaDoc file.

Please note that current (4.1.0) version is improved compare to the version 3.0.0. The API has not chnaged, however the pl.mat.pcj has chnaged to org.pcj.

The usage should be acknowledged by reference to the PCJ web site and/or reference to the papers:

Usage of the PCJ:

Contact: bala@icm.edu.pl faramir@icm.edu.pl

New version of the PCJ has been released.

The new version 5.0 introduces changes in the API:

  • sync and async versions of put, get and broadcast
  • new handling of shared variables

The library (jar file) and accompying JavaDoc is avaliale in the Download section.

Updated version of the PCJ has been released.

The new version 4.1.0 introduces some improvements:

  • fixed classloader problem
  • PCJ.wait() now returns integer value useful to check status of remaining communication
  • PCJ.cas() allows to check value of the variable at remote PCJ thread and cheng it according to some rules

The library (jar file) and accompying JavaDoc is avaliale in the Download section.

Obtaining PCJ

In order to use PCJ library you have to dowload PCJ.jar file from the PCJ web site:pcj.icm.edu.pl. The PCJ.jar should be located in the directory accessible by java compiler and java runtime, for example in the lib directory of your IDE. File you dowlnoad from website has to be renamed to PCJ.jar otherwise you have to use in the examples full name.

Starting PCJ application - Hello World

Starting PCJ application is simple. It can be built in the form of a single class which extends Storage class and implements StartPoint interface. The Storage class can be used to define shared variables. StartPoint interface provides necessary functionality to start required threads, enumerate them and performs initial synchronization of tasks.

 

PCJ.deploy() method initializes application using list of nodes provided as third argument. List of nodes contains internet address of the computers (cluster nodes) used in the simulations.

 

import java.io.IOException;
import org.pcj.*;

public class HelloWorld implements StartPoint {

    public static void main(String[] args) throws IOException {
        String nodesFile  = "nodes.txt";
       
        PCJ.deploy(HelloWorld.classnew NodesDescription("nodes.txt"));
    }

    @Override
    public void main() throws Throwable {
                System.out.println("Hello World from PCJ Thread " + PCJ.myId()
                                     + " out of " + PCJ.threadCount() );
            }
}

The compilation and execution requires PCJ.jar in the path:

javac -cp .:PCJ.jar HelloWorld.java
java -cp .:PCJ.jar HelloWorld

 

The expected output is presented below:

wrz 23, 2016 2:00:22 AM org.pcj.internal.InternalPCJ start
INFO: PCJ version 5.0.0.SNAPSHOT-a728f5f built on 2016-09-13 00:58:48.180 CEST.
wrz 23, 2016 2:00:22 AM org.pcj.internal.InternalPCJ start
INFO: Starting HelloWorld with 4 threads (on 1 node)...
Hello World from PCJ Thread 2 out of 4
Hello World from PCJ Thread 0 out of 4
Hello World from PCJ Thread 1 out of 4
Hello World from PCJ Thread 3 out of 4
wrz 23, 2016 2:00:22 AM org.pcj.internal.InternalPCJ start
INFO: Completed HelloWorld with 4 threads (on 1 node) after 0h 0m 0s.
BUILD SUCCESSFUL (total time: 0 seconds)

 

The above scenario allows to run PCJ application within single Java Virtual Machine. The same code can be run using multiple JVM's.