annotate libhsail-rt/rt/queue.c @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* queue.c -- Builtins for HSAIL queue related instructions.
kono
parents:
diff changeset
2
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3 Copyright (C) 2015-2018 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
4 Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com>
kono
parents:
diff changeset
5 for General Processor Tech.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 Permission is hereby granted, free of charge, to any person obtaining a
kono
parents:
diff changeset
8 copy of this software and associated documentation files
kono
parents:
diff changeset
9 (the "Software"), to deal in the Software without restriction, including
kono
parents:
diff changeset
10 without limitation the rights to use, copy, modify, merge, publish,
kono
parents:
diff changeset
11 distribute, sublicense, and/or sell copies of the Software, and to
kono
parents:
diff changeset
12 permit persons to whom the Software is furnished to do so, subject to
kono
parents:
diff changeset
13 the following conditions:
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 The above copyright notice and this permission notice shall be included
kono
parents:
diff changeset
16 in all copies or substantial portions of the Software.
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
kono
parents:
diff changeset
19 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
kono
parents:
diff changeset
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
kono
parents:
diff changeset
21 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
kono
parents:
diff changeset
22 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
kono
parents:
diff changeset
23 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
kono
parents:
diff changeset
24 USE OR OTHER DEALINGS IN THE SOFTWARE.
kono
parents:
diff changeset
25 */
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 #include "phsa-queue-interface.h"
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 uint64_t
kono
parents:
diff changeset
30 __hsail_ldqueuereadindex (uint64_t queue_addr)
kono
parents:
diff changeset
31 {
kono
parents:
diff changeset
32 phsa_queue_t *queue = (phsa_queue_t *) (uintptr_t) queue_addr;
kono
parents:
diff changeset
33 return queue->read_index;
kono
parents:
diff changeset
34 }
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 uint64_t
kono
parents:
diff changeset
37 __hsail_ldqueuewriteindex (uint64_t queue_addr)
kono
parents:
diff changeset
38 {
kono
parents:
diff changeset
39 phsa_queue_t *queue = (phsa_queue_t *) (uintptr_t) queue_addr;
kono
parents:
diff changeset
40 return queue->write_index;
kono
parents:
diff changeset
41 }
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 uint64_t
kono
parents:
diff changeset
44 __hsail_addqueuewriteindex (uint64_t queue_addr, uint64_t value)
kono
parents:
diff changeset
45 {
kono
parents:
diff changeset
46 phsa_queue_t *queue = (phsa_queue_t *) (uintptr_t) queue_addr;
kono
parents:
diff changeset
47 return __sync_fetch_and_add (&queue->write_index, value);
kono
parents:
diff changeset
48 }
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 uint64_t
kono
parents:
diff changeset
51 __hsail_casqueuewriteindex (uint64_t queue_addr, uint64_t cmp_value,
kono
parents:
diff changeset
52 uint64_t new_value)
kono
parents:
diff changeset
53 {
kono
parents:
diff changeset
54 phsa_queue_t *queue = (phsa_queue_t *) (uintptr_t) queue_addr;
kono
parents:
diff changeset
55 return __sync_val_compare_and_swap (&queue->write_index, cmp_value,
kono
parents:
diff changeset
56 new_value);
kono
parents:
diff changeset
57 }
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 void
kono
parents:
diff changeset
60 __hsail_stqueuereadindex (uint64_t queue_addr, uint64_t value)
kono
parents:
diff changeset
61 {
kono
parents:
diff changeset
62 phsa_queue_t *queue = (phsa_queue_t *) (uintptr_t) queue_addr;
kono
parents:
diff changeset
63 queue->read_index = value;
kono
parents:
diff changeset
64 }
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 void
kono
parents:
diff changeset
67 __hsail_stqueuewriteindex (uint64_t queue_addr, uint64_t value)
kono
parents:
diff changeset
68 {
kono
parents:
diff changeset
69 phsa_queue_t *queue = (phsa_queue_t *) (uintptr_t) queue_addr;
kono
parents:
diff changeset
70 queue->write_index = value;
kono
parents:
diff changeset
71 }