]> git.ipfire.org Git - thirdparty/gcc.git/blame - libhsail-rt/rt/fbarrier.c
Remove BRIG front-end.
[thirdparty/gcc.git] / libhsail-rt / rt / fbarrier.c
CommitLineData
5fd1486c
PJ
1/* fbarrier.c -- HSAIL fbarrier built-ins.
2
99dee823 3 Copyright (C) 2015-2021 Free Software Foundation, Inc.
5fd1486c
PJ
4 Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com>
5 for General Processor Tech.
6
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files
9 (the "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
14
15 The above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 USE OR OTHER DEALINGS IN THE SOFTWARE.
25*/
26
27#include <stdlib.h>
28#include <signal.h>
29
30#include "workitems.h"
31#include "phsa-rt.h"
32
33#ifdef HAVE_FIBERS
34#include "fibers.h"
35
36typedef fiber_barrier_t fbarrier;
37
38void
39__hsail_initfbar (uint32_t addr, PHSAWorkItem *wi)
40{
41 fbarrier *fbar = (fbarrier *) (wi->wg->group_base_ptr + addr);
42 fbar->threshold = 0;
43 fbar->reached = 0;
44 fbar->waiting_count = 0;
45}
46
47void
48__hsail_releasefbar (uint32_t addr, PHSAWorkItem *wi)
49{
50 fbarrier *fbar = (fbarrier *) (wi->wg->group_base_ptr + addr);
51 fbar->threshold = 0;
52 fbar->reached = 0;
53 fbar->waiting_count = 0;
54}
55
56void
57__hsail_joinfbar (uint32_t addr, PHSAWorkItem *wi)
58{
59 fbarrier *fbar = (fbarrier *) (wi->wg->group_base_ptr + addr);
60 ++fbar->threshold;
61}
62
63void
64__hsail_leavefbar (uint32_t addr, PHSAWorkItem *wi)
65{
66 fbarrier *fbar = (fbarrier *) (wi->wg->group_base_ptr + addr);
67 --fbar->threshold;
68}
69
70void
71__hsail_waitfbar (uint32_t addr, PHSAWorkItem *wi)
72{
73 fbarrier *fbar = (fbarrier *) (wi->wg->group_base_ptr + addr);
74 fiber_barrier_reach (fbar);
75}
76
77void
78__hsail_arrivefbar (uint32_t addr, PHSAWorkItem *wi)
79{
80 fbarrier *fbar = (fbarrier *) (wi->wg->group_base_ptr + addr);
81 ++fbar->reached;
82 if (fbar->reached == fbar->threshold)
83 fbar->reached = 0;
84}
85
86#endif
87