Me@6: /* Me@6: * Copyright 2009 OpenSourceStewardshipFoundation.org Me@6: * Licensed under GNU General Public License version 2 Me@6: * Me@6: * Author: seanhalle@yahoo.com Me@6: * Me@6: */ Me@6: Me@6: #ifndef _SSR_H Me@6: #define _SSR_H Me@6: Me@6: #include "VMS/Queue_impl/PrivateQueue.h" Me@6: #include "VMS/Hash_impl/PrivateHash.h" Me@6: #include "VMS/VMS.h" Nina@39: #include "dependency.h" Me@6: Me@17: Me@17: //=========================================================================== Me@17: #define NUM_STRUCS_IN_SEM_ENV 1000 Me@17: Me@17: //=========================================================================== Me@6: /*This header defines everything specific to the SSR semantic plug-in Me@6: */ Me@6: typedef struct _SSRSemReq SSRSemReq; Me@17: typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master Me@17: //=========================================================================== Me@6: Me@6: /*Semantic layer-specific data sent inside a request from lib called in app Me@6: * to request handler called in MasterLoop Me@6: */ Me@21: Me@21: typedef struct Me@21: { Me@21: VirtProcr *VPCurrentlyExecuting; Me@21: PrivQueueStruc *waitingVPQ; Me@21: } Me@21: SSRTrans; Me@21: msach@24: /*WARNING: assembly hard-codes position of endInstrAddr as first field msach@24: */ Me@21: typedef struct Me@21: { Me@22: void *endInstrAddr; Me@21: int32 hasBeenStarted; Me@21: int32 hasFinished; Me@21: PrivQueueStruc *waitQ; Me@21: } Me@21: SSRSingleton; Me@21: Me@6: enum SSRReqType Me@6: { Me@6: send_type = 1, Me@6: send_from_to, Me@6: receive_any, //order and grouping matter -- send before receive Me@6: receive_type, // and receive_any first of the receives -- Handlers Me@6: receive_from_to,// rely upon this ordering of enum Me@6: transfer_to, Me@17: transfer_out, Me@17: malloc_req, Me@17: free_req, Me@21: singleton_fn_start, Me@21: singleton_fn_end, Me@21: singleton_data_start, Me@21: singleton_data_end, Me@17: atomic, Me@17: trans_start, Me@17: trans_end Me@6: }; Me@6: Me@6: struct _SSRSemReq Me@6: { enum SSRReqType reqType; Me@17: VirtProcr *sendPr; Me@17: VirtProcr *receivePr; Me@17: int32 msgType; Me@17: void *msg; Me@6: SSRSemReq *nextReqInHashEntry; Me@17: Me@17: void *initData; Me@17: VirtProcrFnPtr fnPtr; Me@17: int32 coreToScheduleOnto; Me@17: Me@17: int32 sizeToMalloc; Me@17: void *ptrToFree; Me@17: Me@17: int32 singletonID; Me@22: SSRSingleton **singletonPtrAddr; Me@17: Me@17: PtrToAtomicFn fnToExecInMaster; Me@17: void *dataForFn; Me@17: Me@17: int32 transID; Me@6: } Me@6: /* SSRSemReq */; Me@6: Me@17: Me@17: typedef struct Me@17: { Me@6: PrivQueueStruc **readyVPQs; Me@14: HashTable *commHashTbl; Me@14: int32 numVirtPr; Me@14: int32 nextCoreToGetNewPr; Me@14: int32 primitiveStartTime; Me@17: Me@17: //fix limit on num with dynArray Me@21: SSRSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV]; Me@17: SSRTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV]; Nina@39: Nina@39: #ifdef OBSERVE_UCC Nina@39: Unit*** unitcollection; Nina@39: PrivDynArrayInfo* unitcollectionInfo; nengel@46: ListOfArrays* ctlDependenciesList; nengel@46: ListOfArrays* commDependenciesList; Nina@39: //NtoN structure? Nina@39: #endif Nina@39: Me@6: } Me@6: SSRSemEnv; Me@6: Me@6: Me@17: typedef struct _TransListElem TransListElem; Me@17: struct _TransListElem Me@17: { Me@17: int32 transID; Me@17: TransListElem *nextTrans; Me@17: }; Me@18: //TransListElem Me@18: Me@17: typedef struct Me@17: { Me@17: int32 highestTransEntered; Me@17: TransListElem *lastTransEntered; Me@17: } Me@17: SSRSemData; Me@17: Me@6: //=========================================================================== Me@6: Me@6: void Me@6: SSR__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData ); Me@6: Me@14: int32 Me@14: SSR__giveMinWorkUnitCycles( float32 percentOverhead ); Me@14: Me@20: void Me@14: SSR__start_primitive(); Me@14: Me@20: int32 Me@14: SSR__end_primitive_and_give_cycles(); Me@14: Me@16: int32 Me@16: SSR__giveIdealNumWorkUnits(); Me@14: Me@17: int32 Me@17: SSR__give_number_of_cores_to_schedule_onto(); Me@17: Me@6: //======================= Me@6: Me@6: void Me@6: SSR__init(); Me@6: Me@6: void Me@6: SSR__cleanup_after_shutdown(); Me@6: Me@6: //======================= Me@6: Me@20: VirtProcr * Me@6: SSR__create_procr_with( VirtProcrFnPtr fnPtr, void *initData, Me@6: VirtProcr *creatingPr ); Me@6: Me@20: VirtProcr * Me@17: SSR__create_procr_with_affinity( VirtProcrFnPtr fnPtr, void *initData, Me@17: VirtProcr *creatingPr, int32 coreToScheduleOnto); Me@17: Me@6: void Me@6: SSR__dissipate_procr( VirtProcr *procrToDissipate ); Me@6: Me@6: //======================= Me@6: void * Me@17: SSR__malloc_to( int numBytes, VirtProcr *ownerPr ); Me@17: Me@17: void Me@17: SSR__free( void *ptrToFree, VirtProcr *owningPr ); Me@6: Me@6: void Me@6: SSR__transfer_ownership_of_from_to( void *data, VirtProcr *oldOwnerPr, Me@6: VirtProcr *newOwnerPr ); Me@6: Me@6: void Me@6: SSR__add_ownership_by_to( VirtProcr *newOwnerPr, void *data ); Me@6: Me@6: void Me@6: SSR__remove_ownership_by_from( VirtProcr *loserPr, void *dataLosing ); Me@6: Me@6: void Me@6: SSR__transfer_ownership_to_outside( void *dataToTransferOwnershipOf ); Me@6: Me@6: Me@6: Me@6: //======================= Me@6: void Me@6: SSR__send_of_type_to( VirtProcr *sendPr, void *msg, const int type, Me@6: VirtProcr *receivePr); Me@6: Me@6: void Me@6: SSR__send_from_to( void *msg, VirtProcr *sendPr, VirtProcr *receivePr); Me@6: Me@6: void * Me@6: SSR__receive_type_to( const int type, VirtProcr *receivePr ); Me@6: Me@6: void * Me@6: SSR__receive_from_to( VirtProcr *sendPr, VirtProcr *receivePr ); Me@6: Me@6: Me@17: //======================= Concurrency Stuff ====================== Me@17: void Me@21: SSR__start_fn_singleton( int32 singletonID, VirtProcr *animPr ); Me@21: Me@21: void Me@21: SSR__end_fn_singleton( int32 singletonID, VirtProcr *animPr ); Me@21: Me@21: void Me@21: SSR__start_data_singleton( SSRSingleton **singeltonAddr, VirtProcr *animPr ); Me@21: Me@21: void Me@21: SSR__end_data_singleton( SSRSingleton **singletonAddr, VirtProcr *animPr ); Me@6: Me@6: void Me@17: SSR__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster, Me@17: void *data, VirtProcr *animPr ); Me@17: Me@17: void Me@17: SSR__start_transaction( int32 transactionID, VirtProcr *animPr ); Me@17: Me@17: void Me@17: SSR__end_transaction( int32 transactionID, VirtProcr *animPr ); Me@6: Me@6: Me@6: //========================= Internal use only ============================= Me@6: void Me@6: SSR__Request_Handler( VirtProcr *requestingPr, void *_semEnv ); Me@6: Me@6: VirtProcr * Me@6: SSR__schedule_virt_procr( void *_semEnv, int coreNum ); Me@6: msach@27: VirtProcr* msach@27: SSR__create_procr_helper( VirtProcrFnPtr fnPtr, void *initData, msach@27: SSRSemEnv *semEnv, int32 coreToScheduleOnto ); Me@6: Me@6: #endif /* _SSR_H */ Me@6: