Me@0: /* Me@0: * Copyright 2009 OpenSourceStewardshipFoundation.org Me@0: * Licensed under GNU General Public License version 2 Me@0: * Me@0: * Author: seanhalle@yahoo.com Me@0: * Me@0: */ Me@0: Me@0: #ifndef _VCilk_H Me@0: #define _VCilk_H Me@0: Me@0: #include "VMS/Queue_impl/PrivateQueue.h" Me@0: #include "VMS/Hash_impl/PrivateHash.h" Me@0: #include "VMS/VMS.h" Me@0: Me@2: Me@2: Me@0: /*This header defines everything specific to the VCilk semantic plug-in Me@0: */ Me@2: Me@2: //=========================================================================== Me@2: #define NUM_STRUCS_IN_SEM_ENV 1000 Me@2: Me@2: //=========================================================================== Me@0: typedef struct _VCilkSemReq VCilkSemReq; Me@2: typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master Me@2: Me@2: //=========================================================================== Me@0: Me@0: Me@0: /*Semantic layer-specific data sent inside a request from lib called in app Me@0: * to request handler called in MasterLoop Me@0: */ Me@0: enum VCilkReqType Me@0: { Me@0: syncReq = 1, Me@0: mallocReq, Me@2: freeReq, Me@2: singleton, Me@2: atomic, Me@2: trans_start, Me@2: trans_end Me@0: }; Me@0: Me@0: struct _VCilkSemReq Me@0: { enum VCilkReqType reqType; Me@0: VirtProcr *requestingPr; Me@2: Me@0: int32 sizeToMalloc; Me@0: void *ptrToFree; Me@2: Me@0: VirtProcrFnPtr fnPtr; Me@0: void *initData; Me@0: int32 coreToSpawnOnto; Me@2: Me@2: int32 singletonID; Me@2: void *endJumpPt; Me@2: Me@2: PtrToAtomicFn fnToExecInMaster; Me@2: void *dataForFn; Me@2: Me@2: int32 transID; Me@0: } Me@0: /* VCilkSemReq */; Me@0: Me@0: typedef struct Me@0: { Me@2: VirtProcr *VPCurrentlyExecuting; Me@2: PrivQueueStruc *waitingVPQ; Me@2: } Me@2: VCilkTrans; Me@2: Me@2: typedef struct Me@2: { Me@0: PrivQueueStruc **readyVPQs; Me@0: HashTable *commHashTbl; Me@0: int32 numVirtPr; Me@0: int32 nextCoreToGetNewPr; Me@0: int32 primitiveStartTime; Me@2: Me@2: //fix limit on num with dynArray Me@2: int32 singletonHasBeenExecutedFlags[NUM_STRUCS_IN_SEM_ENV]; Me@2: VCilkTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV]; Me@0: } Me@0: VCilkSemEnv; Me@0: Me@2: typedef struct _TransListElem TransListElem; Me@2: struct _TransListElem Me@2: { Me@2: int32 transID; Me@2: TransListElem *nextTrans; Me@2: }; Me@2: //TransListElem Me@2: Me@0: typedef struct Me@0: { Me@2: int32 syncPending; Me@2: int32 numLiveChildren; Me@2: VirtProcr *parentPr; Me@2: Me@2: int32 highestTransEntered; Me@2: TransListElem *lastTransEntered; Me@0: } Me@0: VCilkSemData; Me@0: Me@0: //=========================================================================== Me@0: Me@0: void Me@0: VCilk__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData ); Me@0: Me@0: int32 Me@0: VCilk__giveMinWorkUnitCycles( float32 percentOverhead ); Me@0: Me@0: void inline Me@0: VCilk__start_primitive(); Me@0: Me@0: int32 inline Me@0: VCilk__end_primitive_and_give_cycles(); Me@0: Me@0: int32 Me@0: VCilk__giveIdealNumWorkUnits(); Me@0: Me@0: //======================= Me@0: Me@0: void Me@0: VCilk__init(); Me@0: Me@0: void Me@2: VCilk__cleanup_at_end_of_shutdown(); Me@0: Me@0: //======================= Me@0: Me@0: void inline Me@0: VCilk__spawn( int32 coreToSpawnOnto, VirtProcrFnPtr fnPtr, Me@0: void *initData, VirtProcr *creatingPr ); Me@0: Me@0: int32 Me@0: VCilk__give_number_of_cores_to_spawn_onto(); Me@0: Me@0: void Me@0: VCilk__sync( VirtProcr *animatingPr ); Me@0: Me@0: void * Me@0: VCilk__malloc( int32 sizeToMalloc, VirtProcr *animPr ); Me@0: Me@0: void Me@0: VCilk__free( void *ptrToFree, VirtProcr *animPr ); Me@0: Me@0: void Me@0: VCilk__dissipate_procr( VirtProcr *procrToDissipate ); Me@0: Me@2: Me@2: //======================= Concurrency Stuff ====================== Me@2: void Me@2: VCilk__start_singleton( int32 singletonID, void *endSingletonLabelAddr, Me@2: VirtProcr *animPr ); Me@0: Me@0: void Me@2: VCilk__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster, Me@2: void *data, VirtProcr *animPr ); Me@2: Me@2: void Me@2: VCilk__start_transaction( int32 transactionID, VirtProcr *animPr ); Me@2: Me@2: void Me@2: VCilk__end_transaction( int32 transactionID, VirtProcr *animPr ); Me@0: Me@0: Me@0: //========================= Internal use only ============================= Me@0: void Me@0: VCilk__Request_Handler( VirtProcr *requestingPr, void *_semEnv ); Me@0: Me@0: VirtProcr * Me@0: VCilk__schedule_virt_procr( void *_semEnv, int coreNum ); Me@0: Me@0: Me@0: #endif /* _VCilk_H */ Me@0: