summaryrefslogtreecommitdiff
path: root/external/clBLAS/src/library/blas/include/blas_mempat.h
blob: dfca4a6a9b465fb45d332ab7f2e6c0a0a64bf757 (plain)
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
/* ************************************************************************
 * Copyright 2013 Advanced Micro Devices, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ************************************************************************/


/*
 * Related to BLAS memory patterns
 */

#ifndef BLAS_MEMPAT_H_
#define BLAS_MEMPAT_H_

#include <clBLAS.h>
#include <mempat.h>
#include <clkern.h>
#include <kern_cache.h>

/**
 * @brief Type of internal function implementation
 */
typedef enum clblasImplementation {

    clblasDefaultGemm,           /**< Default: let the library decide what to use. */
    clblasLdsBlockGemm,          /**< Use blocked GEMM with LDS optimization. */
    clblasImageBlockGemm,        /**< Use blocked GEMM with image-based... */
    clblasBlockGemmWithCaching,  /**< Use blocked GEMM with cache-usage optimization. */
    clblasSubgroupGemmWithCaching,/**< Use subgroup GEMM with cache-usage optimization. */

    clblasDefaultTrmm,           /**< Default: let the library decide what to use. */
    clblasLdsBlockTrmm,          /**< Use blocked TRMM with LDS optimization. */
    clblasImageBlockTrmm,        /**< Use blocked TRMM with image-based... */
    clblasBlockTrmmWithCaching,  /**< Use blocked TRMM with cache-usage optimization. */
    clblasSubgroupTrmmWithCaching,/**< Use subgroup TRMM with cache-usage optimization. */

    clblasDefaultTrsm,           /**< Default: let the library decide what to use. */
    clblasLdsBlockTrsm,          /**< Use blocked TRSM with LDS optimization. */
    clblasImageBlockTrsm,        /**< Use blocked TRSM with image-based... */
    clblasBlockTrsmWithCaching,  /**< Use blocked TRSM with cache-usage optimization. */
    clblasBlockTrsmWithoutLds,

    clblasDefaultSyrk,
    clblasBlockSyrk,
    clblasSubgSyrk,

    clblasDefaultSyr2k,
    clblasBlockSyr2k,
    clblasSubgSyr2k

} clblasImplementation;

/**
 * @internal
 * @brief extra information for a memory pattern
 *        used for BLAS problem solving
 * @ingroup BLAS_SOLVERIF_SPEC
 */
typedef struct CLBLASMpatExtra {
    /** memory levels used to store blocks of matrix A */
    meml_set_t aMset;
    /** memory levels used to store blocks of matrix B */
    meml_set_t bMset;
    CLMemType mobjA;
    CLMemType mobjB;
} CLBLASMpatExtra;

/*
 * init memory patterns for the xGEMM functions
 *
 * Returns number of the initialized patterns
 */
unsigned int
initGemmMemPatterns(MemoryPattern *mempats);

/*
 * Get index of the specific xGEMM pattern
 */
int
getGemmMemPatternIndex(clblasImplementation impl);

/*
 * Get preferred xGEMM pattern
 */
clblasImplementation
getGemmPreferredPattern(void);

/*
 * init memory patterns for the xGEMV functions
 *
 * Returns number of the initialized patterns
 */
unsigned int
initGemvMemPatterns(MemoryPattern *mempats);

/*
 * Get index of the specific xGEMV pattern
 */
int
getGemvMemPatternIndex(clblasImplementation impl);

/*
 * init memory patterns for the xSYMV functions
 *
 * Returns number of the initialized patterns
 */
unsigned int
initSymvMemPatterns(MemoryPattern *mempats);

/*
 * Get index of the specific xSYMV pattern
 */
int
getSymvMemPatternIndex(clblasImplementation impl);

/*
 * init memory patterns for the xTRMM functions
 *
 * Returns number of the initialized patterns
 */
unsigned int
initTrmmMemPatterns(MemoryPattern *mempats);

/*
 * Get index of the specific xTRMM pattern
 */
int
getTrmmMemPatternIndex(clblasImplementation impl);

/*
 * Get preferred xTRMM pattern
 */
clblasImplementation
getTrmmPreferredPattern(void);

/*
 * init memory patterns for the xTRSM functions
 *
 * Returns number of the initialized patterns
 */
unsigned int
initTrsmMemPatterns(MemoryPattern *mempats);

/*
 * Get index of the specific xTRSM pattern
 */
int
getTrsmMemPatternIndex(clblasImplementation impl);

/*
 * Get preferred xTRSM pattern
 */
clblasImplementation
getTrsmPreferredPattern(void);

/*
 * init memory patterns for the xSYR2K functions
 *
 * Returns number of the initialized patterns
 */
unsigned int
initSyr2kMemPatterns(MemoryPattern *mempats);

