39.9 Overriding Bridge Routing (.NET, C#, CSharp, VB, Visual Basic, F#)
In some cases, you may wish to explicitly take control of how problems are routed between the CPU and GPUs. For example, you might want to run all problems, regardless of problem size, in one thread on the GPU, thus freeing the CPU for work in another thread.
Bridge objects provide methods for forcing routing to CPU or GPU, thus overriding any problem-size-based routing:
● ForceCpu() overrides routing for a specified bridge function.
● ForceCpuAll() overrides routing for all bridge functions.
● ForceGpu() overrides routing for a specified bridge function.
● ForceGpuAll() overrides routing for all bridge functions.
For example, this code forces all computation to the GPU.
Code Example – C# bridge routing override
var device = BridgeManager.Instance.GetComputeDevice( 0 ); var bridge = BridgeManager.Instance.GetBridge( device ); bridge.ForceGpuAll();
Code Example – VB bridge routing override
Dim Device = BridgeManager.Instance.GetComputeDevice( 0 ) Dim Bridge = BridgeManager.Instance.GetBridge( Device ) Bridge.ForceGpuAll()
Method RestoreDefaultRouting() restores the routing for a bridge to the default state.