Skip to content

Incubator Module

ExodusCoder9 edited this page Jun 20, 2026 · 1 revision

Incubator Module

The math-incubator module contains experimental features that require --add-modules jdk.incubator.vector --enable-preview.

VectorApiMath — SIMD-Accelerated Operations

Uses jdk.incubator.vector.DoubleVector (SPECIES_256) for SIMD operations on Vector4d.

Vector4d sum = VectorApiMath.add(a, b);
Vector4d diff = VectorApiMath.sub(a, b);
Vector4d prod = VectorApiMath.mul(a, b);
Vector4d scaled = VectorApiMath.scale(v, s);
double dot = VectorApiMath.dot(a, b);

// Batch operation
VectorApiMath.batchAdd(results, inputsA, inputsB);
ParallelOpsParallel Batch Operations
Uses StructuredTaskScope to parallelize vector operations across cores.
// Parallel batch addition (threshold: 4096 elements)
Vector3d[] results = ParallelOps.batchAddParallel(inputA, inputB);
// Falls back to sequential below threshold
MemoryOpsOff-Heap Memory Management
// Allocate
MemorySegment vec4 = MemoryOps.allocateVec4(arena);
MemorySegment array = MemoryOps.allocateVec4Array(arena, count);

// Write
MemoryOps.setVec4(segment, x, y, z, w);

// Read individual components
double x = MemoryOps.getVec4X(segment);
double y = MemoryOps.getVec4Y(segment);
double z = MemoryOps.getVec4Z(segment);
double w = MemoryOps.getVec4W(segment);

Clone this wiki locally