Skylark (Sketching Library)
0.1
|
00001 #ifndef SKYLARK_SKETCHC_HPP 00002 #define SKYLARK_SKETCHC_HPP 00003 00004 #include "mpi.h" 00005 #include "../../config.h" 00006 #include "../../utility/distributions.hpp" 00007 00008 #include "../sketch.hpp" 00009 #include "../../base/context.hpp" 00010 00011 00012 // Some tools require special API declaration. Customizing the 00013 // SKYLARK_EXTERN_API allows this. The default is simply nothing. 00014 #ifndef SKYLARK_EXTERN_API 00015 #define SKYLARK_EXTERN_API 00016 #endif 00017 00018 namespace skylark { 00019 namespace sketch { 00020 namespace c { 00021 00022 enum transform_type_t { 00023 TRANSFORM_TYPE_ERROR, 00024 JLT, 00025 CT, 00026 FJLT, 00027 CWT, 00028 MMT, 00029 WZT, 00030 PPT, 00031 GaussianRFT, 00032 LaplacianRFT, 00033 FastGaussianRFT, 00034 ExpSemigroupRLT 00035 }; 00036 00037 enum matrix_type_t { 00038 MATRIX_TYPE_ERROR, 00039 MATRIX, 00040 SHARED_MATRIX, 00041 ROOT_MATRIX, 00042 DIST_MATRIX, 00043 DIST_MATRIX_VC_STAR, 00044 DIST_MATRIX_VR_STAR, 00045 DIST_MATRIX_STAR_VC, 00046 DIST_MATRIX_STAR_VR, 00047 DIST_SPARSE_MATRIX, 00048 SPARSE_MATRIX 00049 }; 00050 00051 struct sketch_transform_t { 00052 const transform_type_t type; 00053 sketch_transform_data_t * const transform_obj; 00054 00055 sketch_transform_t(transform_type_t type, 00056 sketch_transform_data_t *transform_obj) 00057 : type(type), transform_obj(transform_obj) {} 00058 }; 00059 00060 } // namespace c 00061 } // namespace sketch 00062 } // namespace skylark 00063 00064 namespace base = skylark::base; 00065 namespace sketch = skylark::sketch; 00066 namespace sketchc = skylark::sketch::c; 00067 00068 #define SL_COLUMNWISE 1 00069 #define SL_ROWWISE 2 00070 00071 extern "C" { 00072 00075 SKYLARK_EXTERN_API char *sl_supported_sketch_transforms(); 00076 00081 SKYLARK_EXTERN_API const char* sl_strerror(const int errorcode); 00082 00086 SKYLARK_EXTERN_API bool sl_has_elemental(); 00087 SKYLARK_EXTERN_API bool sl_has_combblas(); 00088 00089 00090 // Support for skylark::base::context_t. 00091 00096 SKYLARK_EXTERN_API int sl_create_default_context(int seed, 00097 base::context_t **ctxt); 00098 00104 SKYLARK_EXTERN_API int sl_create_context(int seed, MPI_Comm cm, 00105 base::context_t **ctxt); 00106 00110 SKYLARK_EXTERN_API int sl_free_context(base::context_t *ctxt); 00111 00119 SKYLARK_EXTERN_API int sl_create_sketch_transform( 00120 base::context_t *ctxt, char *type, 00121 int n, int s, sketchc::sketch_transform_t **sketch, ...); 00122 00127 SKYLARK_EXTERN_API int sl_deserialize_sketch_transform( 00128 const char *data, sketchc::sketch_transform_t **sketch); 00129 00134 SKYLARK_EXTERN_API int sl_serialize_sketch_transform( 00135 const sketchc::sketch_transform_t *sketch, char **data); 00136 00140 SKYLARK_EXTERN_API int sl_free_sketch_transform( 00141 sketchc::sketch_transform_t *S); 00142 00151 SKYLARK_EXTERN_API int sl_apply_sketch_transform( 00152 sketchc::sketch_transform_t *S, 00153 char *input_type, void *A, 00154 char *output_type, void *SA, int dim); 00155 00156 // Helper functions to allow wrapping of object 00157 00158 SKYLARK_EXTERN_API int sl_wrap_raw_matrix(double *data, int m, int n, void **A); 00159 00160 SKYLARK_EXTERN_API int sl_free_raw_matrix_wrap(void *A_); 00161 00162 SKYLARK_EXTERN_API int sl_wrap_raw_sp_matrix(int *indptr, int *ind, 00163 double *data, int nnz, int n_rows, int n_cols, void **A); 00164 00165 SKYLARK_EXTERN_API int sl_free_raw_sp_matrix_wrap(void *A_); 00166 00167 SKYLARK_EXTERN_API int sl_raw_sp_matrix_struct_updated(void *A_, 00168 bool *struct_updated); 00169 00170 SKYLARK_EXTERN_API int sl_raw_sp_matrix_reset_update_flag(void *A_); 00171 00172 SKYLARK_EXTERN_API int sl_raw_sp_matrix_nnz(void *A_, int *nnz); 00173 00174 SKYLARK_EXTERN_API int sl_raw_sp_matrix_data(void *A_, int32_t *indptr, 00175 int32_t *indices, double *values); 00176 00177 } // extern "C" 00178 00179 #endif // SKYLARK_SKETCHC_HPP