Core mechanism
Backend code generation translates the same primitive operations and adjoint rules into device kernels. Results are compared to the CPU reference before performance is considered.
Java prices the CPU reference from the editable tape inputs. The table includes historical OpenCL code generation; current jax4j has no OpenCL engine. ROCm is implemented but hardware unverified; GPU runtimes are unavailable in this browser build, so no GPU result or parity is invented.
CPU reference defaults to 20,000 scenarios for an interactive browser run.
This exact source runs in TeaVM. Form changes update its Java literals and reset manual edits.
import com.nablatensor.quant.EquityMarket;
import com.nablatensor.quant.MonteCarlo;
import com.nablatensor.quant.Products;
public final class GpuPortabilityReferenceRiskStudio {
private GpuPortabilityReferenceRiskStudio() {}
public static void main(String[] args) {
EquityMarket market = EquityMarket.of()
.spot(100.0)
.strike(100.0)
.vol(0.20)
.rate(0.03)
.maturity(1.0)
.build();
int steps = 64;
long scenarios = 20000L, seed = 42L;
try (MonteCarlo<EquityMarket> mc = MonteCarlo.of(Products.asianCall())
.market(market)
.steps(steps)
.fp64()
.greeks()
.on("cpu")
.build()) {
var value = mc.run(scenarios, seed);
System.out.println("RESULT|" + mc.nodes() + "|" + value.price() + "|" + value.greek(EquityMarket::spot)
+ "|" + value.scenariosPerSecond());
}
}
}
GPU targets differ in kernel language and runtime, but a recorded tape gives them a common computational contract.
Backend code generation translates the same primitive operations and adjoint rules into device kernels. Results are compared to the CPU reference before performance is considered.
Verify device discovery and numerical parity, profile transfer and kernel costs separately, keep driver/runtime versions observable, and maintain a tested CPU fallback.
*Keywords: gpu monte carlo java, cuda vulkan rocm opencl, gpu kernel generation, fp32 fp64*
The editable Java cell prices a recorded Asian-call tape on the portable TeaVM CPU backend. The table includes historical OpenCL code generation, which has no current jax4j engine. ROCm is implemented but hardware unverified in 0.2.1; SIMD is optional scalar replay with the incubator module flag.
GPU runtimes are unavailable in this browser build. The CPU result is a reference calculation; this page does not measure GPU throughput or verify agreement between GPU backends.
To compare current GPU engines, first consult /docs/engines and use compatible release APIs, modules and drivers. Native wgpu has no scalar replay adapter. Keep the tape, precision, scenario count and seed consistent when comparing results.
A common graph does not eliminate platform differences. Hardware capability, precision support and deployment constraints remain backend-specific.