MAGMA  magma-1.4.0
Matrix Algebra on GPU and Multicore Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
magma.h
Go to the documentation of this file.
1 /*
2  -- MAGMA (version 1.4.0) --
3  Univ. of Tennessee, Knoxville
4  Univ. of California, Berkeley
5  Univ. of Colorado, Denver
6  August 2013
7 */
8 
9 #ifndef MAGMA_H
10 #define MAGMA_H
11 
12 /* ------------------------------------------------------------
13  * MAGMA BLAS Functions
14  * --------------------------------------------------------- */
15 #include "magmablas.h"
16 
17 /* ------------------------------------------------------------
18  * MAGMA functions
19  * --------------------------------------------------------- */
20 #include "magma_z.h"
21 #include "magma_c.h"
22 #include "magma_d.h"
23 #include "magma_s.h"
24 #include "magma_zc.h"
25 #include "magma_ds.h"
26 #include "auxiliary.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 // ========================================
33 // initialization
35 magma_init( void );
36 
38 magma_finalize( void );
39 
40 void magma_version( int* major, int* minor, int* micro );
41 
42 
43 // ========================================
44 // memory allocation
46 magma_malloc( magma_ptr *ptrPtr, size_t bytes );
47 
49 magma_malloc_cpu( void **ptrPtr, size_t bytes );
50 
52 magma_malloc_pinned( void **ptrPtr, size_t bytes );
53 
55 magma_free_cpu( void *ptr );
56 
57 #define magma_free( ptr ) \
58  magma_free_internal( ptr, __func__, __FILE__, __LINE__ )
59 
60 #define magma_free_pinned( ptr ) \
61  magma_free_pinned_internal( ptr, __func__, __FILE__, __LINE__ )
62 
65  magma_ptr ptr,
66  const char* func, const char* file, int line );
67 
70  void *ptr,
71  const char* func, const char* file, int line );
72 
73 
74 // type-safe convenience functions to avoid using (void**) cast and sizeof(...)
75 // here n is the number of elements (floats, doubles, etc.) not the number of bytes.
76 static inline magma_err_t magma_imalloc( magmaInt_ptr *ptrPtr, size_t n ) { return magma_malloc( (magma_ptr*) ptrPtr, n*sizeof(magma_int_t) ); }
77 static inline magma_err_t magma_smalloc( magmaFloat_ptr *ptrPtr, size_t n ) { return magma_malloc( (magma_ptr*) ptrPtr, n*sizeof(float) ); }
78 static inline magma_err_t magma_dmalloc( magmaDouble_ptr *ptrPtr, size_t n ) { return magma_malloc( (magma_ptr*) ptrPtr, n*sizeof(double) ); }
79 static inline magma_err_t magma_cmalloc( magmaFloatComplex_ptr *ptrPtr, size_t n ) { return magma_malloc( (magma_ptr*) ptrPtr, n*sizeof(magmaFloatComplex) ); }
80 static inline magma_err_t magma_zmalloc( magmaDoubleComplex_ptr *ptrPtr, size_t n ) { return magma_malloc( (magma_ptr*) ptrPtr, n*sizeof(magmaDoubleComplex) ); }
81 
82 static inline magma_err_t magma_imalloc_cpu( magma_int_t **ptrPtr, size_t n ) { return magma_malloc_cpu( (void**) ptrPtr, n*sizeof(magma_int_t) ); }
83 static inline magma_err_t magma_smalloc_cpu( float **ptrPtr, size_t n ) { return magma_malloc_cpu( (void**) ptrPtr, n*sizeof(float) ); }
84 static inline magma_err_t magma_dmalloc_cpu( double **ptrPtr, size_t n ) { return magma_malloc_cpu( (void**) ptrPtr, n*sizeof(double) ); }
85 static inline magma_err_t magma_cmalloc_cpu( magmaFloatComplex **ptrPtr, size_t n ) { return magma_malloc_cpu( (void**) ptrPtr, n*sizeof(magmaFloatComplex) ); }
86 static inline magma_err_t magma_zmalloc_cpu( magmaDoubleComplex **ptrPtr, size_t n ) { return magma_malloc_cpu( (void**) ptrPtr, n*sizeof(magmaDoubleComplex) ); }
87 
88 static inline magma_err_t magma_imalloc_pinned( magma_int_t **ptrPtr, size_t n ) { return magma_malloc_pinned( (void**) ptrPtr, n*sizeof(magma_int_t) ); }
89 static inline magma_err_t magma_smalloc_pinned( float **ptrPtr, size_t n ) { return magma_malloc_pinned( (void**) ptrPtr, n*sizeof(float) ); }
90 static inline magma_err_t magma_dmalloc_pinned( double **ptrPtr, size_t n ) { return magma_malloc_pinned( (void**) ptrPtr, n*sizeof(double) ); }
91 static inline magma_err_t magma_cmalloc_pinned( magmaFloatComplex **ptrPtr, size_t n ) { return magma_malloc_pinned( (void**) ptrPtr, n*sizeof(magmaFloatComplex) ); }
92 static inline magma_err_t magma_zmalloc_pinned( magmaDoubleComplex **ptrPtr, size_t n ) { return magma_malloc_pinned( (void**) ptrPtr, n*sizeof(magmaDoubleComplex) ); }
93 
94 
95 // ========================================
96 // device support
98 
99 void magma_getdevices(
100  magma_device_t* devices,
101  magma_int_t size,
102  magma_int_t* numPtr );
103 
104 void magma_getdevice( magma_device_t* dev );
105 
106 void magma_setdevice( magma_device_t dev );
107 
108 void magma_device_sync();
109 
110 
111 // ========================================
112 // queue support
113 #define magma_queue_create( /*device,*/ queuePtr ) \
114  magma_queue_create_internal( queuePtr, __func__, __FILE__, __LINE__ )
115 
116 #define magma_queue_destroy( queue ) \
117  magma_queue_destroy_internal( queue, __func__, __FILE__, __LINE__ )
118 
119 #define magma_queue_sync( queue ) \
120  magma_queue_sync_internal( queue, __func__, __FILE__, __LINE__ )
121 
123  /*magma_device_t device,*/ magma_queue_t* queuePtr,
124  const char* func, const char* file, int line );
125 
127  magma_queue_t queue,
128  const char* func, const char* file, int line );
129 
131  magma_queue_t queue,
132  const char* func, const char* file, int line );
133 
134 
135 // ========================================
136 // event support
137 void magma_event_create( magma_event_t* eventPtr );
138 
139 void magma_event_destroy( magma_event_t event );
140 
141 void magma_event_record( magma_event_t event, magma_queue_t queue );
142 
143 void magma_event_query( magma_event_t event );
144 
145 // blocks CPU until event occurs
146 void magma_event_sync( magma_event_t event );
147 
148 // blocks queue (but not CPU) until event occurs
149 void magma_queue_wait_event( magma_queue_t queue, magma_event_t event );
150 
151 
152 // ========================================
153 // error handler
154 void magma_xerbla( const char *name, magma_int_t info );
155 
156 const char* magma_strerror( magma_err_t error );
157 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #endif /* MAGMA_H */
static magma_err_t magma_dmalloc_pinned(double **ptrPtr, size_t n)
Definition: magma.h:90
void magma_device_sync()
magma_err_t magma_malloc_pinned(void **ptrPtr, size_t bytes)
static magma_err_t magma_imalloc_pinned(magma_int_t **ptrPtr, size_t n)
Definition: magma.h:88
static magma_err_t magma_imalloc(magmaInt_ptr *ptrPtr, size_t n)
Definition: magma.h:76
static magma_err_t magma_zmalloc(magmaDoubleComplex_ptr *ptrPtr, size_t n)
Definition: magma.h:80
void magma_event_destroy(magma_event_t event)
static magma_err_t magma_dmalloc(magmaDouble_ptr *ptrPtr, size_t n)
Definition: magma.h:78
float * magmaFloat_ptr
Definition: magma_types.h:230
static magma_err_t magma_cmalloc(magmaFloatComplex_ptr *ptrPtr, size_t n)
Definition: magma.h:79
void magma_queue_sync_internal(magma_queue_t queue, const char *func, const char *file, int line)
magmaFloatComplex * magmaFloatComplex_ptr
Definition: magma_types.h:232
int magma_int_t
Definition: magmablas.h:12
magma_err_t magma_malloc_cpu(void **ptrPtr, size_t bytes)
void * magma_ptr
Definition: magma_types.h:228
double * magmaDouble_ptr
Definition: magma_types.h:231
static magma_err_t magma_smalloc_cpu(float **ptrPtr, size_t n)
Definition: magma.h:83
void magma_queue_wait_event(magma_queue_t queue, magma_event_t event)
void magma_setdevice(magma_device_t dev)
magma_err_t magma_malloc(magma_ptr *ptrPtr, size_t bytes)
void magma_event_query(magma_event_t event)
void magma_getdevice(magma_device_t *dev)
void magma_xerbla(const char *srname, magma_int_t info)
Definition: xerbla.cpp:8
void magma_event_record(magma_event_t event, magma_queue_t queue)
void magma_queue_destroy_internal(magma_queue_t queue, const char *func, const char *file, int line)
void magma_event_sync(magma_event_t event)
magma_err_t magma_free_pinned_internal(void *ptr, const char *func, const char *file, int line)
void magma_finalize(magma_context_t *cntxt)
static magma_err_t magma_cmalloc_pinned(magmaFloatComplex **ptrPtr, size_t n)
Definition: magma.h:91
static magma_err_t magma_dmalloc_cpu(double **ptrPtr, size_t n)
Definition: magma.h:84
magma_err_t magma_free_internal(magma_ptr ptr, const char *func, const char *file, int line)
static magma_err_t magma_zmalloc_pinned(magmaDoubleComplex **ptrPtr, size_t n)
Definition: magma.h:92
static magma_err_t magma_imalloc_cpu(magma_int_t **ptrPtr, size_t n)
Definition: magma.h:82
static magma_err_t magma_smalloc(magmaFloat_ptr *ptrPtr, size_t n)
Definition: magma.h:77
static magma_err_t magma_cmalloc_cpu(magmaFloatComplex **ptrPtr, size_t n)
Definition: magma.h:85
void magma_event_create(magma_event_t *eventPtr)
void magma_getdevices(magma_device_t *devices, magma_int_t size, magma_int_t *numPtr)
magma_int_t magma_getdevice_arch()
static magma_err_t magma_zmalloc_cpu(magmaDoubleComplex **ptrPtr, size_t n)
Definition: magma.h:86
magmaDoubleComplex * magmaDoubleComplex_ptr
Definition: magma_types.h:233
void magma_version(int *major, int *minor, int *micro)
Definition: auxiliary.cpp:29
int magma_err_t
Definition: magma_types.h:23
void magma_queue_create_internal(magma_queue_t *queuePtr, const char *func, const char *file, int line)
const char * magma_strerror(magma_err_t error)
Definition: error.cpp:227
magma_context_t * magma_init(void *, void *(*func)(void *a), magma_int_t nthread, magma_int_t ncpu, magma_int_t ngpu, magma_int_t argc, char **argv)
Definition: init.cpp:27
magma_int_t * magmaInt_ptr
Definition: magma_types.h:229
magma_err_t magma_free_cpu(void *ptr)
static magma_err_t magma_smalloc_pinned(float **ptrPtr, size_t n)
Definition: magma.h:89