00001 
00002 #ifndef MSA_COMMON_H
00003 #define MSA_COMMON_H
00004 
00005 #if 0
00006 #define MSADEBPRINT(x) printf("MSA[%d]:",CkMyPe());x;
00007 #else
00008 #define MSADEBPRINT(x) 
00009 #endif
00010 
00011 
00012 
00013 
00014 enum { MSA_INVALID_PAGE_NO = 0xFFFFFFFF };
00015 enum { MSA_INVALID_PE = -1 };
00016 typedef void* page_ptr_t;
00017 
00018 typedef enum {
00019  Uninit_State = 0,
00020  Read_Fault = 1,
00021  Write_Fault = 2,
00022  Accumulate_Fault = 3
00023 } MSA_Page_Fault_t;
00024 
00026 inline void operator|(PUP::er &p,MSA_Page_Fault_t &f) {
00027   int i=f; 
00028   p|i;
00029   f=(MSA_Page_Fault_t)i; 
00030 }
00031 
00032 enum { MSA_DEFAULT_ENTRIES_PER_PAGE = 1024 };
00033 
00034 
00035 
00036 enum { MSA_DEFAULT_MAX_BYTES = 16*1024*1024 };
00037 
00038 typedef enum { MSA_COL_MAJOR=0, MSA_ROW_MAJOR=1 } MSA_Array_Layout_t;
00039 
00040 
00041 
00048 template <class T, bool PUP_EVERY_ELEMENT=false >
00049 class DefaultEntry {
00050 public:
00051     template<typename U>
00052     static inline void accumulate(T& a, const U& b) { a += b; }
00053     
00054     static inline T getIdentity() { return (T)0; }
00055     static inline bool pupEveryElement(){ return PUP_EVERY_ELEMENT; }
00056 };
00057 
00058 template <class T, bool PUP_EVERY_ELEMENT=false >
00059 class ProductEntry {
00060 public:
00061     static inline void accumulate(T& a, const T& b) { a *= b; }
00062     static inline T getIdentity() { return (T)1; }
00063     static inline bool pupEveryElement(){ return PUP_EVERY_ELEMENT; }
00064 };
00065 
00066 template <class T, T minVal, bool PUP_EVERY_ELEMENT=false >
00067 class MaxEntry {
00068 public:
00069     static inline void accumulate(T& a, const T& b) { a = (a<b)?b:a; }
00070     static inline T getIdentity() { return minVal; }
00071     static inline bool pupEveryElement(){ return PUP_EVERY_ELEMENT; }
00072 };
00073 
00074 
00075 
00076 #define DEBUG_PRINTS
00077 
00078 #endif