annotate SSR.h @ 72:d20b105981b7

make idle VPs optional
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Wed, 28 Mar 2012 18:02:38 +0200
parents 8882e795016d
children f20b4d9d3086
rev   line source
Me@6 1 /*
Me@6 2 * Copyright 2009 OpenSourceStewardshipFoundation.org
Me@6 3 * Licensed under GNU General Public License version 2
Me@6 4 *
Me@6 5 * Author: seanhalle@yahoo.com
Me@6 6 *
Me@6 7 */
Me@6 8
Me@6 9 #ifndef _SSR_H
Me@6 10 #define _SSR_H
Me@6 11
seanhalle@60 12 #include "Queue_impl/PrivateQueue.h"
seanhalle@60 13 #include "Hash_impl/PrivateHash.h"
seanhalle@60 14 #include "VMS_impl/VMS.h"
Nina@39 15 #include "dependency.h"
Me@6 16
Me@17 17
Me@17 18 //===========================================================================
Me@17 19 #define NUM_STRUCS_IN_SEM_ENV 1000
Me@17 20
nengel@72 21 //#define IDLE_SLAVES
nengel@72 22
seanhalle@62 23 //This is hardware dependent -- it's the number of cycles of scheduling
seanhalle@62 24 // overhead -- if a work unit is fewer than this, it is better being
seanhalle@62 25 // combined sequentially with other work
seanhalle@62 26 //This value depends on both VMS overhead and SSR's plugin. At some point
seanhalle@62 27 // it will be derived by perf-counter measurements during init of SSR
seanhalle@62 28 #define MIN_WORK_UNIT_CYCLES 20000
seanhalle@62 29
Me@17 30 //===========================================================================
Me@6 31 /*This header defines everything specific to the SSR semantic plug-in
Me@6 32 */
Me@6 33 typedef struct _SSRSemReq SSRSemReq;
Me@17 34 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
Me@17 35 //===========================================================================
Me@6 36
Me@6 37 /*Semantic layer-specific data sent inside a request from lib called in app
seanhalle@67 38 * to request handler called in AnimationMaster
Me@6 39 */
Me@21 40
Me@21 41 typedef struct
Me@21 42 {
seanhalle@60 43 SlaveVP *VPCurrentlyExecuting;
Me@21 44 PrivQueueStruc *waitingVPQ;
Me@21 45 }
Me@21 46 SSRTrans;
Me@21 47
msach@24 48 /*WARNING: assembly hard-codes position of endInstrAddr as first field
msach@24 49 */
Me@21 50 typedef struct
Me@21 51 {
Me@22 52 void *endInstrAddr;
Me@21 53 int32 hasBeenStarted;
Me@21 54 int32 hasFinished;
Me@21 55 PrivQueueStruc *waitQ;
Me@21 56 }
Me@21 57 SSRSingleton;
Me@21 58
Me@6 59 enum SSRReqType
Me@6 60 {
Me@6 61 send_type = 1,
Me@6 62 send_from_to,
Me@6 63 receive_any, //order and grouping matter -- send before receive
Me@6 64 receive_type, // and receive_any first of the receives -- Handlers
Me@6 65 receive_from_to,// rely upon this ordering of enum
Me@6 66 transfer_to,
Me@17 67 transfer_out,
Me@17 68 malloc_req,
Me@17 69 free_req,
Me@21 70 singleton_fn_start,
Me@21 71 singleton_fn_end,
Me@21 72 singleton_data_start,
Me@21 73 singleton_data_end,
Me@17 74 atomic,
Me@17 75 trans_start,
Me@17 76 trans_end
Me@6 77 };
Me@6 78
Me@6 79 struct _SSRSemReq
Me@6 80 { enum SSRReqType reqType;
seanhalle@60 81 SlaveVP *sendPr;
seanhalle@60 82 SlaveVP *receivePr;
Me@17 83 int32 msgType;
Me@17 84 void *msg;
Me@6 85 SSRSemReq *nextReqInHashEntry;
Me@17 86
Me@17 87 void *initData;
seanhalle@60 88 TopLevelFnPtr fnPtr;
seanhalle@64 89 int32 coreToAssignOnto;
Me@17 90
Me@17 91 int32 sizeToMalloc;
Me@17 92 void *ptrToFree;
Me@17 93
Me@17 94 int32 singletonID;
Me@22 95 SSRSingleton **singletonPtrAddr;
Me@17 96
Me@17 97 PtrToAtomicFn fnToExecInMaster;
Me@17 98 void *dataForFn;
Me@17 99
Me@17 100 int32 transID;
Me@6 101 }
Me@6 102 /* SSRSemReq */;
Me@6 103
Me@17 104
Me@17 105 typedef struct
Me@17 106 {
Me@6 107 PrivQueueStruc **readyVPQs;
Me@14 108 HashTable *commHashTbl;
seanhalle@60 109 int32 numSlaveVP;
Me@14 110 int32 nextCoreToGetNewPr;
Me@14 111 int32 primitiveStartTime;
Me@17 112
Me@17 113 //fix limit on num with dynArray
Me@21 114 SSRSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
Me@17 115 SSRTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
Nina@39 116
seanhalle@60 117 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC
nengel@47 118 ListOfArrays* unitList;
nengel@46 119 ListOfArrays* ctlDependenciesList;
nengel@46 120 ListOfArrays* commDependenciesList;
nengel@48 121 NtoN** ntonGroups;
nengel@48 122 PrivDynArrayInfo* ntonGroupsInfo;
nengel@49 123 ListOfArrays* dynDependenciesList;
seanhalle@69 124 Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS];
nengel@49 125 ListOfArrays* hwArcs;
Nina@39 126 #endif
nengel@50 127
seanhalle@60 128 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
nengel@56 129 ListOfArrays* counterList[NUM_CORES];
nengel@50 130 #endif
nengel@72 131 #ifdef IDLE_SLAVES
seanhalle@69 132 SlaveVP* idlePr[NUM_CORES][NUM_ANIM_SLOTS];
nengel@66 133 int shutdownInitiated;
nengel@72 134 #endif
Me@6 135 }
Me@6 136 SSRSemEnv;
Me@6 137
Me@6 138
Me@17 139 typedef struct _TransListElem TransListElem;
Me@17 140 struct _TransListElem
Me@17 141 {
Me@17 142 int32 transID;
Me@17 143 TransListElem *nextTrans;
Me@17 144 };
Me@18 145 //TransListElem
Me@18 146
Me@17 147 typedef struct
Me@17 148 {
Me@17 149 int32 highestTransEntered;
Me@17 150 TransListElem *lastTransEntered;
Me@17 151 }
Me@17 152 SSRSemData;
Me@17 153
Me@6 154 //===========================================================================
Me@6 155
Me@6 156 void
seanhalle@60 157 SSR__create_seed_procr_and_do_work( TopLevelFnPtr fn, void *initData );
Me@6 158
Me@14 159 int32
Me@14 160 SSR__giveMinWorkUnitCycles( float32 percentOverhead );
Me@14 161
Me@20 162 void
Me@14 163 SSR__start_primitive();
Me@14 164
Me@20 165 int32
Me@14 166 SSR__end_primitive_and_give_cycles();
Me@14 167
Me@16 168 int32
Me@16 169 SSR__giveIdealNumWorkUnits();
Me@14 170
Me@17 171 int32
Me@17 172 SSR__give_number_of_cores_to_schedule_onto();
Me@17 173
Me@6 174 //=======================
Me@6 175
Me@6 176 void
Me@6 177 SSR__init();
Me@6 178
Me@6 179 void
Me@6 180 SSR__cleanup_after_shutdown();
Me@6 181
Me@6 182 //=======================
Me@6 183
seanhalle@60 184 SlaveVP *
seanhalle@60 185 SSR__create_procr_with( TopLevelFnPtr fnPtr, void *initData,
seanhalle@60 186 SlaveVP *creatingSlv );
Me@6 187
seanhalle@60 188 SlaveVP *
seanhalle@60 189 SSR__create_procr_with_affinity( TopLevelFnPtr fnPtr, void *initData,
seanhalle@64 190 SlaveVP *creatingPr, int32 coreToAssignOnto);
Me@17 191
Me@6 192 void
seanhalle@60 193 SSR__dissipate_procr( SlaveVP *procrToDissipate );
Me@6 194
Me@6 195 //=======================
Me@6 196 void *
seanhalle@60 197 SSR__malloc_to( int numBytes, SlaveVP *ownerSlv );
Me@17 198
Me@17 199 void
seanhalle@60 200 SSR__free( void *ptrToFree, SlaveVP *owningSlv );
Me@6 201
Me@6 202 void
seanhalle@60 203 SSR__transfer_ownership_of_from_to( void *data, SlaveVP *oldOwnerPr,
seanhalle@60 204 SlaveVP *newOwnerSlv );
Me@6 205
Me@6 206 void
seanhalle@60 207 SSR__add_ownership_by_to( SlaveVP *newOwnerPr, void *data );
Me@6 208
Me@6 209 void
seanhalle@60 210 SSR__remove_ownership_by_from( SlaveVP *loserPr, void *dataLosing );
Me@6 211
Me@6 212 void
Me@6 213 SSR__transfer_ownership_to_outside( void *dataToTransferOwnershipOf );
Me@6 214
Me@6 215
Me@6 216
Me@6 217 //=======================
Me@6 218 void
seanhalle@60 219 SSR__send_of_type_to( SlaveVP *sendPr, void *msg, const int type,
seanhalle@60 220 SlaveVP *receivePr);
Me@6 221
Me@6 222 void
seanhalle@60 223 SSR__send_from_to( void *msg, SlaveVP *sendPr, SlaveVP *receivePr);
Me@6 224
Me@6 225 void *
seanhalle@60 226 SSR__receive_type_to( const int type, SlaveVP *receiveSlv );
Me@6 227
Me@6 228 void *
seanhalle@60 229 SSR__receive_from_to( SlaveVP *sendPr, SlaveVP *receiveSlv );
Me@6 230
Me@6 231
Me@17 232 //======================= Concurrency Stuff ======================
Me@17 233 void
seanhalle@60 234 SSR__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
Me@21 235
Me@21 236 void
seanhalle@60 237 SSR__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
Me@21 238
Me@21 239 void
seanhalle@60 240 SSR__start_data_singleton( SSRSingleton **singeltonAddr, SlaveVP *animSlv );
Me@21 241
Me@21 242 void
seanhalle@60 243 SSR__end_data_singleton( SSRSingleton **singletonAddr, SlaveVP *animSlv );
Me@6 244
Me@6 245 void
Me@17 246 SSR__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
seanhalle@60 247 void *data, SlaveVP *animSlv );
Me@17 248
Me@17 249 void
seanhalle@60 250 SSR__start_transaction( int32 transactionID, SlaveVP *animSlv );
Me@17 251
Me@17 252 void
seanhalle@60 253 SSR__end_transaction( int32 transactionID, SlaveVP *animSlv );
Me@6 254
Me@6 255
Me@6 256 //========================= Internal use only =============================
Me@6 257 void
seanhalle@60 258 SSR__Request_Handler( SlaveVP *requestingPr, void *_semEnv );
Me@6 259
seanhalle@60 260 SlaveVP *
seanhalle@67 261 SSR__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
Me@6 262
seanhalle@60 263 SlaveVP*
seanhalle@60 264 SSR__create_procr_helper( TopLevelFnPtr fnPtr, void *initData,
seanhalle@64 265 SSRSemEnv *semEnv, int32 coreToAssignOnto );
Me@6 266
seanhalle@64 267 //===================== Measurement of Lang Overheads =====================
seanhalle@64 268 #include "SSR_Measurement.h"
seanhalle@64 269
seanhalle@64 270 //===========================================================================
Me@6 271 #endif /* _SSR_H */
Me@6 272