1 /* misc.c -- Builtins for HSAIL misc instructions.
3 Copyright (C) 2015-2018 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"
32 /* Return the monotonic clock as nanoseconds. */
38 clock_gettime (CLOCK_MONOTONIC
, &t
);
39 return (uint64_t) t
.tv_sec
* 1000000000 + (uint64_t) t
.tv_nsec
;
43 __hsail_cuid (PHSAWorkItem
*wi
)
45 /* All WIs are executed with a single compute unit (core/thread)
51 __hsail_maxcuid (PHSAWorkItem
*wi
)
53 /* All WIs are executed with a single compute unit (core/thread)
59 __hsail_debugtrap (uint32_t src
, PHSAWorkItem
*wi
)
61 /* Could we produce a SIGTRAP signal here to drop to gdb
62 console, or similar? In any case, the execution of the
69 __hsail_groupbaseptr (PHSAWorkItem
*wi
)
71 return (uint32_t) (uintptr_t) (wi
->wg
->group_base_ptr
72 - wi
->launch_data
->group_segment_start_addr
);
76 __hsail_kernargbaseptr_u64 (PHSAWorkItem
*wi
)
78 /* For now assume only a single kernarg allocation at a time.
79 Proper kernarg memory management to do. */
80 return (uint64_t) (uintptr_t) wi
->launch_data
->kernarg_addr
;
84 __hsail_kernargbaseptr_u32 (PHSAWorkItem
*wi
)
86 /* For now assume only a single kernarg allocation at a time.
87 Proper kernarg memory management to do. */