File: GB_mxm_shared_definitions.h

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (237 lines) | stat: -rw-r--r-- 6,335 bytes parent folder | download
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
//------------------------------------------------------------------------------
// GB_mxm_shared_definitions.h: common macros for A*B kernels
//------------------------------------------------------------------------------

// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2025, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//------------------------------------------------------------------------------

// GB_mxm_shared_definitions.h provides default definitions for all semirings,
// if the special cases have not been #define'd prior to #include'ing this
// file.  This file is shared by generic, pre-generated, and both CPU and CUDA
// JIT kernels.

#include "include/GB_monoid_shared_definitions.h"

#ifndef GB_MXM_SHARED_DEFINITIONS_H
#define GB_MXM_SHARED_DEFINITIONS_H

//------------------------------------------------------------------------------
// special semirings
//------------------------------------------------------------------------------

// 1 for the symbolic ANY_PAIR semiring
#ifndef GB_IS_ANY_PAIR_SEMIRING
#define GB_IS_ANY_PAIR_SEMIRING 0
#endif

// 1 for PLUS_PAIR semirings (integer, float, and double; not bool or complex)
#ifndef GB_IS_PLUS_PAIR_REAL_SEMIRING
#define GB_IS_PLUS_PAIR_REAL_SEMIRING 0
#endif

// 1 for LXOR_PAIR_BOOL
#ifndef GB_IS_LXOR_PAIR_SEMIRING
#define GB_IS_LXOR_PAIR_SEMIRING 0
#endif

// 1 for PLUS_PAIR_INT8 and PLUS_PAIR_UINT8
#ifndef GB_IS_PLUS_PAIR_8_SEMIRING
#define GB_IS_PLUS_PAIR_8_SEMIRING 0
#endif

// 1 for PLUS_PAIR_INT16 and PLUS_PAIR_UINT16
#ifndef GB_IS_PLUS_PAIR_16_SEMIRING
#define GB_IS_PLUS_PAIR_16_SEMIRING 0
#endif

// 1 for PLUS_PAIR_INT32 and PLUS_PAIR_UINT32
#ifndef GB_IS_PLUS_PAIR_32_SEMIRING
#define GB_IS_PLUS_PAIR_32_SEMIRING 0
#endif

// 1 for PLUS_PAIR_(INT64, UINT64, FP32, and FP64)
#ifndef GB_IS_PLUS_PAIR_BIG_SEMIRING
#define GB_IS_PLUS_PAIR_BIG_SEMIRING 0
#endif

// 1 for MIN_FIRSTJ
#ifndef GB_IS_MIN_FIRSTJ_SEMIRING
#define GB_IS_MIN_FIRSTJ_SEMIRING 0
#endif

// 1 for MAX_FIRSTJ
#ifndef GB_IS_MAX_FIRSTJ_SEMIRING
#define GB_IS_MAX_FIRSTJ_SEMIRING 0
#endif

// 1 if the semiring has an AVX512 or AVX2 implementation
#ifndef GB_SEMIRING_HAS_AVX_IMPLEMENTATION
#define GB_SEMIRING_HAS_AVX_IMPLEMENTATION 0
#endif

//------------------------------------------------------------------------------
// special multiply operators
//------------------------------------------------------------------------------

// 1 if the multiply operator is PAIR
#ifndef GB_IS_PAIR_MULTIPLIER
#define GB_IS_PAIR_MULTIPLIER 0
#endif

// 1 for the FIRSTI1, FIRSTJ1, SECONDI1, or SECONDJ1 multiply operators
#ifndef GB_OFFSET
#define GB_OFFSET 0
#endif

// 1 for the FIRSTI or FIRSTI1 multiply operator
#ifndef GB_IS_FIRSTI_MULTIPLIER
#define GB_IS_FIRSTI_MULTIPLIER 0
#endif

// 1 for the FIRSTJ, FIRSTJ1, SECONDI, or SECONDI1 multiply operator
#ifndef GB_IS_FIRSTJ_MULTIPLIER
#define GB_IS_FIRSTJ_MULTIPLIER 0
#endif

// 1 for the SECONDJ or SECONDJ1 multiply operator
#ifndef GB_IS_SECONDJ_MULTIPLIER
#define GB_IS_SECONDJ_MULTIPLIER 0
#endif

// 1 if values of A not accessed
#ifndef GB_A_IS_PATTERN
#define GB_A_IS_PATTERN 0
#endif

