00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _CHARM_IDXL_LAYOUT_H
00009 #define _CHARM_IDXL_LAYOUT_H
00010 #include "idxlc.h"
00011 #include "pup.h"
00012
00019
00020 class IDXL_Layout {
00021 public:
00022 int type;
00023 int width;
00024 int offset;
00025 int distance;
00026 int skew;
00027
00028 IDXL_Layout(void) { type=0; width=0; }
00029 IDXL_Layout( const int b, const int v=1, const int i=0, const int fd=0, const int id=0)
00030 {
00031 type=b; width=v; offset=i; distance=fd; skew=id;
00032 if (distance==0) distance=compressedBytes();
00033 if (skew==0) skew=type_size(type);
00034 }
00035
00036 void pup(PUP::er &p) {
00037 p|type; p|width; p|offset; p|distance; p|skew;
00038 }
00039
00041 static int type_size(int dataType,const char *callingRoutine="");
00042
00044 static const char *type_name(int dataType,const char *callingRoutine="");
00045
00047 inline int userBytes(void) const {
00048 return distance;
00049 }
00050
00052 inline int compressedBytes(void) const {
00053 return type_size(type) * width;
00054 }
00055
00060 void gather(int nNodes,const int *nodes,
00061 const void *v_in,void *v_out) const;
00062
00067 void scatter(int nNodes,const int *nodes,
00068 const void *v_in,void *v_out) const;
00069
00074 void scatteradd(int nNodes,const int *nodes,
00075 const void *v_in,void *v_out) const;
00076 };
00077
00082 void reduction_initialize(const IDXL_Layout& dt, void *lhs, int op,const char *callingRoutine="");
00083
00089 typedef void (*reduction_combine_fn)(unsigned char *dest,const unsigned char *src,const IDXL_Layout *srcLayout);
00090 reduction_combine_fn reduction_combine(const IDXL_Layout& dt, int op,const char *callingRoutine="");
00091
00093 #define IDXL_LAYOUT_PARAM int width,int offset,int distance,int skew
00095 #define IDXL_LAYOUT_CALL(dt) (dt).width,(dt).offset,(dt).distance,(dt).skew
00098 #define IDXL_LAYOUT_DEREF(T,src,record,field) \
00099 *(T *)(((unsigned char *)src)+offset+(record)*distance+(field)*skew)
00100
00102 class IDXL_Layout_List {
00103 enum {FIRST_DT=IDXL_FIRST_IDXL_LAYOUT_T, MAX_DT=20};
00104 IDXL_Layout *list[MAX_DT];
00105 void badLayout(IDXL_Layout_t l,const char *callingRoutine) const;
00106 public:
00107 IDXL_Layout_List();
00108 void pup(PUP::er &p);
00109 ~IDXL_Layout_List();
00110
00112 inline void check(IDXL_Layout_t l,const char *callingRoutine) const {
00113 if (l<FIRST_DT || l>=FIRST_DT+MAX_DT || list[l-FIRST_DT]==NULL)
00114 badLayout(l,callingRoutine);
00115 }
00116
00118 IDXL_Layout_t put(const IDXL_Layout &dt);
00119
00121 inline const IDXL_Layout &get(IDXL_Layout_t l,const char *callingRoutine) const {
00122 check(l,callingRoutine);
00123 return *list[l-FIRST_DT];
00124 }
00125
00127 void destroy(IDXL_Layout_t l,const char *callingRoutine);
00128
00130 void empty(void);
00131
00132 static IDXL_Layout_List &get(void);
00133 };
00134 PUPmarshall(IDXL_Layout_List)
00135
00136 #endif
00137