GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Classes | Typedefs | Functions
cu_util.h File Reference

CUDA utility functions. More...

#include "config.h"
#include "types.h"
#include "error.h"
Include dependency graph for cu_util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ghost_gpu_info
 Information about avaiable GPUs. More...
 

Typedefs

typedef int ghost_cublas_handle_t
 
typedef int ghost_cusparse_handle_t
 
typedef int ghost_cu_deviceprop
 
typedef int ghost_cu_rand_generator
 

Functions

ghost_error ghost_cu_init (int dev)
 Initalize CUDA on a given device. More...
 
ghost_error ghost_cu_malloc_managed (void **mem, size_t bytesize)
 Allocate managed CUDA device memory. More...
 
ghost_error ghost_cu_malloc (void **mem, size_t bytesize)
 Allocate CUDA device memory. More...
 
ghost_error ghost_cu_malloc_mapped (void **mem, const size_t size)
 Allocate mapped host memory. More...
 
ghost_error ghost_cu_malloc_pinned (void **mem, const size_t size)
 Allocate pinned host memory. More...
 
ghost_error ghost_cu_download (void *hostmem, void *devmem, size_t bytesize)
 Download memory from a GPU to the host. More...
 
ghost_error ghost_cu_download2d (void *dest, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height)
 Download strided memory from a GPU to the host. Copy height rows of width bytes each. More...
 
ghost_error ghost_cu_upload (void *devmem, void *hostmem, size_t bytesize)
 Upload memory from the the host to the GPU. More...
 
ghost_error ghost_cu_upload2d (void *dest, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height)
 Upload strided memory from the host to the GPU. Copy height rows of width bytes each. More...
 
ghost_error ghost_cu_memcpy (void *dest, void *src, size_t bytesize)
 Memcpy GPU memory. More...
 
ghost_error ghost_cu_memcpy2d (void *dest, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height)
 Memcpy strided GPU memory. Copy height rows of width bytes each. More...
 
ghost_error ghost_cu_memset (void *s, int c, size_t n)
 Memset GPU memory. More...
 
ghost_error ghost_cu_free (void *mem)
 Free GPU memory. More...
 
ghost_error ghost_cu_free_host (void *mem)
 Free host memory which has been allocated with ghost_cu_malloc_pinned() or ghost_cu_malloc_mapped(). More...
 
ghost_error ghost_cu_barrier ()
 Wait for any outstanding CUDA kernel. More...
 
ghost_error ghost_cu_ndevice (int *devcount)
 Get the number of available GPUs. More...
 
ghost_error ghost_cu_version (int *ver)
 Get the CUDA version. More...
 
ghost_error ghost_cu_gpu_info_create (ghost_gpu_info **gpu_info)
 Get information about available GPUs. More...
 
ghost_error ghost_cu_device (int *device)
 Get the active GPU. More...
 
ghost_error ghost_cu_cublas_handle (ghost_cublas_handle_t *handle)
 Get the cuBLAS handle. More...
 
ghost_error ghost_cu_cusparse_handle (ghost_cusparse_handle_t *handle)
 Get the CuSparse handle. More...
 
ghost_error ghost_cu_deviceprop_get (ghost_cu_deviceprop *prop)
 Get the CUDA device properties. More...
 
ghost_error ghost_cu_rand_generator_get (ghost_cu_rand_generator *gen)
 
ghost_error ghost_cu_finalize ()
 
ghost_error ghost_cu_memtranspose (int torows, int tocols, void *to, int ldto, const void *from, int ldfrom, ghost_datatype dt)
 
ghost_error ghost_cu_reduce (void *out, void *data, ghost_datatype dt, ghost_lidx n)
 
ghost_error ghost_cu_reduce_multiple (void *out, void *data, ghost_datatype dt, ghost_lidx n, ghost_lidx ncols)
 

Detailed Description

CUDA utility functions.

CUDA utility functions. If CUDA ist disabled, the function are still defined but stubs.

Author
Moritz Kreutzer morit.nosp@m.z.kr.nosp@m.eutze.nosp@m.r@fa.nosp@m.u.de

Typedef Documentation

typedef int ghost_cu_deviceprop
typedef int ghost_cublas_handle_t

Function Documentation

ghost_error ghost_cu_barrier ( )

Wait for any outstanding CUDA kernel.

Returns
GHOST_SUCCESS on success or an error indicator.

Here is the call graph for this function:

ghost_error ghost_cu_cublas_handle ( ghost_cublas_handle_t handle)

Get the cuBLAS handle.

Parameters
handleWhere to store the handle.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_cusparse_handle ( ghost_cusparse_handle_t handle)

Get the CuSparse handle.

