PLASMA 2.8.0 PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures

- Main Page
- Modules
- Data Types List

descriptor.h
1
14 #ifndef _PLASMA_DESCRIPTOR_H_
15 #define _PLASMA_DESCRIPTOR_H_
16
17 #include <stdio.h>
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
41 typedef struct plasma_desc_t {
42 void *mat;
43 size_t A21;
44 size_t A12;
45 size_t A22;
46 PLASMA_enum dtyp;
47 int mb;
48 int nb;
49 int bsiz;
50 int lm;
51 int ln;
52 int lm1;
53 int ln1;
54 int lmt;
55 int lnt;
56 int i;
57 int j;
58 int m;
59 int n;
60 int mt;
61 int nt;
62 } PLASMA_desc;
63
64
65 /***************************************************************************/
68 PLASMA_desc plasma_desc_init(PLASMA_enum dtyp, int mb, int nb, int bsiz,
69 int lm, int ln, int i, int j, int m, int n);
70 PLASMA_desc plasma_desc_submatrix(PLASMA_desc descA, int i, int j, int m, int n);
71
72
73 static inline int plasma_element_size(int type)
74 {
75 switch(type) {
76 case PlasmaByte: return 1;
77 case PlasmaInteger: return sizeof(int);
78 case PlasmaRealFloat: return sizeof(float);
79 case PlasmaRealDouble: return sizeof(double);
80 case PlasmaComplexFloat: return 2*sizeof(float);
81 case PlasmaComplexDouble: return 2*sizeof(double);
82 default:
83 fprintf(stderr, "plasma_element_size: invalide type parameter\n");
84 return -1;
85 }
86 }
87
88 /***************************************************************************/
91 inline static void *plasma_getaddr(PLASMA_desc A, int m, int n)
92 {
93 size_t mm = m+A.i/A.mb;
94 size_t nn = n+A.j/A.nb;
95 size_t eltsize = plasma_element_size(A.dtyp);
96 size_t offset = 0;
97
98 if (mm < (size_t)(A.lm1)) {
99 if (nn < (size_t)(A.ln1))
100 offset = A.bsiz*(mm + (size_t)A.lm1 * nn);
101 else
102 offset = A.A12 + ((size_t)A.mb * (A.ln%A.nb) * mm);
103 }
104 else {
105 if (nn < (size_t)(A.ln1))
106 offset = A.A21 + ((size_t)A.nb * (A.lm%A.mb) * nn);
107 else
108 offset = A.A22;
109 }
110
111 return (void*)((char*)A.mat + (offset*eltsize) );
112 }
113
114 /***************************************************************************/
117 inline static void *plasma_geteltaddr( const PLASMA_desc *A, int m, int n, int eltsize)
118 {
119 size_t mm = m/A->mb;
120 size_t nn = n/A->nb;
121 size_t offset = 0;
122
123 if (mm < (size_t)(A->lm1)) {
124 if (nn < (size_t)(A->ln1))
125 offset = A->bsiz*(mm+A->lm1*nn) + m%A->mb + A->mb * (size_t)(n%A->nb);
126 else
127 offset = A->A12 + (A->mb*(A->ln%A->nb)*mm) + m%A->mb + A->mb * (size_t)(n%A->nb);
128 }
129 else {
130 if (nn < (size_t)(A->ln1))
131 offset = A->A21 + ((A->lm%A->mb)*A->nb*nn) + m%A->mb + (A->lm%A->mb) * (size_t)(n%A->nb);
132 else
133 offset = A->A22 + m%A->mb + (A->lm%A->mb) * (size_t)(n%A->nb);
134 }
135 return (void*)((char*)A->mat + (offset*eltsize) );
136 }
137
138 #ifdef __cplusplus
139 }
140 #endif
141
142 #endif
plasma_desc_t::nt
int nt
Definition: descriptor.h:61
plasma_desc_t::A21
size_t A21
Definition: descriptor.h:43
plasma_desc_t::m
int m
Definition: descriptor.h:58
plasma_desc_t::mb
int mb
Definition: descriptor.h:47
plasma_desc_t::ln
int ln
Definition: descriptor.h:51
plasma_desc_t::j
int j
Definition: descriptor.h:57
plasma_desc_t::lnt
int lnt
Definition: descriptor.h:55
plasma_desc_t::bsiz
int bsiz
Definition: descriptor.h:49
plasma_desc_t::lmt
int lmt
Definition: descriptor.h:54
plasma_desc_t::dtyp
PLASMA_enum dtyp
Definition: descriptor.h:46
plasma_desc_t::mt
int mt
Definition: descriptor.h:60
plasma_desc_t::n
int n
Definition: descriptor.h:59
plasma_desc_t::lm1
int lm1
Definition: descriptor.h:52
plasma_desc_t::ln1
int ln1
Definition: descriptor.h:53
plasma_desc_t::nb
int nb
Definition: descriptor.h:48
plasma_desc_t::A12
size_t A12
Definition: descriptor.h:44
plasma_desc_t::i
int i
Definition: descriptor.h:56
plasma_desc_t::lm
int lm
Definition: descriptor.h:50
plasma_desc_t::A22
size_t A22
Definition: descriptor.h:45
plasma_desc_t
Definition: descriptor.h:41
plasma_desc_t::mat
void * mat
Definition: descriptor.h:42