GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
spmv.h
Go to the documentation of this file.
1 
6 #ifndef GHOST_SPMV_H
7 #define GHOST_SPMV_H
8 
9 #include "sparsemat.h"
10 #include "densemat.h"
11 
15 typedef enum {
17  GHOST_SPMV_AXPY = 1 << 0,
22  GHOST_SPMV_SHIFT = 1 << 5,
23  GHOST_SPMV_SCALE = 1 << 6,
24  GHOST_SPMV_AXPBY = 1 << 7,
27  GHOST_SPMV_DOT_XX = 1 << 10,
29  GHOST_SPMV_LOCAL = 1 << 12,
30  GHOST_SPMV_REMOTE = 1 << 13,
31  GHOST_SPMV_VSHIFT = 1 << 14,
35 
36 
37 #define GHOST_SPMV_DOT (GHOST_SPMV_DOT_YY | GHOST_SPMV_DOT_XY | GHOST_SPMV_DOT_XX)
38 
42 #define GHOST_SPMV_AUG_FLAGS \
43  (GHOST_SPMV_SHIFT | GHOST_SPMV_VSHIFT | GHOST_SPMV_SCALE | GHOST_SPMV_AXPY | GHOST_SPMV_AXPBY \
44  | GHOST_SPMV_DOT | GHOST_SPMV_CHAIN_AXPBY)
45 
69 #define GHOST_SPMV_PARSE_TRAITS(traits, _alpha, _beta, _gamma, _dot, _z, _delta, _eta, dt_in, dt_out) \
70  { \
71  dt_in *arg = NULL; \
72  if (traits.flags & GHOST_SPMV_SCALE) { \
73  arg = (dt_in *)traits.alpha; \
74  if (!arg) { \
75  GHOST_ERROR_LOG("Scale argument is NULL!"); \
76  return GHOST_ERR_INVALID_ARG; \
77  } \
78  _alpha = *(dt_out *)arg; \
79  } \
80  if (traits.flags & GHOST_SPMV_AXPBY) { \
81  arg = (dt_in *)traits.beta; \
82  if (!arg) { \
83  GHOST_ERROR_LOG("AXPBY argument is NULL!"); \
84  return GHOST_ERR_INVALID_ARG; \
85  } \
86  _beta = *(dt_out *)arg; \
87  } \
88  if (traits.flags & (GHOST_SPMV_SHIFT | GHOST_SPMV_VSHIFT)) { \
89  arg = (dt_in *)traits.gamma; \
90  if (!arg) { \
91  GHOST_ERROR_LOG("Shift argument is NULL!"); \
92  return GHOST_ERR_INVALID_ARG; \
93  } \
94  _gamma = (dt_out *)arg; \
95  } \
96  if (traits.flags & GHOST_SPMV_DOT) { \
97  arg = (dt_in *)traits.dot; \
98  if (!arg) { \
99  GHOST_ERROR_LOG("Dot argument is NULL!"); \
100  return GHOST_ERR_INVALID_ARG; \
101  } \
102  _dot = arg; \
103  } \
104  if (traits.flags & GHOST_SPMV_CHAIN_AXPBY) { \
105  ghost_densemat *zarg; \
106  zarg = (ghost_densemat *)traits.z; \
107  if (!zarg) { \
108  GHOST_ERROR_LOG("z argument is NULL!"); \
109  return GHOST_ERR_INVALID_ARG; \
110  } \
111  _z = zarg; \
112  arg = (dt_in *)traits.delta; \
113  if (!arg) { \
114  GHOST_ERROR_LOG("delta argument is NULL!"); \
115  return GHOST_ERR_INVALID_ARG; \
116  } \
117  _delta = *(dt_out *)arg; \
118  arg = (dt_in *)traits.eta; \
119  if (!arg) { \
120  GHOST_ERROR_LOG("eta argument is NULL!"); \
121  return GHOST_ERR_INVALID_ARG; \
122  } \
123  _eta = *(dt_out *)arg; \
124  } \
125  if (traits.flags & GHOST_SPMV_REMOTE) { \
126  traits.flags = (ghost_spmv_flags)(traits.flags & ~GHOST_SPMV_AXPBY); \
127  traits.flags = (ghost_spmv_flags)(traits.flags & ~GHOST_SPMV_SHIFT); \
128  traits.flags = (ghost_spmv_flags)(traits.flags & ~GHOST_SPMV_VSHIFT); \
129  traits.flags = (ghost_spmv_flags)(traits.flags | GHOST_SPMV_AXPY); \
130  } else if (traits.flags & GHOST_SPMV_LOCAL) { \
131  traits.flags = (ghost_spmv_flags)(traits.flags & ~GHOST_SPMV_DOT); \
132  traits.flags = (ghost_spmv_flags)(traits.flags & ~GHOST_SPMV_CHAIN_AXPBY); \
133  } \
134  }
135 
139 #define GHOST_SPMV_MODES_FULL \
140  (GHOST_SPMV_MODE_NOMPI | GHOST_SPMV_MODE_VECTOR | GHOST_SPMV_MODE_PIPELINED)
141 
144 #define GHOST_SPMV_MODES_SPLIT (GHOST_SPMV_MODE_OVERLAP | GHOST_SPMV_MODE_TASK)
145 
148 #define GHOST_SPMV_MODES_ALL (GHOST_SPMV_MODES_FULL | GHOST_SPMV_MODES_SPLIT)
149 
150 #define GHOST_SPMV_MODES_MPI \
151  (GHOST_SPMV_MODE_VECTOR | GHOST_SPMV_MODES_SPLIT | GHOST_SPMV_MODE_PIPELINED)
152 
153 #ifdef __cplusplus
154 
162 inline ghost_spmv_flags operator|(const ghost_spmv_flags &a, const ghost_spmv_flags &b)
163 {
164  return static_cast<ghost_spmv_flags>(static_cast<int>(a) | static_cast<int>(b));
165 }
166 
167 inline ghost_spmv_flags operator&(const ghost_spmv_flags &a, const ghost_spmv_flags &b)
168 {
169  return static_cast<ghost_spmv_flags>(static_cast<int>(a) & static_cast<int>(b));
170 }
171 
172 #endif
173 
175 {
176  return a && b;
177 }
178 
180 {
181 
182  return (ghost_spmv_flags)((int)a | (int)b);
183 }
185 {
186  return (ghost_spmv_flags)((int)a & ~(int)b);
187 }
188 
189 
190 #endif
Definition: spmv.h:16
Definition: spmv.h:22
bool ghost_spmvflags_isset(const ghost_spmv_flags a, const ghost_spmv_flags b)
Definition: spmv.h:174
Definition: spmv.h:27
Definition: spmv.h:25
Definition: spmv.h:19
Definition: spmv.h:21
Definition: spmv.h:24
Definition: spmv.h:17
Definition: spmv.h:30
Definition: spmv.h:33
Definition: spmv.h:20
Definition: spmv.h:32
ghost_spmv_flags ghost_spmvflags_disable(ghost_spmv_flags a, ghost_spmv_flags b)
Definition: spmv.h:184
Definition: spmv.h:29
ghost_spmv_flags ghost_spmvflags_enable(ghost_spmv_flags a, ghost_spmv_flags b)
Definition: spmv.h:179
ghost_spmv_flags
Flags to be passed to sparse matrix-vector multiplication.
Definition: spmv.h:15
Definition: spmv.h:31
Definition: spmv.h:28
Types and functions related to sparse matrices.
Definition: spmv.h:26
Definition: spmv.h:18
Definition: spmv.h:23