WaveRadar Simulation Computational Workload

Source-level computational workload of the GPU ocean simulation.

FFT Resolution:
Frame rate: FPS

Overview

1. FFT Workload

Number of FFT stages

For an FFT of size \(N\), the number of stages in one dimension is:

A two-dimensional FFT performs the transform once in each dimension:

The simulation performs three separate IFFTs:

FFT Butterfly Operations

Each active FFT thread performs one butterfly operation. A butterfly combines two complex values.

The number of butterfly operations in one complete two-dimensional IFFT is:

Since the simulation performs three IFFTs:

2. FFT Mathematics

Complex multiplication

The shader implements complex multiplication as:

\[ (a_r + ia_i) (b_r + ib_i) = (a_r b_r - a_i b_i) + i(a_r b_i + a_i b_r) \]

This requires:

Twiddle factor

\[ \theta = \frac{ 2\pi p }{ B } \]
\[ W = \cos(\theta) + i\sin(\theta) \]

Butterfly

\[ t = bW \] \[ A' = a+t \] \[ B' = a-t \]

Therefore one butterfly contains:

3. WaveRadar Spectrum Construction

The WaveRadar data contains:

frequency/direction bins.

Wave amplitude

\[ A = A_m \sqrt{E} C \]

Phase

\[ \phi(t) = \phi_0 + \omega t \]

Fourier coefficient

\[ C = \frac{ AN^2 }{ 2 } \]

Wavenumber

\[ \omega = 2\pi f \] \[ k = \frac{ \omega^2 }{ g } \]

Wave direction

\[ k_x = k\cos(\theta) \] \[ k_z = k\sin(\theta) \]

4. Horizontal Displacement

\[ i(a+ib) = -b+ia \]

The rotated Fourier coefficient is scaled by the wave direction and configured horizontal choppiness:

\[ D_x \propto iC \left( d_x\lambda \right) \] \[ D_z \propto iC \left( d_z\lambda \right) \]

5. Surface Normals

The normal kernel calculates spatial derivatives using central differences.

\[ \frac{ \partial h }{ \partial x } \approx \frac{ h(x+\Delta x) - h(x-\Delta x) }{ 2\Delta x } \]

The surface tangents are:

\[ T_x = \begin{bmatrix} 1+D_{x,x}\\ h_x\\ D_{z,x} \end{bmatrix} \]
\[ T_z = \begin{bmatrix} D_{x,z}\\ h_z\\ 1+D_{z,z} \end{bmatrix} \]

The surface normal is:

\[ n = \operatorname{normalize} \left( T_z \times T_x \right) \]

6. Foam Mathematics

Jacobian

\[ J = \begin{bmatrix} 1+D_{x,x} & D_{x,z}\\ D_{z,x} & 1+D_{z,z} \end{bmatrix} \]

Jacobian determinant

\[ J_{\mathrm{det}} = (1+D_{x,x}) (1+D_{z,z}) - D_{x,z}D_{z,x} \]

Compression

\[ C = \operatorname{saturate} \left( \frac{ J_{\mathrm{threshold}} - J_{\mathrm{det}} }{ J_{\mathrm{threshold}} } \right) \]
\[ C' = C^2 \]

Generated foam

\[ F_g = \operatorname{saturate} \left( C' S \right) \]

Foam decay

\[ F_d = F_{\mathrm{previous}} e^{-rt} \]

Persistent foam

\[ F = \operatorname{saturate} \left( \max ( F_d, F_g ) \right) \]

7. Computational Operation Summary

Important: These are source-level counts derived from the shader code. They are not equivalent to GPU instruction counts. Functions such as sin(), cos(), sqrt(), exp() and normalize() may compile into multiple hardware instructions.

FFT

Operation Per butterfly Per frame Per second
Multiplications 4
Additions / subtractions 6
Divisions 1
sin() 1
cos() 1

Spectrum Construction

Operation Per frame Per second
WaveRadar bins
sqrt()
sin()
cos()
Atomic additions

Kernel Workload

Kernel Threads / frame Threads / second
Clear spectrum accumulation
Build spectrum
Height conversion
Displacement conversion
Bit reversal
Normals
Foam

8. Final Computational Estimate

FFT butterflies / frame
FFT arithmetic / frame
FFT arithmetic / second
Surface elements / frame

Explicit Arithmetic Operations

This is the source-level arithmetic count from the explicitly counted FFT and spectrum operations.

Estimated Arithmetic Operations Per Second

Calculated as:

\[ \text{Operations/s} = \text{Operations/frame} \times \text{FPS} \]

This is a source-level estimate and should not be interpreted as an exact GPU instruction count or FLOP measurement.

Complete Operation Category Summary

Category Per frame Per second
FFT multiplications
FFT additions / subtractions
FFT divisions
FFT sin()
FFT cos()
Spectrum sqrt()
Spectrum sin()
Spectrum cos()
Atomic additions
Normal kernel threads
Foam kernel threads
Interpretation: The arithmetic total counts explicit scalar/vector arithmetic operations represented directly in the shader. It does not attempt to convert special functions, memory accesses, atomics, branches or GPU compiler instructions into an artificial single number.