Skip to content

BlackScholesFloat4

Portalez Régis edited this page May 11, 2026 · 14 revisions

BlackScholes float4

Same numerics as BlackScholes but each thread processes 4 options at a time using float4. Two effects:

  • 128-bit wide loads/stores (ld.global.v4.f32) — much higher effective bandwidth than four 32-bit transactions.
  • ILP — the four lanes give the scheduler more independent work to overlap with memory latency.

Source: src/4.Finance/BlackScholesFloat4/Program.cs

Same kernel structure, with arithmetic replicated across .x / .y / .z / .w. For example, the cumulative-normal-distribution helper:

Scalar version:

float K = 1.0f / (1.0f + 0.2316419f * fabsf(f));

float4 version:

float4 K;
K.x = __fdividef(1.0F, 1.0f + 0.2316419f * fabsf(f.x));
K.y = __fdividef(1.0F, 1.0f + 0.2316419f * fabsf(f.y));
K.z = __fdividef(1.0F, 1.0f + 0.2316419f * fabsf(f.z));
K.w = __fdividef(1.0F, 1.0f + 0.2316419f * fabsf(f.w));

__fdividef is mapped via [IntrinsicFunction] and skips IEEE-754 division denormal handling — significantly faster, slight precision loss acceptable here.

Clone this wiki locally