Parameters
handleWhere to store the handle.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_device ( int *  device)

Get the active GPU.

Parameters
deviceWhere to store the device number.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_deviceprop_get ( ghost_cu_deviceprop prop)

Get the CUDA device properties.

Parameters
propWhere to store the properties.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_download ( void *  hostmem,
void *  devmem,
size_t  bytesize 
)

Download memory from a GPU to the host.

Parameters
hostmemThe host side memory location.
devmemThe device side memory location.
bytesizeNumber of bytes.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_download2d ( void *  dest,
size_t  dpitch,
const void *  src,
size_t  spitch,
size_t  width,
size_t  height 
)

Download strided memory from a GPU to the host. Copy height rows of width bytes each.

Parameters
destThe host memory.
dpitchThe pitch in the host memory.
srcThe device memory.
spitchThe pitch in the device memory.
widthThe number of bytes per row.
heightThe number of rows.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_finalize ( )
ghost_error ghost_cu_free ( void *  mem)

Free GPU memory.

Parameters
memThe memory location.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_free_host ( void *  mem)

Free host memory which has been allocated with ghost_cu_malloc_pinned() or ghost_cu_malloc_mapped().

Parameters
memThe memory location.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_gpu_info_create ( ghost_gpu_info **  gpu_info)

Get information about available GPUs.

Parameters
gpu_infoWhere to store the GPU info.
Returns
GHOST_SUCCESS on success or an error indicator.

Here is the call graph for this function:

ghost_error ghost_cu_init ( int  dev)

Initalize CUDA on a given device.

Parameters
devThe device number.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_malloc ( void **  mem,
size_t  bytesize 
)

Allocate CUDA device memory.

Parameters
memWhere to store the memory.
bytesizeThe number of bytes to allocate.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_malloc_managed ( void **  mem,
size_t  bytesize 
)

Allocate managed CUDA device memory.

Parameters
memWhere to store the memory.
bytesizeThe number of bytes to allocate.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_malloc_mapped ( void **  mem,
const size_t  size 
)

Allocate mapped host memory.

Parameters
memWhere to store the memory.
sizeThe number of bytes to allocate.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_malloc_pinned ( void **  mem,
const size_t  size 
)

Allocate pinned host memory.

Parameters
memWhere to store the memory.
sizeThe number of bytes to allocate.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_memcpy ( void *  dest,
void *  src,
size_t  bytesize 
)

Memcpy GPU memory.

Parameters
destThe destination memory location.
srcThe source memory location.
bytesizeThe number of bytes.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_memcpy2d ( void *  dest,
size_t  dpitch,
const void *  src,
size_t  spitch,
size_t  width,
size_t  height 
)

Memcpy strided GPU memory. Copy height rows of width bytes each.

Parameters
destThe device memory.
dpitchThe pitch in the device memory.
srcThe host memory.
spitchThe pitch in the host memory.
widthThe number of bytes per row.
heightThe number of rows.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_memset ( void *  s,
int  c,
size_t  n 
)

Memset GPU memory.

Parameters
sThe memory location.
cWhat to write to the memory.
nThe number of bytes.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_memtranspose ( int  torows,
int  tocols,
void *  to,
int  ldto,
const void *  from,
int  ldfrom,
ghost_datatype  dt 
)
ghost_error ghost_cu_ndevice ( int *  devcount)

Get the number of available GPUs.

Parameters
devcountWhere to store the number.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_rand_generator_get ( ghost_cu_rand_generator gen)

Here is the call graph for this function:

ghost_error ghost_cu_reduce ( void *  out,
void *  data,
ghost_datatype  dt,
ghost_lidx  n 
)
ghost_error ghost_cu_reduce_multiple ( void *  out,
void *  data,
ghost_datatype  dt,
ghost_lidx  n,
ghost_lidx  ncols 
)
ghost_error ghost_cu_upload ( void *  devmem,
void *  hostmem,
size_t  bytesize 
)

Upload memory from the the host to the GPU.

Parameters
devmemThe device side memory location.
hostmemThe host side memory location.
bytesizeNumber of bytes.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_upload2d ( void *  dest,
size_t  dpitch,
const void *  src,
size_t  spitch,
size_t  width,
size_t  height 
)

Upload strided memory from the host to the GPU. Copy height rows of width bytes each.

Parameters
destThe device memory.
dpitchThe pitch in the device memory.
srcThe host memory.
spitchThe pitch in the host memory.
widthThe number of bytes per row.
heightThe number of rows.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_cu_version ( int *  ver)

Get the CUDA version.

Parameters
verWhere to store the version.
Returns
GHOST_SUCCESS on success or an error indicator.

Here is the call graph for this function: