Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
changeset 146:a49f02980151
fixed: hist index error, zero devision
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Thu, 12 May 2011 14:23:41 +0200 |
| parents | 9c3107044f86 |
| children | c11b9dcf6d24 |
| files | CoreLoop.c SwitchAnimators.h VMS.h VMS__DESIGN_NOTES.txt VMS_primitive_data_types.h probes.h vmalloc.h vutilities.h |
| diffstat | 8 files changed, 1037 insertions(+), 1037 deletions(-) [+] |
line diff
1.1 --- a/CoreLoop.c Sat Nov 20 08:19:05 2010 +0100 1.2 +++ b/CoreLoop.c Thu May 12 14:23:41 2011 +0200 1.3 @@ -8,7 +8,7 @@ 1.4 #include "VMS.h" 1.5 #include "Queue_impl/BlockingQueue.h" 1.6 1.7 -#include <stdio.h> 1.8 +//#include <stdio.h> 1.9 #include <stdlib.h> 1.10 #include <time.h> 1.11
2.1 --- a/SwitchAnimators.h Sat Nov 20 08:19:05 2010 +0100 2.2 +++ b/SwitchAnimators.h Thu May 12 14:23:41 2011 +0200 2.3 @@ -1,237 +1,237 @@ 2.4 -/* 2.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 2.6 - * Licensed under GNU General Public License version 2 2.7 - * 2.8 - * Author: seanhalle@yahoo.com 2.9 - * 2.10 - */ 2.11 - 2.12 -#ifndef _SwitchAnimators_H 2.13 -#define _SwitchAnimators_H 2.14 -#define __USE_GNU 2.15 - 2.16 -/*Isolating code for switching between animators within these macros -- at 2.17 - * some point will make switches to compile for 32 bit or for 64 bit, which 2.18 - * having these isolated will make cleaner 2.19 - * 2.20 - *This also makes it easier to change architectures, at some point 2.21 - *And it cleans the code up, having the ugly assembly out of the way 2.22 - */ 2.23 - 2.24 -/*Originally, let GCC handle input and output variables, which 2.25 - * worked fine with -O0, but with -O3, it eliminated what it 2.26 - * thought was un-used stores -- to fix this, am now hard-coding 2.27 - * the offsets of the fields of VirtProcr and VMSMasterEnv data 2.28 - * structs into the assembly for switching between VPs. 2.29 - *To see what the offsets are, copy the following code to 2.30 - * someplace, set compile to -O0 so it doesn't optimize, and 2.31 - * set a break-point on the first line. In DDD or Eclipse, look 2.32 - * at the disassembly to see what it compiled for the offsets. 2.33 - * 2.34 - void *foo; 2.35 - foo = currPr->stackPtr; \ 2.36 - foo = currPr->framePtr; \ 2.37 - foo = currPr->nextInstrPt; \ 2.38 - foo = currPr->coreLoopStackPtr; 2.39 - foo = currPr->coreLoopFramePtr; 2.40 - foo = _VMSMasterEnv->coreLoopStartPt; 2.41 - foo = _VMSMasterEnv->coreLoopEndPt; 2.42 - foo = _VMSMasterEnv->masterLock; 2.43 - 2.44 - * VirtProcr offsets: 2.45 - * 0xc stackPtr 2.46 - * 0x10 framePtr 2.47 - * 0x14 nextInstrPt 2.48 - * 0x1c coreLoopFramePtr 2.49 - * 0x20 coreLoopStackPtr 2.50 - * 2.51 - * _VMSMasterEnv offsets: 2.52 - * 0x24 coreLoopStartPt 2.53 - * 0x28 coreLoopEndPt 2.54 - * 0x30 masterLock 2.55 - * 2.56 - *For reference on the switch-VP assembly, the %%eax, %%ebx, %%ecx are 2.57 - * general purpose registers -- the "clobber" at the end tells GCC that the 2.58 - * values in the listed registers are overwritten inside the assembly, so 2.59 - * that GCC doesn't rely on keeping values in registers across the assembly. 2.60 - *The "input" tells GCC to generate the assembly form of the variable name. 2.61 - *The "%0" and "%1" mean the first and second items in the "input" list at 2.62 - * the bottom, respectively. So, where %0 appears, GCC looks at the bottom, 2.63 - * gets the first item it sees, generates the assembly for accessing that 2.64 - * variable, and replaces %0 with that. 2.65 - * 2.66 - *%%ebp is the frame-ptr register and %%esp is the stack-ptr register 2.67 - */ 2.68 - 2.69 -//=========================== MasterVP to CoreLoop ========================== 2.70 -// 2.71 - //Save stack ptr and frame, restore CoreLoop's stack and frame, 2.72 - // and clear the MasterLock 2.73 - //GCC's -O3 messes with this -- go through generated -- protect somehow 2.74 - // 2.75 -#define masterSwitchToCoreLoop( masterPr ) \ 2.76 - void *stackPtrAddr, *framePtrAddr; \ 2.77 - volatile void *masterLockAddr; \ 2.78 - void *jmpPt, *coreLoopFramePtr, *coreLoopStackPtr; \ 2.79 -\ 2.80 - masterLockAddr = &(_VMSMasterEnv->masterLock); \ 2.81 -\ 2.82 - jmpPt = _VMSMasterEnv->coreLoopStartPt; \ 2.83 - coreLoopStackPtr = masterPr->coreLoopStackPtr; \ 2.84 - coreLoopFramePtr = masterPr->coreLoopFramePtr; \ 2.85 -\ 2.86 - asm volatile("mov %0, %%ecx; \ 2.87 - mov %1, %%ebx; \ 2.88 - mov %%ebx, %%eax; \ 2.89 - add $0x10, %%eax; \ 2.90 - movl %%esp, (%%eax); \ 2.91 - mov %%ebx, %%eax; \ 2.92 - add $0x14, %%eax; \ 2.93 - movl %%ebp, (%%eax); \ 2.94 - movl %2, %%eax; \ 2.95 - movl %3, %%esp; \ 2.96 - movl %4, %%ebp; \ 2.97 - movl $0x0, (%%ecx); \ 2.98 - jmp %%eax" \ 2.99 - /* outputs */ : "=g"(masterLockAddr) \ 2.100 - /* inputs */ : "g"(masterPr), "g" (jmpPt), "g" (coreLoopStackPtr), \ 2.101 - "g" (coreLoopFramePtr) \ 2.102 - /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi" \ 2.103 - ); 2.104 - 2.105 -// asm volatile("movl %0, %%eax; \ 2.106 - movl %%esp, (%%eax); \ 2.107 - movl %1, %%eax; \ 2.108 - movl %%ebp, (%%eax); \ 2.109 - movl %2, %%ebx; \ 2.110 - movl %3, %%eax; \ 2.111 - movl %4, %%esp; \ 2.112 - movl %5, %%ebp; \ 2.113 - movl $0x0, (%%ebx); \ 2.114 - jmp %%eax;" \ 2.115 - /* outputs */ : "=g" (stackPtrAddr), "=g" (framePtrAddr), \ 2.116 - "=g"(masterLockAddr) \ 2.117 - /* inputs */ : "g" (jmpPt), "g"(coreLoopStackPtr), "g"(coreLoopFramePtr)\ 2.118 - /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi" \ 2.119 - );//can probably make clobber list empty -- but safe for now 2.120 - 2.121 - 2.122 -//=========================== SlaveVP to CoreLoop =========================== 2.123 -// 2.124 - 2.125 -#define SwitchToCoreLoop( animatingPr ) \ 2.126 - void *jmpPt, *coreLoopStackPtr; \ 2.127 - void *coreLoopFramePtr; \ 2.128 -\ 2.129 - jmpPt = _VMSMasterEnv->coreLoopStartPt; \ 2.130 - coreLoopStackPtr = animatingPr->coreLoopStackPtr; \ 2.131 - coreLoopFramePtr = animatingPr->coreLoopFramePtr; \ 2.132 -\ 2.133 - asm volatile("mov %0,%%ebx; \ 2.134 - mov %%ebx, %%eax; \ 2.135 - add $0x10, %%eax; \ 2.136 - movl %%esp, (%%eax); \ 2.137 - mov %%ebx, %%eax; \ 2.138 - add $0x14, %%eax; \ 2.139 - movl %%ebp, (%%eax); \ 2.140 - movl %1, %%eax; \ 2.141 - movl %2, %%esp; \ 2.142 - movl %3, %%ebp; \ 2.143 - jmp %%eax" \ 2.144 - /* outputs */ : \ 2.145 - /* inputs */ : "g"(animatingPr), "g" (jmpPt), "g" (coreLoopStackPtr), \ 2.146 - "g" (coreLoopFramePtr) \ 2.147 - /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi" \ 2.148 - ); 2.149 - 2.150 - /*Save the virt procr's stack and frame ptrs*/ \ 2.151 -// asm volatile("movl %0, %%eax; \ 2.152 - movl %%esp, (%%eax); \ 2.153 - movl %1, %%eax; \ 2.154 - movl %%ebp, (%%eax) "\ 2.155 - /* outputs */ : "=g" (stackPtrAddr), "=g" (framePtrAddr) \ 2.156 - /* inputs */ : \ 2.157 - /* clobber */ : "%eax" \ 2.158 - ); \ 2.159 -\ 2.160 - /*restore coreloop's frame ptr, then jump back to "start" of core loop*/\ 2.161 - /*Note, GCC compiles to assembly that saves esp and ebp in the stack*/ \ 2.162 - /* frame -- so have to explicitly do assembly that saves to memory*/ \ 2.163 - asm volatile("movl %0, %%eax; \ 2.164 - movl %1, %%esp; \ 2.165 - movl %2, %%ebp; \ 2.166 - jmp %%eax " \ 2.167 - /* outputs */ : \ 2.168 - /* inputs */ : "m" (jmpPt), "m"(coreLoopStackPtr), "m"(coreLoopFramePtr)\ 2.169 - /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi","%esi" \ 2.170 - ); 2.171 - //list everything as clobbered to force GCC to save all 2.172 - // live vars that are in regs on stack before this 2.173 - // assembly, so that stack pointer is correct, before jmp 2.174 - 2.175 - 2.176 - 2.177 -//============================== CoreLoop to VP ============================= 2.178 -// 2.179 - //Save the core loop's stack and frame pointers into virt procr struct 2.180 - // then switch to stack ptr and frame ptr of virt procr & jmp to it 2.181 - //This was a pain to get right because GCC converts the "(jmpPt)" to 2.182 - // frame-relative mem-op -- so generated machine code first changed the 2.183 - // frame pointer, then tried to jump to an addr stored on stack, which 2.184 - // it accessed as an offset from frame-ptr! (wrong frame-ptr now) 2.185 - //Explicitly loading into eax before changing frame-ptr fixed it 2.186 - //Also, it turns "(currPr->coreLoopFramePtr)" into a temporary on the 2.187 - // stack, so "movl %%ebp, %0" saves to the temp, NOT the data-struc! 2.188 - 2.189 - 2.190 - //switch to virt procr's stack and frame ptr then jump to virt procr fn 2.191 -/* VirtProcr offsets: 2.192 - * 0xc stackPtr 2.193 - * 0x10 framePtr 2.194 - * 0x14 nextInstrPt 2.195 - * 0x1c coreLoopFramePtr 2.196 - * 0x20 coreLoopStackPtr 2.197 - * 2.198 - * _VMSMasterEnv offsets: 2.199 - * 0x24 coreLoopStartPt 2.200 - * 0x28 coreLoopEndPt 2.201 - * 0x30 masterLock 2.202 - */ 2.203 -#define SwitchToVP( currPr ) \ 2.204 - asm volatile("movl %0, %%ebx; \ 2.205 - movl %%esp, 0x20(%%ebx); \ 2.206 - movl %%ebp, 0x1c(%%ebx); \ 2.207 - movl 0x14(%%ebx), %%eax; \ 2.208 - movl 0x0c(%%ebx), %%esp; \ 2.209 - movl 0x10(%%ebx), %%ebp; \ 2.210 - jmp *%%eax" \ 2.211 - /* outputs */ : \ 2.212 - /* inputs */ : "g"(currPr) \ 2.213 - /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi" \ 2.214 - ); 2.215 - 2.216 -// void *stackPtr, *framePtr, *jmpPt; \ 2.217 -\ 2.218 - stackPtr = currPr->stackPtr; \ 2.219 - framePtr = currPr->framePtr; \ 2.220 - jmpPt = currPr->nextInstrPt; \ 2.221 -\ 2.222 - asm volatile("mov %0,%%ebx; \ 2.223 - mov %%ebx, %%eax; \ 2.224 - add $0x1c, %%eax; \ 2.225 - movl %%esp, (%%eax); \ 2.226 - mov %%ebx, %%eax; \ 2.227 - add $0x20, %%eax; \ 2.228 - movl %%ebp, (%%eax); \ 2.229 - movl %1, %%eax; \ 2.230 - movl %2, %%esp; \ 2.231 - movl %3, %%ebp; \ 2.232 - jmp %%eax" \ 2.233 - /* outputs */ : \ 2.234 - /* inputs */ : "g"(currPr), "g" (jmpPt), "g" (stackPtr), "g" (framePtr) \ 2.235 - /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi" \ 2.236 - ); 2.237 - 2.238 - 2.239 -#endif /* _SwitchAnimators_H */ 2.240 - 2.241 +/* 2.242 + * Copyright 2009 OpenSourceStewardshipFoundation.org 2.243 + * Licensed under GNU General Public License version 2 2.244 + * 2.245 + * Author: seanhalle@yahoo.com 2.246 + * 2.247 + */ 2.248 + 2.249 +#ifndef _SwitchAnimators_H 2.250 +#define _SwitchAnimators_H 2.251 +#define __USE_GNU 2.252 + 2.253 +/*Isolating code for switching between animators within these macros -- at 2.254 + * some point will make switches to compile for 32 bit or for 64 bit, which 2.255 + * having these isolated will make cleaner 2.256 + * 2.257 + *This also makes it easier to change architectures, at some point 2.258 + *And it cleans the code up, having the ugly assembly out of the way 2.259 + */ 2.260 + 2.261 +/*Originally, let GCC handle input and output variables, which 2.262 + * worked fine with -O0, but with -O3, it eliminated what it 2.263 + * thought was un-used stores -- to fix this, am now hard-coding 2.264 + * the offsets of the fields of VirtProcr and VMSMasterEnv data 2.265 + * structs into the assembly for switching between VPs. 2.266 + *To see what the offsets are, copy the following code to 2.267 + * someplace, set compile to -O0 so it doesn't optimize, and 2.268 + * set a break-point on the first line. In DDD or Eclipse, look 2.269 + * at the disassembly to see what it compiled for the offsets. 2.270 + * 2.271 + void *foo; 2.272 + foo = currPr->stackPtr; \ 2.273 + foo = currPr->framePtr; \ 2.274 + foo = currPr->nextInstrPt; \ 2.275 + foo = currPr->coreLoopStackPtr; 2.276 + foo = currPr->coreLoopFramePtr; 2.277 + foo = _VMSMasterEnv->coreLoopStartPt; 2.278 + foo = _VMSMasterEnv->coreLoopEndPt; 2.279 + foo = _VMSMasterEnv->masterLock; 2.280 + 2.281 + * VirtProcr offsets: 2.282 + * 0xc stackPtr 2.283 + * 0x10 framePtr 2.284 + * 0x14 nextInstrPt 2.285 + * 0x1c coreLoopFramePtr 2.286 + * 0x20 coreLoopStackPtr 2.287 + * 2.288 + * _VMSMasterEnv offsets: 2.289 + * 0x24 coreLoopStartPt 2.290 + * 0x28 coreLoopEndPt 2.291 + * 0x30 masterLock 2.292 + * 2.293 + *For reference on the switch-VP assembly, the %%eax, %%ebx, %%ecx are 2.294 + * general purpose registers -- the "clobber" at the end tells GCC that the 2.295 + * values in the listed registers are overwritten inside the assembly, so 2.296 + * that GCC doesn't rely on keeping values in registers across the assembly. 2.297 + *The "input" tells GCC to generate the assembly form of the variable name. 2.298 + *The "%0" and "%1" mean the first and second items in the "input" list at 2.299 + * the bottom, respectively. So, where %0 appears, GCC looks at the bottom, 2.300 + * gets the first item it sees, generates the assembly for accessing that 2.301 + * variable, and replaces %0 with that. 2.302 + * 2.303 + *%%ebp is the frame-ptr register and %%esp is the stack-ptr register 2.304 + */ 2.305 + 2.306 +//=========================== MasterVP to CoreLoop ========================== 2.307 +// 2.308 + //Save stack ptr and frame, restore CoreLoop's stack and frame, 2.309 + // and clear the MasterLock 2.310 + //GCC's -O3 messes with this -- go through generated -- protect somehow 2.311 + // 2.312 +#define masterSwitchToCoreLoop( masterPr ) \ 2.313 + void *stackPtrAddr, *framePtrAddr; \ 2.314 + volatile void *masterLockAddr; \ 2.315 + void *jmpPt, *coreLoopFramePtr, *coreLoopStackPtr; \ 2.316 +\ 2.317 + masterLockAddr = &(_VMSMasterEnv->masterLock); \ 2.318 +\ 2.319 + jmpPt = _VMSMasterEnv->coreLoopStartPt; \ 2.320 + coreLoopStackPtr = masterPr->coreLoopStackPtr; \ 2.321 + coreLoopFramePtr = masterPr->coreLoopFramePtr; \ 2.322 +\ 2.323 + asm volatile("mov %0, %%ecx; \ 2.324 + mov %1, %%ebx; \ 2.325 + mov %%ebx, %%eax; \ 2.326 + add $0x10, %%eax; \ 2.327 + movl %%esp, (%%eax); \ 2.328 + mov %%ebx, %%eax; \ 2.329 + add $0x14, %%eax; \ 2.330 + movl %%ebp, (%%eax); \ 2.331 + movl %2, %%eax; \ 2.332 + movl %3, %%esp; \ 2.333 + movl %4, %%ebp; \ 2.334 + movl $0x0, (%%ecx); \ 2.335 + jmp %%eax" \ 2.336 + /* outputs */ : "=g"(masterLockAddr) \ 2.337 + /* inputs */ : "g"(masterPr), "g" (jmpPt), "g" (coreLoopStackPtr), \ 2.338 + "g" (coreLoopFramePtr) \ 2.339 + /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi" \ 2.340 + ); 2.341 + 2.342 +// asm volatile("movl %0, %%eax; \ 2.343 + movl %%esp, (%%eax); \ 2.344 + movl %1, %%eax; \ 2.345 + movl %%ebp, (%%eax); \ 2.346 + movl %2, %%ebx; \ 2.347 + movl %3, %%eax; \ 2.348 + movl %4, %%esp; \ 2.349 + movl %5, %%ebp; \ 2.350 + movl $0x0, (%%ebx); \ 2.351 + jmp %%eax;" \ 2.352 + /* outputs */ : "=g" (stackPtrAddr), "=g" (framePtrAddr), \ 2.353 + "=g"(masterLockAddr) \ 2.354 + /* inputs */ : "g" (jmpPt), "g"(coreLoopStackPtr), "g"(coreLoopFramePtr)\ 2.355 + /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi" \ 2.356 + );//can probably make clobber list empty -- but safe for now 2.357 + 2.358 + 2.359 +//=========================== SlaveVP to CoreLoop =========================== 2.360 +// 2.361 + 2.362 +#define SwitchToCoreLoop( animatingPr ) \ 2.363 + void *jmpPt, *coreLoopStackPtr; \ 2.364 + void *coreLoopFramePtr; \ 2.365 +\ 2.366 + jmpPt = _VMSMasterEnv->coreLoopStartPt; \ 2.367 + coreLoopStackPtr = animatingPr->coreLoopStackPtr; \ 2.368 + coreLoopFramePtr = animatingPr->coreLoopFramePtr; \ 2.369 +\ 2.370 + asm volatile("mov %0,%%ebx; \ 2.371 + mov %%ebx, %%eax; \ 2.372 + add $0x10, %%eax; \ 2.373 + movl %%esp, (%%eax); \ 2.374 + mov %%ebx, %%eax; \ 2.375 + add $0x14, %%eax; \ 2.376 + movl %%ebp, (%%eax); \ 2.377 + movl %1, %%eax; \ 2.378 + movl %2, %%esp; \ 2.379 + movl %3, %%ebp; \ 2.380 + jmp %%eax" \ 2.381 + /* outputs */ : \ 2.382 + /* inputs */ : "g"(animatingPr), "g" (jmpPt), "g" (coreLoopStackPtr), \ 2.383 + "g" (coreLoopFramePtr) \ 2.384 + /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi" \ 2.385 + ); 2.386 + 2.387 + /*Save the virt procr's stack and frame ptrs*/ \ 2.388 +// asm volatile("movl %0, %%eax; \ 2.389 + movl %%esp, (%%eax); \ 2.390 + movl %1, %%eax; \ 2.391 + movl %%ebp, (%%eax) "\ 2.392 + /* outputs */ : "=g" (stackPtrAddr), "=g" (framePtrAddr) \ 2.393 + /* inputs */ : \ 2.394 + /* clobber */ : "%eax" \ 2.395 + ); \ 2.396 +\ 2.397 + /*restore coreloop's frame ptr, then jump back to "start" of core loop*/\ 2.398 + /*Note, GCC compiles to assembly that saves esp and ebp in the stack*/ \ 2.399 + /* frame -- so have to explicitly do assembly that saves to memory*/ \ 2.400 + asm volatile("movl %0, %%eax; \ 2.401 + movl %1, %%esp; \ 2.402 + movl %2, %%ebp; \ 2.403 + jmp %%eax " \ 2.404 + /* outputs */ : \ 2.405 + /* inputs */ : "m" (jmpPt), "m"(coreLoopStackPtr), "m"(coreLoopFramePtr)\ 2.406 + /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi","%esi" \ 2.407 + ); 2.408 + //list everything as clobbered to force GCC to save all 2.409 + // live vars that are in regs on stack before this 2.410 + // assembly, so that stack pointer is correct, before jmp 2.411 + 2.412 + 2.413 + 2.414 +//============================== CoreLoop to VP ============================= 2.415 +// 2.416 + //Save the core loop's stack and frame pointers into virt procr struct 2.417 + // then switch to stack ptr and frame ptr of virt procr & jmp to it 2.418 + //This was a pain to get right because GCC converts the "(jmpPt)" to 2.419 + // frame-relative mem-op -- so generated machine code first changed the 2.420 + // frame pointer, then tried to jump to an addr stored on stack, which 2.421 + // it accessed as an offset from frame-ptr! (wrong frame-ptr now) 2.422 + //Explicitly loading into eax before changing frame-ptr fixed it 2.423 + //Also, it turns "(currPr->coreLoopFramePtr)" into a temporary on the 2.424 + // stack, so "movl %%ebp, %0" saves to the temp, NOT the data-struc! 2.425 + 2.426 + 2.427 + //switch to virt procr's stack and frame ptr then jump to virt procr fn 2.428 +/* VirtProcr offsets: 2.429 + * 0xc stackPtr 2.430 + * 0x10 framePtr 2.431 + * 0x14 nextInstrPt 2.432 + * 0x1c coreLoopFramePtr 2.433 + * 0x20 coreLoopStackPtr 2.434 + * 2.435 + * _VMSMasterEnv offsets: 2.436 + * 0x24 coreLoopStartPt 2.437 + * 0x28 coreLoopEndPt 2.438 + * 0x30 masterLock 2.439 + */ 2.440 +#define SwitchToVP( currPr ) \ 2.441 + asm volatile("movl %0, %%ebx; \ 2.442 + movl %%esp, 0x20(%%ebx); \ 2.443 + movl %%ebp, 0x1c(%%ebx); \ 2.444 + movl 0x14(%%ebx), %%eax; \ 2.445 + movl 0x0c(%%ebx), %%esp; \ 2.446 + movl 0x10(%%ebx), %%ebp; \ 2.447 + jmp *%%eax" \ 2.448 + /* outputs */ : \ 2.449 + /* inputs */ : "g"(currPr) \ 2.450 + /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi" \ 2.451 + ); 2.452 + 2.453 +// void *stackPtr, *framePtr, *jmpPt; \ 2.454 +\ 2.455 + stackPtr = currPr->stackPtr; \ 2.456 + framePtr = currPr->framePtr; \ 2.457 + jmpPt = currPr->nextInstrPt; \ 2.458 +\ 2.459 + asm volatile("mov %0,%%ebx; \ 2.460 + mov %%ebx, %%eax; \ 2.461 + add $0x1c, %%eax; \ 2.462 + movl %%esp, (%%eax); \ 2.463 + mov %%ebx, %%eax; \ 2.464 + add $0x20, %%eax; \ 2.465 + movl %%ebp, (%%eax); \ 2.466 + movl %1, %%eax; \ 2.467 + movl %2, %%esp; \ 2.468 + movl %3, %%ebp; \ 2.469 + jmp %%eax" \ 2.470 + /* outputs */ : \ 2.471 + /* inputs */ : "g"(currPr), "g" (jmpPt), "g" (stackPtr), "g" (framePtr) \ 2.472 + /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi" \ 2.473 + ); 2.474 + 2.475 + 2.476 +#endif /* _SwitchAnimators_H */ 2.477 +
3.1 --- a/VMS.h Sat Nov 20 08:19:05 2010 +0100 3.2 +++ b/VMS.h Thu May 12 14:23:41 2011 +0200 3.3 @@ -1,473 +1,473 @@ 3.4 -/* 3.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 3.6 - * Licensed under GNU General Public License version 2 3.7 - * 3.8 - * Author: seanhalle@yahoo.com 3.9 - * 3.10 - */ 3.11 - 3.12 -#ifndef _VMS_H 3.13 -#define _VMS_H 3.14 -#define __USE_GNU 3.15 - 3.16 -#include "VMS_primitive_data_types.h" 3.17 -#include "Queue_impl/PrivateQueue.h" 3.18 -#include "Histogram/Histogram.h" 3.19 -#include "DynArray/DynArray.h" 3.20 -#include "Hash_impl/PrivateHash.h" 3.21 -#include "vmalloc.h" 3.22 - 3.23 -#include <pthread.h> 3.24 -#include <sys/time.h> 3.25 - 3.26 - 3.27 -//=============================== Debug =================================== 3.28 -// 3.29 - //When SEQUENTIAL is defined, VMS does sequential exe in the main thread 3.30 - // It still does co-routines and all the mechanisms are the same, it just 3.31 - // has only a single thread and animates VPs one at a time 3.32 -//#define SEQUENTIAL 3.33 - 3.34 -//#define USE_WORK_STEALING 3.35 - 3.36 - //turns on the probe-instrumentation in the application -- when not 3.37 - // defined, the calls to the probe functions turn into comments 3.38 -#define STATS__ENABLE_PROBES 3.39 -//#define TURN_ON_DEBUG_PROBES 3.40 - 3.41 - //These defines turn types of bug messages on and off 3.42 - // be sure debug messages are un-commented (next block of defines) 3.43 -#define dbgAppFlow TRUE /* Top level flow of application code -- general*/ 3.44 -#define dbgProbes FALSE /* for issues inside probes themselves*/ 3.45 -#define dbgB2BMaster FALSE /* in coreloop, back to back master VPs*/ 3.46 -#define dbgRqstHdlr FALSE /* in request handler code*/ 3.47 - 3.48 - //Comment or un- the substitute half to turn on/off types of debug message 3.49 -#define DEBUG( bool, msg) \ 3.50 -// if( bool){ printf(msg); fflush(stdin);} 3.51 -#define DEBUG1( bool, msg, param) \ 3.52 -// if(bool){printf(msg, param); fflush(stdin);} 3.53 -#define DEBUG2( bool, msg, p1, p2) \ 3.54 -// if(bool) {printf(msg, p1, p2); fflush(stdin);} 3.55 - 3.56 -#define ERROR(msg) printf(msg); fflush(stdin); 3.57 -#define ERROR1(msg, param) printf(msg, param); fflush(stdin); 3.58 -#define ERROR2(msg, p1, p2) printf(msg, p1, p2); fflush(stdin); 3.59 - 3.60 -//=========================== STATS ======================= 3.61 - 3.62 - //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and 3.63 - // compiled-in that saves the low part of the time stamp count just before 3.64 - // suspending a processor and just after resuming that processor. It is 3.65 - // saved into a field added to VirtProcr. Have to sanity-check for 3.66 - // rollover of low portion into high portion. 3.67 -//#define MEAS__TIME_STAMP_SUSP 3.68 -//#define MEAS__TIME_MASTER 3.69 -#define MEAS__TIME_PLUGIN 3.70 -#define MEAS__TIME_MALLOC 3.71 -//#define MEAS__TIME_MASTER_LOCK 3.72 -#define MEAS__NUM_TIMES_TO_RUN 100000 3.73 - 3.74 - //For code that calculates normalization-offset between TSC counts of 3.75 - // different cores. 3.76 -#define NUM_TSC_ROUND_TRIPS 10 3.77 - 3.78 - 3.79 -//========================= Hardware related Constants ===================== 3.80 - //This value is the number of hardware threads in the shared memory 3.81 - // machine 3.82 -#define NUM_CORES 4 3.83 - 3.84 - // tradeoff amortizing master fixed overhead vs imbalance potential 3.85 - // when work-stealing, can make bigger, at risk of losing cache affinity 3.86 -#define NUM_SCHED_SLOTS 5 3.87 - 3.88 -#define MIN_WORK_UNIT_CYCLES 20000 3.89 - 3.90 -#define MASTERLOCK_RETRIES 10000 3.91 - 3.92 - // stack size in virtual processors created 3.93 -#define VIRT_PROCR_STACK_SIZE 0x4000 /* 16K */ 3.94 - 3.95 - // memory for VMS__malloc 3.96 -#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */ 3.97 - 3.98 - 3.99 -//============================== 3.100 - 3.101 -#define SUCCESS 0 3.102 - 3.103 -#define writeVMSQ writePrivQ 3.104 -#define readVMSQ readPrivQ 3.105 -#define makeVMSQ makeVMSPrivQ 3.106 -#define numInVMSQ numInPrivQ 3.107 -#define VMSQueueStruc PrivQueueStruc 3.108 - 3.109 - 3.110 - 3.111 -//=========================================================================== 3.112 -typedef unsigned long long TSCount; 3.113 - 3.114 -typedef struct _SchedSlot SchedSlot; 3.115 -typedef struct _VMSReqst VMSReqst; 3.116 -typedef struct _VirtProcr VirtProcr; 3.117 -typedef struct _IntervalProbe IntervalProbe; 3.118 -typedef struct _GateStruc GateStruc; 3.119 - 3.120 - 3.121 -typedef VirtProcr * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx 3.122 -typedef void (*RequestHandler) ( VirtProcr *, void * ); //prWReqst, semEnv 3.123 -typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); //initData, animPr 3.124 -typedef void VirtProcrFn ( void *, VirtProcr * ); //initData, animPr 3.125 -typedef void (*ResumePrFnPtr) ( VirtProcr *, void * ); 3.126 - 3.127 - 3.128 -//============= Requests =========== 3.129 -// 3.130 - 3.131 -enum VMSReqstType //avoid starting enums at 0, for debug reasons 3.132 - { 3.133 - semantic = 1, 3.134 - createReq, 3.135 - dissipate, 3.136 - VMSSemantic //goes with VMSSemReqst below 3.137 - }; 3.138 - 3.139 -struct _VMSReqst 3.140 - { 3.141 - enum VMSReqstType reqType;//used for dissipate and in future for IO requests 3.142 - void *semReqData; 3.143 - 3.144 - VMSReqst *nextReqst; 3.145 - }; 3.146 -//VMSReqst 3.147 - 3.148 -enum VMSSemReqstType //These are equivalent to semantic requests, but for 3.149 - { // VMS's services available directly to app, like OS 3.150 - createProbe = 1, // and probe services -- like a VMS-wide built-in lang 3.151 - openFile, 3.152 - otherIO 3.153 - }; 3.154 - 3.155 -typedef struct 3.156 - { enum VMSSemReqstType reqType; 3.157 - VirtProcr *requestingPr; 3.158 - char *nameStr; //for create probe 3.159 - } 3.160 - VMSSemReq; 3.161 - 3.162 - 3.163 -//==================== Core data structures =================== 3.164 - 3.165 -struct _SchedSlot 3.166 - { 3.167 - int workIsDone; 3.168 - int needsProcrAssigned; 3.169 - VirtProcr *procrAssignedToSlot; 3.170 - }; 3.171 -//SchedSlot 3.172 - 3.173 -/*WARNING: re-arranging this data structure could cause VP switching 3.174 - * assembly code to fail -- hard-codes offsets of fields 3.175 - */ 3.176 -struct _VirtProcr 3.177 - { int procrID; //for debugging -- count up each time create 3.178 - int coreAnimatedBy; 3.179 - void *startOfStack; 3.180 - void *stackPtr; 3.181 - void *framePtr; 3.182 - void *nextInstrPt; 3.183 - 3.184 - void *coreLoopStartPt; //allows proto-runtime to be linked later 3.185 - void *coreLoopFramePtr; //restore before jmp back to core loop 3.186 - void *coreLoopStackPtr; //restore before jmp back to core loop 3.187 - 3.188 - void *initialData; 3.189 - 3.190 - SchedSlot *schedSlot; 3.191 - VMSReqst *requests; 3.192 - 3.193 - void *semanticData; //this lives here for the life of VP 3.194 - void *dataRetFromReq;//values returned from plugin to VP go here 3.195 - 3.196 - //=========== MEASUREMENT STUFF ========== 3.197 - #ifdef MEAS__TIME_STAMP_SUSP 3.198 - unsigned int preSuspTSCLow; 3.199 - unsigned int postSuspTSCLow; 3.200 - #endif 3.201 - #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/ 3.202 - unsigned int startMasterTSCLow; 3.203 - unsigned int endMasterTSCLow; 3.204 - #endif 3.205 - //======================================== 3.206 - 3.207 - float64 createPtInSecs; //have space but don't use on some configs 3.208 - }; 3.209 -//VirtProcr 3.210 - 3.211 - 3.212 -/*WARNING: re-arranging this data structure could cause VP-switching 3.213 - * assembly code to fail -- hard-codes offsets of fields 3.214 - * (because -O3 messes with things otherwise) 3.215 - */ 3.216 -typedef struct 3.217 - { 3.218 - SlaveScheduler slaveScheduler; 3.219 - RequestHandler requestHandler; 3.220 - 3.221 - SchedSlot ***allSchedSlots; 3.222 - VMSQueueStruc **readyToAnimateQs; 3.223 - VirtProcr **masterVPs; 3.224 - 3.225 - void *semanticEnv; 3.226 - void *OSEventStruc; //for future, when add I/O to BLIS 3.227 - MallocProlog *freeListHead; 3.228 - int32 amtOfOutstandingMem; //total currently allocated 3.229 - 3.230 - void *coreLoopStartPt;//addr to jump to to re-enter coreLoop 3.231 - void *coreLoopEndPt; //addr to jump to to shut down a coreLoop 3.232 - 3.233 - int32 setupComplete; 3.234 - int32 masterLock; 3.235 - 3.236 - int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP 3.237 - GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal 3.238 - int32 workStealingLock; 3.239 - 3.240 - int32 numProcrsCreated; //gives ordering to processor creation 3.241 - 3.242 - //=========== MEASUREMENT STUFF ============= 3.243 - IntervalProbe **intervalProbes; 3.244 - PrivDynArrayInfo *dynIntervalProbesInfo; 3.245 - HashTable *probeNameHashTbl; 3.246 - int32 masterCreateProbeID; 3.247 - float64 createPtInSecs; 3.248 - Histogram **measHists; 3.249 - PrivDynArrayInfo *measHistsInfo; 3.250 - #ifdef MEAS__TIME_PLUGIN 3.251 - Histogram *reqHdlrLowTimeHist; 3.252 - Histogram *reqHdlrHighTimeHist; 3.253 - #endif 3.254 - #ifdef MEAS__TIME_MALLOC 3.255 - Histogram *mallocTimeHist; 3.256 - Histogram *freeTimeHist; 3.257 - #endif 3.258 - #ifdef MEAS__TIME_MASTER_LOCK 3.259 - Histogram *masterLockLowTimeHist; 3.260 - Histogram *masterLockHighTimeHist; 3.261 - #endif 3.262 - } 3.263 -MasterEnv; 3.264 - 3.265 -//========================= Extra Stuff Data Strucs ======================= 3.266 -typedef struct 3.267 - { 3.268 - 3.269 - } 3.270 -VMSExcp; 3.271 - 3.272 -struct _GateStruc 3.273 - { 3.274 - int32 gateClosed; 3.275 - int32 preGateProgress; 3.276 - int32 waitProgress; 3.277 - int32 exitProgress; 3.278 - }; 3.279 -//GateStruc 3.280 - 3.281 -//======================= OS Thread related =============================== 3.282 - 3.283 -void * coreLoop( void *paramsIn ); //standard PThreads fn prototype 3.284 -void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype 3.285 -void masterLoop( void *initData, VirtProcr *masterPr ); 3.286 - 3.287 - 3.288 -typedef struct 3.289 - { 3.290 - void *endThdPt; 3.291 - unsigned int coreNum; 3.292 - } 3.293 -ThdParams; 3.294 - 3.295 -pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state 3.296 -ThdParams *coreLoopThdParams [ NUM_CORES ]; 3.297 -pthread_mutex_t suspendLock; 3.298 -pthread_cond_t suspend_cond; 3.299 - 3.300 - 3.301 - 3.302 -//===================== Global Vars =================== 3.303 - 3.304 -volatile MasterEnv *_VMSMasterEnv; 3.305 - 3.306 - 3.307 - 3.308 - 3.309 -//=========================== Function Prototypes ========================= 3.310 - 3.311 - 3.312 -//========== Setup and shutdown ========== 3.313 -void 3.314 -VMS__init(); 3.315 - 3.316 -void 3.317 -VMS__init_Seq(); 3.318 - 3.319 -void 3.320 -VMS__start_the_work_then_wait_until_done(); 3.321 - 3.322 -void 3.323 -VMS__start_the_work_then_wait_until_done_Seq(); 3.324 - 3.325 -VirtProcr * 3.326 -VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData ); 3.327 - 3.328 -void 3.329 -VMS__dissipate_procr( VirtProcr *procrToDissipate ); 3.330 - 3.331 - //Use this to create processor inside entry point & other places outside 3.332 - // the VMS system boundary (IE, not run in slave nor Master) 3.333 -VirtProcr * 3.334 -VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData ); 3.335 - 3.336 -void 3.337 -VMS_ext__dissipate_procr( VirtProcr *procrToDissipate ); 3.338 - 3.339 -void 3.340 -VMS__throw_exception( char *msgStr, VirtProcr *reqstPr, VMSExcp *excpData ); 3.341 - 3.342 -void 3.343 -VMS__shutdown(); 3.344 - 3.345 -void 3.346 -VMS__cleanup_at_end_of_shutdown(); 3.347 - 3.348 -void * 3.349 -VMS__give_sem_env_for( VirtProcr *animPr ); 3.350 - 3.351 - 3.352 -//============== Request Related =============== 3.353 - 3.354 -void 3.355 -VMS__suspend_procr( VirtProcr *callingPr ); 3.356 - 3.357 -inline void 3.358 -VMS__add_sem_request_in_mallocd_VMSReqst( void *semReqData, VirtProcr *callingPr ); 3.359 - 3.360 -inline void 3.361 -VMS__send_sem_request( void *semReqData, VirtProcr *callingPr ); 3.362 - 3.363 -void 3.364 -VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr ); 3.365 - 3.366 -void inline 3.367 -VMS__send_dissipate_req( VirtProcr *prToDissipate ); 3.368 - 3.369 -inline void 3.370 -VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ); 3.371 - 3.372 -VMSReqst * 3.373 -VMS__take_next_request_out_of( VirtProcr *procrWithReq ); 3.374 - 3.375 -inline void * 3.376 -VMS__take_sem_reqst_from( VMSReqst *req ); 3.377 - 3.378 -//======================== STATS ====================== 3.379 - 3.380 -//===== RDTSC wrapper ===== 3.381 - 3.382 -#define saveTimeStampCountInto(low, high) \ 3.383 - asm volatile("RDTSC; \ 3.384 - movl %%eax, %0; \ 3.385 - movl %%edx, %1;" \ 3.386 - /* outputs */ : "=m" (low), "=m" (high)\ 3.387 - /* inputs */ : \ 3.388 - /* clobber */ : "%eax", "%edx" \ 3.389 - ); 3.390 - 3.391 -#define saveLowTimeStampCountInto(low) \ 3.392 - asm volatile("RDTSC; \ 3.393 - movl %%eax, %0;" \ 3.394 - /* outputs */ : "=m" (low) \ 3.395 - /* inputs */ : \ 3.396 - /* clobber */ : "%eax", "%edx" \ 3.397 - ); 3.398 - 3.399 -//==================== 3.400 -#define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \ 3.401 - makeHighestDynArrayIndexBeAtLeast( _VMSMasterEnv->measHistsInfo, idx ); \ 3.402 - _VMSMasterEnv->measHists[idx] = \ 3.403 - makeFixedBinHist( numBins, startVal, binWidth, name ); 3.404 - 3.405 - 3.406 -#define MEAS__SUB_CREATE /*turn on/off subtraction of create from plugin*/ 3.407 -#define createHistIdx 1 3.408 -#define mutexLockHistIdx 2 3.409 -#define mutexUnlockHistIdx 3 3.410 -#define condWaitHistIdx 4 3.411 -#define condSignalHistIdx 5 3.412 - 3.413 - 3.414 -#define MakeTheMeasHists \ 3.415 - _VMSMasterEnv->measHistsInfo = \ 3.416 - makePrivDynArrayOfSize( &(_VMSMasterEnv->measHists), 200);\ 3.417 - makeAMeasHist( createHistIdx, "Create", 50, 0, 200 ) \ 3.418 - makeAMeasHist( mutexLockHistIdx, "mutex lock", 50, 0, 100 ) \ 3.419 - makeAMeasHist( mutexUnlockHistIdx, "mutex unlock", 50, 0, 100 ) \ 3.420 - makeAMeasHist( condWaitHistIdx, "cond wait", 50, 0, 100 ) \ 3.421 - makeAMeasHist( condSignalHistIdx, "cond signal", 50, 0, 100 ) 3.422 - 3.423 -#define Meas_startCreate \ 3.424 - int32 startStamp, endStamp; \ 3.425 - saveLowTimeStampCountInto( startStamp ); \ 3.426 - 3.427 -#define Meas_endCreate \ 3.428 - saveLowTimeStampCountInto( endStamp ); \ 3.429 - addIntervalToHist( startStamp, endStamp, \ 3.430 - _VMSMasterEnv->measHists[ createHistIdx ] ); 3.431 - 3.432 -#define Meas_startMutexLock \ 3.433 - int32 startStamp, endStamp; \ 3.434 - saveLowTimeStampCountInto( startStamp ); \ 3.435 - 3.436 -#define Meas_endMutexLock \ 3.437 - saveLowTimeStampCountInto( endStamp ); \ 3.438 - addIntervalToHist( startStamp, endStamp, \ 3.439 - _VMSMasterEnv->measHists[ mutexLockHistIdx ] ); 3.440 - 3.441 -#define Meas_startMutexUnlock \ 3.442 - int32 startStamp, endStamp; \ 3.443 - saveLowTimeStampCountInto( startStamp ); \ 3.444 - 3.445 -#define Meas_endMutexUnlock \ 3.446 - saveLowTimeStampCountInto( endStamp ); \ 3.447 - addIntervalToHist( startStamp, endStamp, \ 3.448 - _VMSMasterEnv->measHists[ mutexUnlockHistIdx ] ); 3.449 - 3.450 -#define Meas_startCondWait \ 3.451 - int32 startStamp, endStamp; \ 3.452 - saveLowTimeStampCountInto( startStamp ); \ 3.453 - 3.454 -#define Meas_endCondWait \ 3.455 - saveLowTimeStampCountInto( endStamp ); \ 3.456 - addIntervalToHist( startStamp, endStamp, \ 3.457 - _VMSMasterEnv->measHists[ condWaitHistIdx ] ); 3.458 - 3.459 -#define Meas_startCondSignal \ 3.460 - int32 startStamp, endStamp; \ 3.461 - saveLowTimeStampCountInto( startStamp ); \ 3.462 - 3.463 -#define Meas_endCondSignal \ 3.464 - saveLowTimeStampCountInto( endStamp ); \ 3.465 - addIntervalToHist( startStamp, endStamp, \ 3.466 - _VMSMasterEnv->measHists[ condSignalHistIdx ] ); 3.467 - 3.468 - 3.469 -//===== 3.470 - 3.471 -#include "SwitchAnimators.h" 3.472 -#include "probes.h" 3.473 -#include "vutilities.h" 3.474 - 3.475 -#endif /* _VMS_H */ 3.476 - 3.477 +/* 3.478 + * Copyright 2009 OpenSourceStewardshipFoundation.org 3.479 + * Licensed under GNU General Public License version 2 3.480 + * 3.481 + * Author: seanhalle@yahoo.com 3.482 + * 3.483 + */ 3.484 + 3.485 +#ifndef _VMS_H 3.486 +#define _VMS_H 3.487 +#define __USE_GNU 3.488 + 3.489 +#include "VMS_primitive_data_types.h" 3.490 +#include "Queue_impl/PrivateQueue.h" 3.491 +#include "Histogram/Histogram.h" 3.492 +#include "DynArray/DynArray.h" 3.493 +#include "Hash_impl/PrivateHash.h" 3.494 +#include "vmalloc.h" 3.495 + 3.496 +#include <pthread.h> 3.497 +#include <sys/time.h> 3.498 + 3.499 + 3.500 +//=============================== Debug =================================== 3.501 +// 3.502 + //When SEQUENTIAL is defined, VMS does sequential exe in the main thread 3.503 + // It still does co-routines and all the mechanisms are the same, it just 3.504 + // has only a single thread and animates VPs one at a time 3.505 +//#define SEQUENTIAL 3.506 + 3.507 +//#define USE_WORK_STEALING 3.508 + 3.509 + //turns on the probe-instrumentation in the application -- when not 3.510 + // defined, the calls to the probe functions turn into comments 3.511 +#define STATS__ENABLE_PROBES 3.512 +//#define TURN_ON_DEBUG_PROBES 3.513 + 3.514 + //These defines turn types of bug messages on and off 3.515 + // be sure debug messages are un-commented (next block of defines) 3.516 +#define dbgAppFlow TRUE /* Top level flow of application code -- general*/ 3.517 +#define dbgProbes FALSE /* for issues inside probes themselves*/ 3.518 +#define dbgB2BMaster FALSE /* in coreloop, back to back master VPs*/ 3.519 +#define dbgRqstHdlr FALSE /* in request handler code*/ 3.520 + 3.521 + //Comment or un- the substitute half to turn on/off types of debug message 3.522 +#define DEBUG( bool, msg) \ 3.523 +// if( bool){ printf(msg); fflush(stdin);} 3.524 +#define DEBUG1( bool, msg, param) \ 3.525 +// if(bool){printf(msg, param); fflush(stdin);} 3.526 +#define DEBUG2( bool, msg, p1, p2) \ 3.527 +// if(bool) {printf(msg, p1, p2); fflush(stdin);} 3.528 + 3.529 +#define ERROR(msg) printf(msg); 3.530 +#define ERROR1(msg, param) printf(msg, param); 3.531 +#define ERROR2(msg, p1, p2) printf(msg, p1, p2); 3.532 + 3.533 +//=========================== STATS ======================= 3.534 + 3.535 + //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and 3.536 + // compiled-in that saves the low part of the time stamp count just before 3.537 + // suspending a processor and just after resuming that processor. It is 3.538 + // saved into a field added to VirtProcr. Have to sanity-check for 3.539 + // rollover of low portion into high portion. 3.540 +//#define MEAS__TIME_STAMP_SUSP 3.541 +//#define MEAS__TIME_MASTER 3.542 +#define MEAS__TIME_PLUGIN 3.543 +#define MEAS__TIME_MALLOC 3.544 +//#define MEAS__TIME_MASTER_LOCK 3.545 +#define MEAS__NUM_TIMES_TO_RUN 100000 3.546 + 3.547 + //For code that calculates normalization-offset between TSC counts of 3.548 + // different cores. 3.549 +#define NUM_TSC_ROUND_TRIPS 10 3.550 + 3.551 + 3.552 +//========================= Hardware related Constants ===================== 3.553 + //This value is the number of hardware threads in the shared memory 3.554 + // machine 3.555 +#define NUM_CORES 4 3.556 + 3.557 + // tradeoff amortizing master fixed overhead vs imbalance potential 3.558 + // when work-stealing, can make bigger, at risk of losing cache affinity 3.559 +#define NUM_SCHED_SLOTS 5 3.560 + 3.561 +#define MIN_WORK_UNIT_CYCLES 20000 3.562 + 3.563 +#define MASTERLOCK_RETRIES 10000 3.564 + 3.565 + // stack size in virtual processors created 3.566 +#define VIRT_PROCR_STACK_SIZE 0x4000 /* 16K */ 3.567 + 3.568 + // memory for VMS__malloc 3.569 +#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */ 3.570 + 3.571 + 3.572 +//============================== 3.573 + 3.574 +#define SUCCESS 0 3.575 + 3.576 +#define writeVMSQ writePrivQ 3.577 +#define readVMSQ readPrivQ 3.578 +#define makeVMSQ makeVMSPrivQ 3.579 +#define numInVMSQ numInPrivQ 3.580 +#define VMSQueueStruc PrivQueueStruc 3.581 + 3.582 + 3.583 + 3.584 +//=========================================================================== 3.585 +typedef unsigned long long TSCount; 3.586 + 3.587 +typedef struct _SchedSlot SchedSlot; 3.588 +typedef struct _VMSReqst VMSReqst; 3.589 +typedef struct _VirtProcr VirtProcr; 3.590 +typedef struct _IntervalProbe IntervalProbe; 3.591 +typedef struct _GateStruc GateStruc; 3.592 + 3.593 + 3.594 +typedef VirtProcr * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx 3.595 +typedef void (*RequestHandler) ( VirtProcr *, void * ); //prWReqst, semEnv 3.596 +typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); //initData, animPr 3.597 +typedef void VirtProcrFn ( void *, VirtProcr * ); //initData, animPr 3.598 +typedef void (*ResumePrFnPtr) ( VirtProcr *, void * ); 3.599 + 3.600 + 3.601 +//============= Requests =========== 3.602 +// 3.603 + 3.604 +enum VMSReqstType //avoid starting enums at 0, for debug reasons 3.605 + { 3.606 + semantic = 1, 3.607 + createReq, 3.608 + dissipate, 3.609 + VMSSemantic //goes with VMSSemReqst below 3.610 + }; 3.611 + 3.612 +struct _VMSReqst 3.613 + { 3.614 + enum VMSReqstType reqType;//used for dissipate and in future for IO requests 3.615 + void *semReqData; 3.616 + 3.617 + VMSReqst *nextReqst; 3.618 + }; 3.619 +//VMSReqst 3.620 + 3.621 +enum VMSSemReqstType //These are equivalent to semantic requests, but for 3.622 + { // VMS's services available directly to app, like OS 3.623 + createProbe = 1, // and probe services -- like a VMS-wide built-in lang 3.624 + openFile, 3.625 + otherIO 3.626 + }; 3.627 + 3.628 +typedef struct 3.629 + { enum VMSSemReqstType reqType; 3.630 + VirtProcr *requestingPr; 3.631 + char *nameStr; //for create probe 3.632 + } 3.633 + VMSSemReq; 3.634 + 3.635 + 3.636 +//==================== Core data structures =================== 3.637 + 3.638 +struct _SchedSlot 3.639 + { 3.640 + int workIsDone; 3.641 + int needsProcrAssigned; 3.642 + VirtProcr *procrAssignedToSlot; 3.643 + }; 3.644 +//SchedSlot 3.645 + 3.646 +/*WARNING: re-arranging this data structure could cause VP switching 3.647 + * assembly code to fail -- hard-codes offsets of fields 3.648 + */ 3.649 +struct _VirtProcr 3.650 + { int procrID; //for debugging -- count up each time create 3.651 + int coreAnimatedBy; 3.652 + void *startOfStack; 3.653 + void *stackPtr; 3.654 + void *framePtr; 3.655 + void *nextInstrPt; 3.656 + 3.657 + void *coreLoopStartPt; //allows proto-runtime to be linked later 3.658 + void *coreLoopFramePtr; //restore before jmp back to core loop 3.659 + void *coreLoopStackPtr; //restore before jmp back to core loop 3.660 + 3.661 + void *initialData; 3.662 + 3.663 + SchedSlot *schedSlot; 3.664 + VMSReqst *requests; 3.665 + 3.666 + void *semanticData; //this lives here for the life of VP 3.667 + void *dataRetFromReq;//values returned from plugin to VP go here 3.668 + 3.669 + //=========== MEASUREMENT STUFF ========== 3.670 + #ifdef MEAS__TIME_STAMP_SUSP 3.671 + unsigned int preSuspTSCLow; 3.672 + unsigned int postSuspTSCLow; 3.673 + #endif 3.674 + #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/ 3.675 + unsigned int startMasterTSCLow; 3.676 + unsigned int endMasterTSCLow; 3.677 + #endif 3.678 + //======================================== 3.679 + 3.680 + float64 createPtInSecs; //have space but don't use on some configs 3.681 + }; 3.682 +//VirtProcr 3.683 + 3.684 + 3.685 +/*WARNING: re-arranging this data structure could cause VP-switching 3.686 + * assembly code to fail -- hard-codes offsets of fields 3.687 + * (because -O3 messes with things otherwise) 3.688 + */ 3.689 +typedef struct 3.690 + { 3.691 + SlaveScheduler slaveScheduler; 3.692 + RequestHandler requestHandler; 3.693 + 3.694 + SchedSlot ***allSchedSlots; 3.695 + VMSQueueStruc **readyToAnimateQs; 3.696 + VirtProcr **masterVPs; 3.697 + 3.698 + void *semanticEnv; 3.699 + void *OSEventStruc; //for future, when add I/O to BLIS 3.700 + MallocProlog *freeListHead; 3.701 + int32 amtOfOutstandingMem; //total currently allocated 3.702 + 3.703 + void *coreLoopStartPt;//addr to jump to to re-enter coreLoop 3.704 + void *coreLoopEndPt; //addr to jump to to shut down a coreLoop 3.705 + 3.706 + int32 setupComplete; 3.707 + int32 masterLock; 3.708 + 3.709 + int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP 3.710 + GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal 3.711 + int32 workStealingLock; 3.712 + 3.713 + int32 numProcrsCreated; //gives ordering to processor creation 3.714 + 3.715 + //=========== MEASUREMENT STUFF ============= 3.716 + IntervalProbe **intervalProbes; 3.717 + PrivDynArrayInfo *dynIntervalProbesInfo; 3.718 + HashTable *probeNameHashTbl; 3.719 + int32 masterCreateProbeID; 3.720 + float64 createPtInSecs; 3.721 + Histogram **measHists; 3.722 + PrivDynArrayInfo *measHistsInfo; 3.723 + #ifdef MEAS__TIME_PLUGIN 3.724 + Histogram *reqHdlrLowTimeHist; 3.725 + Histogram *reqHdlrHighTimeHist; 3.726 + #endif 3.727 + #ifdef MEAS__TIME_MALLOC 3.728 + Histogram *mallocTimeHist; 3.729 + Histogram *freeTimeHist; 3.730 + #endif 3.731 + #ifdef MEAS__TIME_MASTER_LOCK 3.732 + Histogram *masterLockLowTimeHist; 3.733 + Histogram *masterLockHighTimeHist; 3.734 + #endif 3.735 + } 3.736 +MasterEnv; 3.737 + 3.738 +//========================= Extra Stuff Data Strucs ======================= 3.739 +typedef struct 3.740 + { 3.741 + 3.742 + } 3.743 +VMSExcp; 3.744 + 3.745 +struct _GateStruc 3.746 + { 3.747 + int32 gateClosed; 3.748 + int32 preGateProgress; 3.749 + int32 waitProgress; 3.750 + int32 exitProgress; 3.751 + }; 3.752 +//GateStruc 3.753 + 3.754 +//======================= OS Thread related =============================== 3.755 + 3.756 +void * coreLoop( void *paramsIn ); //standard PThreads fn prototype 3.757 +void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype 3.758 +void masterLoop( void *initData, VirtProcr *masterPr ); 3.759 + 3.760 + 3.761 +typedef struct 3.762 + { 3.763 + void *endThdPt; 3.764 + unsigned int coreNum; 3.765 + } 3.766 +ThdParams; 3.767 + 3.768 +pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state 3.769 +ThdParams *coreLoopThdParams [ NUM_CORES ]; 3.770 +pthread_mutex_t suspendLock; 3.771 +pthread_cond_t suspend_cond; 3.772 + 3.773 + 3.774 + 3.775 +//===================== Global Vars =================== 3.776 + 3.777 +volatile MasterEnv *_VMSMasterEnv; 3.778 + 3.779 + 3.780 + 3.781 + 3.782 +//=========================== Function Prototypes ========================= 3.783 + 3.784 + 3.785 +//========== Setup and shutdown ========== 3.786 +void 3.787 +VMS__init(); 3.788 + 3.789 +void 3.790 +VMS__init_Seq(); 3.791 + 3.792 +void 3.793 +VMS__start_the_work_then_wait_until_done(); 3.794 + 3.795 +void 3.796 +VMS__start_the_work_then_wait_until_done_Seq(); 3.797 + 3.798 +VirtProcr * 3.799 +VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData ); 3.800 + 3.801 +void 3.802 +VMS__dissipate_procr( VirtProcr *procrToDissipate ); 3.803 + 3.804 + //Use this to create processor inside entry point & other places outside 3.805 + // the VMS system boundary (IE, not run in slave nor Master) 3.806 +VirtProcr * 3.807 +VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData ); 3.808 + 3.809 +void 3.810 +VMS_ext__dissipate_procr( VirtProcr *procrToDissipate ); 3.811 + 3.812 +void 3.813 +VMS__throw_exception( char *msgStr, VirtProcr *reqstPr, VMSExcp *excpData ); 3.814 + 3.815 +void 3.816 +VMS__shutdown(); 3.817 + 3.818 +void 3.819 +VMS__cleanup_at_end_of_shutdown(); 3.820 + 3.821 +void * 3.822 +VMS__give_sem_env_for( VirtProcr *animPr ); 3.823 + 3.824 + 3.825 +//============== Request Related =============== 3.826 + 3.827 +void 3.828 +VMS__suspend_procr( VirtProcr *callingPr ); 3.829 + 3.830 +inline void 3.831 +VMS__add_sem_request_in_mallocd_VMSReqst( void *semReqData, VirtProcr *callingPr ); 3.832 + 3.833 +inline void 3.834 +VMS__send_sem_request( void *semReqData, VirtProcr *callingPr ); 3.835 + 3.836 +void 3.837 +VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr ); 3.838 + 3.839 +void inline 3.840 +VMS__send_dissipate_req( VirtProcr *prToDissipate ); 3.841 + 3.842 +inline void 3.843 +VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ); 3.844 + 3.845 +VMSReqst * 3.846 +VMS__take_next_request_out_of( VirtProcr *procrWithReq ); 3.847 + 3.848 +inline void * 3.849 +VMS__take_sem_reqst_from( VMSReqst *req ); 3.850 + 3.851 +//======================== STATS ====================== 3.852 + 3.853 +//===== RDTSC wrapper ===== 3.854 + 3.855 +#define saveTimeStampCountInto(low, high) \ 3.856 + asm volatile("RDTSC; \ 3.857 + movl %%eax, %0; \ 3.858 + movl %%edx, %1;" \ 3.859 + /* outputs */ : "=m" (low), "=m" (high)\ 3.860 + /* inputs */ : \ 3.861 + /* clobber */ : "%eax", "%edx" \ 3.862 + ); 3.863 + 3.864 +#define saveLowTimeStampCountInto(low) \ 3.865 + asm volatile("RDTSC; \ 3.866 + movl %%eax, %0;" \ 3.867 + /* outputs */ : "=m" (low) \ 3.868 + /* inputs */ : \ 3.869 + /* clobber */ : "%eax", "%edx" \ 3.870 + ); 3.871 + 3.872 +//==================== 3.873 +#define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \ 3.874 + makeHighestDynArrayIndexBeAtLeast( _VMSMasterEnv->measHistsInfo, idx ); \ 3.875 + _VMSMasterEnv->measHists[idx] = \ 3.876 + makeFixedBinHist( numBins, startVal, binWidth, name ); 3.877 + 3.878 + 3.879 +#define MEAS__SUB_CREATE /*turn on/off subtraction of create from plugin*/ 3.880 +#define createHistIdx 0 3.881 +#define mutexLockHistIdx 1 3.882 +#define mutexUnlockHistIdx 2 3.883 +#define condWaitHistIdx 3 3.884 +#define condSignalHistIdx 4 3.885 + 3.886 + 3.887 +#define MakeTheMeasHists \ 3.888 + _VMSMasterEnv->measHistsInfo = \ 3.889 + makePrivDynArrayOfSize( &(_VMSMasterEnv->measHists), 200);\ 3.890 + makeAMeasHist( createHistIdx, "Create", 50, 0, 200 ) \ 3.891 + makeAMeasHist( mutexLockHistIdx, "mutex lock", 50, 0, 100 ) \ 3.892 + makeAMeasHist( mutexUnlockHistIdx, "mutex unlock", 50, 0, 100 ) \ 3.893 + makeAMeasHist( condWaitHistIdx, "cond wait", 50, 0, 100 ) \ 3.894 + makeAMeasHist( condSignalHistIdx, "cond signal", 50, 0, 100 ) 3.895 + 3.896 +#define Meas_startCreate \ 3.897 + int32 startStamp, endStamp; \ 3.898 + saveLowTimeStampCountInto( startStamp ); \ 3.899 + 3.900 +#define Meas_endCreate \ 3.901 + saveLowTimeStampCountInto( endStamp ); \ 3.902 + addIntervalToHist( startStamp, endStamp, \ 3.903 + _VMSMasterEnv->measHists[ createHistIdx ] ); 3.904 + 3.905 +#define Meas_startMutexLock \ 3.906 + int32 startStamp, endStamp; \ 3.907 + saveLowTimeStampCountInto( startStamp ); \ 3.908 + 3.909 +#define Meas_endMutexLock \ 3.910 + saveLowTimeStampCountInto( endStamp ); \ 3.911 + addIntervalToHist( startStamp, endStamp, \ 3.912 + _VMSMasterEnv->measHists[ mutexLockHistIdx ] ); 3.913 + 3.914 +#define Meas_startMutexUnlock \ 3.915 + int32 startStamp, endStamp; \ 3.916 + saveLowTimeStampCountInto( startStamp ); \ 3.917 + 3.918 +#define Meas_endMutexUnlock \ 3.919 + saveLowTimeStampCountInto( endStamp ); \ 3.920 + addIntervalToHist( startStamp, endStamp, \ 3.921 + _VMSMasterEnv->measHists[ mutexUnlockHistIdx ] ); 3.922 + 3.923 +#define Meas_startCondWait \ 3.924 + int32 startStamp, endStamp; \ 3.925 + saveLowTimeStampCountInto( startStamp ); \ 3.926 + 3.927 +#define Meas_endCondWait \ 3.928 + saveLowTimeStampCountInto( endStamp ); \ 3.929 + addIntervalToHist( startStamp, endStamp, \ 3.930 + _VMSMasterEnv->measHists[ condWaitHistIdx ] ); 3.931 + 3.932 +#define Meas_startCondSignal \ 3.933 + int32 startStamp, endStamp; \ 3.934 + saveLowTimeStampCountInto( startStamp ); \ 3.935 + 3.936 +#define Meas_endCondSignal \ 3.937 + saveLowTimeStampCountInto( endStamp ); \ 3.938 + addIntervalToHist( startStamp, endStamp, \ 3.939 + _VMSMasterEnv->measHists[ condSignalHistIdx ] ); 3.940 + 3.941 + 3.942 +//===== 3.943 + 3.944 +#include "SwitchAnimators.h" 3.945 +#include "probes.h" 3.946 +#include "vutilities.h" 3.947 + 3.948 +#endif /* _VMS_H */ 3.949 +
4.1 --- a/VMS__DESIGN_NOTES.txt Sat Nov 20 08:19:05 2010 +0100 4.2 +++ b/VMS__DESIGN_NOTES.txt Thu May 12 14:23:41 2011 +0200 4.3 @@ -1,2 +1,2 @@ 4.4 - 4.5 -Implement VMS this way: 4.6 + 4.7 4.8 +Implement VMS this way: 4.9
5.1 --- a/VMS_primitive_data_types.h Sat Nov 20 08:19:05 2010 +0100 5.2 +++ b/VMS_primitive_data_types.h Thu May 12 14:23:41 2011 +0200 5.3 @@ -1,53 +1,53 @@ 5.4 -/* 5.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 5.6 - * Licensed under GNU General Public License version 2 5.7 - * 5.8 - * Author: seanhalle@yahoo.com 5.9 - * 5.10 - 5.11 - */ 5.12 - 5.13 -#ifndef _BLIS_PRIMITIVE_DATA_TYPES_H 5.14 -#define _BLIS_PRIMITIVE_DATA_TYPES_H 5.15 - 5.16 - 5.17 -/*For portability, need primitive data types that have a well defined 5.18 - * size, and well-defined layout into bytes 5.19 - *To do this, provide BLIS standard aliases for all primitive data types 5.20 - *These aliases must be used in all BLIS functions instead of the ANSI types 5.21 - * 5.22 - *These definitions will be replaced inside each specialization module 5.23 - * according to the compiler used in that module and the hardware being 5.24 - * specialized to. 5.25 - */ 5.26 -/* 5.27 -#define int8 char 5.28 -#define uint8 char 5.29 -#define int16 short 5.30 -#define uint16 unsigned short 5.31 -#define int32 int 5.32 -#define uint32 unsigned int 5.33 -#define int64 long long 5.34 -#define uint64 unsigned long long 5.35 -#define float32 float 5.36 -#define float64 double 5.37 -*/ 5.38 -typedef char bool8; 5.39 -typedef char int8; 5.40 -typedef char uint8; 5.41 -typedef short int16; 5.42 -typedef unsigned short uint16; 5.43 -typedef int int32; 5.44 -typedef unsigned int uint32; 5.45 -typedef long long int64; 5.46 -typedef unsigned long long uint64; 5.47 -typedef float float32; 5.48 -typedef double float64; 5.49 -//typedef double double float128; 5.50 -#define float128 double double 5.51 - 5.52 -#define TRUE 1 5.53 -#define FALSE 0 5.54 - 5.55 -#endif /* _BLIS_PRIMITIVE_DATA_TYPES_H */ 5.56 - 5.57 +/* 5.58 + * Copyright 2009 OpenSourceStewardshipFoundation.org 5.59 + * Licensed under GNU General Public License version 2 5.60 + * 5.61 + * Author: seanhalle@yahoo.com 5.62 + * 5.63 + 5.64 + */ 5.65 + 5.66 +#ifndef _BLIS_PRIMITIVE_DATA_TYPES_H 5.67 +#define _BLIS_PRIMITIVE_DATA_TYPES_H 5.68 + 5.69 + 5.70 +/*For portability, need primitive data types that have a well defined 5.71 + * size, and well-defined layout into bytes 5.72 + *To do this, provide BLIS standard aliases for all primitive data types 5.73 + *These aliases must be used in all BLIS functions instead of the ANSI types 5.74 + * 5.75 + *These definitions will be replaced inside each specialization module 5.76 + * according to the compiler used in that module and the hardware being 5.77 + * specialized to. 5.78 + */ 5.79 +/* 5.80 +#define int8 char 5.81 +#define uint8 char 5.82 +#define int16 short 5.83 +#define uint16 unsigned short 5.84 +#define int32 int 5.85 +#define uint32 unsigned int 5.86 +#define int64 long long 5.87 +#define uint64 unsigned long long 5.88 +#define float32 float 5.89 +#define float64 double 5.90 +*/ 5.91 +typedef char bool8; 5.92 +typedef char int8; 5.93 +typedef char uint8; 5.94 +typedef short int16; 5.95 +typedef unsigned short uint16; 5.96 +typedef int int32; 5.97 +typedef unsigned int uint32; 5.98 +typedef long long int64; 5.99 +typedef unsigned long long uint64; 5.100 +typedef float float32; 5.101 +typedef double float64; 5.102 +//typedef double double float128; 5.103 +#define float128 double double 5.104 + 5.105 +#define TRUE 1 5.106 +#define FALSE 0 5.107 + 5.108 +#endif /* _BLIS_PRIMITIVE_DATA_TYPES_H */ 5.109 +
6.1 --- a/probes.h Sat Nov 20 08:19:05 2010 +0100 6.2 +++ b/probes.h Thu May 12 14:23:41 2011 +0200 6.3 @@ -1,195 +1,195 @@ 6.4 -/* 6.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 6.6 - * Licensed under GNU General Public License version 2 6.7 - * 6.8 - * Author: seanhalle@yahoo.com 6.9 - * 6.10 - */ 6.11 - 6.12 -#ifndef _PROBES_H 6.13 -#define _PROBES_H 6.14 -#define __USE_GNU 6.15 - 6.16 -#include "VMS_primitive_data_types.h" 6.17 - 6.18 -#include <sys/time.h> 6.19 - 6.20 - 6.21 - //when STATS__TURN_ON_PROBES is defined allows using probes to measure 6.22 - // time intervals. The probes are macros that only compile to something 6.23 - // when STATS__TURN_ON_PROBES is defined. The probes are saved in the 6.24 - // master env -- but only when this is defined. 6.25 - //The TSC probes use RDTSC instr, can be unreliable, Dbl uses gettimeofday 6.26 -#define STATS__TURN_ON_PROBES 6.27 -//#define STATS__USE_TSC_PROBES 6.28 -#define STATS__USE_DBL_PROBES 6.29 - 6.30 -//typedef struct _IntervalProbe IntervalProbe; //in VMS.h 6.31 - 6.32 -struct _IntervalProbe 6.33 - { 6.34 - char *nameStr; 6.35 - int32 probeID; 6.36 - 6.37 - int32 schedChoiceWasRecorded; 6.38 - int32 coreNum; 6.39 - int32 procrID; 6.40 - float64 procrCreateSecs; 6.41 - 6.42 - #ifdef STATS__USE_TSC_PROBES 6.43 - TSCount startStamp; 6.44 - TSCount endStamp; 6.45 - #else 6.46 - struct timeval startStamp; 6.47 - struct timeval endStamp; 6.48 - #endif 6.49 - float64 startSecs; 6.50 - float64 endSecs; 6.51 - float64 interval; 6.52 - DblHist *hist;//if NULL, then is single interval probe 6.53 - }; 6.54 - 6.55 - 6.56 -//============================= Statistics ================================== 6.57 - 6.58 - //Frequency of TS counts 6.59 - //TODO: change freq for each machine 6.60 -#define TSCOUNT_FREQ 3180000000 6.61 - 6.62 -inline TSCount getTSCount(); 6.63 - 6.64 - 6.65 -//======================== Probes ============================= 6.66 -// 6.67 -// Use macros to allow turning probes off with a #define switch 6.68 -#ifdef STATS__ENABLE_PROBES 6.69 -int32 6.70 -VMS_impl__record_time_point_into_new_probe( char *nameStr,VirtProcr *animPr); 6.71 -#define VMS__record_time_point_into_new_probe( nameStr, animPr ) \ 6.72 - VMS_impl__record_time_point_in_new_probe( nameStr, animPr ) 6.73 - 6.74 -int32 6.75 -VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ); 6.76 -#define VMS_ext__record_time_point_into_new_probe( nameStr ) \ 6.77 - VMS_ext_impl__record_time_point_into_new_probe( nameStr ) 6.78 - 6.79 - 6.80 -int32 6.81 -VMS_impl__create_single_interval_probe( char *nameStr, VirtProcr *animPr ); 6.82 -#define VMS__create_single_interval_probe( nameStr, animPr ) \ 6.83 - VMS_impl__create_single_interval_probe( nameStr, animPr ) 6.84 - 6.85 - 6.86 -int32 6.87 -VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, 6.88 - float64 binWidth, char *nameStr, VirtProcr *animPr ); 6.89 -#define VMS__create_histogram_probe( numBins, startValue, \ 6.90 - binWidth, nameStr, animPr ) \ 6.91 - VMS_impl__create_histogram_probe( numBins, startValue, \ 6.92 - binWidth, nameStr, animPr ) 6.93 -void 6.94 -VMS_impl__free_probe( IntervalProbe *probe ); 6.95 -#define VMS__free_probe( probe ) \ 6.96 - VMS_impl__free_probe( probe ) 6.97 - 6.98 -void 6.99 -VMS_impl__index_probe_by_its_name( int32 probeID, VirtProcr *animPr ); 6.100 -#define VMS__index_probe_by_its_name( probeID, animPr ) \ 6.101 - VMS_impl__index_probe_by_its_name( probeID, animPr ) 6.102 - 6.103 -IntervalProbe * 6.104 -VMS_impl__get_probe_by_name( char *probeName, VirtProcr *animPr ); 6.105 -#define VMS__get_probe_by_name( probeID, animPr ) \ 6.106 - VMS_impl__get_probe_by_name( probeName, animPr ) 6.107 - 6.108 -void 6.109 -VMS_impl__record_sched_choice_into_probe( int32 probeID, VirtProcr *animPr ); 6.110 -#define VMS__record_sched_choice_into_probe( probeID, animPr ) \ 6.111 - VMS_impl__record_sched_choice_into_probe( probeID, animPr ) 6.112 - 6.113 -void 6.114 -VMS_impl__record_interval_start_in_probe( int32 probeID ); 6.115 -#define VMS__record_interval_start_in_probe( probeID ) \ 6.116 - VMS_impl__record_interval_start_in_probe( probeID ) 6.117 - 6.118 -void 6.119 -VMS_impl__record_interval_end_in_probe( int32 probeID ); 6.120 -#define VMS__record_interval_end_in_probe( probeID ) \ 6.121 - VMS_impl__record_interval_end_in_probe( probeID ) 6.122 - 6.123 -void 6.124 -VMS_impl__print_stats_of_probe( int32 probeID ); 6.125 -#define VMS__print_stats_of_probe( probeID ) \ 6.126 - VMS_impl__print_stats_of_probe( probeID ) 6.127 - 6.128 -void 6.129 -VMS_impl__print_stats_of_all_probes(); 6.130 -#define VMS__print_stats_of_all_probes \ 6.131 - VMS_impl__print_stats_of_all_probes 6.132 - 6.133 - 6.134 -#else 6.135 -int32 6.136 -VMS_impl__record_time_point_into_new_probe( char *nameStr,VirtProcr *animPr); 6.137 -#define VMS__record_time_point_into_new_probe( nameStr, animPr ) \ 6.138 - 0 /* do nothing */ 6.139 - 6.140 -int32 6.141 -VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ); 6.142 -#define VMS_ext__record_time_point_into_new_probe( nameStr ) \ 6.143 - 0 /* do nothing */ 6.144 - 6.145 - 6.146 -int32 6.147 -VMS_impl__create_single_interval_probe( char *nameStr, VirtProcr *animPr ); 6.148 -#define VMS__create_single_interval_probe( nameStr, animPr ) \ 6.149 - 0 /* do nothing */ 6.150 - 6.151 - 6.152 -int32 6.153 -VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, 6.154 - float64 binWidth, char *nameStr, VirtProcr *animPr ); 6.155 -#define VMS__create_histogram_probe( numBins, startValue, \ 6.156 - binWidth, nameStr, animPr ) \ 6.157 - 0 /* do nothing */ 6.158 - 6.159 -void 6.160 -VMS_impl__index_probe_by_its_name( int32 probeID, VirtProcr *animPr ); 6.161 -#define VMS__index_probe_by_its_name( probeID, animPr ) \ 6.162 - /* do nothing */ 6.163 - 6.164 -IntervalProbe * 6.165 -VMS_impl__get_probe_by_name( char *probeName, VirtProcr *animPr ); 6.166 -#define VMS__get_probe_by_name( probeID, animPr ) \ 6.167 - NULL /* do nothing */ 6.168 - 6.169 -void 6.170 -VMS_impl__record_sched_choice_into_probe( int32 probeID, VirtProcr *animPr ); 6.171 -#define VMS__record_sched_choice_into_probe( probeID, animPr ) \ 6.172 - /* do nothing */ 6.173 - 6.174 -void 6.175 -VMS_impl__record_interval_start_in_probe( int32 probeID ); 6.176 -#define VMS__record_interval_start_in_probe( probeID ) \ 6.177 - /* do nothing */ 6.178 - 6.179 -void 6.180 -VMS_impl__record_interval_end_in_probe( int32 probeID ); 6.181 -#define VMS__record_interval_end_in_probe( probeID ) \ 6.182 - /* do nothing */ 6.183 - 6.184 -inline void doNothing(); 6.185 -void 6.186 -VMS_impl__print_stats_of_probe( int32 probeID ); 6.187 -#define VMS__print_stats_of_probe( probeID ) \ 6.188 - doNothing/* do nothing */ 6.189 - 6.190 -void 6.191 -VMS_impl__print_stats_of_all_probes(); 6.192 -#define VMS__print_stats_of_all_probes \ 6.193 - doNothing/* do nothing */ 6.194 - 6.195 -#endif /* defined STATS__ENABLE_PROBES */ 6.196 - 6.197 -#endif /* _PROBES_H */ 6.198 - 6.199 +/* 6.200 + * Copyright 2009 OpenSourceStewardshipFoundation.org 6.201 + * Licensed under GNU General Public License version 2 6.202 + * 6.203 + * Author: seanhalle@yahoo.com 6.204 + * 6.205 + */ 6.206 + 6.207 +#ifndef _PROBES_H 6.208 +#define _PROBES_H 6.209 +#define __USE_GNU 6.210 + 6.211 +#include "VMS_primitive_data_types.h" 6.212 + 6.213 +#include <sys/time.h> 6.214 + 6.215 + 6.216 + //when STATS__TURN_ON_PROBES is defined allows using probes to measure 6.217 + // time intervals. The probes are macros that only compile to something 6.218 + // when STATS__TURN_ON_PROBES is defined. The probes are saved in the 6.219 + // master env -- but only when this is defined. 6.220 + //The TSC probes use RDTSC instr, can be unreliable, Dbl uses gettimeofday 6.221 +#define STATS__TURN_ON_PROBES 6.222 +//#define STATS__USE_TSC_PROBES 6.223 +#define STATS__USE_DBL_PROBES 6.224 + 6.225 +//typedef struct _IntervalProbe IntervalProbe; //in VMS.h 6.226 + 6.227 +struct _IntervalProbe 6.228 + { 6.229 + char *nameStr; 6.230 + int32 probeID; 6.231 + 6.232 + int32 schedChoiceWasRecorded; 6.233 + int32 coreNum; 6.234 + int32 procrID; 6.235 + float64 procrCreateSecs; 6.236 + 6.237 + #ifdef STATS__USE_TSC_PROBES 6.238 + TSCount startStamp; 6.239 + TSCount endStamp; 6.240 + #else 6.241 + struct timeval startStamp; 6.242 + struct timeval endStamp; 6.243 + #endif 6.244 + float64 startSecs; 6.245 + float64 endSecs; 6.246 + float64 interval; 6.247 + DblHist *hist;//if NULL, then is single interval probe 6.248 + }; 6.249 + 6.250 + 6.251 +//============================= Statistics ================================== 6.252 + 6.253 + //Frequency of TS counts 6.254 + //TODO: change freq for each machine 6.255 +#define TSCOUNT_FREQ 3180000000 6.256 + 6.257 +inline TSCount getTSCount(); 6.258 + 6.259 + 6.260 +//======================== Probes ============================= 6.261 +// 6.262 +// Use macros to allow turning probes off with a #define switch 6.263 +#ifdef STATS__ENABLE_PROBES 6.264 +int32 6.265 +VMS_impl__record_time_point_into_new_probe( char *nameStr,VirtProcr *animPr); 6.266 +#define VMS__record_time_point_into_new_probe( nameStr, animPr ) \ 6.267 + VMS_impl__record_time_point_in_new_probe( nameStr, animPr ) 6.268 + 6.269 +int32 6.270 +VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ); 6.271 +#define VMS_ext__record_time_point_into_new_probe( nameStr ) \ 6.272 + VMS_ext_impl__record_time_point_into_new_probe( nameStr ) 6.273 + 6.274 + 6.275 +int32 6.276 +VMS_impl__create_single_interval_probe( char *nameStr, VirtProcr *animPr ); 6.277 +#define VMS__create_single_interval_probe( nameStr, animPr ) \ 6.278 + VMS_impl__create_single_interval_probe( nameStr, animPr ) 6.279 + 6.280 + 6.281 +int32 6.282 +VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, 6.283 + float64 binWidth, char *nameStr, VirtProcr *animPr ); 6.284 +#define VMS__create_histogram_probe( numBins, startValue, \ 6.285 + binWidth, nameStr, animPr ) \ 6.286 + VMS_impl__create_histogram_probe( numBins, startValue, \ 6.287 + binWidth, nameStr, animPr ) 6.288 +void 6.289 +VMS_impl__free_probe( IntervalProbe *probe ); 6.290 +#define VMS__free_probe( probe ) \ 6.291 + VMS_impl__free_probe( probe ) 6.292 + 6.293 +void 6.294 +VMS_impl__index_probe_by_its_name( int32 probeID, VirtProcr *animPr ); 6.295 +#define VMS__index_probe_by_its_name( probeID, animPr ) \ 6.296 + VMS_impl__index_probe_by_its_name( probeID, animPr ) 6.297 + 6.298 +IntervalProbe * 6.299 +VMS_impl__get_probe_by_name( char *probeName, VirtProcr *animPr ); 6.300 +#define VMS__get_probe_by_name( probeID, animPr ) \ 6.301 + VMS_impl__get_probe_by_name( probeName, animPr ) 6.302 + 6.303 +void 6.304 +VMS_impl__record_sched_choice_into_probe( int32 probeID, VirtProcr *animPr ); 6.305 +#define VMS__record_sched_choice_into_probe( probeID, animPr ) \ 6.306 + VMS_impl__record_sched_choice_into_probe( probeID, animPr ) 6.307 + 6.308 +void 6.309 +VMS_impl__record_interval_start_in_probe( int32 probeID ); 6.310 +#define VMS__record_interval_start_in_probe( probeID ) \ 6.311 + VMS_impl__record_interval_start_in_probe( probeID ) 6.312 + 6.313 +void 6.314 +VMS_impl__record_interval_end_in_probe( int32 probeID ); 6.315 +#define VMS__record_interval_end_in_probe( probeID ) \ 6.316 + VMS_impl__record_interval_end_in_probe( probeID ) 6.317 + 6.318 +void 6.319 +VMS_impl__print_stats_of_probe( int32 probeID ); 6.320 +#define VMS__print_stats_of_probe( probeID ) \ 6.321 + VMS_impl__print_stats_of_probe( probeID ) 6.322 + 6.323 +void 6.324 +VMS_impl__print_stats_of_all_probes(); 6.325 +#define VMS__print_stats_of_all_probes \ 6.326 + VMS_impl__print_stats_of_all_probes 6.327 + 6.328 + 6.329 +#else 6.330 +int32 6.331 +VMS_impl__record_time_point_into_new_probe( char *nameStr,VirtProcr *animPr); 6.332 +#define VMS__record_time_point_into_new_probe( nameStr, animPr ) \ 6.333 + 0 /* do nothing */ 6.334 + 6.335 +int32 6.336 +VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ); 6.337 +#define VMS_ext__record_time_point_into_new_probe( nameStr ) \ 6.338 + 0 /* do nothing */ 6.339 + 6.340 + 6.341 +int32 6.342 +VMS_impl__create_single_interval_probe( char *nameStr, VirtProcr *animPr ); 6.343 +#define VMS__create_single_interval_probe( nameStr, animPr ) \ 6.344 + 0 /* do nothing */ 6.345 + 6.346 + 6.347 +int32 6.348 +VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, 6.349 + float64 binWidth, char *nameStr, VirtProcr *animPr ); 6.350 +#define VMS__create_histogram_probe( numBins, startValue, \ 6.351 + binWidth, nameStr, animPr ) \ 6.352 + 0 /* do nothing */ 6.353 + 6.354 +void 6.355 +VMS_impl__index_probe_by_its_name( int32 probeID, VirtProcr *animPr ); 6.356 +#define VMS__index_probe_by_its_name( probeID, animPr ) \ 6.357 + /* do nothing */ 6.358 + 6.359 +IntervalProbe * 6.360 +VMS_impl__get_probe_by_name( char *probeName, VirtProcr *animPr ); 6.361 +#define VMS__get_probe_by_name( probeID, animPr ) \ 6.362 + NULL /* do nothing */ 6.363 + 6.364 +void 6.365 +VMS_impl__record_sched_choice_into_probe( int32 probeID, VirtProcr *animPr ); 6.366 +#define VMS__record_sched_choice_into_probe( probeID, animPr ) \ 6.367 + /* do nothing */ 6.368 + 6.369 +void 6.370 +VMS_impl__record_interval_start_in_probe( int32 probeID ); 6.371 +#define VMS__record_interval_start_in_probe( probeID ) \ 6.372 + /* do nothing */ 6.373 + 6.374 +void 6.375 +VMS_impl__record_interval_end_in_probe( int32 probeID ); 6.376 +#define VMS__record_interval_end_in_probe( probeID ) \ 6.377 + /* do nothing */ 6.378 + 6.379 +inline void doNothing(); 6.380 +void 6.381 +VMS_impl__print_stats_of_probe( int32 probeID ); 6.382 +#define VMS__print_stats_of_probe( probeID ) \ 6.383 + doNothing/* do nothing */ 6.384 + 6.385 +void 6.386 +VMS_impl__print_stats_of_all_probes(); 6.387 +#define VMS__print_stats_of_all_probes \ 6.388 + doNothing/* do nothing */ 6.389 + 6.390 +#endif /* defined STATS__ENABLE_PROBES */ 6.391 + 6.392 +#endif /* _PROBES_H */ 6.393 +
7.1 --- a/vmalloc.h Sat Nov 20 08:19:05 2010 +0100 7.2 +++ b/vmalloc.h Thu May 12 14:23:41 2011 +0200 7.3 @@ -1,57 +1,57 @@ 7.4 -/* 7.5 - * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 7.6 - * Licensed under GNU General Public License version 2 7.7 - * 7.8 - * Author: seanhalle@yahoo.com 7.9 - * 7.10 - * Created on November 14, 2009, 9:07 PM 7.11 - */ 7.12 - 7.13 -#ifndef _VMALLOC_H 7.14 -#define _VMALLOC_H 7.15 - 7.16 -#include <malloc.h> 7.17 -#include "VMS_primitive_data_types.h" 7.18 - 7.19 -typedef struct _MallocProlog MallocProlog; 7.20 - 7.21 -struct _MallocProlog 7.22 - { 7.23 - MallocProlog *nextChunkInFreeList; 7.24 - MallocProlog *prevChunkInFreeList; 7.25 - MallocProlog *nextHigherInMem; 7.26 - MallocProlog *nextLowerInMem; 7.27 - }; 7.28 -//MallocProlog 7.29 - 7.30 -typedef struct 7.31 - { 7.32 - MallocProlog *firstChunkInFreeList; 7.33 - int32 numInList; 7.34 - } 7.35 -FreeListHead; 7.36 - 7.37 -void * 7.38 -VMS__malloc( int32 sizeRequested ); 7.39 - 7.40 -void 7.41 -VMS__free( void *ptrToFree ); 7.42 - 7.43 -/*Allocates memory from the external system -- higher overhead 7.44 - */ 7.45 -void * 7.46 -VMS__malloc_in_ext( int32 sizeRequested ); 7.47 - 7.48 -/*Frees memory that was allocated in the external system -- higher overhead 7.49 - */ 7.50 -void 7.51 -VMS__free_in_ext( void *ptrToFree ); 7.52 - 7.53 - 7.54 -MallocProlog * 7.55 -VMS_ext__create_free_list(); 7.56 - 7.57 -void 7.58 -VMS_ext__free_free_list( MallocProlog *freeListHead ); 7.59 - 7.60 +/* 7.61 + * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 7.62 + * Licensed under GNU General Public License version 2 7.63 + * 7.64 + * Author: seanhalle@yahoo.com 7.65 + * 7.66 + * Created on November 14, 2009, 9:07 PM 7.67 + */ 7.68 + 7.69 +#ifndef _VMALLOC_H 7.70 +#define _VMALLOC_H 7.71 + 7.72 +#include <malloc.h> 7.73 +#include "VMS_primitive_data_types.h" 7.74 + 7.75 +typedef struct _MallocProlog MallocProlog; 7.76 + 7.77 +struct _MallocProlog 7.78 + { 7.79 + MallocProlog *nextChunkInFreeList; 7.80 + MallocProlog *prevChunkInFreeList; 7.81 + MallocProlog *nextHigherInMem; 7.82 + MallocProlog *nextLowerInMem; 7.83 + }; 7.84 +//MallocProlog 7.85 + 7.86 +typedef struct 7.87 + { 7.88 + MallocProlog *firstChunkInFreeList; 7.89 + int32 numInList; 7.90 + } 7.91 +FreeListHead; 7.92 + 7.93 +void * 7.94 +VMS__malloc( int32 sizeRequested ); 7.95 + 7.96 +void 7.97 +VMS__free( void *ptrToFree ); 7.98 + 7.99 +/*Allocates memory from the external system -- higher overhead 7.100 + */ 7.101 +void * 7.102 +VMS__malloc_in_ext( int32 sizeRequested ); 7.103 + 7.104 +/*Frees memory that was allocated in the external system -- higher overhead 7.105 + */ 7.106 +void 7.107 +VMS__free_in_ext( void *ptrToFree ); 7.108 + 7.109 + 7.110 +MallocProlog * 7.111 +VMS_ext__create_free_list(); 7.112 + 7.113 +void 7.114 +VMS_ext__free_free_list( MallocProlog *freeListHead ); 7.115 + 7.116 #endif 7.117 \ No newline at end of file
8.1 --- a/vutilities.h Sat Nov 20 08:19:05 2010 +0100 8.2 +++ b/vutilities.h Thu May 12 14:23:41 2011 +0200 8.3 @@ -1,20 +1,20 @@ 8.4 -/* 8.5 - * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 8.6 - * Licensed under GNU General Public License version 2 8.7 - * 8.8 - * Author: seanhalle@yahoo.com 8.9 - * 8.10 - * Created on November 14, 2009, 9:07 PM 8.11 - */ 8.12 - 8.13 - 8.14 -#ifndef _UTILITIES_H 8.15 -#define _UTILITIES_H 8.16 - 8.17 -#include <string.h> 8.18 -#include "VMS_primitive_data_types.h" 8.19 - 8.20 -inline char * 8.21 -VMS__strDup( char *str ); 8.22 - 8.23 -#endif 8.24 +/* 8.25 + * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 8.26 + * Licensed under GNU General Public License version 2 8.27 + * 8.28 + * Author: seanhalle@yahoo.com 8.29 + * 8.30 + * Created on November 14, 2009, 9:07 PM 8.31 + */ 8.32 + 8.33 + 8.34 +#ifndef _UTILITIES_H 8.35 +#define _UTILITIES_H 8.36 + 8.37 +#include <string.h> 8.38 +#include "VMS_primitive_data_types.h" 8.39 + 8.40 +inline char * 8.41 +VMS__strDup( char *str ); 8.42 + 8.43 +#endif
