Utilities for GPU
Utilities for GPU manipulations.
- ultraspy.gpu.gpu_utils.all_equal(d_array_1, d_array_2)
Returns True if both arrays are all close.
- Parameters:
d_array_1 (cupy.array) – The first array, on device
d_array_2 (cupy.array) – The second array, on device
- ultraspy.gpu.gpu_utils.compute_flat_grid_size(nb_points, max_threads=512)
Returns the appropriate grid / block size given the number of points we want to compute in a kernel.
- Parameters:
nb_points (int) – The number of points we’ll have to compute in our kernel
max_threads (int) – The maximum number of threads to use at the same time
- Returns:
The grid / block architectures
- Return type:
tuple
- ultraspy.gpu.gpu_utils.initialize_empty(data_shape, dtype)
Initialized an empty array on GPU based on the library currently used.
- Parameters:
data_shape (tuple) – The shape of the data
dtype (type) – The data type
- Returns:
The GPU array
- Return type:
cupy.array
- ultraspy.gpu.gpu_utils.move_axis(d_data, src_axis, dst_axis)
Moves an axis from a source dimension to a destination dimension.
- Parameters:
d_data (cupy.array) – The input array
src_axis (int) – The source axis
dst_axis (int) – The destination axis
- ultraspy.gpu.gpu_utils.reshape(d_data, shape)
Reshapes the d_data array to the new shape.
- Parameters:
d_data (cupy.array) – The input array
shape (tuple) – The final shape
- ultraspy.gpu.gpu_utils.send_to_gpu(data, dtype)
Send the data on GPU.
- Parameters:
data (numpy.ndarray) – The data array to send to GPU
dtype (type) – The data type
- Returns:
The GPU array
- Return type:
cupy.array
- ultraspy.gpu.gpu_utils.set_values(dst, src)
Replaces the values within dst by those on src.
- Parameters:
dst (cupy.array) – The array to replace
src (cupy.array) – The array with the values
- ultraspy.gpu.gpu_utils.squeeze_axes(d_data, axes)
Squeezes the data along the requested axes.
- Parameters:
d_data (cupy.array) – The input array
axes (tuple) – The axes where to squeeze the data
- ultraspy.gpu.gpu_utils.swap_axes(d_data, axis_1, axis_2)
Interchanges two axes of an array.
- Parameters:
d_data (cupy.array) – The input array
axis_1 (int) – The first axis
axis_2 (int) – The second axis