]>
Commit | Line | Data |
---|---|---|
5fd1486c PJ |
1 | /* misc.c -- Builtins for HSAIL misc instructions. |
2 | ||
8d9254fc | 3 | Copyright (C) 2015-2020 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 <stdint.h> | |
28 | #include <time.h> | |
29 | ||
30 | #include "workitems.h" | |
31 | ||
32 | /* Return the monotonic clock as nanoseconds. */ | |
33 | ||
34 | uint64_t | |
35 | __hsail_clock () | |
36 | { | |
37 | struct timespec t; | |
38 | clock_gettime (CLOCK_MONOTONIC, &t); | |
39 | return (uint64_t) t.tv_sec * 1000000000 + (uint64_t) t.tv_nsec; | |
40 | } | |
41 | ||
42 | uint32_t | |
43 | __hsail_cuid (PHSAWorkItem *wi) | |
44 | { | |
45 | /* All WIs are executed with a single compute unit (core/thread) | |
46 | for now. */ | |
47 | return 0; | |
48 | } | |
49 | ||
50 | uint32_t | |
51 | __hsail_maxcuid (PHSAWorkItem *wi) | |
52 | { | |
53 | /* All WIs are executed with a single compute unit (core/thread) | |
54 | for now. */ | |
55 | return 0; | |
56 | } | |
57 | ||
58 | void | |
59 | __hsail_debugtrap (uint32_t src, PHSAWorkItem *wi) | |
60 | { | |
61 | /* Could we produce a SIGTRAP signal here to drop to gdb | |
62 | console, or similar? In any case, the execution of the | |
63 | kernel should halt. | |
64 | */ | |
65 | return; | |
66 | } | |
67 | ||
68 | uint32_t | |
69 | __hsail_groupbaseptr (PHSAWorkItem *wi) | |
70 | { | |
315405b6 JJ |
71 | return (uint32_t) (uintptr_t) (wi->wg->group_base_ptr |
72 | - wi->launch_data->group_segment_start_addr); | |
5fd1486c PJ |
73 | } |
74 | ||
75 | uint64_t | |
76 | __hsail_kernargbaseptr_u64 (PHSAWorkItem *wi) | |
77 | { | |
78 | /* For now assume only a single kernarg allocation at a time. | |
79 | Proper kernarg memory management to do. */ | |
315405b6 | 80 | return (uint64_t) (uintptr_t) wi->launch_data->kernarg_addr; |
5fd1486c PJ |
81 | } |
82 | ||
83 | uint32_t | |
84 | __hsail_kernargbaseptr_u32 (PHSAWorkItem *wi) | |
85 | { | |
86 | /* For now assume only a single kernarg allocation at a time. | |
87 | Proper kernarg memory management to do. */ | |
88 | return 0; | |
89 | } |