GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros
densemat_iter_macros.h File Reference

Macros for iterating through densemats. More...

#include "ghost/omp.h"
Include dependency graph for densemat_iter_macros.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DENSEMAT_DT   char
 
#define DENSEMAT_ELSIZE(vec)   vec->elSize
 
#define DENSEMAT_COMPACT(vec)   (!(vec->traits.flags & GHOST_DENSEMAT_SCATTERED))
 
#define DENSEMAT_COMPACT_ROWS(vec)   (!(vec->traits.flags & GHOST_DENSEMAT_SCATTERED_ROWS))
 
#define DENSEMAT_SCATTERED_COLS(vec)   ((vec->traits.flags & GHOST_DENSEMAT_SCATTERED_COLS))
 
#define DENSEMAT_SINGLECOL_STRIDE1(vec)   (vec->traits.ncols == 1 && ((vec->traits.storage == GHOST_DENSEMAT_COLMAJOR) || ((vec->traits.storage == GHOST_DENSEMAT_ROWMAJOR) && (vec->stride == 1))))
 
#define DENSEMAT_ITER(vec, call)
 Iterate over a densemats and execute a statement for each entry. More...
 
#define DENSEMAT_ITER_INIT(vec, call)
 Iterate over a densemats and execute a statement for each entry. More...
 
#define DENSEMAT_ITER2(vec1, vec2, call)   DENSEMAT_ITER2_OFFS(vec1,vec2,0,0,call)
 
#define DENSEMAT_ITER2_OFFS(vec1, vec2, vec2roffs, vec2coffs, call)
 Iterate over two densemats synchronously and execute a statement for each entry. An offset may be given for the second input densemat. More...
 
#define DENSEMAT_ITER2_COMPACT_OFFS_TRANSPOSED(vec1, vec2, vec2roffs, vec2coffs, call)
 Iterate over two densemats synchronously and execute a statement for each entry. The second densemat is stored transposed (compared to the first). An offset may be given for the second input densemat. More...
 
#define DENSEMAT_ITER_BEGIN_COMPACT_SINGLECOL(vec, valptr, row, col, memrow, memcol)
 
#define DENSEMAT_ITER_COMPACT_SINGLECOL_PAD(vec, valptr, row, col, memrow, memcol)
 
#define DENSEMAT_ITER_BEGIN_COMPACT(vec, valptr, row, col, memrow, memcol)
 
#define DENSEMAT_ITER_COMPACT_PAD(vec, valptr, row, col, memrow, memcol)
 
#define DENSEMAT_ITER_END()
 
#define DENSEMAT_ITER2_BEGIN_COMPACT(vec1, vec2, row, col, memrow1, memrow2, memcol1, memcol2)   DENSEMAT_ITER2_BEGIN_COMPACT_OFFS(vec1,vec2,row,col,memrow1,memrow2,memcol1,memcol2,0,0)
 
#define DENSEMAT_ITER2_BEGIN_COMPACT_OFFS(vec1, vec2, valptr1, valptr2, row, col, memrow1, memrow2, memcol1, memcol2, vec2roffs, vec2coffs)
 
#define DENSEMAT_ITER2_BEGIN_COMPACT_OFFS_SINGLECOL(vec1, vec2, valptr1, valptr2, row, col, memrow1, memrow2, memcol1, memcol2, vec2roffs, vec2coffs)
 
#define DENSEMAT_ITER2_BEGIN_COMPACT_OFFS_TRANSPOSED(vec1, vec2, row, col, memrow1, memrow2, memcol1, memcol2, vec2roffs, vec2coffs)
 
#define DENSEMAT_ITER2_BEGIN_SCATTEREDCOLS_COMPACTROWS1_OFFS(vec1, vec2, row, col, memrow1, memrow2, memcol1, memcol2, vec2roffs, vec2coffs)
 

Detailed Description

Macros for iterating through densemats.

