Class GenesisBackend
java.lang.Object
org.episteme.nativ.physics.classical.mechanics.collision.backends.GenesisBackend
- All Implemented Interfaces:
AlgorithmProvider, Backend, ComputeBackend, CPUBackend, NativeCollisionProvider, NativeBackend, CollisionProvider, MechanicsBackend, SimulationProvider
@AutoService({MechanicsBackend.class,ComputeBackend.class,Backend.class,SimulationProvider.class})
public class GenesisBackend
extends Object
implements NativeCollisionProvider, MechanicsBackend, CPUBackend, NativeBackend, SimulationProvider
Implementation of
MechanicsBackend for Genesis physics engine.
High-performance backend specialized for robotics and many-body systems. Prefers the native `GenesisC` library (via Project Panama) but falls back to a pure Java implementation using JDK Vector API (SIMD) if native is unavailable.
- Since:
- 1.1
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates and returns the backend instance (or returns self if it is the backend).Creates an execution context for running operations.createRigidBody(RigidBody body) Creates a backend representation for a RigidBody.Creates a new physics world (simulation environment).intdetectSphereCollisions(double[] positions, double[] radii, int n, int[] collisions) intdetectSphereCollisions(MemorySegment positions, MemorySegment radii, int n, MemorySegment collisions, ValueLayout layout) Performs collision detection between spheres using MemorySegments.intdetectSphereCollisions(Real[] positions, Real[] radii, int n, int[] collisions) Returns the type of hardware accelerator used by this backend.Returns the unique category of the algorithm.Returns a description of the backend.getId()Returns the unique identifier for this backend (e.g., "javafx", "jmol", "cuda").getName()Returns the display name for UI presentation.Returns the name of the native library this backend depends on.intReturns the execution priority (higher is better).Returns a human-readable status message for this backend.getType()Returns the backend type category (e.g., "plotting", "molecular", "tensor", "math").booleanChecks if the provider is available in the current environment.booleanisLoaded()Returns true if the native library is loaded and operational.voidparallelExecute(List<Runnable> tasks, int parallelism) voidresolveCollisions(double[] positions, double[] velocities, double[] masses, int n, int[] collisions, int numCollisions) voidresolveCollisions(MemorySegment positions, MemorySegment velocities, MemorySegment masses, int n, MemorySegment collisions, int numCollisions, ValueLayout layout) Resolves collisions using MemorySegments.voidresolveCollisions(Real[] positions, Real[] velocities, Real[] masses, int n, int[] collisions, int numCollisions) voidshutdown()Called when the provider is no longer needed (e.g., application shutdown).Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AlgorithmProvider
description, getMetadata, scoreMethods inherited from interface Backend
getAlgorithmProviders, isExplicitlyDisabledMethods inherited from interface CPUBackend
supportsComplexNumbers, supportsFloatingPoint, supportsParallelOpsMethods inherited from interface MechanicsBackend
scoreMethods inherited from interface NativeCollisionProvider
detectSphereCollisions, resolveCollisions
-
Constructor Details
-
GenesisBackend
public GenesisBackend()
-
-
Method Details
-
getId
-
getName
Description copied from interface:BackendReturns the display name for UI presentation.- Specified by:
getNamein interfaceAlgorithmProvider- Specified by:
getNamein interfaceBackend- Specified by:
getNamein interfaceSimulationProvider
-
getDescription
Description copied from interface:BackendReturns a description of the backend.- Specified by:
getDescriptionin interfaceBackend- Specified by:
getDescriptionin interfaceComputeBackend
-
isAvailable
public boolean isAvailable()Description copied from interface:AlgorithmProviderChecks if the provider is available in the current environment.- Specified by:
isAvailablein interfaceAlgorithmProvider- Specified by:
isAvailablein interfaceBackend- Specified by:
isAvailablein interfaceMechanicsBackend
-
getStatusMessage
Description copied from interface:BackendReturns a human-readable status message for this backend. Useful for debugging "Unavailable" states.- Specified by:
getStatusMessagein interfaceBackend- Returns:
- status message (e.g., "Ready", "Native library missing", etc.)
-
shutdown
public void shutdown()Description copied from interface:AlgorithmProviderCalled when the provider is no longer needed (e.g., application shutdown). Use this to release local resources or close native segments.- Specified by:
shutdownin interfaceAlgorithmProvider- Specified by:
shutdownin interfaceBackend- Specified by:
shutdownin interfaceMechanicsBackend
-
isLoaded
public boolean isLoaded()Description copied from interface:NativeCollisionProviderReturns true if the native library is loaded and operational.- Specified by:
isLoadedin interfaceNativeBackend- Specified by:
isLoadedin interfaceNativeCollisionProvider- Returns:
- true if the native library has been successfully loaded
-
getNativeLibraryName
Description copied from interface:NativeBackendReturns the name of the native library this backend depends on.- Specified by:
getNativeLibraryNamein interfaceNativeBackend- Returns:
- library name (e.g., "openblas", "cuda", "fftw3")
-
getAcceleratorType
Description copied from interface:ComputeBackendReturns the type of hardware accelerator used by this backend.- Specified by:
getAcceleratorTypein interfaceComputeBackend- Specified by:
getAcceleratorTypein interfaceCPUBackend- Returns:
- the accelerator type
-
createWorld
Description copied from interface:MechanicsBackendCreates a new physics world (simulation environment).- Specified by:
createWorldin interfaceMechanicsBackend- Returns:
- a new PhysicsWorld instance
-
createRigidBody
Description copied from interface:MechanicsBackendCreates a backend representation for a RigidBody.- Specified by:
createRigidBodyin interfaceMechanicsBackend- Parameters:
body- the Episteme RigidBody definition- Returns:
- the backend implementation
-
detectSphereCollisions
public int detectSphereCollisions(double[] positions, double[] radii, int n, int[] collisions) - Specified by:
detectSphereCollisionsin interfaceCollisionProvider- Specified by:
detectSphereCollisionsin interfaceNativeCollisionProvider
-
resolveCollisions
public void resolveCollisions(double[] positions, double[] velocities, double[] masses, int n, int[] collisions, int numCollisions) - Specified by:
resolveCollisionsin interfaceCollisionProvider- Specified by:
resolveCollisionsin interfaceNativeCollisionProvider
-
detectSphereCollisions
- Specified by:
detectSphereCollisionsin interfaceCollisionProvider
-
resolveCollisions
public void resolveCollisions(Real[] positions, Real[] velocities, Real[] masses, int n, int[] collisions, int numCollisions) - Specified by:
resolveCollisionsin interfaceCollisionProvider
-
detectSphereCollisions
public int detectSphereCollisions(MemorySegment positions, MemorySegment radii, int n, MemorySegment collisions, ValueLayout layout) Description copied from interface:NativeCollisionProviderPerforms collision detection between spheres using MemorySegments.- Specified by:
detectSphereCollisionsin interfaceCollisionProvider- Specified by:
detectSphereCollisionsin interfaceNativeCollisionProvider
-
resolveCollisions
public void resolveCollisions(MemorySegment positions, MemorySegment velocities, MemorySegment masses, int n, MemorySegment collisions, int numCollisions, ValueLayout layout) Description copied from interface:NativeCollisionProviderResolves collisions using MemorySegments.- Specified by:
resolveCollisionsin interfaceCollisionProvider- Specified by:
resolveCollisionsin interfaceNativeCollisionProvider
-
parallelExecute
- Specified by:
parallelExecutein interfaceSimulationProvider
-
getPriority
public int getPriority()Description copied from interface:AlgorithmProviderReturns the execution priority (higher is better).- Specified by:
getPriorityin interfaceAlgorithmProvider- Specified by:
getPriorityin interfaceBackend- Specified by:
getPriorityin interfaceMechanicsBackend
-
getType
Description copied from interface:BackendReturns the backend type category (e.g., "plotting", "molecular", "tensor", "math").- Specified by:
getTypein interfaceBackend- Specified by:
getTypein interfaceComputeBackend- Specified by:
getTypein interfaceCPUBackend- Specified by:
getTypein interfaceMechanicsBackend
-
getAlgorithmType
Description copied from interface:AlgorithmProviderReturns the unique category of the algorithm.- Specified by:
getAlgorithmTypein interfaceAlgorithmProvider- Specified by:
getAlgorithmTypein interfaceCollisionProvider- Specified by:
getAlgorithmTypein interfaceMechanicsBackend
-
createContext
Description copied from interface:ComputeBackendCreates an execution context for running operations.The context should be used within a try-with-resources block to ensure proper cleanup of resources.
- Specified by:
createContextin interfaceComputeBackend- Returns:
- new execution context
-
createBackend
Description copied from interface:BackendCreates and returns the backend instance (or returns self if it is the backend).- Specified by:
createBackendin interfaceBackend- Specified by:
createBackendin interfaceComputeBackend- Specified by:
createBackendin interfaceMechanicsBackend- Returns:
- The backend implementation object
-