File: GB_sort.h

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, 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 (286 lines) | stat: -rw-r--r-- 8,998 bytes parent folder | download | duplicates (2)
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
//------------------------------------------------------------------------------
// GB_sort.h: definitions for sorting functions
//------------------------------------------------------------------------------

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

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

// All of the GB_qsort_* functions are single-threaded, by design.  The
// GB_msort_* functions are parallel.  None of these sorting methods are
// guaranteed to be stable, but they are always used in GraphBLAS with unique
// keys, so they do not have to be stable.

#ifndef GB_SORT_H
#define GB_SORT_H

#include "GB.h"
#include "sort/include/GB_sort_kernels.h"
#define GB_MSORT_BASECASE (2*1024)

void GB_qsort_1b_32_generic // sort array A of size 2-by-n, using A0: 32 bit
(
    uint32_t *restrict A_0,     // size n array
    GB_void *restrict A_1,      // size n array
    const size_t xsize,         // size of entries in A_1
    const int64_t n
) ;

void GB_qsort_1b_64_generic // sort array A of size 2-by-n, using A0: 64 bit
(
    uint64_t *restrict A_0,     // size n array
    GB_void *restrict A_1,      // size n array
    const size_t xsize,         // size of entries in A_1
    const int64_t n
) ;

void GB_qsort_1b_32_size1  // GB_qsort_1b, A1 with sizeof = 1, A0: 32 bit
(
    uint32_t *restrict A_0,     // size n array
    uint8_t *restrict A_1,      // size n array
    const int64_t n
) ;

void GB_qsort_1b_64_size1  // GB_qsort_1b, A1 with sizeof = 1, A0: 64 bit
(
    uint64_t *restrict A_0,     // size n array
    uint8_t *restrict A_1,      // size n array
    const int64_t n
) ;

void GB_qsort_1b_32_size2  // GB_qsort_1b, A1 with sizeof = 2, A0: 32 bit
(
    uint32_t *restrict A_0,     // size n array
    uint16_t *restrict A_1,     // size n array
    const int64_t n
) ;

void GB_qsort_1b_64_size2  // GB_qsort_1b, A1 with sizeof = 2, A0: 64 bit
(
    uint64_t *restrict A_0,     // size n array
    uint16_t *restrict A_1,     // size n array
    const int64_t n
) ;

void GB_qsort_1b_32_size4  // GB_qsort_1b, A1 with sizeof = 4, A0: 32 bit
(
    uint32_t *restrict A_0,     // size n array
    uint32_t *restrict A_1,     // size n array
    const int64_t n
) ;

void GB_qsort_1b_64_size4  // GB_qsort_1b, A1 with sizeof = 4, A0: 64 bit
(
    uint64_t *restrict A_0,     // size n array
    uint32_t *restrict A_1,     // size n array
    const int64_t n
) ;

void GB_qsort_1b_32_size8  // GB_qsort_1b, A_1 with sizeof = 8, A0: 32 bit
(
    uint32_t *restrict A_0,     // size n array
    uint64_t *restrict A_1,     // size n array
    const int64_t n
) ;

void GB_qsort_1b_64_size8  // GB_qsort_1b, A_1 with sizeof = 8, A0: 64 bit
(
    uint64_t *restrict A_0,     // size n array
    uint64_t *restrict A_1,     // size n array
    const int64_t n
) ;

void GB_qsort_1b_32_size16 // GB_qsort_1b, A_1 with sizeof = 16, A0: 64 bit
(
    uint32_t *restrict A_0,     // size n array
    GB_blob16 *restrict A_1,    // size n array
    const int64_t n
) ;

void GB_qsort_1b_64_size16 // GB_qsort_1b, A_1 with sizeof = 16, A0: 64 bit
(
    uint64_t *restrict A_0,     // size n array
    GB_blob16 *restrict A_1,    // size n array
    const int64_t n
) ;

void GB_qsort_1_32
(
    uint32_t *restrict A_0,     // size n array
    const int64_t n
) ;

void GB_qsort_1_64
(
    uint64_t *restrict A_0,     // size n array
    const int64_t n
) ;

void GB_qsort_1
(
    void *restrict A_0,         // size n array
    bool A0_is_32,              // if true: A_0 is 32-bit; else 64-bit
    const int64_t n
) ;

void GB_qsort_2_64_64   // sort A of size 2-by-n, A0: 64bit, A1: 64bit
(
    uint64_t *restrict A_0,     // size n array
    uint64_t *restrict A_1,     // size n array
    const int64_t n
) ;

void GB_qsort_2_32_64   // sort A of size 2-by-n, A0: 32bit, A1: 64bit
(
    uint32_t *restrict A_0,     // size n array
    uint64_t *restrict A_1,     // size n array
    const int64_t n
) ;

void GB_qsort_2_64_32   // sort A of size 2-by-n, A0: 64bit, A1: 32bit
(
    uint64_t *restrict A_0,     // size n array
    uint32_t *restrict A_1,     // size n array
    const int64_t n
) ;

void GB_qsort_2_32_32   // sort A of size 2-by-n, A0: 32bit, A1: 32bit
(
    uint32_t *restrict A_0,     // size n array
    uint32_t *restrict A_1,     // size n array
    const int64_t n
) ;

