PLASMA: /home/mathieu/svn/plasma/trunk/tools/plasma_2.5.0/control/descriptor.h Source File

PLASMA 2.4.6

- Main Page
- Modules
- Data Types List

All Data Structures Functions Groups
descriptor.h
1
14 #ifndef _PLASMA_DESCRIPTOR_H_
15 #define _PLASMA_DESCRIPTOR_H_
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 /***************************************************************************/
24 inline static void *plasma_geteltaddr( const PLASMA_desc *A, int m, int n, int eltsize);
25 inline static void *plasma_getaddr(PLASMA_desc A, int m, int n);
26 PLASMA_desc plasma_desc_init(PLASMA_enum dtyp, int mb, int nb, int bsiz, int lm, int ln, int i, int j, int m, int n);
27 PLASMA_desc plasma_desc_submatrix(PLASMA_desc descA, int i, int j, int m, int n);
28 int plasma_desc_check(PLASMA_desc *desc);
29 int plasma_desc_mat_alloc(PLASMA_desc *desc);
30 int plasma_desc_mat_free(PLASMA_desc *desc);
31
32 /***************************************************************************/
35 inline static void *plasma_getaddr(PLASMA_desc A, int m, int n)
36 {
37 size_t mm = m+A.i/A.mb;
38 size_t nn = n+A.j/A.nb;
39 size_t eltsize = plasma_element_size(A.dtyp);
40 size_t offset = 0;
41
42 if (mm < A.lm1) {
43 if (nn < A.ln1)
44 offset = A.bsiz*(mm+A.lm1*nn);
45 else
46 offset = A.A12 + (A.mb*(A.ln%A.nb)*mm);
47 }
48 else {
49 if (nn < A.ln1)
50 offset = A.A21 + ((A.lm%A.mb)*A.nb*nn);
51 else
52 offset = A.A22;
53 }
54
55 return (void*)((intptr_t)A.mat + (offset*eltsize) );
56 }
57
58 /***************************************************************************/
61 inline static void *plasma_geteltaddr( const PLASMA_desc *A, int m, int n, int eltsize)
62 {
63 size_t mm = m/A->mb;
64 size_t nn = n/A->nb;
65 size_t offset = 0;
66
67 if (mm < A->lm1) {
68 if (nn < A->ln1)
69 offset = A->bsiz*(mm+A->lm1*nn) + m%A->mb + A->mb*(n%A->nb);
70 else
71 offset = A->A12 + (A->mb*(A->ln%A->nb)*mm) + m%A->mb + A->mb*(n%A->nb);
72 }
73 else {
74 if (nn < A->ln1)
75 offset = A->A21 + ((A->lm%A->mb)*A->nb*nn) + m%A->mb + (A->lm%A->mb)*(n%A->nb);
76 else
77 offset = A->A22 + m%A->mb + (A->lm%A->mb)*(n%A->nb);
78 }
79 return (void*)((intptr_t)A->mat + (offset*eltsize) );
80 }
81
82 /***************************************************************************/
85 int PLASMA_Desc_Create(PLASMA_desc **desc, void *mat, PLASMA_enum dtyp, int mb, int nb, int bsiz, int lm, int ln, int i, int j, int m, int n);
86 int PLASMA_Desc_Destroy(PLASMA_desc **desc);
87
88 #ifdef __cplusplus
89 }
90 #endif
91
92 #endif