Class MPIDistributedContext

java.lang.Object
org.episteme.core.distributed.MPIDistributedContext
All Implemented Interfaces:
DistributedContext

public class MPIDistributedContext extends Object implements DistributedContext
MPI-based implementation of DistributedContext.

This class provides integration with Message Passing Interface (MPI) for high-performance cluster computing.

Requirements:

  • An MPI implementation (e.g., OpenMPI, MPICH) installed on the system.
  • Java bindings for MPI (e.g., mpj-express or openmpi-java) on the classpath.

Simulation Mode: If MPI classes are not found, this context transparently falls back to

Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Constructor Details

    • MPIDistributedContext

      public MPIDistributedContext(String[] args)
      Creates a new MPI Distributed Context.

      Attempts to initialize the MPI environment with the provided arguments. If MPI is not available or initialization fails, it falls back to a local simulation mode.

      Parameters:
      args - Command line arguments for MPI initialization
  • Method Details

    • getRank

      public int getRank()
      Returns the rank of the current node in the MPI world.
      Returns:
      the rank (0 if local or master)
    • getSize

      public int getSize()
      Returns the total size of the MPI world.
      Returns:
      the size (1 if local)
    • submit

      public <T extends Serializable> Future<T> submit(Callable<T> task)
      Description copied from interface: DistributedContext
      Submits a task for execution with NORMAL priority.
      Specified by:
      submit in interface DistributedContext
      Type Parameters:
      T - Result type
      Parameters:
      task - Task to execute
      Returns:
      Future representing the result
    • invokeAll

      public <T extends Serializable> List<Future<T>> invokeAll(List<Callable<T>> tasks)
      Description copied from interface: DistributedContext
      Submits a collection of tasks for execution.
      Specified by:
      invokeAll in interface DistributedContext
      Type Parameters:
      T - Result type
      Parameters:
      tasks - List of tasks
      Returns:
      List of Futures
    • getParallelism

      public int getParallelism()
      Description copied from interface: DistributedContext
      Returns the number of available processing nodes or cores.
      Specified by:
      getParallelism in interface DistributedContext
    • shutdown

      public void shutdown()
      Description copied from interface: DistributedContext
      Shuts down the context.
      Specified by:
      shutdown in interface DistributedContext
    • isMpiAvailable

      public boolean isMpiAvailable()
      Checks if the context is utilizing a real MPI environment.
      Returns:
      true if MPI is loaded and connected, false if running in local fallback mode.