Author
Moritz Kreutzer morit.nosp@m.z.kr.nosp@m.eutze.nosp@m.r@fa.nosp@m.u.de

Macro Definition Documentation

#define DENSEMAT_COMPACT (   vec)    (!(vec->traits.flags & GHOST_DENSEMAT_SCATTERED))
#define DENSEMAT_COMPACT_ROWS (   vec)    (!(vec->traits.flags & GHOST_DENSEMAT_SCATTERED_ROWS))
#define DENSEMAT_DT   char
#define DENSEMAT_ELSIZE (   vec)    vec->elSize
#define DENSEMAT_ITER (   vec,
  call 
)

Iterate over a densemats and execute a statement for each entry.

This macro sets the following variables: row,col,memrow,memcol,valptr

Parameters
vecThe densemat.
callThe statement to call for each entry.
Returns
#define DENSEMAT_ITER2 (   vec1,
  vec2,
  call 
)    DENSEMAT_ITER2_OFFS(vec1,vec2,0,0,call)
See Also
DENSEMAT_ITER2_OFFS with offsets set to (0,0).
#define DENSEMAT_ITER2_BEGIN_COMPACT (   vec1,
  vec2,
  row,
  col,
  memrow1,
  memrow2,
  memcol1,
  memcol2 
)    DENSEMAT_ITER2_BEGIN_COMPACT_OFFS(vec1,vec2,row,col,memrow1,memrow2,memcol1,memcol2,0,0)
#define DENSEMAT_ITER2_BEGIN_COMPACT_OFFS (   vec1,
  vec2,
  valptr1,
  valptr2,
  row,
  col,
  memrow1,
  memrow2,
  memcol1,
  memcol2,
  vec2roffs,
  vec2coffs 
)
Value:
_Pragma("omp for schedule(runtime) private(col,memcol1,memcol2,memrow1,memrow2,valptr1,valptr2,cuvalptr1,cuvalptr2)")\
for (row=0; row<DM_NROWS(vec1); row++) {\
memrow1 = row;\
memrow2 = row;\
for (col = 0; col<vec1->traits.ncols; col++) {\
memcol1 = col;\
memcol2 = col;
#define DM_NROWS(dm)
Definition: densemat.h:303
#define DENSEMAT_ITER2_BEGIN_COMPACT_OFFS_SINGLECOL (   vec1,
  vec2,
  valptr1,
  valptr2,
  row,
  col,
  memrow1,
  memrow2,
  memcol1,
  memcol2,
  vec2roffs,
  vec2coffs 
)
Value:
memcol1 = 0;\
memcol2 = 0;\
col = 0;\
_Pragma("omp for schedule(runtime) private(memrow1,memrow2,valptr1,valptr2,cuvalptr1,cuvalptr2)")\
for (row=0; row<DM_NROWS(vec1); row++) {\
memrow1 = row;\
memrow2 = row;\
{\
#define DM_NROWS(dm)
Definition: densemat.h:303
#define DENSEMAT_ITER2_BEGIN_COMPACT_OFFS_TRANSPOSED (   vec1,
  vec2,
  row,
  col,
  memrow1,
  memrow2,
  memcol1,
  memcol2,
  vec2roffs,
  vec2coffs 
)
Value:
_Pragma("omp for schedule(runtime) private(col,memcol1,memcol2,memrow1,memrow2,valptr1,valptr2,cuvalptr1,cuvalptr2)")\
for (row=0; row<DM_NROWS(vec1); row++) {\
memrow1 = row;\
memrow2 = row;\
for (col = 0; col<vec1->traits.ncols; col++) {\
memcol1 = col;\
memcol2 = col;
#define DM_NROWS(dm)
Definition: densemat.h:303
#define DENSEMAT_ITER2_BEGIN_SCATTEREDCOLS_COMPACTROWS1_OFFS (   vec1,
  vec2,
  row,
  col,
  memrow1,
  memrow2,
  memcol1,
  memcol2,
  vec2roffs,
  vec2coffs 
)
Value:
memcol1 = -1;\
for (col = 0; col<vec1->traits.ncols; col++) {\
memcol1 = ghost_bitmap_next(vec1->colmask,memcol1);\
memcol2 = col;\
_Pragma("omp for schedule(runtime) private(memrow1,memrow2,valptr1,valptr2,cuvalptr1,cuvalptr2)")\
for (row=0; row<DM_NROWS(vec1); row++) {\
memrow1 = row;\
memrow2 = row;\
#define DM_NROWS(dm)
Definition: densemat.h:303
#define ghost_bitmap_next(bitmap, idx)
Definition: bitmap.h:27
#define DENSEMAT_ITER2_COMPACT_OFFS_TRANSPOSED (   vec1,
  vec2,
  vec2roffs,
  vec2coffs,
  call 
)
Value:
ghost_lidx row=0,col=0,memrow1=0,memcol1=0,memrow2=0,memcol2=0;\
DENSEMAT_DT *valptr1 = NULL, *valptr2 = NULL, *cuvalptr1 = NULL, *cuvalptr2 = NULL;\
DENSEMAT_ITER2_BEGIN_COMPACT_OFFS_TRANSPOSED(vec1,vec2,row,col,memrow1,memrow2,memcol1,memcol2,vec2roffs,vec2coffs);\
valptr1 = DENSEMAT_VALPTR(vec1,row,col);\
valptr2 = DENSEMAT_VALPTR_TRANSPOSED(vec2,row+vec2roffs,col+vec2coffs);\
cuvalptr1 = DENSEMAT_CUVALPTR(vec1,row,col);\
cuvalptr2 = DENSEMAT_CUVALPTR_TRANSPOSED(vec2,row+vec2roffs,col+vec2coffs);\
call;\
} else {\
_Pragma("omp parallel")\
{\
DENSEMAT_ITER2_BEGIN_COMPACT_OFFS_TRANSPOSED(vec1,vec2,row,col,memrow1,memrow2,memcol1,memcol2,vec2roffs,vec2coffs);\
valptr1 = DENSEMAT_VALPTR(vec1,row,col);\
valptr2 = DENSEMAT_VALPTR_TRANSPOSED(vec2,row+vec2roffs,col+vec2coffs);\
cuvalptr1 = DENSEMAT_CUVALPTR(vec1,row,col);\
cuvalptr2 = DENSEMAT_CUVALPTR_TRANSPOSED(vec2,row+vec2roffs,col+vec2coffs);\
call;\
}\
}\
/* Trick the compiler to not produce warnings about unused variables */\
if ((row+col+memrow1+memcol1+memrow2+memcol2 < 0) || \
(valptr1 == (DENSEMAT_DT *)0xbeef) || (valptr2 == (DENSEMAT_DT *)0xbeef) || \
(cuvalptr1 == (DENSEMAT_DT *)0xbeef) || (cuvalptr2 == (DENSEMAT_DT *)0xbeef)) \
{printf("Never happens\n");}
#define DENSEMAT_ITER2_BEGIN_COMPACT_OFFS_TRANSPOSED(vec1, vec2, row, col, memrow1, memrow2, memcol1, memcol2, vec2roffs, vec2coffs)
Definition: densemat_iter_macros.h:379
int32_t ghost_lidx
Definition: types.h:503
#define DENSEMAT_ITER_END()
Definition: densemat_iter_macros.h:352
int ghost_omp_in_parallel()
Check whether one is in an active parallel region.
Definition: omp.c:54
#define DENSEMAT_DT
Definition: densemat_iter_macros.h:12

Iterate over two densemats synchronously and execute a statement for each entry. The second densemat is stored transposed (compared to the first). An offset may be given for the second input densemat.

This macro sets the following variables: row,col,memrow1,memcol1,memrow2,memcol2

Parameters
vec1The first densemat
vec2The second densemat
vec2roffsThe row offset to the second densemat.
vec2coffsThe col offset to the second densemat.
callThe statement to call for each entry.
Returns
#define DENSEMAT_ITER2_OFFS (   vec1,
  vec2,
  vec2roffs,
  vec2coffs,
  call 
)

Iterate over two densemats synchronously and execute a statement for each entry. An offset may be given for the second input densemat.

This macro sets the following variables: row,col,memrow1,memcol1,memrow2,memcol2,valptr1,valptr2

Parameters
vec1The first densemat
vec2The second densemat
vec2roffsThe row offset to the second densemat.
vec2coffsThe col offset to the second densemat.
callThe statement to call for each entry.
Returns
#define DENSEMAT_ITER_BEGIN_COMPACT (   vec,
  valptr,
  row,
  col,
  memrow,
  memcol 
)
Value:
_Pragma("omp for schedule(runtime) private(col,memrow,memcol,valptr,cuvalptr)")\
for (row = 0; row<DM_NROWSPAD(vec); row++) {\
memrow = row;\
col = 0;\
if( row<DM_NROWS(vec) )\
for (; col<vec->traits.ncols; col++) {\
memcol = col;\
#define DM_NROWS(dm)
Definition: densemat.h:303
#define DM_NROWSPAD(dm)
Definition: densemat.h:305
#define DENSEMAT_ITER_BEGIN_COMPACT_SINGLECOL (   vec,
  valptr,
  row,
  col,
  memrow,
  memcol 
)
Value:
col = 0;\
memcol = 0;\
_Pragma("omp for schedule(runtime) private(memrow,valptr,cuvalptr)")\
for (row = 0; row<DM_NROWSPAD(vec); row++) {\
memrow = row;\
if( row < DM_NROWS(vec) ) {\
#define DM_NROWS(dm)
Definition: densemat.h:303
#define DM_NROWSPAD(dm)
Definition: densemat.h:305
#define DENSEMAT_ITER_COMPACT_PAD (   vec,
  valptr,
  row,
  col,
  memrow,
  memcol 
)
Value:
}\
for (; col<vec->traits.ncolspadded; col++) {\
valptr = DENSEMAT_VALPTR(vec,row,col);\
memset(valptr,0,DENSEMAT_ELSIZE(vec)*sizeof(DENSEMAT_DT));\
#define DENSEMAT_ELSIZE(vec)
Definition: densemat_iter_macros.h:13
#define DENSEMAT_DT
Definition: densemat_iter_macros.h:12
#define DENSEMAT_ITER_COMPACT_SINGLECOL_PAD (   vec,
  valptr,
  row,
  col,
  memrow,
  memcol 
)
Value:
} else {\
valptr = DENSEMAT_VALPTR_SINGLECOL_STRIDE1(vec,row,col);\
memset(valptr,0,DENSEMAT_ELSIZE(vec)*sizeof(DENSEMAT_DT));\
#define DENSEMAT_ELSIZE(vec)
Definition: densemat_iter_macros.h:13
#define DENSEMAT_DT
Definition: densemat_iter_macros.h:12
#define DENSEMAT_ITER_END ( )
Value:
}\
}
#define DENSEMAT_ITER_INIT (   vec,
  call 
)

Iterate over a densemats and execute a statement for each entry.

This macro sets the following variables: row,col,memrow,memcol,valptr In addition to DENSEMAT_ITER, this macro intializes padding to zero

Parameters
vecThe densemat.
callThe statement to call for each entry.
Returns
#define DENSEMAT_SCATTERED_COLS (   vec)    ((vec->traits.flags & GHOST_DENSEMAT_SCATTERED_COLS))
#define DENSEMAT_SINGLECOL_STRIDE1 (   vec)    (vec->traits.ncols == 1 && ((vec->traits.storage == GHOST_DENSEMAT_COLMAJOR) || ((vec->traits.storage == GHOST_DENSEMAT_ROWMAJOR) && (vec->stride == 1))))