| rev |
line source |
|
Me@0
|
1 /*
|
|
Me@0
|
2 * Copyright 2009 OpenSourceStewardshipFoundation.org
|
|
Me@0
|
3 * Licensed under GNU General Public License version 2
|
|
Me@0
|
4 *
|
|
Me@0
|
5 * Author: seanhalle@yahoo.com
|
|
Me@0
|
6 *
|
|
Me@0
|
7 */
|
|
Me@0
|
8
|
|
Me@0
|
9 #ifndef _VMS_H
|
|
Me@0
|
10 #define _VMS_H
|
|
Me@0
|
11
|
|
Me@0
|
12 #include "VMS_primitive_data_types.h"
|
|
Me@0
|
13 #include "Queue_impl/BlockingQueue.h"
|
|
Me@7
|
14 #include <windows.h>
|
|
Me@13
|
15 #include <winbase.h>
|
|
Me@0
|
16
|
|
Me@0
|
17 //This value is the number of hardware threads in the shared memory
|
|
Me@5
|
18 // machine -- make double that number scheduling slots, plus extra for master
|
|
Me@7
|
19 #define NUM_CORES 4
|
|
Me@5
|
20 #define NUM_SCHED_SLOTS 9
|
|
Me@0
|
21
|
|
Me@0
|
22 #define SUCCESS 0
|
|
Me@0
|
23
|
|
Me@13
|
24 //#define thdAttrs NULL //For PThreads
|
|
Me@0
|
25
|
|
Me@5
|
26 typedef struct _WorkUnit WorkUnit;
|
|
Me@5
|
27 typedef struct _VirtProcr VirtProcr;
|
|
Me@5
|
28 typedef struct _SlaveReqst SlaveReqst;
|
|
Me@5
|
29 typedef struct _SchedSlot SchedSlot;
|
|
Me@0
|
30
|
|
Me@5
|
31 typedef bool8 (*SlaveScheduler) ( SchedSlot *, void * );
|
|
Me@0
|
32 typedef void (*RequestHandler) ( SlaveReqst * );
|
|
Me@5
|
33 typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * );
|
|
Me@5
|
34 typedef void VirtProcrFn( void *, VirtProcr * );
|
|
Me@0
|
35
|
|
Me@0
|
36 typedef struct
|
|
Me@0
|
37 {
|
|
Me@7
|
38 void *endThdPt;
|
|
Me@7
|
39 unsigned int coreNum;
|
|
Me@0
|
40 }
|
|
Me@0
|
41 ThdParams;
|
|
Me@0
|
42
|
|
Me@5
|
43 struct _SchedSlot
|
|
Me@5
|
44 {
|
|
Me@5
|
45 int workIsDone;
|
|
Me@5
|
46 int needsProcrAssigned;
|
|
Me@5
|
47 VirtProcr *procrAssignedToSlot;
|
|
Me@5
|
48 };
|
|
Me@5
|
49
|
|
Me@5
|
50
|
|
Me@5
|
51 struct _VirtProcr
|
|
Me@13
|
52 { int procrID; //for debugging -- count up each time create
|
|
Me@5
|
53 void *stackPtr;
|
|
Me@5
|
54 void *framePtr;
|
|
Me@5
|
55 void *nextInstrPt;
|
|
Me@5
|
56 void *coreLoopStartPt; //allows proto-runtime to be linked later
|
|
Me@5
|
57
|
|
Me@5
|
58 void *initialData;
|
|
Me@5
|
59
|
|
Me@5
|
60 SchedSlot *schedSlot;
|
|
Me@5
|
61 SlaveReqst *requests;
|
|
Me@5
|
62
|
|
Me@5
|
63 void *semanticData;
|
|
Me@5
|
64 };
|
|
Me@5
|
65
|
|
Me@5
|
66
|
|
Me@5
|
67 //When optimize make a separate flat array in here for each flag in SchedSlot
|
|
Me@5
|
68 //So that polling done flags is fast.. not sure even worth it, though..
|
|
Me@0
|
69 typedef struct
|
|
Me@0
|
70 {
|
|
Me@5
|
71 SlaveScheduler slaveScheduler;
|
|
Me@5
|
72 RequestHandler requestHandler;
|
|
Me@0
|
73
|
|
Me@5
|
74 SchedSlot **schedSlots;
|
|
Me@5
|
75 SchedSlot **filledSlots;
|
|
Me@5
|
76 int numFilled;
|
|
Me@5
|
77
|
|
Me@0
|
78 int stillRunning;
|
|
Me@0
|
79
|
|
Me@5
|
80 VirtProcr *masterVirtPr;
|
|
Me@0
|
81 void *semanticEnv;
|
|
Me@5
|
82 void *OSEventStruc; //for future, when add I/O to BLIS
|
|
Me@0
|
83 }
|
|
Me@0
|
84 MasterEnv;
|
|
Me@0
|
85
|
|
Me@0
|
86
|
|
Me@5
|
87
|
|
Me@5
|
88 struct _SlaveReqst
|
|
Me@0
|
89 {
|
|
Me@5
|
90 VirtProcr *slaveFrom;
|
|
Me@5
|
91 int reqType; //for future when have I/O and OS services
|
|
Me@5
|
92 void *semReqData;
|
|
Me@0
|
93
|
|
Me@0
|
94 SlaveReqst *nextRequest;
|
|
Me@0
|
95 };
|
|
Me@0
|
96
|
|
Me@0
|
97
|
|
Me@7
|
98 DWORD WINAPI coreLoop( LPVOID paramsIn );
|
|
Me@7
|
99 //void * coreLoop( void *paramsIn ); //standard PThreads fn prototype
|
|
Me@7
|
100 void masterLoop( void *initData, VirtProcr *masterPr );
|
|
Me@0
|
101
|
|
Me@0
|
102
|
|
Me@0
|
103 //===================== Global Vars ===================
|
|
Me@0
|
104
|
|
Me@5
|
105
|
|
Me@13
|
106 HANDLE coreLoopThdHandles[ NUM_CORES ]; //windows handle to thread
|
|
Me@13
|
107 ThdParams *coreLoopThdParams[ NUM_CORES ];
|
|
Me@13
|
108 DWORD coreLoopThdIds[ NUM_CORES ];
|
|
Me@0
|
109
|
|
Me@13
|
110 //TODO: Debug: figure out if need to be volatile or not
|
|
Me@13
|
111 volatile MasterEnv *_VMSMasterEnv;
|
|
Me@5
|
112
|
|
Me@5
|
113 //workQ is global, static, and volatile so that core loop has its location
|
|
Me@5
|
114 // hard coded, and reloads every time through the loop -- that way don't
|
|
Me@5
|
115 // need to save any regs used by core loop (will see if this really works)
|
|
Me@13
|
116 volatile CASQueueStruc *_VMSWorkQ;
|
|
Me@0
|
117
|
|
Me@7
|
118 //==========================
|
|
Me@7
|
119 void
|
|
Me@7
|
120 VMS__init();
|
|
Me@7
|
121
|
|
Me@7
|
122 void
|
|
Me@7
|
123 VMS__start();
|
|
Me@7
|
124
|
|
Me@7
|
125 VirtProcr *
|
|
Me@7
|
126 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
|
|
Me@7
|
127
|
|
Me@7
|
128 inline void
|
|
Me@7
|
129 VMS__send_sem_request( void *semReqData, VirtProcr *callingPr );
|
|
Me@7
|
130
|
|
Me@7
|
131 void
|
|
Me@7
|
132 VMS__suspend_processor( VirtProcr *callingPr );
|
|
Me@7
|
133
|
|
Me@13
|
134 //============================= Statistics ==================================
|
|
Me@13
|
135
|
|
Me@13
|
136 typedef unsigned long long TSCount;
|
|
Me@13
|
137
|
|
Me@13
|
138 #define saveTimeStampCountInto(low, high) \
|
|
Me@13
|
139 asm volatile("RDTSC; \
|
|
Me@13
|
140 movl %%eax, %0; \
|
|
Me@13
|
141 movl %%edx, %1;" \
|
|
Me@13
|
142 /* outputs */ : "=m" (low), "=m" (high)\
|
|
Me@13
|
143 /* inputs */ : \
|
|
Me@13
|
144 /* clobber */ : "%eax", "%edx" \
|
|
Me@13
|
145 );
|
|
Me@13
|
146
|
|
Me@13
|
147 inline TSCount getTSCount();
|
|
Me@13
|
148
|
|
Me@13
|
149 int numProcrsCreated;
|
|
Me@0
|
150
|
|
Me@0
|
151 #endif /* _VMS_H */
|
|
Me@0
|
152
|