/*
 * Get index of the specific xSYR2K pattern
 */
int
getSyr2kMemPatternIndex(clblasImplementation impl);

/*
 * init memory patterns for the xSYRK functions
 *
 * Returns number of the initialized patterns
 */
unsigned int
initSyrkMemPatterns(MemoryPattern *mempats);

/*
 * Get index of the specific xSYRK pattern
 */
int
getSyrkMemPatternIndex(clblasImplementation impl);

/*
 * init memory patters for TRMV routine
 * Returns the number of inited patterns
 */
unsigned int
initTrmvMemPatterns(MemoryPattern *mempats);

int
getTrmvMemPatternIndex(clblasImplementation impl);

/*
 * init memory patterns for TRSV TRTRI routine
 * Returns the number of inited patterns
 */
unsigned int
initTrsvMemPatterns(MemoryPattern *mempats);

int
getTrsvMemPatternIndex(clblasImplementation impl);

unsigned int
initTrsvGemvMemPatterns(MemoryPattern *mempats);

int
getTrsvGemvMemPatternIndex(clblasImplementation impl);

unsigned int
initSymmMemPatterns(MemoryPattern *mempats);

int
getSymmMemPatternIndex(clblasImplementation impl);

unsigned int
initGemmV2MemPatterns(MemoryPattern *mempats);

int
getGemmV2MemPatternIndex(clblasImplementation impl);

unsigned int
initGemmV2TailMemPatterns(MemoryPattern *mempats);

int
getGemmV2TailMemPatternIndex(clblasImplementation impl);

/*
 * init memory patterns for the xSYR functions
 *
 * Returns number of the initialized patterns
 */
unsigned int
initSyrMemPatterns(MemoryPattern *mempats);

/*
 * Get index of the specific xSYR pattern
 */
int
getSyrMemPatternIndex(clblasImplementation impl);

/*
 * init memory patterns for the xSYR2 functions
 *
 * Returns number of the initialized patterns
 */
unsigned int
initSyr2MemPatterns(MemoryPattern *mempats);

/*
 * Get index of the specific xSYR2 pattern
 */
int
getSyr2MemPatternIndex(clblasImplementation impl);


/*
 * init memory patters for GER routine
 * Returns the number of inited patterns
 */
unsigned int
initGerMemPatterns(MemoryPattern *mempats);

int
getGerMemPatternIndex(clblasImplementation impl);

unsigned int
initHerMemPatterns(MemoryPattern *mempats);

/*
 * Get index of the specific xSYR pattern
 */
int
getHerMemPatternIndex(clblasImplementation impl);

/*
 * init memory patterns for the xHER2 functions
 *
 * Returns number of the initialized patterns
 */
unsigned int
initHer2MemPatterns(MemoryPattern *mempats);

/*
 * Get index of the specific xHER2 pattern
 */
int
getHer2MemPatternIndex(clblasImplementation impl);

unsigned int
initGbmvMemPatterns(MemoryPattern *mempats);

int
getGbmvMemPatternIndex(clblasImplementation impl);

unsigned int
initSwapMemPatterns(MemoryPattern *mempats);

int
getSwapMemPatternIndex(clblasImplementation impl);

unsigned int
initScalMemPatterns(MemoryPattern *mempats);

int
getScalMemPatternIndex(clblasImplementation impl);

unsigned int
initCopyMemPatterns(MemoryPattern *mempats);

int
getCopyMemPatternIndex(clblasImplementation impl);

unsigned int
initDotMemPatterns(MemoryPattern *mempats);

int
getDotMemPatternIndex(clblasImplementation impl);

unsigned int
initAxpyMemPatterns(MemoryPattern *mempats);

int
getAxpyMemPatternIndex(clblasImplementation impl);

unsigned int
initReductionMemPatterns(MemoryPattern *mempats);

int
getReductionMemPatternIndex(clblasImplementation impl);

unsigned int
initRotgMemPatterns(MemoryPattern *mempats);

int
getRotgMemPatternIndex(clblasImplementation impl);

unsigned int
initRotmgMemPatterns(MemoryPattern *mempats);

int
getRotmgMemPatternIndex(clblasImplementation impl);

unsigned int
initRotmMemPatterns(MemoryPattern *mempats);

int
getRotmMemPatternIndex(clblasImplementation impl);

unsigned int
initiAmaxMemPatterns(MemoryPattern *mempats);

int
getiAmaxMemPatternIndex(clblasImplementation impl);

unsigned int
initNrm2MemPatterns(MemoryPattern *mempats);

int
getNrm2MemPatternIndex(clblasImplementation impl);

unsigned int
initAsumMemPatterns(MemoryPattern *mempats);

int
getAsumMemPatternIndex(clblasImplementation impl);

#endif /* BLAS_MEMPAT_H_ */