diff DKU.h @ 0:9f2a7bd26dd9

Initial add -- code is straight copy of VSs implementation.. to be modified
author Sean Halle <seanhalle@yahoo.com>
date Mon, 27 Aug 2012 02:14:35 -0700
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/DKU.h	Mon Aug 27 02:14:35 2012 -0700
     1.3 @@ -0,0 +1,374 @@
     1.4 +/*
     1.5 + *  Copyright 2009 OpenSourceStewardshipFoundation.org
     1.6 + *  Licensed under GNU General Public License version 2
     1.7 + *
     1.8 + * Author: seanhalle@yahoo.com
     1.9 + *
    1.10 + */
    1.11 +
    1.12 +#ifndef _VSs_H
    1.13 +#define	_VSs_H
    1.14 +
    1.15 +#include "Queue_impl/PrivateQueue.h"
    1.16 +#include "Hash_impl/PrivateHash.h"
    1.17 +#include "VMS_impl/VMS.h"
    1.18 +#include "Measurement/dependency.h"
    1.19 +
    1.20 +
    1.21 +//===========================================================================
    1.22 +#define NUM_STRUCS_IN_SEM_ENV 1000
    1.23 +
    1.24 +   //This is hardware dependent -- it's the number of cycles of scheduling
    1.25 +   // overhead -- if a work unit is fewer than this, it is better being
    1.26 +   // combined sequentially with other work
    1.27 +   //This value depends on both VMS overhead and VSs's plugin.  At some point
    1.28 +   // it will be derived by perf-counter measurements during init of VSs
    1.29 +#define MIN_WORK_UNIT_CYCLES 20000
    1.30 +
    1.31 +//===========================================================================
    1.32 +/*This header defines everything specific to the VSs semantic plug-in
    1.33 + */
    1.34 +typedef struct _VSsSemReq   VSsSemReq;
    1.35 +typedef void  (*VSsTaskFnPtr )   ( void *, SlaveVP *);
    1.36 +typedef void  (*PtrToAtomicFn )  ( void * ); //executed atomically in master
    1.37 +//===========================================================================
    1.38 +
    1.39 +#define NONCTLD 0
    1.40 +#define IN      1  /*Trick -- READER same as IN*/
    1.41 +#define OUT     2  /*Trick -- WRITER same as OUT and INOUT*/
    1.42 +#define INOUT   2  /*Trick -- WRITER same as OUT and INOUT*/
    1.43 +
    1.44 +#define READER  1  /*Trick -- READER same as IN*/
    1.45 +#define WRITER  2  /*Trick -- WRITER same as OUT and INOUT*/
    1.46 +
    1.47 +#define IS_A_THREAD NULL
    1.48 +#define IS_ENDED    NULL
    1.49 +#define SEED_SLV    NULL
    1.50 +
    1.51 +typedef struct
    1.52 + {
    1.53 +   VSsTaskFnPtr fn;
    1.54 +   int32  numTotalArgs;//the number of inputs to function
    1.55 +   int32  numCtldArgs;//how many of args have dependencies
    1.56 +   int32 *argTypes;   //says reader, writer, or non-ctld
    1.57 +   int32 *argSizes;   //for detecting overlap
    1.58 +   int32  sizeOfArgs; //for memcpy of args struct
    1.59 + }
    1.60 +VSsTaskType;
    1.61 +
    1.62 +
    1.63 +typedef struct
    1.64 + {
    1.65 +   bool32       hasEnabledNonFinishedWriter;
    1.66 +   int32        numEnabledNonDoneReaders;
    1.67 +   PrivQueueStruc *waitersQ;
    1.68 + }
    1.69 +VSsPointerEntry;
    1.70 +
    1.71 +typedef struct
    1.72 + {
    1.73 +   void       **args; //ctld args must come first, as ptrs
    1.74 +   VSsTaskType *taskType;
    1.75 +   int32       *taskID;
    1.76 +   int32        numBlockingProp;
    1.77 +   SlaveVP     *slaveAssignedTo; //only valid before end task (thread)
    1.78 +   VSsPointerEntry  **ptrEntries;
    1.79 +   void*        parentTaskStub;
    1.80 +   int32        numLiveChildTasks;
    1.81 +   int32        numLiveChildThreads;
    1.82 +   bool32       isWaitingForChildTasksToEnd;
    1.83 +   bool32       isWaitingForChildThreadsToEnd;
    1.84 +   bool32       isEnded;
    1.85 + }
    1.86 +VSsTaskStub;
    1.87 +
    1.88 +
    1.89 +typedef struct
    1.90 + {
    1.91 +   VSsTaskStub *taskStub;
    1.92 +   int32        argNum;
    1.93 +   int32        isReader;
    1.94 + }
    1.95 +VSsTaskStubCarrier;
    1.96 +
    1.97 +
    1.98 +/*Semantic layer-specific data sent inside a request from lib called in app
    1.99 + * to request handler called in AnimationMaster
   1.100 + */
   1.101 +
   1.102 +typedef struct
   1.103 + {
   1.104 +   SlaveVP      *VPCurrentlyExecuting;
   1.105 +   PrivQueueStruc *waitingVPQ;
   1.106 + }
   1.107 +VSsTrans;
   1.108 +
   1.109 +/*WARNING: assembly hard-codes position of endInstrAddr as first field
   1.110 + */
   1.111 +typedef struct
   1.112 + {
   1.113 +   void           *endInstrAddr;
   1.114 +   int32           hasBeenStarted;
   1.115 +   int32           hasFinished;
   1.116 +   PrivQueueStruc *waitQ;
   1.117 + }
   1.118 +VSsSingleton;
   1.119 +
   1.120 +enum VSsReqType
   1.121 + {
   1.122 +   submit_task = 1,
   1.123 +   end_task,
   1.124 +   create_slave,
   1.125 +   create_slave_w_aff,
   1.126 +   dissipate_slave,
   1.127 +   //===============================
   1.128 +   send_type_to,
   1.129 +   receive_type_to,
   1.130 +   send_from_to,
   1.131 +   receive_from_to,
   1.132 +   //===============================
   1.133 +   taskwait,
   1.134 +   malloc_req,
   1.135 +   free_req,
   1.136 +   singleton_fn_start,
   1.137 +   singleton_fn_end,
   1.138 +   singleton_data_start,
   1.139 +   singleton_data_end,
   1.140 +   atomic,
   1.141 +   trans_start,
   1.142 +   trans_end
   1.143 + };
   1.144 +
   1.145 +struct _VSsSemReq
   1.146 + { enum VSsReqType    reqType;
   1.147 +   SlaveVP           *callingSlv;
   1.148 +   VSsTaskType       *taskType;
   1.149 +   void              *args;
   1.150 +   VSsTaskStub       *taskStub;
   1.151 +   
   1.152 +   SlaveVP           *senderSlv;
   1.153 +   SlaveVP           *receiverSlv;
   1.154 +   int32             *senderID;
   1.155 +   int32             *receiverID;
   1.156 +   int32              msgType;
   1.157 +   void              *msg;
   1.158 +   VSsSemReq         *nextReqInHashEntry;
   1.159 +   int32             *taskID;
   1.160 +   
   1.161 +   TopLevelFnPtr      fnPtr;
   1.162 +   void              *initData;
   1.163 +   int32              coreToAssignOnto;
   1.164 +
   1.165 +   int32              sizeToMalloc;
   1.166 +   void              *ptrToFree;
   1.167 +
   1.168 +   int32              singletonID;
   1.169 +   VSsSingleton     **singletonPtrAddr;
   1.170 +
   1.171 +   PtrToAtomicFn      fnToExecInMaster;
   1.172 +   void              *dataForFn;
   1.173 +
   1.174 +   int32              transID;
   1.175 + }
   1.176 +/* VSsSemReq */;
   1.177 +
   1.178 +
   1.179 +typedef struct
   1.180 + {
   1.181 +   PrivQueueStruc  *slavesReadyToResumeQ; //Shared (slaves not pinned)
   1.182 +   PrivQueueStruc  *freeExtraTaskSlvQ;    //Shared
   1.183 +   PrivQueueStruc  *taskReadyQ;           //Shared (tasks not pinned)
   1.184 +   SlaveVP         *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS];
   1.185 +   HashTable       *argPtrHashTbl;
   1.186 +   HashTable       *commHashTbl;
   1.187 +   int32            numLiveExtraTaskSlvs;
   1.188 +   int32            numLiveThreadSlvs;
   1.189 +   int32            nextCoreToGetNewSlv;
   1.190 +   int32            primitiveStartTime;
   1.191 +
   1.192 +                       //fix limit on num with dynArray
   1.193 +   VSsSingleton     fnSingletons[NUM_STRUCS_IN_SEM_ENV];
   1.194 +   VSsTrans         transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
   1.195 +
   1.196 +   bool32          *coreIsDone;
   1.197 +   int32            numCoresDone;
   1.198 +   
   1.199 +   #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
   1.200 +   ListOfArrays* unitList;
   1.201 +   ListOfArrays* ctlDependenciesList;
   1.202 +   ListOfArrays* commDependenciesList;
   1.203 +   NtoN** ntonGroups;
   1.204 +   PrivDynArrayInfo* ntonGroupsInfo;
   1.205 +   ListOfArrays* dynDependenciesList;
   1.206 +   Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS];
   1.207 +   ListOfArrays* hwArcs;
   1.208 +   #endif
   1.209 +
   1.210 +   #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
   1.211 +   ListOfArrays* counterList[NUM_CORES];
   1.212 +   #endif
   1.213 +   SlaveVP* idleSlv[NUM_CORES][NUM_ANIM_SLOTS];
   1.214 +   int shutdownInitiated;
   1.215 + }
   1.216 +VSsSemEnv;
   1.217 +
   1.218 +
   1.219 +typedef struct _TransListElem TransListElem;
   1.220 +struct _TransListElem
   1.221 + {
   1.222 +   int32          transID;
   1.223 +   TransListElem *nextTrans;
   1.224 + };
   1.225 +//TransListElem
   1.226 + 
   1.227 +enum VSsSlvType
   1.228 + { ExtraTaskSlv = 1,
   1.229 +   SlotTaskSlv,
   1.230 +   ThreadSlv
   1.231 + };
   1.232 + 
   1.233 +typedef struct
   1.234 + {
   1.235 +   int32           highestTransEntered;
   1.236 +   TransListElem  *lastTransEntered;
   1.237 +   bool32          needsTaskAssigned;
   1.238 +   VSsTaskStub    *taskStub;
   1.239 +   enum VSsSlvType slaveType;
   1.240 + }
   1.241 +VSsSemData;
   1.242 + 
   1.243 +//===========================================================================
   1.244 +
   1.245 +void
   1.246 +VSs__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData );
   1.247 +
   1.248 +int32
   1.249 +VSs__giveMinWorkUnitCycles( float32 percentOverhead );
   1.250 +
   1.251 +void
   1.252 +VSs__start_primitive();
   1.253 +
   1.254 +int32
   1.255 +VSs__end_primitive_and_give_cycles();
   1.256 +
   1.257 +int32
   1.258 +VSs__giveIdealNumWorkUnits();
   1.259 +
   1.260 +int32
   1.261 +VSs__give_number_of_cores_to_schedule_onto();
   1.262 +
   1.263 +//=======================
   1.264 +
   1.265 +void
   1.266 +VSs__init();
   1.267 +
   1.268 +void
   1.269 +VSs__cleanup_after_shutdown();
   1.270 +
   1.271 +//=======================
   1.272 +
   1.273 +SlaveVP *
   1.274 +VSs__create_thread( TopLevelFnPtr fnPtr,   void *initData,
   1.275 +                                                     SlaveVP *creatingThd );
   1.276 +
   1.277 +void
   1.278 +VSs__end_thread( SlaveVP *thdToEnd );
   1.279 +
   1.280 +//=======================
   1.281 +
   1.282 +#define VSs__malloc( numBytes, callingSlave ) VMS_App__malloc( numBytes, callingSlave)
   1.283 +
   1.284 +#define VSs__free(ptrToFree, callingSlave ) VMS_App__free( ptrToFree, callingSlave )
   1.285 +
   1.286 +
   1.287 +//=======================
   1.288 +void
   1.289 +VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv);
   1.290 +
   1.291 +inline int32 *
   1.292 +VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv );
   1.293 +
   1.294 +void
   1.295 +VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID, 
   1.296 +                          SlaveVP     *animSlv);
   1.297 +
   1.298 +void
   1.299 +VSs__end_task( SlaveVP *animSlv );
   1.300 +
   1.301 +//=========================
   1.302 +void
   1.303 +VSs__taskwait(SlaveVP *animSlv);
   1.304 +
   1.305 +
   1.306 +inline int32 *
   1.307 +VSs__give_self_taskID( SlaveVP *animSlv );
   1.308 +
   1.309 +void
   1.310 +VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID,
   1.311 +                      SlaveVP *senderSlv );
   1.312 +
   1.313 +void
   1.314 +VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv );
   1.315 +
   1.316 +void *
   1.317 +VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv );
   1.318 +
   1.319 +void *
   1.320 +VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv );
   1.321 +
   1.322 +//======================= Concurrency Stuff ======================
   1.323 +void
   1.324 +VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
   1.325 +
   1.326 +void
   1.327 +VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
   1.328 +
   1.329 +void
   1.330 +VSs__start_data_singleton( VSsSingleton **singeltonAddr, SlaveVP *animSlv );
   1.331 +
   1.332 +void
   1.333 +VSs__end_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv );
   1.334 +
   1.335 +void
   1.336 +VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
   1.337 +                                    void *data, SlaveVP *animSlv );
   1.338 +
   1.339 +void
   1.340 +VSs__start_transaction( int32 transactionID, SlaveVP *animSlv );
   1.341 +
   1.342 +void
   1.343 +VSs__end_transaction( int32 transactionID, SlaveVP *animSlv );
   1.344 +
   1.345 +
   1.346 +//=========================  Internal use only  =============================
   1.347 +void
   1.348 +VSs__Request_Handler( SlaveVP *requestingSlv, void *_semEnv );
   1.349 +
   1.350 +SlaveVP *
   1.351 +VSs__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
   1.352 +
   1.353 +SlaveVP*
   1.354 +VSs__create_slave_helper( TopLevelFnPtr fnPtr, void *initData,
   1.355 +                          VSsSemEnv *semEnv,    int32 coreToAssignOnto );
   1.356 +
   1.357 +VSsTaskStub *
   1.358 +create_thread_task_stub( void *initData );
   1.359 +
   1.360 +
   1.361 +SlaveVP *
   1.362 +VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData,
   1.363 +                          SlaveVP *creatingSlv );
   1.364 +
   1.365 +SlaveVP *
   1.366 +VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr,    void *initData,
   1.367 +                            SlaveVP *creatingSlv, int32 coreToAssignOnto);
   1.368 +
   1.369 +void 
   1.370 +idle_fn(void* data, SlaveVP *animatingSlv);
   1.371 +
   1.372 +//=====================  Measurement of Lang Overheads  =====================
   1.373 +#include "Measurement/VSs_Measurement.h"
   1.374 +
   1.375 +//===========================================================================
   1.376 +#endif	/* _VSs_H */
   1.377 +