Mercurial > hg > CbC > CbC_gcc
comparison libgomp/plugin/plugin-hsa.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 /* Plugin for HSAIL execution. | 1 /* Plugin for HSAIL execution. |
2 | 2 |
3 Copyright (C) 2013-2018 Free Software Foundation, Inc. | 3 Copyright (C) 2013-2020 Free Software Foundation, Inc. |
4 | 4 |
5 Contributed by Martin Jambor <mjambor@suse.cz> and | 5 Contributed by Martin Jambor <mjambor@suse.cz> and |
6 Martin Liska <mliska@suse.cz>. | 6 Martin Liska <mliska@suse.cz>. |
7 | 7 |
8 This file is part of the GNU Offloading and Multi Processing Library | 8 This file is part of the GNU Offloading and Multi Processing Library |
26 a copy of the GCC Runtime Library Exception along with this program; | 26 a copy of the GCC Runtime Library Exception along with this program; |
27 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | 27 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
28 <http://www.gnu.org/licenses/>. */ | 28 <http://www.gnu.org/licenses/>. */ |
29 | 29 |
30 #include "config.h" | 30 #include "config.h" |
31 #include <stdint.h> | |
31 #include <stdio.h> | 32 #include <stdio.h> |
32 #include <stdlib.h> | 33 #include <stdlib.h> |
33 #include <string.h> | 34 #include <string.h> |
34 #include <pthread.h> | 35 #include <pthread.h> |
36 #ifdef HAVE_INTTYPES_H | |
35 #include <inttypes.h> | 37 #include <inttypes.h> |
38 #endif | |
36 #include <stdbool.h> | 39 #include <stdbool.h> |
37 #include <hsa.h> | 40 #include <hsa.h> |
38 #include <plugin/hsa_ext_finalize.h> | 41 #include <plugin/hsa_ext_finalize.h> |
39 #include <dlfcn.h> | 42 #include <dlfcn.h> |
40 #include "libgomp-plugin.h" | 43 #include "libgomp-plugin.h" |
41 #include "gomp-constants.h" | 44 #include "gomp-constants.h" |
42 #include "secure_getenv.h" | 45 #include "secure_getenv.h" |
46 | |
47 #ifdef HAVE_INTTYPES_H | |
48 typedef uint64_t print_uint64_t; | |
49 #else | |
50 #define PRIu64 "lu" | |
51 typedef unsigned long print_uint64_t; | |
52 #endif | |
43 | 53 |
44 /* As an HSA runtime is dlopened, following structure defines function | 54 /* As an HSA runtime is dlopened, following structure defines function |
45 pointers utilized by the HSA plug-in. */ | 55 pointers utilized by the HSA plug-in. */ |
46 | 56 |
47 struct hsa_runtime_fn_info | 57 struct hsa_runtime_fn_info |
277 hsa_warn (const char *str, hsa_status_t status) | 287 hsa_warn (const char *str, hsa_status_t status) |
278 { | 288 { |
279 if (!debug) | 289 if (!debug) |
280 return; | 290 return; |
281 | 291 |
282 const char *hsa_error_msg; | 292 const char *hsa_error_msg = "[unknown]"; |
283 hsa_fns.hsa_status_string_fn (status, &hsa_error_msg); | 293 hsa_fns.hsa_status_string_fn (status, &hsa_error_msg); |
284 | 294 |
285 fprintf (stderr, "HSA warning: %s\nRuntime message: %s", str, hsa_error_msg); | 295 fprintf (stderr, "HSA warning: %s\nRuntime message: %s", str, hsa_error_msg); |
286 } | 296 } |
287 | 297 |
289 and terminate execution of the current process. */ | 299 and terminate execution of the current process. */ |
290 | 300 |
291 static void | 301 static void |
292 hsa_fatal (const char *str, hsa_status_t status) | 302 hsa_fatal (const char *str, hsa_status_t status) |
293 { | 303 { |
294 const char *hsa_error_msg; | 304 const char *hsa_error_msg = "[unknown]"; |
295 hsa_fns.hsa_status_string_fn (status, &hsa_error_msg); | 305 hsa_fns.hsa_status_string_fn (status, &hsa_error_msg); |
296 GOMP_PLUGIN_fatal ("HSA fatal error: %s\nRuntime message: %s", str, | 306 GOMP_PLUGIN_fatal ("HSA fatal error: %s\nRuntime message: %s", str, |
297 hsa_error_msg); | 307 hsa_error_msg); |
298 } | 308 } |
299 | 309 |
301 for propagating error processing to outside of plugin. */ | 311 for propagating error processing to outside of plugin. */ |
302 | 312 |
303 static bool | 313 static bool |
304 hsa_error (const char *str, hsa_status_t status) | 314 hsa_error (const char *str, hsa_status_t status) |
305 { | 315 { |
306 const char *hsa_error_msg; | 316 const char *hsa_error_msg = "[unknown]"; |
307 hsa_fns.hsa_status_string_fn (status, &hsa_error_msg); | 317 hsa_fns.hsa_status_string_fn (status, &hsa_error_msg); |
308 GOMP_PLUGIN_error ("HSA fatal error: %s\nRuntime message: %s", str, | 318 GOMP_PLUGIN_error ("HSA fatal error: %s\nRuntime message: %s", str, |
309 hsa_error_msg); | 319 hsa_error_msg); |
310 return false; | 320 return false; |
311 } | 321 } |
1152 /* Release data structure created for a kernel dispatch in SHADOW argument. */ | 1162 /* Release data structure created for a kernel dispatch in SHADOW argument. */ |
1153 | 1163 |
1154 static void | 1164 static void |
1155 release_kernel_dispatch (struct GOMP_hsa_kernel_dispatch *shadow) | 1165 release_kernel_dispatch (struct GOMP_hsa_kernel_dispatch *shadow) |
1156 { | 1166 { |
1157 HSA_DEBUG ("Released kernel dispatch: %p has value: %lu (%p)\n", shadow, | 1167 HSA_DEBUG ("Released kernel dispatch: %p has value: %" PRIu64 " (%p)\n", |
1158 shadow->debug, (void *) shadow->debug); | 1168 shadow, (print_uint64_t) shadow->debug, |
1169 (void *) (uintptr_t) shadow->debug); | |
1159 | 1170 |
1160 hsa_fns.hsa_memory_free_fn (shadow->kernarg_address); | 1171 hsa_fns.hsa_memory_free_fn (shadow->kernarg_address); |
1161 | 1172 |
1162 hsa_signal_t s; | 1173 hsa_signal_t s; |
1163 s.handle = shadow->signal; | 1174 s.handle = shadow->signal; |
1274 indent_stream (stderr, indent); | 1285 indent_stream (stderr, indent); |
1275 fprintf (stderr, "omp_data_memory: %p\n", dispatch->omp_data_memory); | 1286 fprintf (stderr, "omp_data_memory: %p\n", dispatch->omp_data_memory); |
1276 indent_stream (stderr, indent); | 1287 indent_stream (stderr, indent); |
1277 fprintf (stderr, "kernarg_address: %p\n", dispatch->kernarg_address); | 1288 fprintf (stderr, "kernarg_address: %p\n", dispatch->kernarg_address); |
1278 indent_stream (stderr, indent); | 1289 indent_stream (stderr, indent); |
1279 fprintf (stderr, "object: %lu\n", dispatch->object); | 1290 fprintf (stderr, "object: %" PRIu64 "\n", (print_uint64_t) dispatch->object); |
1280 indent_stream (stderr, indent); | 1291 indent_stream (stderr, indent); |
1281 fprintf (stderr, "signal: %lu\n", dispatch->signal); | 1292 fprintf (stderr, "signal: %" PRIu64 "\n", (print_uint64_t) dispatch->signal); |
1282 indent_stream (stderr, indent); | 1293 indent_stream (stderr, indent); |
1283 fprintf (stderr, "private_segment_size: %u\n", | 1294 fprintf (stderr, "private_segment_size: %u\n", |
1284 dispatch->private_segment_size); | 1295 dispatch->private_segment_size); |
1285 indent_stream (stderr, indent); | 1296 indent_stream (stderr, indent); |
1286 fprintf (stderr, "group_segment_size: %u\n", | 1297 fprintf (stderr, "group_segment_size: %u\n", |
1287 dispatch->group_segment_size); | 1298 dispatch->group_segment_size); |
1288 indent_stream (stderr, indent); | 1299 indent_stream (stderr, indent); |
1289 fprintf (stderr, "children dispatches: %lu\n", | 1300 fprintf (stderr, "children dispatches: %" PRIu64 "\n", |
1290 dispatch->kernel_dispatch_count); | 1301 (print_uint64_t) dispatch->kernel_dispatch_count); |
1291 indent_stream (stderr, indent); | 1302 indent_stream (stderr, indent); |
1292 fprintf (stderr, "omp_num_threads: %u\n", | 1303 fprintf (stderr, "omp_num_threads: %u\n", |
1293 dispatch->omp_num_threads); | 1304 dispatch->omp_num_threads); |
1294 fprintf (stderr, "\n"); | 1305 fprintf (stderr, "\n"); |
1295 | 1306 |
1592 for (unsigned i = 0; i < shadow->kernel_dispatch_count; i++) | 1603 for (unsigned i = 0; i < shadow->kernel_dispatch_count; i++) |
1593 { | 1604 { |
1594 hsa_signal_t child_s; | 1605 hsa_signal_t child_s; |
1595 child_s.handle = shadow->children_dispatches[i]->signal; | 1606 child_s.handle = shadow->children_dispatches[i]->signal; |
1596 | 1607 |
1597 HSA_DEBUG ("Waiting for children completion signal: %lu\n", | 1608 HSA_DEBUG ("Waiting for children completion signal: %" PRIu64 "\n", |
1598 shadow->children_dispatches[i]->signal); | 1609 (print_uint64_t) shadow->children_dispatches[i]->signal); |
1599 hsa_fns.hsa_signal_load_acquire_fn (child_s); | 1610 hsa_fns.hsa_signal_load_acquire_fn (child_s); |
1600 } | 1611 } |
1601 | 1612 |
1602 release_kernel_dispatch (shadow); | 1613 release_kernel_dispatch (shadow); |
1603 | 1614 |