]> git.ipfire.org Git - thirdparty/gcc.git/blob - libcilkrts/runtime/metacall_impl.c
[Patch AArch64] Fixup floating point division with -march=armv8-a+nosimd
[thirdparty/gcc.git] / libcilkrts / runtime / metacall_impl.c
1 /* metacall_impl.c -*-C-*-
2 *
3 *************************************************************************
4 *
5 * Copyright (C) 2009-2016, Intel Corporation
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
29 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
32 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 *
35 * *********************************************************************
36 *
37 * PLEASE NOTE: This file is a downstream copy of a file mainitained in
38 * a repository at cilkplus.org. Changes made to this file that are not
39 * submitted through the contribution process detailed at
40 * http://www.cilkplus.org/submit-cilk-contribution will be lost the next
41 * time that a new version is released. Changes only submitted to the
42 * GNU compiler collection or posted to the git repository at
43 * https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
44 * not tracked.
45 *
46 * We welcome your contributions to this open source project. Thank you
47 * for your assistance in helping us improve Cilk Plus.
48 **************************************************************************/
49
50 #include "metacall_impl.h"
51
52 NOINLINE
53 CILK_API_VOID
54 __cilkrts_metacall(unsigned int tool, unsigned int code, void *data)
55 {
56 #ifdef ENABLE_NOTIFY_ZC_INTRINSIC
57 // The metacall type, code and data are packed together into a single
58 // struct which will be interpreted by the tool. This function is the
59 // one and only use of a "cilkscreen_metacall" annotation
60 metacall_data_t d = { tool, code, data };
61
62 // Note that Inspector uses probe mode, and is implementing the metacall
63 // interface to force the runtime to run with a single worker. So
64 // __cilkrts_metacall must use __notify_intrinsic instead of
65 // __notify_zc_intrinsic
66 __notify_intrinsic("cilkscreen_metacall", &d);
67 #endif // ENABLE_NOTIFY_ZC_INTRINSIC
68 }
69
70 int __cilkrts_running_under_sequential_ptool(void)
71 {
72 static int running_under_sequential_ptool = -1;
73 volatile char c = ~0;
74
75 // If we haven't been called before, see if we're running under Cilkscreen
76 // or Cilkview
77 if (-1 == running_under_sequential_ptool)
78 {
79 // metacall #2 writes 0 in C if we are running under
80 // a p-tools that requires serial execution, and is a
81 // no-op otherwise
82 //
83 // Note that removing the volatile is required to prevent the compiler
84 // from assuming that the value has not changed
85 __cilkrts_metacall(METACALL_TOOL_SYSTEM,
86 HYPER_ZERO_IF_SEQUENTIAL_PTOOL, (void *)&c);
87
88 running_under_sequential_ptool = (0 == c);
89 }
90
91 return running_under_sequential_ptool;
92 }
93
94 /*
95 * __cilkrts_cilkscreen_establish_c_stack
96 *
97 * Notify Cilkscreen of the extent of the stack
98 */
99
100 void __cilkrts_cilkscreen_establish_c_stack(char *begin, char *end)
101 {
102 char *limits[2] = {begin, end};
103
104 __cilkrts_metacall(METACALL_TOOL_SYSTEM, HYPER_ESTABLISH_C_STACK, limits);
105 }
106
107 #ifdef WORKSPAN // Workspan stuff - remove when we're sure what we can drop
108
109 void __cilkview_workspan_start(void) {
110 __cilkrts_metacall(HYPER_WORKSPAN_START, 0);
111 }
112
113 void __cilkview_workspan_stop(void) {
114 __cilkrts_metacall(HYPER_WORKSPAN_STOP, 0);
115 }
116
117 void __cilkview_workspan_dump(const char *str) {
118 __cilkrts_metacall(HYPER_WORKSPAN_DUMP, (void*)str);
119 }
120
121
122 void __cilkview_workspan_reset(void) {
123 __cilkrts_metacall(HYPER_WORKSPAN_RESET, 0);
124 }
125
126
127 void __cilkview_use_default_grain(void) {
128 __cilkrts_metacall(HYPER_USE_DEFAULT_GRAIN, 0);
129 }
130
131 void __cilkview_get_workspan_data(unsigned long long *values, int size)
132 {
133 void *data[2];
134
135 /* reset counters to zero in case we are not running under
136 a p-tool */
137
138 values[0] = 0;
139
140 data[0] = (void*) values;
141 data[1] = (void*) &size;
142 __cilkrts_metacall(HYPER_WORKSPAN_QUERY, &data);
143 }
144
145 void __cilkview_workspan_connected (int *flag) {
146 *flag = 0;
147 __cilkrts_metacall(HYPER_WORKSPAN_CONNECTED, (void *)flag);
148 }
149
150 void __cilkview_workspan_suspend() {
151 __cilkrts_metacall(HYPER_WORKSPAN_SUSPEND, 0);
152 }
153
154 void __cilkview_workspan_resume() {
155 __cilkrts_metacall(HYPER_WORKSPAN_RESUME, 0);
156 }
157
158 /* depreciated interfaces */
159 void __cilkometer_workspan_start(void) {
160 __cilkrts_metacall(HYPER_WORKSPAN_START, 0);
161 }
162
163 void __cilkometer_workspan_stop(void) {
164 __cilkrts_metacall(HYPER_WORKSPAN_STOP, 0);
165 }
166
167 void __cilkometer_workspan_dump(const char *str) {
168 __cilkrts_metacall(HYPER_WORKSPAN_DUMP, (void*)str);
169 }
170
171
172 void __cilkometer_workspan_reset(void) {
173 __cilkrts_metacall(HYPER_WORKSPAN_RESET, 0);
174 }
175
176 #endif // WORKSPAN
177
178 /* End metacall_impl.c */