1 /* fbarrier.c -- HSAIL fbarrier built-ins.
3 Copyright (C) 2015-2017 Free Software Foundation, Inc.
4 Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com>
5 for General Processor Tech.
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:
15 The above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
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.
30 #include "workitems.h"
36 typedef fiber_barrier_t fbarrier
;
39 __hsail_initfbar (uint32_t addr
, PHSAWorkItem
*wi
)
41 fbarrier
*fbar
= (fbarrier
*) (wi
->wg
->group_base_ptr
+ addr
);
44 fbar
->waiting_count
= 0;
48 __hsail_releasefbar (uint32_t addr
, PHSAWorkItem
*wi
)
50 fbarrier
*fbar
= (fbarrier
*) (wi
->wg
->group_base_ptr
+ addr
);
53 fbar
->waiting_count
= 0;
57 __hsail_joinfbar (uint32_t addr
, PHSAWorkItem
*wi
)
59 fbarrier
*fbar
= (fbarrier
*) (wi
->wg
->group_base_ptr
+ addr
);
64 __hsail_leavefbar (uint32_t addr
, PHSAWorkItem
*wi
)
66 fbarrier
*fbar
= (fbarrier
*) (wi
->wg
->group_base_ptr
+ addr
);
71 __hsail_waitfbar (uint32_t addr
, PHSAWorkItem
*wi
)
73 fbarrier
*fbar
= (fbarrier
*) (wi
->wg
->group_base_ptr
+ addr
);
74 fiber_barrier_reach (fbar
);
78 __hsail_arrivefbar (uint32_t addr
, PHSAWorkItem
*wi
)
80 fbarrier
*fbar
= (fbarrier
*) (wi
->wg
->group_base_ptr
+ addr
);
82 if (fbar
->reached
== fbar
->threshold
)