annotate SSR.h @ 73:f20b4d9d3086

add recording of req type for unit fusing in ucc
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Mon, 16 Apr 2012 18:25:31 +0200
parents d20b105981b7
children b73e4a6f3497
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;
nengel@73 126 int lastReqType;
Nina@39 127 #endif
nengel@50 128
seanhalle@60 129 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS
nengel@56 130 ListOfArrays* counterList[NUM_CORES];
nengel@50 131 #endif
nengel@72 132 #ifdef IDLE_SLAVES
seanhalle@69 133 SlaveVP* idlePr[NUM_CORES][NUM_ANIM_SLOTS];
nengel@66 134 int shutdownInitiated;
nengel@72 135 #endif
Me@6 136 }
Me@6 137 SSRSemEnv;
Me@6 138
Me@6 139
Me@17 140 typedef struct _TransListElem TransListElem;
Me@17 141 struct _TransListElem
Me@17 142 {
Me@17 143 int32 transID;
Me@17 144 TransListElem *nextTrans;
Me@17 145 };
Me@18 146 //TransListElem
Me@18 147
Me@17 148 typedef struct
Me@17 149 {
Me@17 150 int32 highestTransEntered;
Me@17 151 TransListElem *lastTransEntered;
Me@17 152 }
Me@17 153 SSRSemData;
Me@17 154
Me@6 155 //===========================================================================
Me@6 156
Me@6 157 void
seanhalle@60 158 SSR__create_seed_procr_and_do_work( TopLevelFnPtr fn, void *initData );
Me@6 159
Me@14 160 int32
Me@14 161 SSR__giveMinWorkUnitCycles( float32 percentOverhead );
Me@14 162
Me@20 163 void
Me@14 164 SSR__start_primitive();
Me@14 165
Me@20 166 int32
Me@14 167 SSR__end_primitive_and_give_cycles();
Me@14 168
Me@16 169 int32
Me@16 170 SSR__giveIdealNumWorkUnits();
Me@14 171
Me@17 172 int32
Me@17 173 SSR__give_number_of_cores_to_schedule_onto();
Me@17 174
Me@6 175 //=======================
Me@6 176
Me@6 177 void
Me@6 178 SSR__init();
Me@6 179
Me@6 180 void
Me@6 181 SSR__cleanup_after_shutdown();
Me@6 182
Me@6 183 //=======================
Me@6 184
seanhalle@60 185 SlaveVP *
seanhalle@60 186 SSR__create_procr_with( TopLevelFnPtr fnPtr, void *initData,
seanhalle@60 187 SlaveVP *creatingSlv );
Me@6 188
seanhalle@60 189 SlaveVP *
seanhalle@60 190 SSR__create_procr_with_affinity( TopLevelFnPtr fnPtr, void *initData,
seanhalle@64 191 SlaveVP *creatingPr, int32 coreToAssignOnto);
Me@17 192
Me@6 193 void
seanhalle@60 194 SSR__dissipate_procr( SlaveVP *procrToDissipate );
Me@6 195
Me@6 196 //=======================
Me@6 197 void *
seanhalle@60 198 SSR__malloc_to( int numBytes, SlaveVP *ownerSlv );
Me@17 199
Me@17 200 void
seanhalle@60 201 SSR__free( void *ptrToFree, SlaveVP *owningSlv );
Me@6 202
Me@6 203 void
seanhalle@60 204 SSR__transfer_ownership_of_from_to( void *data, SlaveVP *oldOwnerPr,
seanhalle@60 205 SlaveVP *newOwnerSlv );
Me@6 206
Me@6 207 void
seanhalle@60 208 SSR__add_ownership_by_to( SlaveVP *newOwnerPr, void *data );
Me@6 209
Me@6 210 void
seanhalle@60 211 SSR__remove_ownership_by_from( SlaveVP *loserPr, void *dataLosing );
Me@6 212
Me@6 213 void
Me@6 214 SSR__transfer_ownership_to_outside( void *dataToTransferOwnershipOf );
Me@6 215
Me@6 216
Me@6 217
Me@6 218 //=======================
Me@6 219 void
seanhalle@60 220 SSR__send_of_type_to( SlaveVP *sendPr, void *msg, const int type,
seanhalle@60 221 SlaveVP *receivePr);
Me@6 222
Me@6 223 void
seanhalle@60 224 SSR__send_from_to( void *msg, SlaveVP *sendPr, SlaveVP *receivePr);
Me@6 225
Me@6 226 void *
seanhalle@60 227 SSR__receive_type_to( const int type, SlaveVP *receiveSlv );
Me@6 228
Me@6 229 void *
seanhalle@60 230 SSR__receive_from_to( SlaveVP *sendPr, SlaveVP *receiveSlv );
Me@6 231
Me@6 232
Me@17 233 //======================= Concurrency Stuff ======================
Me@17 234 void
seanhalle@60 235 SSR__start_fn_singleton( int32 singletonID, SlaveVP *animSlv );
Me@21 236
Me@21 237 void
seanhalle@60 238 SSR__end_fn_singleton( int32 singletonID, SlaveVP *animSlv );
Me@21 239
Me@21 240 void
seanhalle@60 241 SSR__start_data_singleton( SSRSingleton **singeltonAddr, SlaveVP *animSlv );
Me@21 242
Me@21 243 void
seanhalle@60 244 SSR__end_data_singleton( SSRSingleton **singletonAddr, SlaveVP *animSlv );
Me@6 245
Me@6 246 void
Me@17 247 SSR__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
seanhalle@60 248 void *data, SlaveVP *animSlv );
Me@17 249
Me@17 250 void
seanhalle@60 251 SSR__start_transaction( int32 transactionID, SlaveVP *animSlv );
Me@17 252
Me@17 253 void
seanhalle@60 254 SSR__end_transaction( int32 transactionID, SlaveVP *animSlv );
Me@6 255
Me@6 256
Me@6 257 //========================= Internal use only =============================
Me@6 258 void
seanhalle@60 259 SSR__Request_Handler( SlaveVP *requestingPr, void *_semEnv );
Me@6 260
seanhalle@60 261 SlaveVP *
seanhalle@67 262 SSR__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot );
Me@6 263
seanhalle@60 264 SlaveVP*
seanhalle@60 265 SSR__create_procr_helper( TopLevelFnPtr fnPtr, void *initData,
seanhalle@64 266 SSRSemEnv *semEnv, int32 coreToAssignOnto );
Me@6 267
seanhalle@64 268 //===================== Measurement of Lang Overheads =====================
seanhalle@64 269 #include "SSR_Measurement.h"
seanhalle@64 270
seanhalle@64 271 //===========================================================================
Me@6 272 #endif /* _SSR_H */
Me@6 273