VMS/VMS_Implementations/VCilk_impls/VCilk__MC_shared_impl

view VCilk.h @ 8:e649c2387a60

new sequential version
author Merten Sach <msach@mailbox.tu-berlin.de>
date Thu, 02 Jun 2011 13:54:34 +0200
parents 5494943ed3a4
children 5131f941f42c
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 /*WARNING: assembly hard-codes position of endInstrAddr as first field
32 */
33 typedef struct
34 {
35 void *endInstrAddr;
36 int32 hasBeenStarted;
37 int32 hasFinished;
38 PrivQueueStruc *waitQ;
39 }
40 VCilkSingleton;
42 /*Semantic layer-specific data sent inside a request from lib called in app
43 * to request handler called in MasterLoop
44 */
45 enum VCilkReqType
46 {
47 syncReq = 1,
48 mallocReq,
49 freeReq,
50 singleton_fn_start,
51 singleton_fn_end,
52 singleton_data_start,
53 singleton_data_end,
54 atomic,
55 trans_start,
56 trans_end
57 };
59 struct _VCilkSemReq
60 { enum VCilkReqType reqType;
61 VirtProcr *requestingPr;
63 int32 sizeToMalloc;
64 void *ptrToFree;
66 VirtProcrFnPtr fnPtr;
67 void *initData;
68 int32 coreToSpawnOnto;
70 int32 singletonID;
71 VCilkSingleton **singletonPtrAddr;
73 PtrToAtomicFn fnToExecInMaster;
74 void *dataForFn;
76 int32 transID;
77 }
78 /* VCilkSemReq */;
80 typedef struct
81 {
82 VirtProcr *VPCurrentlyExecuting;
83 PrivQueueStruc *waitingVPQ;
84 }
85 VCilkTrans;
87 typedef struct
88 {
89 PrivQueueStruc **readyVPQs;
90 HashTable *commHashTbl;
91 int32 numVirtPr;
92 int32 nextCoreToGetNewPr;
93 int32 primitiveStartTime;
95 //fix limit on num with dynArray
96 VCilkSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV];
97 VCilkTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV];
98 }
99 VCilkSemEnv;
101 typedef struct _TransListElem TransListElem;
102 struct _TransListElem
103 {
104 int32 transID;
105 TransListElem *nextTrans;
106 };
107 //TransListElem
109 typedef struct
110 {
111 int32 syncPending;
112 int32 numLiveChildren;
113 VirtProcr *parentPr;
115 int32 highestTransEntered;
116 TransListElem *lastTransEntered;
117 }
118 VCilkSemData;
120 //===========================================================================
122 void
123 VCilk__create_seed_procr_and_do_work( VirtProcrFnPtr fn, void *initData );
125 int32
126 VCilk__giveMinWorkUnitCycles( float32 percentOverhead );
128 void inline
129 VCilk__start_primitive();
131 int32 inline
132 VCilk__end_primitive_and_give_cycles();
134 int32
135 VCilk__giveIdealNumWorkUnits();
137 //=======================
139 void
140 VCilk__init();
142 void
143 VCilk__cleanup_at_end_of_shutdown();
145 //=======================
147 void inline
148 VCilk__spawn( int32 coreToSpawnOnto, VirtProcrFnPtr fnPtr,
149 void *initData, VirtProcr *creatingPr );
151 int32
152 VCilk__give_number_of_cores_to_spawn_onto();
154 void
155 VCilk__sync( VirtProcr *animatingPr );
157 void *
158 VCilk__malloc( int32 sizeToMalloc, VirtProcr *animPr );
160 void
161 VCilk__free( void *ptrToFree, VirtProcr *animPr );
163 void
164 VCilk__dissipate_procr( VirtProcr *procrToDissipate );
167 //======================= Concurrency Stuff ======================
168 void
169 VCilk__start_fn_singleton( int32 singletonID, VirtProcr *animPr );
171 void
172 VCilk__end_fn_singleton( int32 singletonID, VirtProcr *animPr );
174 void
175 VCilk__start_data_singleton( VCilkSingleton **singeltonAddr, VirtProcr *animPr );
177 void
178 VCilk__end_data_singleton( VCilkSingleton **singletonAddr, VirtProcr *animPr );
180 void
181 VCilk__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster,
182 void *data, VirtProcr *animPr );
184 void
185 VCilk__start_transaction( int32 transactionID, VirtProcr *animPr );
187 void
188 VCilk__end_transaction( int32 transactionID, VirtProcr *animPr );
191 //========================= Internal use only =============================
192 void
193 VCilk__Request_Handler( VirtProcr *requestingPr, void *_semEnv );
195 VirtProcr *
196 VCilk__schedule_virt_procr( void *_semEnv, int coreNum );
199 #endif /* _VCilk_H */