view VCilk.h @ 4:96420af6b7e8

Nov15 vers for PLDI Fixed bug in create procr & added plugin time-meas
author Me
date Tue, 16 Nov 2010 15:59:23 +0100
parents b456b67cddd0
children 5494943ed3a4
line source
1 /*
2 * Copyright 2009 OpenSourceStewardshipFoundation.org
3 * Licensed under GNU General Public License version 2
4 *
5 * Author: seanhalle@yahoo.com
6 *
7 */
9 #ifndef _VCilk_H
10 #define _VCilk_H
12 #include "VMS/Queue_impl/PrivateQueue.h"
13 #include "VMS/Hash_impl/PrivateHash.h"
14 #include "VMS/VMS.h"
18 /*This header defines everything specific to the VCilk semantic plug-in
19 */
21 //===========================================================================
22 #define NUM_STRUCS_IN_SEM_ENV 1000
24 //===========================================================================
25 typedef struct _VCilkSemReq VCilkSemReq;
26 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master
28 //===========================================================================
31 /*Semantic layer-specific data sent inside a request from lib called in app
32 * to request handler called in MasterLoop
33 */
34 enum VCilkReqType
35 {
36 syncReq = 1,
37 mallocReq,
38 freeReq,
39 singleton,
40 atomic,
41 trans_start,
42 trans_end
43 };
45 struct _VCilkSemReq
46 { enum VCilkReqType reqType;
47 VirtProcr *requestingPr;
49 int32 sizeToMalloc;
50 void *ptrToFree;
52 VirtProcrFnPtr fnPtr;
53 void *initData;
54 int32 coreToSpawnOnto;
56 int32 singletonID;
57 void *endJumpPt;
59 PtrToAtomicFn fnToExecInMaster;
60 void *dataForFn;
62 int32 transID;
63 }
64 /* VCilkSemReq */;
66 typedef struct
67 {
68 VirtProcr *VPCurrentlyExecuting;
69 PrivQueueStruc *waitingVPQ;
70 }
71 VCilkTrans;
73 typedef struct
74 {
75 PrivQueueStruc **readyVPQs;
76 HashTable *commHashTbl;
77 int32 numVirtPr;
78 int32 nextCoreToGetNewPr;
79 int32 primitiveStartTime;
81 //fix limit on num with dynArray
82 int32 singletonHasBeenExecutedFlags[NUM_STRUCS_IN_SEM_ENV];
83 VCilkTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
84 }
85 VCilkSemEnv;
87 typedef struct _TransListElem TransListElem;
88 struct _TransListElem
89 {
90 int32 transID;
91 TransListElem *nextTrans;
92 };
93 //TransListElem
95 typedef struct
96 {
97 int32 syncPending;
98 int32 numLiveChildren;
99 VirtProcr *parentPr;
101 int32 highestTransEntered;
102 TransListElem *lastTransEntered;
103 }
104 VCilkSemData;
106 //===========================================================================
108 void
109 VCilk__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData );
111 int32
112 VCilk__giveMinWorkUnitCycles( float32 percentOverhead );
114 void inline
115 VCilk__start_primitive();
117 int32 inline
118 VCilk__end_primitive_and_give_cycles();
120 int32
121 VCilk__giveIdealNumWorkUnits();
123 //=======================
125 void
126 VCilk__init();
128 void
129 VCilk__cleanup_at_end_of_shutdown();
131 //=======================
133 void inline
134 VCilk__spawn( int32 coreToSpawnOnto, VirtProcrFnPtr fnPtr,
135 void *initData, VirtProcr *creatingPr );
137 int32
138 VCilk__give_number_of_cores_to_spawn_onto();
140 void
141 VCilk__sync( VirtProcr *animatingPr );
143 void *
144 VCilk__malloc( int32 sizeToMalloc, VirtProcr *animPr );
146 void
147 VCilk__free( void *ptrToFree, VirtProcr *animPr );
149 void
150 VCilk__dissipate_procr( VirtProcr *procrToDissipate );
153 //======================= Concurrency Stuff ======================
154 void
155 VCilk__start_singleton( int32 singletonID, void *endSingletonLabelAddr,
156 VirtProcr *animPr );
158 void
159 VCilk__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
160 void *data, VirtProcr *animPr );
162 void
163 VCilk__start_transaction( int32 transactionID, VirtProcr *animPr );
165 void
166 VCilk__end_transaction( int32 transactionID, VirtProcr *animPr );
169 //========================= Internal use only =============================
170 void
171 VCilk__Request_Handler( VirtProcr *requestingPr, void *_semEnv );
173 VirtProcr *
174 VCilk__schedule_virt_procr( void *_semEnv, int coreNum );
177 #endif /* _VCilk_H */