Skip to content

morapi_DeviceBufCB Struct Reference

dnn » device

Callback functions for device buffer.
More...

#include <morapi_softneuro.h>

Public Types

typedef void *(*  morapi_Create_DeviceBufCB) (morapi_Env *io_env)
typedef morapi_Result(*  morapi_Destroy_DeviceBufCB) (morapi_Env *io_env, void *obj)
typedef morapi_Result(*  morapi_DeviceBufCB_Malloc) (void *obj, const morapi_Device *i_dev, morapi_Size i_size)
typedef morapi_Result(*  morapi_DeviceBufCB_Free) (void *obj)
typedef morapi_Result(*  morapi_DeviceBufCB_MemcpyCpuToDevice) (void *obj, void *i_src, morapi_Size i_offset, morapi_Size i_size)
typedef morapi_Result(*  morapi_DeviceBufCB_MemcpyDeviceToCpu) (void *obj, void *o_dst, morapi_Size i_offset, morapi_Size i_size)

Public Member Functions

morapi_Result  morapi_DeviceBufCB_clear (morapi_DeviceBufCB *self)

Data Fields

morapi_Create_DeviceBufCB  create
morapi_Destroy_DeviceBufCB  destroy
morapi_DeviceBufCB_Malloc  malloc
morapi_DeviceBufCB_Free  free
morapi_DeviceBufCB_MemcpyCpuToDevice  memcpy_cpu_to_device
morapi_DeviceBufCB_MemcpyDeviceToCpu  memcpy_device_to_cpu

morapi_DeviceBufCB morapi_installDeviceBufCB (morapi_Env *env, const morapi_Char *i_name, const morapi_DeviceBufCB *i_cb)


Detailed Description

Callback functions for device buffer.


Member Typedef Documentation


morapi_Create_DeviceBufCB

typedef void*(* morapi_Create_DeviceBufCB) (morapi_Env *io_env)

Creates a device buffer object.

Parameters

  • io_env : environment where the object will be created


morapi_Destroy_DeviceBufCB

typedef morapi_Result(* morapi_Destroy_DeviceBufCB) (morapi_Env *io_env, void *obj)

Destroys the device buffer object.

Parameters

  • io_env : environment where the object was created
  • obj : object to be destroyed


morapi_DeviceBufCB_Malloc

typedef morapi_Result(* morapi_DeviceBufCB_Malloc) (void *obj, const morapi_Device *i_dev, morapi_Size i_size)

Allocates the device buffer with i_size.

Parameters

  • obj : device buffer object
  • i_dev : device buffer to be allocated
  • i_size : buffer size


morapi_DeviceBufCB_Free

typedef morapi_Result(* morapi_DeviceBufCB_Free) (void *obj)

Free the device buffer.

Parameters

  • obj : device buffer object


morapi_DeviceBufCB_MemcpyCpuToDevice

typedef morapi_Result(* morapi_DeviceBufCB_MemcpyCpuToDevice) (void *obj, void *i_src, morapi_Size i_offset, morapi_Size i_size)

Copy data from a cpu to a device.

Parameters

  • obj : device buffer object
  • i_src : data source
  • i_offset : data offset
  • i_size : data size


morapi_DeviceBufCB_MemcpyDeviceToCpu

typedef morapi_Result(* morapi_DeviceBufCB_MemcpyDeviceToCpu) (void *obj, void *o_dst, morapi_Size i_offset, morapi_Size i_size)

Copy data from a device to a cpu.

Parameters

  • obj : device buffer object
  • o_dst : data destination
  • i_offset : data offset
  • i_size : data size

Member Function Documentation


morapi_DeviceBufCB_clear()

morapi_Result morapi_DeviceBufCB_clear (morapi_DeviceBufCB * self)

Clears callback functions.

Parameters

  • self : device buffer callbacks object


morapi_installDeviceBufCB()

morapi_DeviceBufCB * morapi_installDeviceBufCB (morapi_Env * env,
                                                const morapi_Char * i_name,
                                                const morapi_DeviceBufCB * i_cb)

Installs callback functions for device buffer.

Use MORAPI_INSTALL_DEVICE_BUF instead of calling this function directly.

Parameters

  • env : environment where the buffer was created
  • i_name : callbacks name
  • i_cb : device buffer callbacks object

Field Documentation


create

morapi_Create_DeviceBufCB morapi_DeviceBufCB::create

Creates a device buffer object.


destroy

morapi_Destroy_DeviceBufCB morapi_DeviceBufCB::destroy

Destroys the device buffer object.


malloc

morapi_DeviceBufCB_Malloc morapi_DeviceBufCB::malloc

Allocates the device buffer.


free

morapi_DeviceBufCB_Free morapi_DeviceBufCB::free

Frees the device buffer.


memcpy_cpu_to_device

morapi_DeviceBufCB_MemcpyCpuToDevice morapi_DeviceBufCB::memcpy_cpu_to_device

Write data to the device buffer from cpu memory.


memcpy_device_to_cpu

morapi_DeviceBufCB_MemcpyDeviceToCpu morapi_DeviceBufCB::memcpy_device_to_cpu

Read data to cpu memory from the device buffer.