• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/elements/genericProc/programs/qthread-1.4/include/qthread/qarray.h

00001 #ifndef QTHREAD_QARRAY_H
00002 #define QTHREAD_QARRAY_H
00003 
00004 #include <qthread/qthread-int.h>
00005 #include <qthread/qthread.h>
00006 #include <qthread/qloop.h>
00007 
00008 Q_STARTCXX                             /* */
00009     typedef enum
00010 {
00011     /* the default, used both as input and after creation */
00012     FIXED_HASH = 0,
00013     /* these are also used both as input and after creation */
00014     FIXED_FIELDS,
00015     /* these are used only after it's created */
00016     ALL_SAME /* if used as input to qarray_create(), treated as ALL_LOCAL */,
00017     DIST /* if used as input to qarray_create(), treated as DIST_RAND */,
00018     /* types of DIST... only used for input to qarray_create();
00019      * note that these only establish an initial condition. */
00020     DIST_STRIPES, DIST_FIELDS, DIST_RAND, DIST_LEAST,
00021     /* types of ALL_SAME... only used for input to qarray_create() */
00022     ALL_LOCAL, ALL_RAND, ALL_LEAST
00023 } distribution_t;
00024 typedef struct qarray_s
00025 {
00026     size_t unit_size;
00027     size_t count;
00028     size_t segment_size;        /* units in a segment */
00029     size_t segment_bytes;       /* bytes per segment (sometimes > unit_size*segment_size) */
00030     char *base_ptr;
00031     distribution_t dist_type;
00032     union
00033     {
00034         qthread_shepherd_id_t dist_shep;        /* for ALL_SAME dist type */
00035         struct {
00036             size_t segs_per_shep;                       /* for FIXED_STRIPES dist type */
00037             size_t extras;
00038         } stripes;
00039     } dist_specific;
00040 } qarray;
00041 
00042 typedef void (*qa_loop_f) (qthread_t * me, const size_t startat,
00043                            const size_t stopat, qarray * array, void *arg);
00044 typedef void (*qa_loopr_f) (qthread_t * me, const size_t startat,
00045                             const size_t stopat, qarray * array, void *arg,
00046                             void *ret);
00047 typedef void (*qa_cloop_f) (qthread_t * me, const size_t startat,
00048                             const size_t stopat, const qarray * array,
00049                             void *arg);
00050 
00051 qarray *qarray_create(const size_t count, const size_t unit_size);
00052 qarray *qarray_create_tight(const size_t count, const size_t unit_size);
00053 qarray *qarray_create_configured(const size_t count, const size_t unit_size,
00054                                  const distribution_t d, const char tight,
00055                                  const int seg_pages);
00056 
00057 void qarray_destroy(qarray * a);
00058 
00059 void qarray_iter(qthread_t * me, qarray * a, const size_t startat,
00060                  const size_t stopat, qthread_f func);
00061 void qarray_iter_loop(qthread_t * me, qarray * a, const size_t startat,
00062                       const size_t stopat, qa_loop_f func, void *arg);
00063 void qarray_iter_loop_nb(qthread_t * me, qarray * a, const size_t startat,
00064                       const size_t stopat, qa_loop_f func, void *arg, aligned_t *ret);
00065 void qarray_iter_constloop(qthread_t * me, const qarray * a,
00066                            const size_t startat, const size_t stopat,
00067                            qa_cloop_f func, void *arg);
00068 void qarray_iter_loopaccum(qthread_t * me, qarray * a, const size_t startat,
00069                            const size_t stopat, qa_loopr_f func, void *arg,
00070                            void *ret, const size_t retsize, qt_accum_f acc);
00071 
00072 void qarray_set_shepof(qarray * a, const size_t i,
00073                        qthread_shepherd_id_t shep);
00074 qthread_shepherd_id_t qarray_shepof(const qarray * a, const size_t index);
00075 void qarray_dist_like(const qarray *ref, qarray *mod);
00076 
00077 #define qarray_elem(me, a, i) qarray_elem_nomigrate(a, i)
00078 void *qarray_elem_migrate(qthread_t * me, const qarray * a,
00079                           const size_t index);
00080 QINLINE static void *qarray_elem_nomigrate(const qarray * a,
00081                                            const size_t index)
00082 {
00083     if (a == NULL || index > a->count)
00084         return NULL;
00085 
00086     {
00087         const size_t segment_num = index / a->segment_size;     /* rounded down */
00088 
00089         return a->base_ptr + ((segment_num * a->segment_bytes) +
00090                               ((index -
00091                                 segment_num * a->segment_size) *
00092                                a->unit_size));
00093     }
00094 }
00095 
00096 Q_ENDCXX
00097 #endif

Generated on Fri Oct 22 2010 11:02:24 for SST by  doxygen 1.7.1