1function codegen_sel
2%CODEGEN_SEL create functions for all selection operators
3%
4% This function creates all files of the form GB_sel__*.c,
5% and the include file GB_sel__include.h.
6
7% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
8% SPDX-License-Identifier: Apache-2.0
9
10fprintf ('\nselection operators:\n') ;
11
12f = fopen ('Generated/GB_sel__include.h', 'w') ;
13fprintf (f, '//------------------------------------------------------------------------------\n') ;
14fprintf (f, '// GB_sel__include.h: definitions for GB_sel__*.c\n') ;
15fprintf (f, '//------------------------------------------------------------------------------\n') ;
16fprintf (f, '\n') ;
17fprintf (f, '// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.\n') ;
18fprintf (f, '// SPDX-License-Identifier: Apache-2.0\n\n') ;
19fprintf (f, '// This file has been automatically generated from Generator/GB_sel.h') ;
20fprintf (f, '\n\n') ;
21fclose (f) ;
22
23%-------------------------------------------------------------------------------
24
25% USER:
26fprintf ('\nuser       ') ;
27codegen_sel_method ('user',  ...
28    [ 'user_select (' ...
29      'flipij ? j : GBI (Ai, p, avlen), flipij ? GBI (Ai, p, avlen) : j, ' ...
30      'Ax +((p)*asize), xthunk)' ] , 'GB_void') ;
31
32% TRIL, TRIU, DIAG, OFFIDIAG, RESIZE:
33fprintf ('\ntril       ') ;
34codegen_sel_method ('tril'      , [ ], 'GB_void' , 'GB_TRIL_SELECTOR'    ) ;
35fprintf ('\ntriu       ') ;
36codegen_sel_method ('triu'      , [ ], 'GB_void' , 'GB_TRIU_SELECTOR'    ) ;
37fprintf ('\ndiag       ') ;
38codegen_sel_method ('diag'      , [ ], 'GB_void' , 'GB_DIAG_SELECTOR'    ) ;
39fprintf ('\noffdiag    ') ;
40codegen_sel_method ('offdiag'   , [ ], 'GB_void' , 'GB_OFFDIAG_SELECTOR' ) ;
41fprintf ('\nresize     ') ;
42codegen_sel_method ('resize'    , [ ], 'GB_void' , 'GB_RESIZE_SELECTOR'  ) ;
43
44% NONZOMBIE:         name         selector                     type
45% phase1: depends on Ai only, so only nonzombie_any is used
46% phase2: use all 14 workers
47fprintf ('\nnonzombie  ') ;
48codegen_sel_method ('nonzombie', 'GB_IS_NOT_ZOMBIE (Ai, p)', 'bool'      ) ;
49codegen_sel_method ('nonzombie', 'GB_IS_NOT_ZOMBIE (Ai, p)', 'int8_t'    ) ;
50codegen_sel_method ('nonzombie', 'GB_IS_NOT_ZOMBIE (Ai, p)', 'int16_t'   ) ;
51codegen_sel_method ('nonzombie', 'GB_IS_NOT_ZOMBIE (Ai, p)', 'int32_t'   ) ;
52codegen_sel_method ('nonzombie', 'GB_IS_NOT_ZOMBIE (Ai, p)', 'int64_t'   ) ;
53codegen_sel_method ('nonzombie', 'GB_IS_NOT_ZOMBIE (Ai, p)', 'uint8_t'   ) ;
54codegen_sel_method ('nonzombie', 'GB_IS_NOT_ZOMBIE (Ai, p)', 'uint16_t'  ) ;
55codegen_sel_method ('nonzombie', 'GB_IS_NOT_ZOMBIE (Ai, p)', 'uint32_t'  ) ;
56codegen_sel_method ('nonzombie', 'GB_IS_NOT_ZOMBIE (Ai, p)', 'uint64_t'  ) ;
57codegen_sel_method ('nonzombie', 'GB_IS_NOT_ZOMBIE (Ai, p)', 'float'     ) ;
58codegen_sel_method ('nonzombie', 'GB_IS_NOT_ZOMBIE (Ai, p)', 'double'    ) ;
59codegen_sel_method ('nonzombie', 'GB_IS_NOT_ZOMBIE (Ai, p)', 'GxB_FC32_t') ;
60codegen_sel_method ('nonzombie', 'GB_IS_NOT_ZOMBIE (Ai, p)', 'GxB_FC64_t') ;
61codegen_sel_method ('nonzombie', 'GB_IS_NOT_ZOMBIE (Ai, p)', 'GB_void'   ) ;
62
63% NONZERO            name         selector       type
64fprintf ('\nnonzero    ') ;
65codegen_sel_method ('nonzero'  , 'Ax [p]',      'bool'    ) ;
66codegen_sel_method ('nonzero'  , 'Ax [p] != 0', 'int8_t'  ) ;
67codegen_sel_method ('nonzero'  , 'Ax [p] != 0', 'int16_t' ) ;
68codegen_sel_method ('nonzero'  , 'Ax [p] != 0', 'int32_t' ) ;
69codegen_sel_method ('nonzero'  , 'Ax [p] != 0', 'int64_t' ) ;
70codegen_sel_method ('nonzero'  , 'Ax [p] != 0', 'uint8_t' ) ;
71codegen_sel_method ('nonzero'  , 'Ax [p] != 0', 'uint16_t') ;
72codegen_sel_method ('nonzero'  , 'Ax [p] != 0', 'uint32_t') ;
73codegen_sel_method ('nonzero'  , 'Ax [p] != 0', 'uint64_t') ;
74codegen_sel_method ('nonzero'  , 'Ax [p] != 0', 'float'   ) ;
75codegen_sel_method ('nonzero'  , 'Ax [p] != 0', 'double'  ) ;
76codegen_sel_method ('nonzero'  , 'GB_FC32_ne0 (Ax [p])', 'GxB_FC32_t') ;
77codegen_sel_method ('nonzero'  , 'GB_FC64_ne0 (Ax [p])', 'GxB_FC64_t') ;
78codegen_sel_method ('nonzero'  , ...
79                    'GB_is_nonzero (Ax +((p)*asize), asize)', 'GB_void') ;
80
81% EQ_ZERO            name         selector       type
82fprintf ('\neq_zero    ') ;
83codegen_sel_method ('eq_zero'  , '!(Ax [p])',   'bool'    ) ;
84codegen_sel_method ('eq_zero'  , 'Ax [p] == 0', 'int8_t'  ) ;
85codegen_sel_method ('eq_zero'  , 'Ax [p] == 0', 'int16_t' ) ;
86codegen_sel_method ('eq_zero'  , 'Ax [p] == 0', 'int32_t' ) ;
87codegen_sel_method ('eq_zero'  , 'Ax [p] == 0', 'int64_t' ) ;
88codegen_sel_method ('eq_zero'  , 'Ax [p] == 0', 'uint8_t' ) ;
89codegen_sel_method ('eq_zero'  , 'Ax [p] == 0', 'uint16_t') ;
90codegen_sel_method ('eq_zero'  , 'Ax [p] == 0', 'uint32_t') ;
91codegen_sel_method ('eq_zero'  , 'Ax [p] == 0', 'uint64_t') ;
92codegen_sel_method ('eq_zero'  , 'Ax [p] == 0', 'float'   ) ;
93codegen_sel_method ('eq_zero'  , 'Ax [p] == 0', 'double'  ) ;
94codegen_sel_method ('eq_zero'  , 'GB_FC32_eq0 (Ax [p])', 'GxB_FC32_t') ;
95codegen_sel_method ('eq_zero'  , 'GB_FC64_eq0 (Ax [p])', 'GxB_FC64_t') ;
96codegen_sel_method ('eq_zero'  , ...
97                    '!GB_is_nonzero (Ax +((p)*asize), asize)', 'GB_void') ;
98
99% GT_ZERO            name         selector       type
100fprintf ('\ngt_zero    ') ;
101codegen_sel_method ('gt_zero'  , 'Ax [p] > 0', 'int8_t'  ) ;
102codegen_sel_method ('gt_zero'  , 'Ax [p] > 0', 'int16_t' ) ;
103codegen_sel_method ('gt_zero'  , 'Ax [p] > 0', 'int32_t' ) ;
104codegen_sel_method ('gt_zero'  , 'Ax [p] > 0', 'int64_t' ) ;
105codegen_sel_method ('gt_zero'  , 'Ax [p] > 0', 'float'   ) ;
106codegen_sel_method ('gt_zero'  , 'Ax [p] > 0', 'double'  ) ;
107
108% GE_ZERO            name         selector       type
109fprintf ('\nge_zero    ') ;
110codegen_sel_method ('ge_zero'  , 'Ax [p] >= 0', 'int8_t'  ) ;
111codegen_sel_method ('ge_zero'  , 'Ax [p] >= 0', 'int16_t' ) ;
112codegen_sel_method ('ge_zero'  , 'Ax [p] >= 0', 'int32_t' ) ;
113codegen_sel_method ('ge_zero'  , 'Ax [p] >= 0', 'int64_t' ) ;
114codegen_sel_method ('ge_zero'  , 'Ax [p] >= 0', 'float'   ) ;
115codegen_sel_method ('ge_zero'  , 'Ax [p] >= 0', 'double'  ) ;
116
117% LT_ZERO            name         selector       type
118fprintf ('\nlt_zero    ') ;
119codegen_sel_method ('lt_zero'  , 'Ax [p] < 0', 'int8_t'  ) ;
120codegen_sel_method ('lt_zero'  , 'Ax [p] < 0', 'int16_t' ) ;
121codegen_sel_method ('lt_zero'  , 'Ax [p] < 0', 'int32_t' ) ;
122codegen_sel_method ('lt_zero'  , 'Ax [p] < 0', 'int64_t' ) ;
123codegen_sel_method ('lt_zero'  , 'Ax [p] < 0', 'float'   ) ;
124codegen_sel_method ('lt_zero'  , 'Ax [p] < 0', 'double'  ) ;
125
126% LE_ZERO            name         selector       type
127fprintf ('\nle_zero    ') ;
128codegen_sel_method ('le_zero'  , 'Ax [p] <= 0', 'int8_t'  ) ;
129codegen_sel_method ('le_zero'  , 'Ax [p] <= 0', 'int16_t' ) ;
130codegen_sel_method ('le_zero'  , 'Ax [p] <= 0', 'int32_t' ) ;
131codegen_sel_method ('le_zero'  , 'Ax [p] <= 0', 'int64_t' ) ;
132codegen_sel_method ('le_zero'  , 'Ax [p] <= 0', 'float'   ) ;
133codegen_sel_method ('le_zero'  , 'Ax [p] <= 0', 'double'  ) ;
134
135% NE_THUNK           name         selector            type
136fprintf ('\nne_thunk   ') ;
137codegen_sel_method ('ne_thunk'  , 'Ax [p] != thunk', 'int8_t'  ) ;
138codegen_sel_method ('ne_thunk'  , 'Ax [p] != thunk', 'int16_t' ) ;
139codegen_sel_method ('ne_thunk'  , 'Ax [p] != thunk', 'int32_t' ) ;
140codegen_sel_method ('ne_thunk'  , 'Ax [p] != thunk', 'int64_t' ) ;
141codegen_sel_method ('ne_thunk'  , 'Ax [p] != thunk', 'uint8_t' ) ;
142codegen_sel_method ('ne_thunk'  , 'Ax [p] != thunk', 'uint16_t') ;
143codegen_sel_method ('ne_thunk'  , 'Ax [p] != thunk', 'uint32_t') ;
144codegen_sel_method ('ne_thunk'  , 'Ax [p] != thunk', 'uint64_t') ;
145codegen_sel_method ('ne_thunk'  , 'Ax [p] != thunk', 'float'   ) ;
146codegen_sel_method ('ne_thunk'  , 'Ax [p] != thunk', 'double'  ) ;
147codegen_sel_method ('ne_thunk'  , 'GB_FC32_ne (Ax [p], thunk)', 'GxB_FC32_t') ;
148codegen_sel_method ('ne_thunk'  , 'GB_FC64_ne (Ax [p], thunk)', 'GxB_FC64_t') ;
149codegen_sel_method ('ne_thunk'  , ...
150                    'memcmp (Ax +((p)*asize), xthunk, asize) != 0', 'GB_void') ;
151
152% EQ_THUNK           name         selector            type
153fprintf ('\neq_thunk   ') ;
154codegen_sel_method ('eq_thunk'  , 'Ax [p] == thunk', 'int8_t'  ) ;
155codegen_sel_method ('eq_thunk'  , 'Ax [p] == thunk', 'int16_t' ) ;
156codegen_sel_method ('eq_thunk'  , 'Ax [p] == thunk', 'int32_t' ) ;
157codegen_sel_method ('eq_thunk'  , 'Ax [p] == thunk', 'int64_t' ) ;
158codegen_sel_method ('eq_thunk'  , 'Ax [p] == thunk', 'uint8_t' ) ;
159codegen_sel_method ('eq_thunk'  , 'Ax [p] == thunk', 'uint16_t') ;
160codegen_sel_method ('eq_thunk'  , 'Ax [p] == thunk', 'uint32_t') ;
161codegen_sel_method ('eq_thunk'  , 'Ax [p] == thunk', 'uint64_t') ;
162codegen_sel_method ('eq_thunk'  , 'Ax [p] == thunk', 'float'   ) ;
163codegen_sel_method ('eq_thunk'  , 'Ax [p] == thunk', 'double'  ) ;
164codegen_sel_method ('eq_thunk'  , 'GB_FC32_eq (Ax [p], thunk)', 'GxB_FC32_t') ;
165codegen_sel_method ('eq_thunk'  , 'GB_FC64_eq (Ax [p], thunk)', 'GxB_FC64_t') ;
166codegen_sel_method ('eq_thunk'  , ...
167                    'memcmp (Ax +((p)*asize), xthunk, asize) == 0', 'GB_void') ;
168
169% GT_THUNK           name         selector            type
170fprintf ('\ngt_thunk   ') ;
171codegen_sel_method ('gt_thunk'  , 'Ax [p] > thunk', 'int8_t'  ) ;
172codegen_sel_method ('gt_thunk'  , 'Ax [p] > thunk', 'int16_t' ) ;
173codegen_sel_method ('gt_thunk'  , 'Ax [p] > thunk', 'int32_t' ) ;
174codegen_sel_method ('gt_thunk'  , 'Ax [p] > thunk', 'int64_t' ) ;
175codegen_sel_method ('gt_thunk'  , 'Ax [p] > thunk', 'uint8_t' ) ;
176codegen_sel_method ('gt_thunk'  , 'Ax [p] > thunk', 'uint16_t') ;
177codegen_sel_method ('gt_thunk'  , 'Ax [p] > thunk', 'uint32_t') ;
178codegen_sel_method ('gt_thunk'  , 'Ax [p] > thunk', 'uint64_t') ;
179codegen_sel_method ('gt_thunk'  , 'Ax [p] > thunk', 'float'   ) ;
180codegen_sel_method ('gt_thunk'  , 'Ax [p] > thunk', 'double'  ) ;
181
182% GE_THUNK           name         selector            type
183fprintf ('\nge_thunk   ') ;
184codegen_sel_method ('ge_thunk'  , 'Ax [p] >= thunk', 'int8_t'  ) ;
185codegen_sel_method ('ge_thunk'  , 'Ax [p] >= thunk', 'int16_t' ) ;
186codegen_sel_method ('ge_thunk'  , 'Ax [p] >= thunk', 'int32_t' ) ;
187codegen_sel_method ('ge_thunk'  , 'Ax [p] >= thunk', 'int64_t' ) ;
188codegen_sel_method ('ge_thunk'  , 'Ax [p] >= thunk', 'uint8_t' ) ;
189codegen_sel_method ('ge_thunk'  , 'Ax [p] >= thunk', 'uint16_t') ;
190codegen_sel_method ('ge_thunk'  , 'Ax [p] >= thunk', 'uint32_t') ;
191codegen_sel_method ('ge_thunk'  , 'Ax [p] >= thunk', 'uint64_t') ;
192codegen_sel_method ('ge_thunk'  , 'Ax [p] >= thunk', 'float'   ) ;
193codegen_sel_method ('ge_thunk'  , 'Ax [p] >= thunk', 'double'  ) ;
194
195% LT_THUNK           name         selector            type
196fprintf ('\nlt_thunk   ') ;
197codegen_sel_method ('lt_thunk'  , 'Ax [p] < thunk', 'int8_t'  ) ;
198codegen_sel_method ('lt_thunk'  , 'Ax [p] < thunk', 'int16_t' ) ;
199codegen_sel_method ('lt_thunk'  , 'Ax [p] < thunk', 'int32_t' ) ;
200codegen_sel_method ('lt_thunk'  , 'Ax [p] < thunk', 'int64_t' ) ;
201codegen_sel_method ('lt_thunk'  , 'Ax [p] < thunk', 'uint8_t' ) ;
202codegen_sel_method ('lt_thunk'  , 'Ax [p] < thunk', 'uint16_t') ;
203codegen_sel_method ('lt_thunk'  , 'Ax [p] < thunk', 'uint32_t') ;
204codegen_sel_method ('lt_thunk'  , 'Ax [p] < thunk', 'uint64_t') ;
205codegen_sel_method ('lt_thunk'  , 'Ax [p] < thunk', 'float'   ) ;
206codegen_sel_method ('lt_thunk'  , 'Ax [p] < thunk', 'double'  ) ;
207
208% LE_THUNK           name         selector            type
209fprintf ('\nle_thunk   ') ;
210codegen_sel_method ('le_thunk'  , 'Ax [p] <= thunk', 'int8_t'  ) ;
211codegen_sel_method ('le_thunk'  , 'Ax [p] <= thunk', 'int16_t' ) ;
212codegen_sel_method ('le_thunk'  , 'Ax [p] <= thunk', 'int32_t' ) ;
213codegen_sel_method ('le_thunk'  , 'Ax [p] <= thunk', 'int64_t' ) ;
214codegen_sel_method ('le_thunk'  , 'Ax [p] <= thunk', 'uint8_t' ) ;
215codegen_sel_method ('le_thunk'  , 'Ax [p] <= thunk', 'uint16_t') ;
216codegen_sel_method ('le_thunk'  , 'Ax [p] <= thunk', 'uint32_t') ;
217codegen_sel_method ('le_thunk'  , 'Ax [p] <= thunk', 'uint64_t') ;
218codegen_sel_method ('le_thunk'  , 'Ax [p] <= thunk', 'float'   ) ;
219codegen_sel_method ('le_thunk'  , 'Ax [p] <= thunk', 'double'  ) ;
220
221fprintf ('\n') ;
222
223