annotate libhsail-rt/rt/misc.c @ 118:fd00160c1b76

ifdef TARGET_64BIT
author mir3636
date Tue, 27 Feb 2018 15:01:35 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* misc.c -- Builtins for HSAIL misc instructions.
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 Copyright (C) 2015-2017 Free Software Foundation, Inc.
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 <stdint.h>
kono
parents:
diff changeset
28 #include <time.h>
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 #include "workitems.h"
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 /* Return the monotonic clock as nanoseconds. */
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 uint64_t
kono
parents:
diff changeset
35 __hsail_clock ()
kono
parents:
diff changeset
36 {
kono
parents:
diff changeset
37 struct timespec t;
kono
parents:
diff changeset
38 clock_gettime (CLOCK_MONOTONIC, &t);
kono
parents:
diff changeset
39 return (uint64_t) t.tv_sec * 1000000000 + (uint64_t) t.tv_nsec;
kono
parents:
diff changeset
40 }
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 uint32_t
kono
parents:
diff changeset
43 __hsail_cuid (PHSAWorkItem *wi)
kono
parents:
diff changeset
44 {
kono
parents:
diff changeset
45 /* All WIs are executed with a single compute unit (core/thread)
kono
parents:
diff changeset
46 for now. */
kono
parents:
diff changeset
47 return 0;
kono
parents:
diff changeset
48 }
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 uint32_t
kono
parents:
diff changeset
51 __hsail_maxcuid (PHSAWorkItem *wi)
kono
parents:
diff changeset
52 {
kono
parents:
diff changeset
53 /* All WIs are executed with a single compute unit (core/thread)
kono
parents:
diff changeset
54 for now. */
kono
parents:
diff changeset
55 return 0;
kono
parents:
diff changeset
56 }
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 void
kono
parents:
diff changeset
59 __hsail_debugtrap (uint32_t src, PHSAWorkItem *wi)
kono
parents:
diff changeset
60 {
kono
parents:
diff changeset
61 /* Could we produce a SIGTRAP signal here to drop to gdb
kono
parents:
diff changeset
62 console, or similar? In any case, the execution of the
kono
parents:
diff changeset
63 kernel should halt.
kono
parents:
diff changeset
64 */
kono
parents:
diff changeset
65 return;
kono
parents:
diff changeset
66 }
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 uint32_t
kono
parents:
diff changeset
69 __hsail_groupbaseptr (PHSAWorkItem *wi)
kono
parents:
diff changeset
70 {
kono
parents:
diff changeset
71 return (uint32_t) (uintptr_t) (wi->wg->group_base_ptr
kono
parents:
diff changeset
72 - wi->launch_data->group_segment_start_addr);
kono
parents:
diff changeset
73 }
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 uint64_t
kono
parents:
diff changeset
76 __hsail_kernargbaseptr_u64 (PHSAWorkItem *wi)
kono
parents:
diff changeset
77 {
kono
parents:
diff changeset
78 /* For now assume only a single kernarg allocation at a time.
kono
parents:
diff changeset
79 Proper kernarg memory management to do. */
kono
parents:
diff changeset
80 return (uint64_t) (uintptr_t) wi->launch_data->kernarg_addr;
kono
parents:
diff changeset
81 }
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 uint32_t
kono
parents:
diff changeset
84 __hsail_kernargbaseptr_u32 (PHSAWorkItem *wi)
kono
parents:
diff changeset
85 {
kono
parents:
diff changeset
86 /* For now assume only a single kernarg allocation at a time.
kono
parents:
diff changeset
87 Proper kernarg memory management to do. */
kono
parents:
diff changeset
88 return 0;
kono
parents:
diff changeset
89 }