// 1 if values of B not accessed
#ifndef GB_B_IS_PATTERN
#define GB_B_IS_PATTERN 0
#endif

//------------------------------------------------------------------------------
// numerical operations and assignments
//------------------------------------------------------------------------------

#if GB_IS_ANY_PAIR_SEMIRING

    //--------------------------------------------------------------------------
    // ANY_PAIR semiring: no values are accessed
    //--------------------------------------------------------------------------

    // declare a scalar of ztype
    #ifndef GB_CIJ_DECLARE
    #define GB_CIJ_DECLARE(cij)
    #endif

    // Cx [p] = t
    #ifndef GB_CIJ_WRITE
    #define GB_CIJ_WRITE(p,t)
    #endif

    // Hx [i] = t
    #ifndef GB_HX_WRITE
    #define GB_HX_WRITE(i,t)
    #endif

    // Cx [p] = Hx [i]
    #ifndef GB_CIJ_GATHER
    #define GB_CIJ_GATHER(p,i)
    #endif

    // C(i,j) += t
    #ifndef GB_CIJ_UPDATE
    #define GB_CIJ_UPDATE(p,t)
    #endif

    // Cx [p] += Hx [i]
    #ifndef GB_CIJ_GATHER_UPDATE
    #define GB_CIJ_GATHER_UPDATE(p,i)
    #endif

    // Hx [i] += t
    #ifndef GB_HX_UPDATE
    #define GB_HX_UPDATE(i,t)
    #endif

    // Cx [p:p+len-1] = Hx [i:i+len-1]
    #ifndef GB_CIJ_MEMCPY
    #define GB_CIJ_MEMCPY(p,i,len)
    #endif

    // rest of the PAIR operator
    #ifndef GB_PAIR_ONE
    #define GB_PAIR_ONE 1
    #endif

    // Zx [p] += aik * bkj where Zx is ztype
    #ifndef GB_MULTADD2
    #define GB_MULTADD2(Zx,p,a,b,i,k,j)
    #endif

#else

    //--------------------------------------------------------------------------
    // all pre-generated and JIT kernels
    //--------------------------------------------------------------------------

    // These definitions require explicit types to be used, not GB_void.
    // Generic methods using GB_void for all types, memcpy, and function
    // pointers for all computations must #define these macros first,
    // or #undef them and re-#define them.

    // declare a scalar of ztype
    #ifndef GB_CIJ_DECLARE
    #define GB_CIJ_DECLARE(cij) GB_Z_TYPE cij
    #endif

    // Cx [p] = t
    #ifndef GB_CIJ_WRITE
    #define GB_CIJ_WRITE(p,t) Cx [p] = t
    #endif

    // Hx [i] = t
    #ifndef GB_HX_WRITE
    #define GB_HX_WRITE(i,t) Hx [i] = t
    #endif

    // Cx [p] = Hx [i]
    #ifndef GB_CIJ_GATHER
    #define GB_CIJ_GATHER(p,i) Cx [p] = Hx [i]
    #endif

    // C(i,j) += t
    #ifndef GB_CIJ_UPDATE
    #define GB_CIJ_UPDATE(p,t) GB_UPDATE (Cx [p], t)
    #endif

    // Hx [i] += t
    #ifndef GB_HX_UPDATE
    #define GB_HX_UPDATE(i,t) GB_UPDATE (Hx [i], t)
    #endif

    // Cx [p] += Hx [i]
    #ifndef GB_CIJ_GATHER_UPDATE
    #define GB_CIJ_GATHER_UPDATE(p,i) GB_UPDATE (Cx [p], Hx [i])
    #endif

    // Cx [p:p+len-1] = Hx [i:i+len-1]
    #ifndef GB_CIJ_MEMCPY
    #define GB_CIJ_MEMCPY(p,i,len) \
        memcpy (Cx +(p), Hx +(i), (len) * sizeof (GB_C_TYPE))
    #endif

    // rest of the PAIR operator
    #ifndef GB_PAIR_ONE
    #define GB_PAIR_ONE ((GB_Z_TYPE) 1)
    #endif

    // Zx [p] += aik * bkj where Zx is ztype
    #ifndef GB_MULTADD2
    #define GB_MULTADD2(Zx,p,a,b,i,k,j) GB_MULTADD (Zx [p], a, b, i, k, j)
    #endif

#endif
#endif