-
Notifications
You must be signed in to change notification settings - Fork 8
Customize:Formats
NCIC-AlphaSparse edited this page Sep 30, 2024
·
16 revisions
AlphaSparseLib provides a series of formats that widely used in various applications, including CSR, COO, CSC, BSR, etc. The formats are defined in file spmat.h and corresponding operations can be find in directory "include/alphasparse/format". We show the way to customize your formats in this page.
为简化kernel接口的复杂性,我们以宏定义的方式将矩阵结构与数据类型进行了融合,根据不同的数据类型在kernel中对矩阵结构进行展开,如#define ALPHA_SPMAT_CSR spmat_csr_s_t,将统一的CSR结构展开为具体的float数据类型的矩阵结构,spmat_csr_s_t结构体则需要具体定义。为兼容不同计算平台(目前有多核和HIP众核)的数据存储要求,具体数据类型的矩阵结构包含了指向不同平台数据存储的指针,如:
typedef struct
{
float *values;
int *rows_ptr;
int *col_indx;
float *d_values;
int *d_row_ptr;
int *d_col_indx;
} spmat_csr_s_t;
CSR格式的三元组values,rows_ptr,col_indx为指向主机端内存数据的指针,而有**d_**前缀的则指向设备端内存数据的指针。