CUDA related classes

CUDA related classes

Functions

Properties

gpointer context Write / Construct Only
gpointer ipc-memory-handle Write / Construct Only

Types and Values

Object Hierarchy

    GObject
    ├── GArrowBuffer
       ├── GArrowMutableBuffer
          ╰── GArrowCUDAHostBuffer
       ╰── GArrowCUDABuffer
    ├── GArrowCUDAContext
    ├── GArrowCUDADeviceManager
    ├── GArrowCUDAIPCMemoryHandle
    ├── GArrowOutputStream
       ╰── GArrowCUDABufferOutputStream
    ╰── GInputStream
        ╰── GArrowInputStream
            ╰── GArrowSeekableInputStream
                ╰── GArrowBufferInputStream
                    ╰── GArrowCUDABufferInputStream

Implemented Interfaces

GArrowCUDABufferInputStream implements GArrowFile and GArrowReadable.

GArrowCUDABufferOutputStream implements GArrowFile and GArrowWritable.

Includes

#include <arrow-cuda-glib/arrow-cuda-glib.h>

Description

The following classes provide CUDA support for Apache Arrow data.

GArrowCUDADeviceManager is the starting point. You need at least one GArrowCUDAContext to process Apache Arrow data on NVIDIA GPU.

GArrowCUDAContext is a class to keep context for one GPU. You need to create GArrowCUDAContext for each GPU that you want to use. You can create GArrowCUDAContext by garrow_cuda_device_manager_get_context().

GArrowCUDABuffer is a class for data on GPU. You can copy data on GPU to/from CPU by garrow_cuda_buffer_copy_to_host() and garrow_cuda_buffer_copy_from_host(). You can share data on GPU with other processes by garrow_cuda_buffer_export() and garrow_cuda_buffer_new_ipc().

GArrowCUDAHostBuffer is a class for data on CPU that is directly accessible from GPU.

GArrowCUDAIPCMemoryHandle is a class to share data on GPU with other processes. You can export your data on GPU to other processes by garrow_cuda_buffer_export() and garrow_cuda_ipc_memory_handle_new(). You can import other process data on GPU by garrow_cuda_ipc_memory_handle_new() and garrow_cuda_buffer_new_ipc().

GArrowCUDABufferInputStream is a class to read data in GArrowCUDABuffer.

GArrowCUDABufferOutputStream is a class to write data into GArrowCUDABuffer.

Functions

garrow_cuda_device_manager_new ()

GArrowCUDADeviceManager *
garrow_cuda_device_manager_new (GError **error);

Parameters

error

Return location for a GError or NULL.

[nullable]

Returns

A newly created GArrowCUDADeviceManager on success, NULL on error.

Since: 0.8.0


garrow_cuda_device_manager_get_context ()

GArrowCUDAContext *
garrow_cuda_device_manager_get_context
                               (GArrowCUDADeviceManager *manager,
                                gint gpu_number,
                                GError **error);

Parameters

manager

A GArrowCUDADeviceManager.

 

gpu_number

A GPU device number for the target context.

 

error

Return location for a GError or NULL.

[nullable]

Returns

A newly created GArrowCUDAContext on success, NULL on error. Contexts for the same GPU device number share the same data internally.

[transfer full]

Since: 0.8.0


garrow_cuda_device_manager_get_n_devices ()

gsize
garrow_cuda_device_manager_get_n_devices
                               (GArrowCUDADeviceManager *manager);

Parameters

manager

A GArrowCUDADeviceManager.

 

Returns

The number of GPU devices.

Since: 0.8.0


garrow_cuda_context_get_allocated_size ()

gint64
garrow_cuda_context_get_allocated_size
                               (GArrowCUDAContext *context);

Parameters

context

A GArrowCUDAContext.

 

Returns

The allocated memory by this context in bytes.

Since: 0.8.0


garrow_cuda_buffer_new ()

GArrowCUDABuffer *
garrow_cuda_buffer_new (GArrowCUDAContext *context,
                        gint64 size,
                        GError **error);

Parameters

context

A GArrowCUDAContext.

 

size

The number of bytes to be allocated on GPU device for this context.

 

error

Return location for a GError or NULL.

[nullable]

Returns

A newly created GArrowCUDABuffer on success, NULL on error.

[transfer full]

Since: 0.8.0


garrow_cuda_buffer_new_ipc ()

GArrowCUDABuffer *
garrow_cuda_buffer_new_ipc (GArrowCUDAContext *context,
                            GArrowCUDAIPCMemoryHandle *handle,
                            GError **error);

Parameters

context

A GArrowCUDAContext.

 

handle

A GArrowCUDAIPCMemoryHandle to be communicated.

 

error

Return location for a GError or NULL.

[nullable]

Returns

A newly created GArrowCUDABuffer on success, NULL on error. The buffer has data from the IPC target.

[transfer full]

Since: 0.8.0


garrow_cuda_buffer_new_record_batch ()

GArrowCUDABuffer *
garrow_cuda_buffer_new_record_batch (GArrowCUDAContext *context,
                                     GArrowRecordBatch *record_batch,
                                     GError **error);