void GB_qsort_2     // sort array A of size 2-by-n, using 2 keys (A [0:1][])
(
    void *restrict A_0,         // size n array
    bool A0_is_32,              // if true: A_0 is uint32, false: uint64
    void *restrict A_1,         // size n array
    bool A1_is_32,              // if true: A_1 is uint32, false: uint64
    const int64_t n
) ;

void GB_qsort_3_32_32_32 // sort A of size 3-by-n, A0: 32bit, A1: 32, A2: 32
(
    uint32_t *restrict A_0,     // size n array
    uint32_t *restrict A_1,     // size n array
    uint32_t *restrict A_2,     // size n array
    const int64_t n
) ;

void GB_qsort_3_32_32_64 // sort A of size 3-by-n, A0: 32bit, A1: 32, A2: 64
(
    uint32_t *restrict A_0,     // size n array
    uint32_t *restrict A_1,     // size n array
    uint64_t *restrict A_2,     // size n array
    const int64_t n
) ;

void GB_qsort_3_32_64_32 // sort A of size 3-by-n, A0: 32bit, A1: 64, A2: 32
(
    uint32_t *restrict A_0,     // size n array
    uint64_t *restrict A_1,     // size n array
    uint32_t *restrict A_2,     // size n array
    const int64_t n
) ;

void GB_qsort_3_32_64_64 // sort A of size 3-by-n, A0: 32bit, A1: 64, A2: 64
(
    uint32_t *restrict A_0,     // size n array
    uint64_t *restrict A_1,     // size n array
    uint64_t *restrict A_2,     // size n array
    const int64_t n
) ;

void GB_qsort_3_64_32_32 // sort A of size 3-by-n, A0: 64bit, A1: 32, A2: 32
(
    uint64_t *restrict A_0,     // size n array
    uint32_t *restrict A_1,     // size n array
    uint32_t *restrict A_2,     // size n array
    const int64_t n
) ;

void GB_qsort_3_64_32_64 // sort A of size 3-by-n, A0: 64bit, A1: 32, A2: 64
(
    uint64_t *restrict A_0,     // size n array
    uint32_t *restrict A_1,     // size n array
    uint64_t *restrict A_2,     // size n array
    const int64_t n
) ;

void GB_qsort_3_64_64_32 // sort A of size 3-by-n, A0: 64bit, A1: 64, A2: 32
(
    uint64_t *restrict A_0,     // size n array
    uint64_t *restrict A_1,     // size n array
    uint32_t *restrict A_2,     // size n array
    const int64_t n
) ;

void GB_qsort_3_64_64_64 // sort A of size 3-by-n, A0: 64bit, A1: 64, A2: 64
(
    uint64_t *restrict A_0,     // size n array
    uint64_t *restrict A_1,     // size n array
    uint64_t *restrict A_2,     // size n array
    const int64_t n
) ;

void GB_qsort_3     // sort array A of size 3-by-n, using 3 keys (A [0:2][])
(
    void *restrict A_0,         // size n array
    bool A0_is_32,              // if true: A_0 is uint32, false: uint64
    void *restrict A_1,         // size n array
    bool A1_is_32,              // if true: A_1 is uint32, false: uint64
    void *restrict A_2,         // size n array
    bool A2_is_32,              // if true: A_1 is uint32, false: uint64
    const int64_t n
) ;

GrB_Info GB_msort_1     // sort array A of size 1-by-n
(
    void *restrict A_0,         // size n array
    bool A0_is_32,              // if true: A_0 is uint32, else uint64
    const int64_t n,
    int nthreads_max            // max # of threads to use
) ;

GrB_Info GB_msort_2     // sort array A of size 2-by-n
(
    void *restrict A_0,         // size n array
    bool A0_is_32,              // if true: A_0 is uint32, else uint64
    void *restrict A_1,         // size n array
    bool A1_is_32,              // if true: A_1 is uint32, else uint64
    const int64_t n,
    int nthreads_max            // max # of threads to use
) ;

GrB_Info GB_msort_3     // sort array A of size 3-by-n
(
    void *restrict A_0,         // size n array
    bool A0_is_32,              // if true: A_0 is uint32, else uint64
    void *restrict A_1,         // size n array
    bool A1_is_32,              // if true: A_1 is uint32, else uint64
    void *restrict A_2,         // size n array
    bool A2_is_32,              // if true: A_2 is uint32, else uint64
    const int64_t n,
    int nthreads_max            // max # of threads to use
) ;

//------------------------------------------------------------------------------
// matrix sorting (for GxB_Matrix_sort and GxB_Vector_sort)
//------------------------------------------------------------------------------

GrB_Info GB_sort
(
    // output:
    GrB_Matrix C,               // matrix with sorted vectors on output
    GrB_Matrix P,               // matrix with permutations on output
    // input:
    GrB_BinaryOp op,            // comparator for the sort
    GrB_Matrix A,               // matrix to sort
    const bool A_transpose,     // false: sort each row, true: sort each column
    GB_Werk Werk
) ;

#endif