java-romp / jromp

Java Runtime implementation of OpenMP.
https://java-romp.github.io/jromp/
MIT License
5 stars 0 forks source link

JROMP (Java Runtime OpenMP)

JROMP is a Java library that provides a simple API for parallel programming using OpenMP-like constructs, but in runtime. It is designed to provide a simple way to parallelize Java code. JROMP is implemented using Java's ThreadPoolExecutor and designed to be efficient and scalable.

Features

Supported constructs

Supported variables

Installation

To use JROMP in your project, you can add the dependency using the following code snippets:

Maven

<dependency>
  <groupId>io.github.java-romp</groupId>
  <artifactId>jromp</artifactId>
  <version>2.2.0</version>
</dependency>

Gradle

implementation 'io.github.java-romp:jromp:2.2.0'

If your package manager is not listed here, you can check the latest version on the Maven Central Repository.

Usage

Here is an example of how to use JROMP to execute a simple parallel task in all available threads:

import jromp.JROMP;

import static jromp.JROMP.getNumThreads;
import static jromp.JROMP.getThreadNum;

public class BasicUsage {
  public static void main(String[] args) {
    JROMP.allThreads()
         .parallel(variables -> System.out.printf("Hello World from thread %d of %d%n", getThreadNum(), getNumThreads()))
         .join();
  }
}

This code will print Hello World from thread X of Y for each thread, where X is the thread ID and Y is the total number of threads.

More examples

If you want to see more examples of how to use JROMP, you can check all the available examples (with its equivalent code written in C) in the jromp-examples repository.