| 1 | /* |
| 2 | cs_par_structs.h: |
| 3 | |
| 4 | Copyright (C) 2011 John ffitch and Chris Wilson |
| 5 | 2013 John ffitch and Martin Brain |
| 6 | |
| 7 | This file is part of Csound. |
| 8 | |
| 9 | The Csound Library is free software; you can redistribute it |
| 10 | and/or modify it under the terms of the GNU Lesser General Public |
| 11 | License as published by the Free Software Foundation; either |
| 12 | version 2.1 of the License, or (at your option) any later version. |
| 13 | |
| 14 | Csound is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU Lesser General Public License for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU Lesser General Public |
| 20 | License along with Csound; if not, write to the Free Software |
| 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 22 | 02110-1301 USA |
| 23 | */ |
| 24 | |
| 25 | #ifndef __CS_PAR_DISPATCH_H |
| 26 | #define __CS_PAR_DISPATCH_H |
| 27 | |
| 28 | /* global variables lock support */ |
| 29 | struct global_var_lock_t; |
| 30 | |
| 31 | struct instr_semantics_t; |
| 32 | |
| 33 | /* New model */ |
| 34 | |
| 35 | /* Current memory subsystems work at the granularity of cache lines. |
| 36 | * Thus concurrent accesses to multiple objects within a cache line |
| 37 | * can cause additional conflicts and memory subsystem traffic. |
| 38 | * The best way to avoid this is to pad the structures so that they don't |
| 39 | * share a cache line. 64 bytes seems to be becoming the usual cache line |
| 40 | * size. If the actual line is smaller, it will waste a little memory but |
| 41 | * shouldn't affect the sharing. If the actual line is larger then it may |
| 42 | * cause a few conflicts and thus a performance hit. Unless you are |
| 43 | * using a very unusual machine and you happen to know it's cache line size |
| 44 | * then leave this as 64, although you can try 32 or maybe even 16. |
| 45 | */ |
| 46 | #define CONCURRENTPADDING 64 |
| 47 | |
| 48 | typedef int taskID; |
| 49 | |
| 50 | /* Each task has a status */ |
| 51 | enum state { WAITING = 3, /* Dependencies have not been finished */ |
| 52 | AVAILABLE = 2, /* Dependencies met, ready to be run */ |
| 53 | INPROGRESS = 1, /* Has been started */ |
| 54 | DONE = 0 }; /* Has been completed */ |
| 55 | |
| 56 | typedef struct _stateWithPadding { |
| 57 | enum state s; |
| 58 | uint8_t padding [(CONCURRENTPADDING - sizeof(enum state)) / sizeof(uint8_t)]; |
| 59 | } stateWithPadding; |
| 60 | |
| 61 | /* Sets of prerequiste tasks for each task */ |
| 62 | typedef struct _watchList { |
| 63 | taskID id; |
| 64 | struct _watchList *next; |
| 65 | uint8_t padding [(CONCURRENTPADDING - |
| 66 | (sizeof(taskID) + |
| 67 | sizeof(struct _watchList *))) / sizeof(uint8_t)]; |
| 68 | } watchList; |
| 69 | |
| 70 | #endif |