Nengo.ca

ca.nengo.util.impl
Class NEFGPUInterface

java.lang.Object
  extended by ca.nengo.util.impl.NEFGPUInterface

public class NEFGPUInterface
extends java.lang.Object

Allows running NEFEnsembles on the GPU. Passes the ensemble data to the GPU through a native function. Passes input to the GPU each step and stores the output from the GPU in the appropriate locations.


Field Summary
protected  float myEndTime
           
protected  NEFEnsembleImpl[] myGPUEnsembles
           
protected  Node[] myGPUNetworkArrays
           
protected  Projection[] myGPUProjections
           
protected  Node[] myNodes
           
protected  Projection[] myProjections
           
protected static boolean myRequireAllOutputsOnCPU
           
protected  float myStartTime
           
protected  Projection[] nonGPUProjections
           
 
Constructor Summary
NEFGPUInterface()
           
 
Method Summary
static int[] findOptimalNodeAssignments(Node[] nodes, Projection[] projections, int numPartitions)
          Used when there are multiple GPU's running a simulation.
static java.lang.String getErrorMessage()
           
static int getNumAvailableDevices()
           
static int getRequestedNumDevices()
           
static boolean getUseGPU()
           
static void hideGPUTiming()
           
 void initialize()
          Gets all the necessary data from the nodes and projections which are assigned to run on GPUss and puts it in a form appropriate for passing to the native setup function.
 void kill()
           
static void requireAllOutputsOnCPU(boolean require)
           
static void setRequestedNumDevices(int value)
           
static void showGPUTiming()
           
 void step(float startTime, float endTime)
          1.
 Node[] takeGPUNodes(Node[] nodes)
          Finds all nodes in the given array which are supposed to execute on the GPU.
 Projection[] takeGPUProjections(Projection[] projections)
          Finds all projections in the given array which are supposed to execute on the GPU.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myRequireAllOutputsOnCPU

protected static boolean myRequireAllOutputsOnCPU

myGPUEnsembles

protected NEFEnsembleImpl[] myGPUEnsembles

myGPUProjections

protected Projection[] myGPUProjections

nonGPUProjections

protected Projection[] nonGPUProjections

myGPUNetworkArrays

protected Node[] myGPUNetworkArrays

myNodes

protected Node[] myNodes

myProjections

protected Projection[] myProjections

myStartTime

protected float myStartTime

myEndTime

protected float myEndTime
Constructor Detail

NEFGPUInterface

public NEFGPUInterface()
Method Detail

getNumAvailableDevices

public static int getNumAvailableDevices()

setRequestedNumDevices

public static void setRequestedNumDevices(int value)

getRequestedNumDevices

public static int getRequestedNumDevices()

getUseGPU

public static boolean getUseGPU()

showGPUTiming

public static void showGPUTiming()

hideGPUTiming

public static void hideGPUTiming()

requireAllOutputsOnCPU

public static void requireAllOutputsOnCPU(boolean require)

getErrorMessage

public static java.lang.String getErrorMessage()

initialize

public void initialize()
Gets all the necessary data from the nodes and projections which are assigned to run on GPUss and puts it in a form appropriate for passing to the native setup function. The native setup function will create a thread for each GPU in use, process the data further until its in a form suitable for running on the GPU, and finally move all the data to the GPU. The GPU threads will be waiting for a call to nativeStep which will tell them to take a step.


step

public void step(float startTime,
                 float endTime)
1. Load data from terminations into "representedInputValues". 2. Call nativeStep which will run the GPU's for one step and return the results in "representedOutputValues". 3. Put the data from "representedOutputValues" into the appropriate origins.


kill

public void kill()

findOptimalNodeAssignments

public static int[] findOptimalNodeAssignments(Node[] nodes,
                                               Projection[] projections,
                                               int numPartitions)
Used when there are multiple GPU's running a simulation. Finds a distribution of nodes to GPU's that minimizes communication between GPU's while also ensuring the number of neurons running on each GPU is relatively balanced. Note that this problem (a variant of the min bisection problem) is NP-Complete, so a heuristic is employed.

Returns:
an array of integers where the value in the i'th entry denotes the partition number of the i'th node ... in the "nodes" input array

takeGPUNodes

public Node[] takeGPUNodes(Node[] nodes)
Finds all nodes in the given array which are supposed to execute on the GPU. Stores those nodes in myGPUNetworkArrays and returns the rest.


takeGPUProjections

public Projection[] takeGPUProjections(Projection[] projections)
Finds all projections in the given array which are supposed to execute on the GPU. Stores those projections in myGPUProjections and returns the rest. takeGPUNodes should be called before this is called, since the nodes which run on the GPU determine which projections run on the GPU. (ie a projection runs on the GPU only if both its target and source run on the GPU).


Nengo.ca