Polaris Project
Functions
polaris.h File Reference

Introduction

A FPGA-accelerated library of primitives for deep neural networks.
Provides highly tuned implementations of routines arising frequently in deep learning applications.

Authors
isa@b.nosp@m.aidu.nosp@m..com

Functions

PolarisContextpolaris_create_context (int devid)
 Create a polaris context object on a specific device. More...
 
void polaris_destroy_context (PolarisContext *ctxt)
 Free and destroy a polaris context. More...
 
PolarisStatus polaris_malloc (PolarisContext *ctxt, size_t size, void **ptr)
 Allocate a block of memory on FPGA. More...
 
PolarisStatus polaris_malloc_host (PolarisContext *ctxt, size_t size, void **ptr)
 Allocate a block of memory on host(CPU) memory. More...
 
PolarisStatus polaris_free (PolarisContext *ctxt, void *ptr)
 Free a block of memory on FPGA. More...
 
PolarisStatus polaris_free_host (PolarisContext *ctxt, void *ptr)
 Free a block of memory on host(CPU) memory. More...
 
PolarisStatus polaris_memcpy (PolarisContext *ctxt, PolarisMemcpyKind kind, void *dest, const void *src, size_t size)
 Copy block of memory between CPU and FPGA. More...
 
PolarisStatus polaris_gemm (PolarisContext *ctxt, PolarisTransType trans_a, PolarisTransType trans_b, int m, int n, int k, float alpha, const void *a, PolarisDataType type_a, int lda, const void *b, PolarisDataType type_b, int ldb, float beta, void *c, PolarisDataType type_c, int ldc, const void *bias, PolarisActivationType activation)
 Perform matrix multiplication with bias and activation support. More...
 
PolarisStatus polaris_memset (PolarisContext *ctxt, void *ptr, size_t size)
 Fill a range of FPGA memory with zero. More...
 
PolarisStatus polaris_activation_2d (PolarisContext *ctxt, PolarisActivationType type, int m, int n, float alpha, const void *x, PolarisDataType type_x, int stride_x, float beta, void *y, PolarisDataType type_y, int stride_y)
 Compute activation functions. More...
 
PolarisStatus polaris_deactivation_2d (PolarisContext *ctxt, PolarisActivationType type, int m, int n, float alpha, const void *y, PolarisDataType type_y, int stride_y, const void *dy, PolarisDataType type_dy, int stride_dy, const void *x, PolarisDataType type_x, int stride_x, float beta, void *dx, PolarisDataType type_dx, int stride_dx)
 Compute derived activation functions. More...
 
PolarisStatus polaris_elementwise_2d (PolarisContext *ctxt, PolarisElementWiseType type, int m, int n, float alpha0, const void *x0, PolarisDataType type_x0, int stride_x0, float alpha1, const void *x1, PolarisDataType type_x1, int stride_x1, float beta, void *y, PolarisDataType type_y, int stride_y)
 Element wise functions. More...
 
PolarisStatus polaris_transpose (PolarisContext *ctxt, int m, int n, const void *x, PolarisDataType type_x, int stride_x, void *y, PolarisDataType type_y, int stride_y)
 Perform matrix transpose on FPGA. More...
 
PolarisStatus polaris_memcpy_2d (PolarisContext *ctxt, PolarisMemcpyKind kind, int m, int n, void *dest, int stride_dest, const void *src, int stride_src)
 Perform batched memcpy in a 2-D pattern. Often used to copy sub-matrices. More...
 
int polaris_get_devices (int *devs, int devs_len)
 Get list of all the FPGA devices. More...
 
int polaris_get_devices (const char *firmware_name, int *devs, int devs_len)
 Get list of all the FPGA devices that match the given firmware name. More...
 
int polaris_get_driver_version (char *ver, int ver_len)
 Get version string of the driver. More...
 
PolarisStatus polaris_read_register (PolarisContext *ctxt, uint64_t addr, uint64_t *value, int bar)
 Read a FPGA register. More...
 
PolarisStatus polaris_write_register (PolarisContext *ctxt, uint64_t addr, uint64_t value, int bar)
 Write a FPGA register. More...
 

Function Documentation

◆ polaris_read_register()

PolarisStatus polaris_read_register ( PolarisContext ctxt,
uint64_t  addr,
uint64_t *  value,
int  bar 
)

Read a FPGA register.

Warning
Make sure you know what you are doing when using this interface, most of the developers do not have to use this interface.
Parameters
[in]ctxtpointer to context
[in]addrregister address
[out]valuewhere to store the value
[in]barbar space id of the register
Returns
Execution status, POLARIS_OK on success.

◆ polaris_write_register()

PolarisStatus polaris_write_register ( PolarisContext ctxt,
uint64_t  addr,
uint64_t  value,
int  bar 
)

Write a FPGA register.

Warning
Make sure you know what you are doing when using this interface, most of the developers do not have to use this interface.
Parameters
[in]ctxtpointer to context
[in]addrregister address
[in]valuethe value to write
[in]barbar space id of the register
Returns
Execution status, POLARIS_OK on success.