Parameters

context

A GArrowCUDAContext.

 

record_batch

A GArrowRecordBatch to be serialized.

 

error

Return location for a GError or NULL.

[nullable]

Returns

A newly created GArrowCUDABuffer on success, NULL on error. The buffer has serialized record batch data.

[transfer full]

Since: 0.8.0


garrow_cuda_buffer_copy_to_host ()

GBytes *
garrow_cuda_buffer_copy_to_host (GArrowCUDABuffer *buffer,
                                 gint64 position,
                                 gint64 size,
                                 GError **error);

Parameters

buffer

A GArrowCUDABuffer.

 

position

The offset of memory on GPU device to be copied.

 

size

The size of memory on GPU device to be copied in bytes.

 

error

Return location for a GError or NULL.

[nullable]

Returns

A GBytes that have copied memory on CPU host on success, NULL on error.

[transfer full]

Since: 0.8.0


garrow_cuda_buffer_copy_from_host ()

gboolean
garrow_cuda_buffer_copy_from_host (GArrowCUDABuffer *buffer,
                                   const guint8 *data,
                                   gint64 size,
                                   GError **error);

Parameters

buffer

A GArrowCUDABuffer.

 

data

Data on CPU host to be copied.

[array length=size]

size

The size of data on CPU host to be copied in bytes.

 

error

Return location for a GError or NULL.

[nullable]

Returns

TRUE on success, FALSE if there was an error.

Since: 0.8.0


garrow_cuda_buffer_export ()

GArrowCUDAIPCMemoryHandle *
garrow_cuda_buffer_export (GArrowCUDABuffer *buffer,
                           GError **error);

Parameters

buffer

A GArrowCUDABuffer.

 

error

Return location for a GError or NULL.

[nullable]

Returns

A newly created GArrowCUDAIPCMemoryHandle to handle the exported buffer on success, NULL on error.

[transfer full]

Since: 0.8.0


garrow_cuda_buffer_get_context ()

GArrowCUDAContext *
garrow_cuda_buffer_get_context (GArrowCUDABuffer *buffer);

Parameters

buffer

A GArrowCUDABuffer.

 

Returns

A newly created GArrowCUDAContext for the buffer. Contexts for the same buffer share the same data internally.

[transfer full]

Since: 0.8.0


garrow_cuda_buffer_read_record_batch ()

GArrowRecordBatch *
garrow_cuda_buffer_read_record_batch (GArrowCUDABuffer *buffer,
                                      GArrowSchema *schema,
                                      GArrowReadOptions *options,
                                      GError **error);

Parameters

buffer

A GArrowCUDABuffer.

 

schema

A GArrowSchema for record batch.

 

options

A GArrowReadOptions.

[nullable]

error

Return location for a GError or NULL.

[nullable]

Returns

A newly created GArrowRecordBatch on success, NULL on error. The record batch data is located on GPU.

[transfer full]

Since: 0.8.0


garrow_cuda_host_buffer_new ()

GArrowCUDAHostBuffer *
garrow_cuda_host_buffer_new (gint gpu_number,
                             gint64 size,
                             GError **error);

Parameters

gpu_number

A GPU device number for the target context.

 

size

The number of bytes to be allocated on CPU host.

 

error

Return location for a GError or NULL.

[nullable]

Returns

A newly created GArrowCUDAHostBuffer on success, NULL on error. The allocated memory is accessible from GPU device for the context .

Since: 0.8.0


garrow_cuda_ipc_memory_handle_new ()

GArrowCUDAIPCMemoryHandle *
garrow_cuda_ipc_memory_handle_new (const guint8 *data,
                                   gsize size,
                                   GError **error);

Parameters

data

A serialized GArrowCUDAIPCMemoryHandle.

[array length=size]

size

The size of data.

 

error

Return location for a GError or NULL.

[nullable]

Returns

A newly created GArrowCUDAIPCMemoryHandle on success, NULL on error.

[transfer full]

Since: 0.8.0


garrow_cuda_ipc_memory_handle_serialize ()

GArrowBuffer *
garrow_cuda_ipc_memory_handle_serialize
                               (GArrowCUDAIPCMemoryHandle *handle,
                                GError **error);

Parameters

handle

A GArrowCUDAIPCMemoryHandle.

 

error

Return location for a GError or NULL.

[nullable]

Returns

A newly created GArrowBuffer on success, NULL on error. The buffer has serialized handle . The serialized handle can be deserialized by garrow_cuda_ipc_memory_handle_new() in other process.

[transfer full]

Since: 0.8.0


garrow_cuda_buffer_input_stream_new ()

GArrowCUDABufferInputStream *
garrow_cuda_buffer_input_stream_new (GArrowCUDABuffer *buffer);

Parameters

buffer

A GArrowCUDABuffer.

 

Returns

A newly created GArrowCUDABufferInputStream.

[transfer full]

Since: 0.8.0


garrow_cuda_buffer_output_stream_new ()

GArrowCUDABufferOutputStream *
garrow_cuda_buffer_output_stream_new (GArrowCUDABuffer *buffer);

