00001
00002
00003
00004
00005
00006
00007
00008
00009 #pragma once
00010
00011 #include <cuComplex.h>
00012 #include "defines.h"
00013
00014
00016 #define is_gpu(id) ((id) == S_GPU || (id) == S_IRITH_SCALAR || (id) == S_IRITH_MATRIX)
00017
00019 enum stype_t {
00020 S_LIN,
00021 S_NON,
00022 S_GPU,
00023 S_I,
00024 S_IRITH_SCALAR,
00025 S_IRITH_MATRIX,
00026 };
00028 enum sty_t {
00029 STY_BOOL,
00030 STY_F32,
00031 STY_F64,
00032 STY_U32,
00033 };
00034
00036 typedef struct {
00037 enum stype_t type;
00038 union {
00039 struct { int first, inc; } lin;
00040 struct { unsigned pos; } non;
00041 struct {
00042 sty_t ty;
00043 int id;
00044 } gpu;
00045 } d;
00046 } sub_t;
00047
00048 #ifdef __cplusplus
00049 #include "exception.h"
00050
00051 namespace af {
00118 class AFAPI seq
00119 {
00120 public:
00121 double first, inc, last;
00122 unsigned size;
00123
00124 seq();
00126 seq(double n);
00128 seq(double first, double last);
00130 seq(double first, double inc, double last);
00131
00133 inline seq operator-() { return seq(-first, -inc, -last); }
00135 inline seq operator+(double x) { return seq(first+x, inc, last+x); }
00137 inline seq operator-(double x) { return seq(first-x, inc, last-x); }
00139 inline seq operator*(double x) { return seq(first*x, inc*x, last*x); }
00140
00142 friend inline seq operator+(double x, seq y) { return y + x; }
00144 friend inline seq operator-(double x, seq y) { return -y + x; }
00146 friend inline seq operator*(double x, seq y) { return y * x; }
00147
00148 private:
00149 void init(double first, double inc, double last);
00150 };
00151
00164 extern AFAPI int end;
00165
00176 extern AFAPI seq span;
00178 }
00179 #endif // __cplusplus
00180
00182 #define _B_ bool
00183 #define _S_ float
00184 #define _D_ double
00185 #define _C_ cuComplex
00186 #define _Z_ cuDoubleComplex
00187 #define _I_ int
00188 #define _U_ unsigned
00189
00190 #define JI_PARAMS \
00191 int nsubs, const sub_t *subs, \
00192 const unsigned *dims_dst, const unsigned *dims_src, unsigned base, \
00193 const unsigned *inds, const void *d0, const void *d1, const void *d2, \
00194 unsigned ngfor_dst, unsigned ngfor_sub, float start, float inc
00195
00196 #define GET(T) AFAPI afError af_get(_##T##_ *d_dst, const _##T##_ *d_src, JI_PARAMS);
00197 #define SET(T) AFAPI afError af_set(_##T##_ *d_dst, const _##T##_ *d_src, JI_PARAMS, unsigned ngfor_src);
00198 #define SETSCALAR(T) \
00199 AFAPI afError af_setscalar(_##T##_ *d_dst, const _##T##_ src, JI_PARAMS); \
00200 AFAPI afError af_setscalar(_##T##_ *d_dst, const _##T##_ *d_src, JI_PARAMS, unsigned ngfor_src);
00201
00203
00204
00205
00206
00207
00208
00209
00212 GET(B)
00213 GET(S) GET(D)
00214 GET(C) GET(Z)
00215 GET(U) GET(I)
00217 #undef GET
00218
00221 SET(B)
00222 SET(S) SET(D)
00223 SET(C) SET(Z)
00224 SET(U) SET(I)
00226 #undef SET
00227
00230 SETSCALAR(B)
00231 SETSCALAR(S) SETSCALAR(D)
00232 SETSCALAR(C) SETSCALAR(Z)
00233 SETSCALAR(U) SETSCALAR(I)
00234 #undef SETSCALAR
00235
00236
00237
00238 #undef JI_PARAMS
00239
00240 AFAPI afError af_remove_SS(float *d_out,
00241 unsigned num_in, float *d_in,
00242 unsigned num_rm, float *h_idx);
00243
00244 AFAPI afError af_remove_DS(double *d_out,
00245 unsigned num_in, double *d_in,
00246 unsigned num_rm, float *h_idx);
00247
00248 AFAPI afError af_remove_CS(cuComplex *d_out,
00249 unsigned num_in, cuComplex *d_in,
00250 unsigned num_rm, float *h_idx);
00251
00252 AFAPI afError af_remove_ZS(cuDoubleComplex *d_out,
00253 unsigned num_in, cuDoubleComplex *d_in,
00254 unsigned num_rm, float *h_idx);
00255
00256 AFAPI afError af_remove_DD(double *d_out,
00257 unsigned num_in, double *d_in,
00258 unsigned num_rm, double *h_idx);
00259
00260 AFAPI afError af_remove_ZD(cuDoubleComplex *d_out,
00261 unsigned num_in, cuDoubleComplex *d_in,
00262 unsigned num_rm, double *h_idx);
00263
00264 AFAPI afError af_remove_SU(float *d_out,
00265 unsigned num_in, float *d_in,
00266 unsigned num_rm, unsigned *h_idx);
00267
00268 AFAPI afError af_remove_DU(double *d_out,
00269 unsigned num_in, double *d_in,
00270 unsigned num_rm, unsigned *h_idx);
00271
00272 AFAPI afError af_remove_CU(cuComplex *d_out,
00273 unsigned num_in, cuComplex *d_in,
00274 unsigned num_rm, unsigned *h_idx);
00275
00276 AFAPI afError af_remove_ZU(cuDoubleComplex *d_out,
00277 unsigned num_in, cuDoubleComplex *d_in,
00278 unsigned num_rm, unsigned *h_idx);