-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmagma.h
187 lines (139 loc) · 6.82 KB
/
magma.h
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
/*
-- MAGMA (version 1.1) --
Univ. of Tennessee, Knoxville
Univ. of California, Berkeley
Univ. of Colorado, Denver
@date
*/
#ifndef MAGMA_H
#define MAGMA_H
#include <math.h> // for sqrt, sqrtf
#include <vector>
/* ------------------------------------------------------------
* MAGMA BLAS Functions
* --------------------------------------------------------- */
#include "magmablas.h"
/* ------------------------------------------------------------
* MAGMA functions
* --------------------------------------------------------- */
#include "magma_z.h"
#include "magma_c.h"
#include "magma_d.h"
#include "magma_s.h"
#include "magma_zc.h"
#include "magma_ds.h"
#include "auxiliary.h"
#ifdef __cplusplus
extern "C" {
#endif
/* ////////////////////////////////////////////////////////////////////////////
-- MAGMA Auxiliary functions to get the NB used
*/
magma_int_t magma_get_smlsize_divideconquer();
// ========================================
// initialization
magma_int_t
magma_init( void );
magma_int_t
magma_init_1(std::vector<cl_device_id> devices, cl_context context);
magma_int_t
magma_init_opencl( cl_platform_id platform, cl_context context, magma_int_t setup_clBlas );
magma_int_t
magma_finalize( void );
magma_int_t
magma_finalize_opencl( magma_int_t finalize_clBlas );
void magma_version( magma_int_t* major, magma_int_t* minor, magma_int_t* micro );
// ========================================
// memory allocation
magma_int_t
magma_malloc( magma_ptr *ptrPtr, size_t bytes );
magma_int_t
magma_malloc_cpu( void **ptrPtr, size_t bytes );
//magma_int_t
//magma_malloc_pinned( void **ptrPtr, size_t bytes );
magma_int_t
magma_free( magma_ptr ptr );
magma_int_t
magma_free_cpu( void *ptr );
//magma_int_t
//magma_free_pinned( void *ptr );
// type-safe convenience functions to avoid using (void**) cast and sizeof(...)
// here n is the number of elements (floats, doubles, etc.) not the number of bytes.
static inline magma_int_t magma_imalloc( magmaInt_ptr *ptrPtr, size_t n ) { return magma_malloc( (magma_ptr*) ptrPtr, n*sizeof(magma_int_t) ); }
static inline magma_int_t magma_index_malloc( magmaIndex_ptr *ptrPtr, size_t n ) { return magma_malloc( (magma_ptr*) ptrPtr, n*sizeof(magma_index_t) ); }
static inline magma_int_t magma_smalloc( magmaFloat_ptr *ptrPtr, size_t n ) { return magma_malloc( (magma_ptr*) ptrPtr, n*sizeof(float) ); }
static inline magma_int_t magma_dmalloc( magmaDouble_ptr *ptrPtr, size_t n ) { return magma_malloc( (magma_ptr*) ptrPtr, n*sizeof(double) ); }
static inline magma_int_t magma_cmalloc( magmaFloatComplex_ptr *ptrPtr, size_t n ) { return magma_malloc( (magma_ptr*) ptrPtr, n*sizeof(magmaFloatComplex) ); }
static inline magma_int_t magma_zmalloc( magmaDoubleComplex_ptr *ptrPtr, size_t n ) { return magma_malloc( (magma_ptr*) ptrPtr, n*sizeof(magmaDoubleComplex) ); }
static inline magma_int_t magma_imalloc_cpu( magma_int_t **ptrPtr, size_t n ) { return magma_malloc_cpu( (void**) ptrPtr, n*sizeof(magma_int_t) ); }
static inline magma_int_t magma_index_malloc_cpu( magma_index_t **ptrPtr, size_t n ) { return magma_malloc_cpu( (void**) ptrPtr, n*sizeof(magma_index_t) ); }
static inline magma_int_t magma_smalloc_cpu( float **ptrPtr, size_t n ) { return magma_malloc_cpu( (void**) ptrPtr, n*sizeof(float) ); }
static inline magma_int_t magma_dmalloc_cpu( double **ptrPtr, size_t n ) { return magma_malloc_cpu( (void**) ptrPtr, n*sizeof(double) ); }
static inline magma_int_t magma_cmalloc_cpu( magmaFloatComplex **ptrPtr, size_t n ) { return magma_malloc_cpu( (void**) ptrPtr, n*sizeof(magmaFloatComplex) ); }
static inline magma_int_t magma_zmalloc_cpu( magmaDoubleComplex **ptrPtr, size_t n ) { return magma_malloc_cpu( (void**) ptrPtr, n*sizeof(magmaDoubleComplex) ); }
//static inline magma_int_t magma_imalloc_pinned( magma_int_t **ptrPtr, size_t n ) { return magma_malloc_pinned( (void**) ptrPtr, n*sizeof(magma_int_t) ); }
//static inline magma_int_t magma_index_malloc_pinned( magma_index_t **ptrPtr, size_t n ) { return magma_malloc_pinned( (void**) ptrPtr, n*sizeof(magma_index_t) ); }
//static inline magma_int_t magma_smalloc_pinned( float **ptrPtr, size_t n ) { return magma_malloc_pinned( (void**) ptrPtr, n*sizeof(float) ); }
//static inline magma_int_t magma_dmalloc_pinned( double **ptrPtr, size_t n ) { return magma_malloc_pinned( (void**) ptrPtr, n*sizeof(double) ); }
//static inline magma_int_t magma_cmalloc_pinned( magmaFloatComplex **ptrPtr, size_t n ) { return magma_malloc_pinned( (void**) ptrPtr, n*sizeof(magmaFloatComplex) ); }
//static inline magma_int_t magma_zmalloc_pinned( magmaDoubleComplex **ptrPtr, size_t n ) { return magma_malloc_pinned( (void**) ptrPtr, n*sizeof(magmaDoubleComplex) ); }
// ========================================
// device support
magma_int_t
magma_getdevices(
magma_device_t* devices,
magma_int_t size,
magma_int_t* numPtr );
// ========================================
// queue support
magma_int_t
magma_queue_meminfo(magma_queue_t queue );
magma_int_t
magma_queue_create( magma_device_t device, magma_queue_t* queuePtr );
magma_int_t
magma_queue_destroy( magma_queue_t queue );
magma_int_t
magma_queue_sync( magma_queue_t queue );
// ========================================
// event support
magma_int_t
magma_setevent( magma_event_t* eventPtr );
magma_int_t
magma_event_create( magma_event_t* eventPtr );
magma_int_t
magma_event_destroy( magma_event_t event );
magma_int_t
magma_event_record( magma_event_t event, magma_queue_t queue );
magma_int_t
magma_event_query( magma_event_t event );
magma_int_t
magma_event_sync( magma_event_t event );
// ========================================
// error handler
void magma_xerbla( const char *name, magma_int_t info );
const char* magma_strerror( magma_int_t error );
// ========================================
/// For integers x >= 0, y > 0, returns ceil( x/y ).
/// For x == 0, this is 0.
static inline magma_int_t magma_ceildiv( magma_int_t x, magma_int_t y )
{
return (x + y - 1)/y;
}
/// For integers x >= 0, y > 0, returns x rounded up to multiple of y.
/// For x == 0, this is 0.
/// This implementation does not assume y is a power of 2.
static inline magma_int_t magma_roundup( magma_int_t x, magma_int_t y )
{
return magma_ceildiv( x, y ) * y;
}
// ========================================
// real and complex square root
// sqrt alone cannot be caught by the generation script because of tsqrt
static inline float magma_ssqrt( float x ) { return sqrtf( x ); }
static inline double magma_dsqrt( double x ) { return sqrt( x ); }
magmaFloatComplex magma_csqrt( magmaFloatComplex x );
magmaDoubleComplex magma_zsqrt( magmaDoubleComplex x );
#ifdef __cplusplus
}
#endif
#endif /* MAGMA_H */