index.h (2014-04-30 15:38:09 -0400, (build fd32605))
Go to the documentation of this file.
1 //-----------------------------------------------------------------------//
2 // Copyright (c) AccelerEyes LLC. All rights reserved. //
3 // See http://www.accelereyes.com/eula for details. //
4 // This software is distributed WITHOUT ANY WARRANTY; without even //
5 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
6 // PURPOSE. See the above copyright notices for more information. //
7 //-----------------------------------------------------------------------//
8 
9 #pragma once
10 #include "defines.h"
11 
13 #define is_gpu(id) ((id) == S_GPU || (id) == S_IRITH_SCALAR || (id) == S_IRITH_MATRIX)
14 
16 enum stype_t {
20  S_I,
23 };
25 enum sty_t {
30 };
31 
33 typedef struct {
34  enum stype_t type;
35  union {
36  struct { int first, inc; } lin;
37  struct { unsigned pos; } non;
38  struct {
40  int id;
41  } gpu;
42  } d;
43 } sub_t;
44 
45 #ifdef __cplusplus
46 #include "exception.h"
47 
48 namespace af {
49 
156 class AFAPI seq
157 {
158  public:
159  double first;
160  double inc;
161  double last;
162  unsigned size;
163 
164  seq();
165 
178  explicit seq(double n);
179 
193  seq(double first, double last);
194 
209  seq(double first, double inc, double last);
210 
219  inline seq operator-() { return seq(-first, -inc, -last); }
220 
229  inline seq operator+(double x) { return seq(first+x, inc, last+x); }
230 
239  inline seq operator-(double x) { return seq(first-x, inc, last-x); }
240 
249  inline seq operator*(double x) { return seq(first*x, inc*x, last*x); }
250 
259  friend inline seq operator+(double x, seq y) { return y + x; }
260 
269  friend inline seq operator-(double x, seq y) { return -y + x; }
270 
279  friend inline seq operator*(double x, seq y) { return y * x; }
280 
281  private:
282  void init(double first, double inc, double last);
283 };
307 extern AFAPI int end;
337 extern AFAPI seq span;
342 } // namespace af
343 #endif // __cplusplus
344 
346 #define _B_ bool
347 #define _S_ float
348 #define _D_ double
349 #define _C_ cfloat
350 #define _Z_ cdouble
351 #define _I_ int
352 #define _U_ unsigned
353 
354 #define JI_PARAMS \
355  int nsubs, const sub_t *subs, \
356  const unsigned *dims_dst, const unsigned *dims_src, unsigned base, \
357  const unsigned *inds, const void *d0, const void *d1, const void *d2, \
358  unsigned ngfor_dst, unsigned ngfor_sub, float start, float inc
359 
360 #define GET(T) AFAPI afError af_get(_##T##_ *d_dst, const _##T##_ *d_src, JI_PARAMS);
361 #define SET(T) AFAPI afError af_set(_##T##_ *d_dst, const _##T##_ *d_src, JI_PARAMS, unsigned ngfor_src);
362 #define SETSCALAR(T) \
363  AFAPI afError af_setscalar(_##T##_ *d_dst, const _##T##_ src, JI_PARAMS); \
364  AFAPI afError af_setscalar(_##T##_ *d_dst, const _##T##_ *d_src, JI_PARAMS, unsigned ngfor_src);
365 
367 
368 
369 // inputs:
370 // - inds -- zero-indexed values
371 // - d* -- zero-indexed values in device memory (float or bool)
372 // - lin.first -- zero-indexed
373 
376 GET(B)
377 GET(S) GET(D)
378 GET(C) GET(Z)
379 GET(U) GET(I)
381 #undef GET
382 
385 SET(B)
386 SET(S) SET(D)
387 SET(C) SET(Z)
388 SET(U) SET(I)
390 #undef SET
391 
394 SETSCALAR(B)
395 SETSCALAR(S) SETSCALAR(D)
396 SETSCALAR(C) SETSCALAR(Z)
397 SETSCALAR(U) SETSCALAR(I)
398 #undef SETSCALAR
399 
401 
402 #undef JI_PARAMS
403 
404 AFAPI afError af_remove_SS(float *d_out,
405  unsigned num_in, float *d_in,
406  unsigned num_rm, float *h_idx);
407 
408 AFAPI afError af_remove_DS(double *d_out,
409  unsigned num_in, double *d_in,
410  unsigned num_rm, float *h_idx);
411 
413  unsigned num_in, cfloat *d_in,
414  unsigned num_rm, float *h_idx);
415 
417  unsigned num_in, cdouble *d_in,
418  unsigned num_rm, float *h_idx);
419 
420 AFAPI afError af_remove_DD(double *d_out,
421  unsigned num_in, double *d_in,
422  unsigned num_rm, double *h_idx);
423 
425  unsigned num_in, cdouble *d_in,
426  unsigned num_rm, double *h_idx);
427 
428 AFAPI afError af_remove_SU(float *d_out,
429  unsigned num_in, float *d_in,
430  unsigned num_rm, unsigned *h_idx);
431 
432 AFAPI afError af_remove_DU(double *d_out,
433  unsigned num_in, double *d_in,
434  unsigned num_rm, unsigned *h_idx);
435 
437  unsigned num_in, cfloat *d_in,
438  unsigned num_rm, unsigned *h_idx);
439 
441  unsigned num_in, cdouble *d_in,
442  unsigned num_rm, unsigned *h_idx);
443 
444 //
445 
446 AFAPI afError af_range_S(float *d_out,
447  float start, float step,
448  unsigned numel);
449 
afError af_range_S(float *d_out, float start, float step, unsigned numel)
Unsigned integer (32-bit)
Definition: index.h:29
Metadata describing subscript.
Definition: index.h:33
seq operator*(double x)
Scale offset sequence.
Definition: index.h:249
#define SETSCALAR(T)
Definition: index.h:362
GFOR iterator.
Definition: index.h:20
seq operator-()
Negative sequence.
Definition: index.h:219
afError af_remove_DD(double *d_out, unsigned num_in, double *d_in, unsigned num_rm, double *h_idx)
Read from GPU device memory (zero-indexed)
Definition: index.h:19
afError af_remove_DS(double *d_out, unsigned num_in, double *d_in, unsigned num_rm, float *h_idx)
afError af_remove_ZD(cdouble *d_out, unsigned num_in, cdouble *d_in, unsigned num_rm, double *h_idx)
unsigned pos
Definition: index.h:37
friend seq operator*(double x, seq y)
Scale offset sequence.
Definition: index.h:279
stype_t
What type of subscript is this?
Definition: index.h:16
int inc
Definition: index.h:36
Linear (inc*i+first)
Definition: index.h:17
afError
Definition: defines.h:10
cuDoubleComplex cdouble
Definition: defines.h:109
GFOR iterator with non-scalar arithmetic.
Definition: index.h:22
double last
Ending value of the sequence.
Definition: index.h:161
afError af_remove_ZS(cdouble *d_out, unsigned num_in, cdouble *d_in, unsigned num_rm, float *h_idx)
int end
Reference last element in dimension.
sequential index generator
Definition: index.h:156
unsigned size
Number of elements in the sequence.
Definition: index.h:162
double first
Starting value of the sequence.
Definition: index.h:159
afError af_remove_SU(float *d_out, unsigned num_in, float *d_in, unsigned num_rm, unsigned *h_idx)
afError af_remove_CU(cfloat *d_out, unsigned num_in, cfloat *d_in, unsigned num_rm, unsigned *h_idx)
double inc
Increment size.
Definition: index.h:160
seq operator-(double x)
Offset sequence.
Definition: index.h:239
#define SET(T)
Definition: index.h:361
afError af_remove_DU(double *d_out, unsigned num_in, double *d_in, unsigned num_rm, unsigned *h_idx)
#define AFAPI
Definition: defines.h:45
sty_t ty
underlying data type
Definition: index.h:39
afError af_remove_ZU(cdouble *d_out, unsigned num_in, cdouble *d_in, unsigned num_rm, unsigned *h_idx)
seq span
Reference entire dimension.
friend seq operator+(double x, seq y)
Offset sequence.
Definition: index.h:259
friend seq operator-(double x, seq y)
Offset sequence.
Definition: index.h:269
sty_t
What type of data is this?
Definition: index.h:25
Single-precision (32-bit)
Definition: index.h:27
afError af_remove_CS(cfloat *d_out, unsigned num_in, cfloat *d_in, unsigned num_rm, float *h_idx)
GFOR iterator with scalar arithmetic.
Definition: index.h:21
Boolean (only scalar subsasgn)
Definition: index.h:26
Double-precision (64-bit)
Definition: index.h:28
cuFloatComplex cfloat
Definition: defines.h:108
Nonlinear (directly specified in d_ind)
Definition: index.h:18
seq operator+(double x)
Offset sequence.
Definition: index.h:229
#define GET(T)
Definition: index.h:360
afError af_remove_SS(float *d_out, unsigned num_in, float *d_in, unsigned num_rm, float *h_idx)
int id
Which device pointer (0,1,2)
Definition: index.h:40