Streaming¶
Module holding the class for streaming operations on the GPU.

class
pyqmri.streaming.
Stream
(fun, outp_shape, inp_shape, par_slices, overlap, nslice, queue, num_dev, reverse=False, lhs=None, DTYPE=<class 'numpy.complex64'>, DTYPE_real=<class 'numpy.float32'>)¶ Basic streaming Class.
This Class is responsible for performing asynchroneous transfer and computation on the GPU for arbitrary large numpy data.
Parameters: fun (list of functions) –  This list contains all functions that should be executed on the
 GPU. The functions are executed in order from first to last element of the list.
 outp_shape (list of tuple):
 The shape of the output array. Slice dimension is assumed to be the same as number of parallel slices plus overlap.
 inp_shape (list of list of tuple):
 The shape of the input arrays. Slice dimension is assumed to be the same as number of parallel slices plus overlap.
 par_slices : int
 Number of slices computed in one transfer on the GPU.
 overlap : int
 Overlap of adjacent blocks
 nslice : int
 Total number of slices
 queue : list of PyOpenCL.Queue
 The OpenCL queues used for transfer and computation. 4 queues are used per device.
 num_dev : int
 Number of computation devices.
 reverse : bool, false
 Indicator of the streaming direction. If False, streaming will start at the first and end at the last slice. If True streaming will be performed vice versa
 lhs : list of bool, None
 Indicator for the norm calculation in the line search of TGV. lhs refers to left hand side. Needs to be passed if a norm should be computed.
 DTYPE : numpy.dype, numpy.complex64
 Complex data type.

fun
¶ This list contains all functions that should be executed on the GPU. The functions are executed in order from first to last element of the list.
Type: list of functions

num_dev
¶ Number of computation devices.
Type: int

slices
¶ Number of slices computed in one transfer on the GPU.
Type: int

overlap
¶ Overlap of adjacent blocks
Type: int

queue
¶ The OpenCL queues used for transfer and computation. 4 queues are used per device.
Type: list of PyOpenCL.Queue

reverse
¶ Indicator of the streaming direction. If False, streaming will start at the first and end at the last slice. If True streaming will be performed vice versa
Type: bool

NSlice
¶ Total number of slices
Type: int

num_fun
¶ Total number of functions to stream (length of fun)
Type: int

lhs
¶ Indicator for the norm calculation in the line search of TGV. lhs refers to left hand side.
Type: list of bool, None

at_end
¶ Specifies if the end of the data slice dimension is reached
Type: bool

inp
(list of list of list of PyOpenCL.Array)¶ For each function a list of devices and a list of inputs is generated. E.g. for one function which needs two inputs and one computation device the list would have dimensions [1][1][2]

outp
(list of list of PyOpenCL.Array)¶ For each function a list of devices with a single output is generated. E.g. for one function and one device the list would have dimension [1][1]

connectouttoin
(outpos, inpos)¶ Connect output to input of functions within the object.
This function can be used to connect the output of a function to the input of another one used in the same stream object.
Parameters:  outpos (int) – The position in the list of outputs which should be connected to an input
 (list of list of np.arrays (inpos) – The position in the list of inputs which should be connected with an output

eval
(outp, inp, par=None)¶ Evaluate all functions of the object.
Perform asynchroneous evaluation of the functions stored in fun.
Parameters:  (list of np.arrays) (outp) – Result of the computation for each function as numpy array
 (list of list of np.arrays) (inp) – For each function contains a list of numpy arrays used as input.
 (list of list of parameters) (par) – Optional list of parameters which should be passed to a function.

evalwithnorm
(outp, inp, par=None)¶ Evaluate all functions of the object and returns norms.
Perform asynchroneous evaluation of the functions stored in fun. Same as eval but also computes the norm relevant for the linesearch in the TGV algorithm.
Parameters:  outp (list of np.arrays) – Result of the computation for each function as numpy array
 (list of list of np.arrays) (inp) – For each function contains a list of numpy arrays used as input.
 par (list of list of parameters) – Optional list of parameters which should be passed to a function.
Returns: (lhs, rhs) The lhs and rhs for the linesearch used in the TGV algorithm.
Return type: tuple of floats