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
|
//------------------------------------------------------------------------------
// GB_red_factory.c: switch factory for reduction operators
//------------------------------------------------------------------------------
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//------------------------------------------------------------------------------
// This is a generic body of code for creating hard-coded versions of code for
// 61 or 87 combinations of associative operators and built-in types:
// 20: min, max: 10 non-boolean real types
// 24: plus, times: 12 non-boolean types
// 4: lor, land, eq (same as lxnor), lxor for boolean
// 13: any: for all 13 types
// 26: first, second: for all 13 types, if GB_INCLUDE_SECOND_OPERATOR
// is defined, for GB_builder.
if (typecode != GB_BOOL_code)
{
//--------------------------------------------------------------------------
// non-boolean case
//--------------------------------------------------------------------------
switch (opcode)
{
case GB_MIN_binop_code :
switch (typecode)
{
case GB_INT8_code : GB_RED_WORKER (_min, _int8, int8_t )
case GB_INT16_code : GB_RED_WORKER (_min, _int16, int16_t )
case GB_INT32_code : GB_RED_WORKER (_min, _int32, int32_t )
case GB_INT64_code : GB_RED_WORKER (_min, _int64, int64_t )
case GB_UINT8_code : GB_RED_WORKER (_min, _uint8, uint8_t )
case GB_UINT16_code : GB_RED_WORKER (_min, _uint16, uint16_t)
case GB_UINT32_code : GB_RED_WORKER (_min, _uint32, uint32_t)
case GB_UINT64_code : GB_RED_WORKER (_min, _uint64, uint64_t)
case GB_FP32_code : GB_RED_WORKER (_min, _fp32, float )
case GB_FP64_code : GB_RED_WORKER (_min, _fp64, double )
default: ;
}
break ;
case GB_MAX_binop_code :
switch (typecode)
{
case GB_INT8_code : GB_RED_WORKER (_max, _int8, int8_t )
case GB_INT16_code : GB_RED_WORKER (_max, _int16, int16_t )
case GB_INT32_code : GB_RED_WORKER (_max, _int32, int32_t )
case GB_INT64_code : GB_RED_WORKER (_max, _int64, int64_t )
case GB_UINT8_code : GB_RED_WORKER (_max, _uint8, uint8_t )
case GB_UINT16_code : GB_RED_WORKER (_max, _uint16, uint16_t)
case GB_UINT32_code : GB_RED_WORKER (_max, _uint32, uint32_t)
case GB_UINT64_code : GB_RED_WORKER (_max, _uint64, uint64_t)
case GB_FP32_code : GB_RED_WORKER (_max, _fp32, float )
case GB_FP64_code : GB_RED_WORKER (_max, _fp64, double )
default: ;
}
break ;
case GB_PLUS_binop_code :
switch (typecode)
{
case GB_INT8_code : GB_RED_WORKER (_plus, _int8, int8_t )
case GB_INT16_code : GB_RED_WORKER (_plus, _int16, int16_t )
case GB_INT32_code : GB_RED_WORKER (_plus, _int32, int32_t )
case GB_INT64_code : GB_RED_WORKER (_plus, _int64, int64_t )
case GB_UINT8_code : GB_RED_WORKER (_plus, _uint8, uint8_t )
case GB_UINT16_code : GB_RED_WORKER (_plus, _uint16, uint16_t)
case GB_UINT32_code : GB_RED_WORKER (_plus, _uint32, uint32_t)
case GB_UINT64_code : GB_RED_WORKER (_plus, _uint64, uint64_t)
case GB_FP32_code : GB_RED_WORKER (_plus, _fp32, float )
case GB_FP64_code : GB_RED_WORKER (_plus, _fp64, double )
case GB_FC32_code : GB_RED_WORKER (_plus, _fc32, GxB_FC32_t)
case GB_FC64_code : GB_RED_WORKER (_plus, _fc64, GxB_FC64_t)
default: ;
}
break ;
case GB_TIMES_binop_code :
switch (typecode)
{
case GB_INT8_code : GB_RED_WORKER (_times, _int8, int8_t )
case GB_INT16_code : GB_RED_WORKER (_times, _int16, int16_t )
case GB_INT32_code : GB_RED_WORKER (_times, _int32, int32_t )
case GB_INT64_code : GB_RED_WORKER (_times, _int64, int64_t )
case GB_UINT8_code : GB_RED_WORKER (_times, _uint8, uint8_t )
case GB_UINT16_code : GB_RED_WORKER (_times, _uint16, uint16_t)
case GB_UINT32_code : GB_RED_WORKER (_times, _uint32, uint32_t)
case GB_UINT64_code : GB_RED_WORKER (_times, _uint64, uint64_t)
case GB_FP32_code : GB_RED_WORKER (_times, _fp32, float )
case GB_FP64_code : GB_RED_WORKER (_times, _fp64, double )
case GB_FC32_code : GB_RED_WORKER (_times, _fc32, GxB_FC32_t)
case GB_FC64_code : GB_RED_WORKER (_times, _fc64, GxB_FC64_t)
default: ;
}
break ;
case GB_ANY_binop_code :
switch (typecode)
{
case GB_INT8_code : GB_RED_WORKER (_any, _int8, int8_t )
case GB_INT16_code : GB_RED_WORKER (_any, _int16, int16_t )
case GB_INT32_code : GB_RED_WORKER (_any, _int32, int32_t )
case GB_INT64_code : GB_RED_WORKER (_any, _int64, int64_t )
case GB_UINT8_code : GB_RED_WORKER (_any, _uint8, uint8_t )
case GB_UINT16_code : GB_RED_WORKER (_any, _uint16, uint16_t)
case GB_UINT32_code : GB_RED_WORKER (_any, _uint32, uint32_t)
case GB_UINT64_code : GB_RED_WORKER (_any, _uint64, uint64_t)
case GB_FP32_code : GB_RED_WORKER (_any, _fp32, float )
case GB_FP64_code : GB_RED_WORKER (_any, _fp64, double )
case GB_FC32_code : GB_RED_WORKER (_any, _fc32, GxB_FC32_t)
case GB_FC64_code : GB_RED_WORKER (_any, _fc64, GxB_FC64_t)
default: ;
}
break ;
//----------------------------------------------------------------------
// FIRST and SECOND for GB_builder
//----------------------------------------------------------------------
#ifdef GB_INCLUDE_SECOND_OPERATOR
case GB_FIRST_binop_code :
switch (typecode)
{
case GB_INT8_code : GB_RED_WORKER (_first, _int8, int8_t )
case GB_INT16_code : GB_RED_WORKER (_first, _int16, int16_t )
case GB_INT32_code : GB_RED_WORKER (_first, _int32, int32_t )
case GB_INT64_code : GB_RED_WORKER (_first, _int64, int64_t )
case GB_UINT8_code : GB_RED_WORKER (_first, _uint8, uint8_t )
case GB_UINT16_code : GB_RED_WORKER (_first, _uint16, uint16_t)
case GB_UINT32_code : GB_RED_WORKER (_first, _uint32, uint32_t)
case GB_UINT64_code : GB_RED_WORKER (_first, _uint64, uint64_t)
case GB_FP32_code : GB_RED_WORKER (_first, _fp32, float )
case GB_FP64_code : GB_RED_WORKER (_first, _fp64, double )
case GB_FC32_code : GB_RED_WORKER (_first, _fc32, GxB_FC32_t)
case GB_FC64_code : GB_RED_WORKER (_first, _fc64, GxB_FC64_t)
default: ;
}
break ;
case GB_SECOND_binop_code :
switch (typecode)
{
case GB_INT8_code : GB_RED_WORKER (_second, _int8, int8_t )
case GB_INT16_code : GB_RED_WORKER (_second, _int16, int16_t )
case GB_INT32_code : GB_RED_WORKER (_second, _int32, int32_t )
case GB_INT64_code : GB_RED_WORKER (_second, _int64, int64_t )
case GB_UINT8_code : GB_RED_WORKER (_second, _uint8, uint8_t )
case GB_UINT16_code : GB_RED_WORKER (_second, _uint16, uint16_t)
case GB_UINT32_code : GB_RED_WORKER (_second, _uint32, uint32_t)
case GB_UINT64_code : GB_RED_WORKER (_second, _uint64, uint64_t)
case GB_FP32_code : GB_RED_WORKER (_second, _fp32, float )
case GB_FP64_code : GB_RED_WORKER (_second, _fp64, double )
case GB_FC32_code : GB_RED_WORKER (_second, _fc32, GxB_FC32_t)
case GB_FC64_code : GB_RED_WORKER (_second, _fc64, GxB_FC64_t)
default: ;
}
break ;
#endif
default: ;
}
}
else
{
//--------------------------------------------------------------------------
// boolean case: rename the opcode as needed
//--------------------------------------------------------------------------
// The FIRST and SECOND operators are not associative, but are added for
// GB_builder.
switch (GB_boolean_rename (opcode))
{
case GB_LOR_binop_code : GB_RED_WORKER (_lor, _bool, bool)
case GB_LAND_binop_code : GB_RED_WORKER (_land, _bool, bool)
case GB_LXOR_binop_code : GB_RED_WORKER (_lxor, _bool, bool)
case GB_EQ_binop_code : GB_RED_WORKER (_eq, _bool, bool)
case GB_ANY_binop_code : GB_RED_WORKER (_any, _bool, bool)
#ifdef GB_INCLUDE_SECOND_OPERATOR
case GB_FIRST_binop_code : GB_RED_WORKER (_first, _bool, bool)
case GB_SECOND_binop_code : GB_RED_WORKER (_second, _bool, bool)
#endif
default: ;
}
}
|