1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
|
//------------------------------------------------------------------------------
// GB_stringify.h: prototype definitions construction of *.h definitions
//------------------------------------------------------------------------------
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2021, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//------------------------------------------------------------------------------
#ifndef GB_STRINGIFY_H
#define GB_STRINGIFY_H
//------------------------------------------------------------------------------
// dump definitions (for debugging and test coverage only)
//------------------------------------------------------------------------------
// uncomment this line to dump GB*.h files to /tmp, or compile with
// -DGB_DEBUGIFY_DEFN=1
// #define GB_DEBUGIFY_DEFN 1
//------------------------------------------------------------------------------
// for GB_boolean_rename and related methods
//------------------------------------------------------------------------------
#include "GB_binop.h"
//------------------------------------------------------------------------------
// left and right shift
//------------------------------------------------------------------------------
#define GB_LSHIFT(x,k) (((uint64_t) x) << k)
#define GB_RSHIFT(x,k,b) ((x >> k) & ((((uint64_t)0x00000001) << b) -1))
//------------------------------------------------------------------------------
// GrB_reduce
//------------------------------------------------------------------------------
void GB_enumify_reduce // enumerate a GrB_reduce problem
(
// output:
uint64_t *rcode, // unique encoding of the entire problem
// input:
GrB_Monoid reduce, // the monoid to enumify
GrB_Matrix A
) ;
void GB_macrofy_reduce // construct all macros for GrB_reduce to scalar
(
FILE *fp, // target file to write, already open
// input:
uint64_t rcode, // encoded problem
GrB_Monoid monoid, // monoid to macrofy
GrB_Type atype // type of the A matrix to reduce
) ;
//------------------------------------------------------------------------------
// GrB_eWiseAdd, GrB_eWiseMult, GxB_eWiseUnion
//------------------------------------------------------------------------------
// FUTURE: add accumulator for eWise operations?
void GB_enumify_ewise // enumerate a GrB_eWise problem
(
// output:
uint64_t *scode, // unique encoding of the entire operation
// input:
// C matrix:
bool C_iso, // if true, operator is ignored
int C_sparsity, // sparse, hyper, bitmap, or full
GrB_Type ctype, // C=((ctype) T) is the final typecast
// M matrix:
GrB_Matrix M, // may be NULL
bool Mask_struct, // mask is structural
bool Mask_comp, // mask is complemented
// operator:
GrB_BinaryOp binaryop, // the binary operator to enumify
bool flipxy, // multiplier is: op(a,b) or op(b,a)
// A and B:
GrB_Matrix A,
GrB_Matrix B
) ;
void GB_macrofy_ewise // construct all macros for GrB_eWise
(
// output:
FILE *fp, // target file to write, already open
// input:
uint64_t scode,
GrB_BinaryOp binaryop, // binaryop to macrofy
GrB_Type ctype,
GrB_Type atype,
GrB_Type btype
) ;
//------------------------------------------------------------------------------
// GrB_mxm
//------------------------------------------------------------------------------
void GB_enumify_mxm // enumerate a GrB_mxm problem
(
// output:
uint64_t *scode, // unique encoding of the entire semiring
// input:
// C matrix:
bool C_iso, // if true, semiring is ignored
int C_sparsity, // sparse, hyper, bitmap, or full
GrB_Type ctype, // C=((ctype) T) is the final typecast
// M matrix:
GrB_Matrix M, // may be NULL
bool Mask_struct, // mask is structural
bool Mask_comp, // mask is complemented
// semiring:
GrB_Semiring semiring, // the semiring to enumify
bool flipxy, // multiplier is: mult(a,b) or mult(b,a)
// A and B:
GrB_Matrix A,
GrB_Matrix B
) ;
void GB_macrofy_mxm // construct all macros for GrB_mxm
(
// output:
FILE *fp, // target file to write, already open
// input:
uint64_t scode,
GrB_Semiring semiring, // the semiring to macrofy
GrB_Type ctype,
GrB_Type atype,
GrB_Type btype
) ;
//------------------------------------------------------------------------------
// enumify and macrofy the mask matrix M
//------------------------------------------------------------------------------
void GB_enumify_mask // return enum to define mask macros
(
// output:
int *mask_ecode, // enumified mask
// input
const GB_Type_code mcode, // typecode of the mask matrix M,
// or 0 if M is not present
bool Mask_struct, // true if M structural, false if valued
bool Mask_comp // true if M complemented
) ;
void GB_macrofy_mask // return enum to define mask macros
(
// input
FILE *fp, // File to write macros, assumed open already
int mask_ecode // enumified mask
) ;
//------------------------------------------------------------------------------
// enumify and macrofy a monoid
//------------------------------------------------------------------------------
void GB_enumify_monoid // enumerate a monoid
(
// outputs:
int *add_ecode, // binary op as an enum
int *id_ecode, // identity value as an enum
int *term_ecode, // terminal value as an enum
// inputs:
int add_opcode, // must be a built-in binary operator from a monoid
int zcode // type of the monoid (x, y, and z)
) ;
void GB_macrofy_monoid // construct the macros for a monoid
(
FILE *fp, // File to write macros, assumed open already
// inputs:
int add_ecode, // binary op as an enum
int id_ecode, // identity value as an enum
int term_ecode, // terminal value as an enum (< 30 is terminal)
GrB_Monoid monoid, // monoid to macrofy
bool skip_defn // if true, do not include the user-defined add function
) ;
//------------------------------------------------------------------------------
// binary operators
//------------------------------------------------------------------------------
void GB_enumify_binop
(
// output:
int *ecode, // enumerated operator, range 0 to 110; -1 on failure
// input:
GB_Opcode opcode, // opcode of GraphBLAS operator to convert into a macro
GB_Type_code zcode, // op->xtype->code of the operator
bool for_semiring // true for A*B, false for A+B or A.*B
) ;
void GB_macrofy_binop
(
FILE *fp,
// input:
const char *macro_name,
bool flipxy, // if true: op is f(y,x), multipicative only
bool is_monoid, // if true: additive operator for monoid
int ecode,
GrB_BinaryOp op,
bool skip_defn
) ;
//------------------------------------------------------------------------------
// monoid identity and terminal values
//------------------------------------------------------------------------------
void GB_enumify_identity // return enum of identity value
(
// output:
int *ecode, // enumerated identity, 0 to 17 (-1 if fail)
// input:
GB_Opcode opcode, // built-in binary opcode of a monoid
GB_Type_code zcode // type code used in the opcode we want
) ;
const char *GB_charify_identity_or_terminal // return string encoding the value
(
// input:
int ecode // enumerated identity/terminal value
) ;
void GB_macrofy_bytes
(
// input:
FILE *fp, // File to write macros, assumed open already
const char *Name, // all-upper-case name
const char *type_name, // name of the type
const uint8_t *value, // array of size nbytes
size_t nbytes
) ;
void GB_enumify_terminal // return enum of terminal value
(
// output:
int *ecode, // enumerated terminal, 0 to 31 (-1 if fail)
// input:
GB_Opcode opcode, // built-in binary opcode of a monoid
GB_Type_code zcode // type code used in the opcode we want
) ;
//------------------------------------------------------------------------------
// sparsity structure
//------------------------------------------------------------------------------
void GB_enumify_sparsity // enumerate the sparsity structure of a matrix
(
// output:
int *ecode, // enumerated sparsity structure
// input:
int A_sparsity // GxB_SPARSE, GxB_HYPERSPARSE, GxB_BITMAP, GxB_FULL
) ;
void GB_macrofy_sparsity // construct macros for sparsity structure
(
// input:
FILE *fp,
char *matrix_name, // "C", "M", "A", or "B"
int ecode
) ;
//------------------------------------------------------------------------------
// typedefs
//------------------------------------------------------------------------------
void GB_macrofy_types
(
FILE *fp,
// input:
const char *ctype_defn,
const char *atype_defn,
const char *btype_defn,
const char *xtype_defn,
const char *ytype_defn,
const char *ztype_defn
) ;
//------------------------------------------------------------------------------
// GB_namify_problem: name a problem
//------------------------------------------------------------------------------
void GB_namify_problem
(
// output:
char *problem_name, // of size at least 256 + 8*GxB_MAX_NAME_LEN
// input:
const uint64_t scode,
const char *opname1, // each string has size at most GxB_MAX_NAME_LEN
const char *opname2,
const char *typename1,
const char *typename2,
const char *typename3,
const char *typename4,
const char *typename5,
const char *typename6
) ;
//------------------------------------------------------------------------------
// GB_debugify_*: dump the definition file to /tmp
//------------------------------------------------------------------------------
void GB_debugify_mxm
(
// C matrix:
bool C_iso, // if true, operator is ignored
int C_sparsity, // sparse, hyper, bitmap, or full
GrB_Type ctype, // C=((ctype) T) is the final typecast
// M matrix:
GrB_Matrix M,
bool Mask_struct,
bool Mask_comp,
// semiring:
GrB_Semiring semiring,
bool flipxy,
// A and B matrices:
GrB_Matrix A,
GrB_Matrix B
) ;
void GB_debugify_ewise
(
// C matrix:
bool C_iso, // if true, operator is ignored
int C_sparsity, // sparse, hyper, bitmap, or full
GrB_Type ctype, // C=((ctype) T) is the final typecast
// M matrix:
GrB_Matrix M,
bool Mask_struct,
bool Mask_comp,
// operator:
GrB_BinaryOp binaryop,
bool flipxy,
// A and B matrices:
GrB_Matrix A,
GrB_Matrix B
) ;
void GB_debugify_reduce // enumerate and macrofy a GrB_reduce problem
(
// input:
GrB_Monoid monoid, // the monoid to enumify
GrB_Matrix A
) ;
#endif
|