Parameters

buffer

A GArrowCUDABuffer.

 

Returns

A newly created GArrowCUDABufferOutputStream.

[transfer full]

Since: 0.8.0


garrow_cuda_buffer_output_stream_set_buffer_size ()

gboolean
garrow_cuda_buffer_output_stream_set_buffer_size
                               (GArrowCUDABufferOutputStream *stream,
                                gint64 size,
                                GError **error);

Parameters

stream

A GArrowCUDABufferOutputStream.

 

size

A size of CPU buffer in bytes.

 

error

Return location for a GError or NULL.

[nullable]

Returns

TRUE on success, FALSE if there was an error.

Sets CPU buffer size. to limit cudaMemcpy() calls. If CPU buffer size is 0, buffering is disabled.

The default is 0.

Since: 0.8.0


garrow_cuda_buffer_output_stream_get_buffer_size ()

gint64
garrow_cuda_buffer_output_stream_get_buffer_size
                               (GArrowCUDABufferOutputStream *stream);

Parameters

Returns

The CPU buffer size in bytes.

See garrow_cuda_buffer_output_stream_set_buffer_size() for CPU buffer size details.

Since: 0.8.0


garrow_cuda_buffer_output_stream_get_buffered_size ()

gint64
garrow_cuda_buffer_output_stream_get_buffered_size
                               (GArrowCUDABufferOutputStream *stream);

Parameters

Returns

The size of buffered data in bytes.

Since: 0.8.0

Types and Values

GARROW_CUDA_TYPE_DEVICE_MANAGER

#define GARROW_CUDA_TYPE_DEVICE_MANAGER (garrow_cuda_device_manager_get_type())

struct GArrowCUDADeviceManagerClass

struct GArrowCUDADeviceManagerClass {
  GObjectClass parent_class;
};

GARROW_CUDA_TYPE_CONTEXT

#define GARROW_CUDA_TYPE_CONTEXT (garrow_cuda_context_get_type())

struct GArrowCUDAContextClass

struct GArrowCUDAContextClass {
  GObjectClass parent_class;
};

GARROW_CUDA_TYPE_BUFFER

#define GARROW_CUDA_TYPE_BUFFER (garrow_cuda_buffer_get_type())

struct GArrowCUDABufferClass

struct GArrowCUDABufferClass {
  GArrowBufferClass parent_class;
};

GARROW_CUDA_TYPE_HOST_BUFFER

#define GARROW_CUDA_TYPE_HOST_BUFFER (garrow_cuda_host_buffer_get_type())

struct GArrowCUDAHostBufferClass

struct GArrowCUDAHostBufferClass {
  GArrowMutableBufferClass parent_class;
};

GARROW_CUDA_TYPE_IPC_MEMORY_HANDLE

#define             GARROW_CUDA_TYPE_IPC_MEMORY_HANDLE

struct GArrowCUDAIPCMemoryHandleClass

struct GArrowCUDAIPCMemoryHandleClass {
  GObjectClass parent_class;
};

GARROW_CUDA_TYPE_BUFFER_INPUT_STREAM

#define             GARROW_CUDA_TYPE_BUFFER_INPUT_STREAM

struct GArrowCUDABufferInputStreamClass

struct GArrowCUDABufferInputStreamClass {
  GArrowBufferInputStreamClass parent_class;
};

GARROW_CUDA_TYPE_BUFFER_OUTPUT_STREAM

#define             GARROW_CUDA_TYPE_BUFFER_OUTPUT_STREAM

struct GArrowCUDABufferOutputStreamClass

struct GArrowCUDABufferOutputStreamClass {
  GArrowOutputStreamClass parent_class;
};

GArrowCUDABuffer

typedef struct _GArrowCUDABuffer GArrowCUDABuffer;

GArrowCUDABufferInputStream

typedef struct _GArrowCUDABufferInputStream GArrowCUDABufferInputStream;

GArrowCUDABufferOutputStream

typedef struct _GArrowCUDABufferOutputStream GArrowCUDABufferOutputStream;

GArrowCUDAContext

typedef struct _GArrowCUDAContext GArrowCUDAContext;

GArrowCUDADeviceManager

typedef struct _GArrowCUDADeviceManager GArrowCUDADeviceManager;

GArrowCUDAHostBuffer

typedef struct _GArrowCUDAHostBuffer GArrowCUDAHostBuffer;

GArrowCUDAIPCMemoryHandle

typedef struct _GArrowCUDAIPCMemoryHandle GArrowCUDAIPCMemoryHandle;

Property Details

The “context” property

  “context”                  gpointer

The raw std::shared_ptr<arrow::cuda::CudaContext>.

Owner: GArrowCUDAContext

Flags: Write / Construct Only

Since: 0.8.0


The “ipc-memory-handle” property

  “ipc-memory-handle”        gpointer

The raw std::shared_ptr<arrow::cuda::CudaIpcMemHandle>.

Owner: GArrowCUDAIPCMemoryHandle

Flags: Write / Construct Only

Since: 0.8.0