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
|
//------------------------------------------------------------------------------
// GB_macrofy_subref: construct all macros for subref methods
//------------------------------------------------------------------------------
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2025, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//------------------------------------------------------------------------------
#include "GB.h"
#include "jitifyer/GB_stringify.h"
void GB_macrofy_subref // construct all macros for GrB_extract
(
// output:
FILE *fp, // target file to write, already open
// input:
uint64_t method_code,
GrB_Type ctype
)
{
//--------------------------------------------------------------------------
// extract the subref method_code
//--------------------------------------------------------------------------
// C, A integer sizes (2 hex digits)
bool Ihead_is_32 = GB_RSHIFT (method_code, 22, 1) ;
bool Cp_is_32 = GB_RSHIFT (method_code, 21, 1) ;
bool Cj_is_32 = GB_RSHIFT (method_code, 20, 1) ;
bool Ci_is_32 = GB_RSHIFT (method_code, 19, 1) ;
bool Ap_is_32 = GB_RSHIFT (method_code, 18, 1) ;
bool Aj_is_32 = GB_RSHIFT (method_code, 17, 1) ;
bool Ai_is_32 = GB_RSHIFT (method_code, 16, 1) ;
// need_qsort, I_has_duplicates, I and J bits (1 hex digit)
bool I_is_32 = GB_RSHIFT (method_code, 15, 1) ;
bool J_is_32 = GB_RSHIFT (method_code, 14, 1) ;
int ihasdupl = GB_RSHIFT (method_code, 13, 1) ;
int needqsort = GB_RSHIFT (method_code, 12, 1) ;
// Ikind, Jkind (1 hex digit)
int Ikind = GB_RSHIFT (method_code, 10, 2) ;
int Jkind = GB_RSHIFT (method_code, 8, 2) ;
// type of C and A (1 hex digit)
// int ccode = GB_RSHIFT (method_code, 4, 4) ;
// sparsity structures of C and A (1 hex digit)
int csparsity = GB_RSHIFT (method_code, 2, 2) ;
int asparsity = GB_RSHIFT (method_code, 0, 2) ;
//--------------------------------------------------------------------------
// describe the subref
//--------------------------------------------------------------------------
fprintf (fp, "// subref: C=A(I,J) where C and A are %s\n",
(asparsity <= 1) ? "sparse/hypersparse" : "bitmap/full") ;
fprintf (fp, "#define GB_I_KIND ") ;
switch (Ikind)
{
case GB_ALL : fprintf (fp, "GB_ALL\n" ) ; break ;
case GB_RANGE : fprintf (fp, "GB_RANGE\n" ) ; break ;
case GB_STRIDE : fprintf (fp, "GB_STRIDE\n" ) ; break ;
case GB_LIST : fprintf (fp, "GB_LIST\n" ) ; break ;
default:;
}
fprintf (fp, "#define GB_I_TYPE uint%d_t\n", I_is_32 ? 32 : 64) ;
if (asparsity <= 1)
{
// C and A are sparse/hypersparse
// Jkind not needed for sparse subsref
fprintf (fp, "#define GB_NEED_QSORT %d\n", needqsort) ;
fprintf (fp, "#define GB_I_HAS_DUPLICATES %d\n", ihasdupl) ;
}
else
{
// C and A are bitmap/full
// need_qsort, I_has_duplicates not needed for bitmap subsref
fprintf (fp, "#define GB_J_KIND ") ;
switch (Jkind)
{
case GB_ALL : fprintf (fp, "GB_ALL\n" ) ; break ;
case GB_RANGE : fprintf (fp, "GB_RANGE\n" ) ; break ;
case GB_STRIDE : fprintf (fp, "GB_STRIDE\n" ) ; break ;
case GB_LIST : fprintf (fp, "GB_LIST\n" ) ; break ;
default:;
}
fprintf (fp, "#define GB_J_TYPE uint%d_t\n", J_is_32 ? 32 : 64) ;
}
fprintf (fp, "#define GB_IHEAD_TYPE uint%d_t\n", Ihead_is_32 ? 32 : 64) ;
//--------------------------------------------------------------------------
// construct the typedefs
//--------------------------------------------------------------------------
GB_macrofy_typedefs (fp, ctype, NULL, NULL, NULL, NULL, NULL) ;
//--------------------------------------------------------------------------
// construct the macros for C and A
//--------------------------------------------------------------------------
GB_macrofy_sparsity (fp, "C", csparsity) ;
GB_macrofy_nvals (fp, "C", csparsity, false) ;
GB_macrofy_type (fp, "C", "_", ctype->name) ;
GB_macrofy_bits (fp, "C", Cp_is_32, Cj_is_32, Ci_is_32) ;
GrB_Type atype = ctype ; // C and A have the same type
GB_macrofy_sparsity (fp, "A", asparsity) ;
GB_macrofy_nvals (fp, "A", asparsity, false) ;
GB_macrofy_type (fp, "A", "_", atype->name) ;
GB_macrofy_bits (fp, "A", Ap_is_32, Aj_is_32, Ai_is_32) ;
//--------------------------------------------------------------------------
// include the final default definitions
//--------------------------------------------------------------------------
fprintf (fp, "\n#include \"include/GB_kernel_shared_definitions.h\"\n") ;
}
|