# NMath User's Guide

39.8 Bridge Visualization (.NET, C#, CSharp, VB, Visual Basic, F#)

After tuning a bridge function (Section 39.6), you can visualize the recorded CPU and GPU benchmarks, and fitted GPU timing model, using the provided convenience functions on NMathChart, in conjunction with the free Microsoft Chart Controls for .NET (Section 1.11).

Code Example – C# Bridge Visualization

```var bmanager = BridgeManager.Instance;
var device = bmanager.GetComputeDevice( 0 );
var bridge = bmanager.GetBridge( device );

var f = BridgeFunctions.dgemm;
bridge.Tune( f, device, 1000 );

double xmin = 0;
double xmax = 1500;
int numInterpolatedValues = 250;
var chart = NMathChart.ToChart( bridge, f, device, xmin, xmax,
numInterpolatedValues );
NMathChart.Show( chart );
```

Code Example – VB Bridge Visualization

```Dim BManager = BridgeManager.Instance
Dim Device = BManager.GetComputeDevice(0)
Dim Bridge = BManager.GetBridge(Device)

Dim F = BridgeFunctions.dgemm
Bridge.Tune(F, Device, 1000)

Dim XMin As Double = 0.0
Dim XMax As Double = 1500
Dim NumInterpolatedValues As Integer = 250
Dim Chart = NMathChart.ToChart( Bridge, F, Device, XMin, XMax,
NumInterpolatedValues )
NMathChart.Show( Chart )
```

Figure 8 – Plotted routing model

As shown in Figure 8, a relatively small set of timings are performed on the GPU, and a timing model is fit to the sampled points. This is an optimization to reduce the time required to tune a bridge function, and generally works well because there is little noise in the GPU timings. The CPU timings are considerably less predictable, and so more benchmarks are performed. A timing model is not fit to the CPU data, but rather a series of heuristics are used to determine the crossover, the problem size at which it makes sense to begin routing problems to the GPU.

Note that you must tune the Bridge first, as shown in the code above. An NMathException is thrown by the visualization code if a previously computed routing model cannot be found for the given function and device in the given Bridge.

Top

Top