[1] | 1 | /* |
---|
| 2 | * remote_barrier.h - distributed kernel barrier definition |
---|
| 3 | * |
---|
| 4 | * Author Alain Greiner (2016) |
---|
| 5 | * |
---|
| 6 | * Copyright (c) UPMC Sorbonne Universites |
---|
| 7 | * |
---|
| 8 | * This file is part of ALMOS-MKH. |
---|
| 9 | * |
---|
| 10 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
| 11 | * under the terms of the GNU General Public License as published by |
---|
| 12 | err* the Free Software Foundation; version 2.0 of the License. |
---|
| 13 | * |
---|
| 14 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 17 | * General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
| 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | #ifndef _REMOTE_BARRIER_H_ |
---|
| 25 | #define _REMOTE_BARRIER_H_ |
---|
| 26 | |
---|
| 27 | #include <almos_config.h> |
---|
| 28 | #include <hal_types.h> |
---|
| 29 | |
---|
| 30 | /***************************************************************************************** |
---|
| 31 | * This structure defines a distributed "rendez-vous" barrier, that can be used |
---|
| 32 | * to synchronise several kernel threads running in different clusters |
---|
| 33 | * It is used in the parallel kernel_init phase. |
---|
| 34 | * It does not need to be initialised, but it must be statically allocated |
---|
| 35 | * in the KDATA segment to be properly initialised by the compiler/loader. |
---|
| 36 | ****************************************************************************************/ |
---|
| 37 | |
---|
| 38 | typedef struct remote_barrier_s |
---|
| 39 | { |
---|
| 40 | uint32_t current; // number of arrived threads |
---|
| 41 | uint32_t sense; // barrier state (toggle) |
---|
| 42 | uint32_t pad[(CONFIG_CACHE_LINE_SIZE>>2)-2]; |
---|
| 43 | } |
---|
| 44 | remote_barrier_t; |
---|
| 45 | |
---|
| 46 | /***************************************************************************************** |
---|
| 47 | * This blocking function implements a toggle barrier. It returns only when all |
---|
| 48 | * expected threads reach the barrier. It can be used several times without |
---|
| 49 | * specific initialisation. |
---|
| 50 | * It is portable, as it uses the remote_lw() & remote_sw() access functions. |
---|
| 51 | * @ xp : extended pointer on barrier in remote cluster |
---|
| 52 | * @ count : number of expected thread |
---|
| 53 | ****************************************************************************************/ |
---|
| 54 | inline void remote_barrier( xptr_t xp, |
---|
| 55 | uint32_t count ); |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | #endif /* _REMOTE_BARRIER_H_ */ |
---|