1 /* Copyright (C) 2013-2020 Free Software Foundation, Inc.
3 Contributed by Mentor Embedded.
5 This file is part of the GNU Offloading and Multi Processing Library
8 Libgomp is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
27 /* This file handles OpenACC constructs. */
31 #include "gomp-constants.h"
33 #ifdef HAVE_INTTYPES_H
34 # include <inttypes.h> /* For PRIu64. */
41 /* In the ABI, the GOACC_FLAGs are encoded as an inverted bitmask, so that we
42 continue to support the following two legacy values. */
43 _Static_assert (GOACC_FLAGS_UNMARSHAL (GOMP_DEVICE_ICV
) == 0,
44 "legacy GOMP_DEVICE_ICV broken");
45 _Static_assert (GOACC_FLAGS_UNMARSHAL (GOMP_DEVICE_HOST_FALLBACK
)
46 == GOACC_FLAG_HOST_FALLBACK
,
47 "legacy GOMP_DEVICE_HOST_FALLBACK broken");
50 /* Handle the mapping pair that are presented when a
51 deviceptr clause is used with Fortran. */
54 handle_ftn_pointers (size_t mapnum
, void **hostaddrs
, size_t *sizes
,
55 unsigned short *kinds
)
59 for (i
= 0; i
< mapnum
; i
++)
61 unsigned short kind1
= kinds
[i
] & 0xff;
63 /* Handle Fortran deviceptr clause. */
64 if (kind1
== GOMP_MAP_FORCE_DEVICEPTR
)
68 if (i
< (signed)mapnum
- 1)
69 kind2
= kinds
[i
+ 1] & 0xff;
73 if (sizes
[i
] == sizeof (void *))
76 /* At this point, we're dealing with a Fortran deviceptr.
77 If the next element is not what we're expecting, then
78 this is an instance of where the deviceptr variable was
79 not used within the region and the pointer was removed
81 if (kind2
== GOMP_MAP_POINTER
83 && hostaddrs
[i
] == *(void **)hostaddrs
[i
+ 1])
85 kinds
[i
+1] = kinds
[i
];
86 sizes
[i
+1] = sizeof (void *);
89 /* Invalidate the entry. */
96 /* Launch a possibly offloaded function with FLAGS. FN is the host fn
97 address. MAPNUM, HOSTADDRS, SIZES & KINDS describe the memory
98 blocks to be copied to/from the device. Varadic arguments are
99 keyed optional parameters terminated with a zero. */
102 GOACC_parallel_keyed (int flags_m
, void (*fn
) (void *),
103 size_t mapnum
, void **hostaddrs
, size_t *sizes
,
104 unsigned short *kinds
, ...)
106 int flags
= GOACC_FLAGS_UNMARSHAL (flags_m
);
109 struct goacc_thread
*thr
;
110 struct gomp_device_descr
*acc_dev
;
111 struct target_mem_desc
*tgt
;
114 struct splay_tree_key_s k
;
115 splay_tree_key tgt_fn_key
;
117 int async
= GOMP_ASYNC_SYNC
;
118 unsigned dims
[GOMP_DIM_MAX
];
121 #ifdef HAVE_INTTYPES_H
122 gomp_debug (0, "%s: mapnum=%"PRIu64
", hostaddrs=%p, size=%p, kinds=%p\n",
123 __FUNCTION__
, (uint64_t) mapnum
, hostaddrs
, sizes
, kinds
);
125 gomp_debug (0, "%s: mapnum=%lu, hostaddrs=%p, sizes=%p, kinds=%p\n",
126 __FUNCTION__
, (unsigned long) mapnum
, hostaddrs
, sizes
, kinds
);
128 goacc_lazy_initialize ();
130 thr
= goacc_thread ();
133 bool profiling_p
= GOACC_PROFILING_DISPATCH_P (true);
135 acc_prof_info prof_info
;
138 thr
->prof_info
= &prof_info
;
140 prof_info
.event_type
= acc_ev_compute_construct_start
;
141 prof_info
.valid_bytes
= _ACC_PROF_INFO_VALID_BYTES
;
142 prof_info
.version
= _ACC_PROF_INFO_VERSION
;
143 prof_info
.device_type
= acc_device_type (acc_dev
->type
);
144 prof_info
.device_number
= acc_dev
->target_id
;
145 prof_info
.thread_id
= -1;
146 prof_info
.async
= async
;
147 prof_info
.async_queue
= prof_info
.async
;
148 prof_info
.src_file
= NULL
;
149 prof_info
.func_name
= NULL
;
150 prof_info
.line_no
= -1;
151 prof_info
.end_line_no
= -1;
152 prof_info
.func_line_no
= -1;
153 prof_info
.func_end_line_no
= -1;
155 acc_event_info compute_construct_event_info
;
158 compute_construct_event_info
.other_event
.event_type
159 = prof_info
.event_type
;
160 compute_construct_event_info
.other_event
.valid_bytes
161 = _ACC_OTHER_EVENT_INFO_VALID_BYTES
;
162 compute_construct_event_info
.other_event
.parent_construct
163 = acc_construct_parallel
;
164 compute_construct_event_info
.other_event
.implicit
= 0;
165 compute_construct_event_info
.other_event
.tool_info
= NULL
;
167 acc_api_info api_info
;
170 thr
->api_info
= &api_info
;
172 api_info
.device_api
= acc_device_api_none
;
173 api_info
.valid_bytes
= _ACC_API_INFO_VALID_BYTES
;
174 api_info
.device_type
= prof_info
.device_type
;
175 api_info
.vendor
= -1;
176 api_info
.device_handle
= NULL
;
177 api_info
.context_handle
= NULL
;
178 api_info
.async_handle
= NULL
;
182 goacc_profiling_dispatch (&prof_info
, &compute_construct_event_info
,
185 handle_ftn_pointers (mapnum
, hostaddrs
, sizes
, kinds
);
187 /* Host fallback if "if" clause is false or if the current device is set to
189 if (flags
& GOACC_FLAG_HOST_FALLBACK
)
191 prof_info
.device_type
= acc_device_host
;
192 api_info
.device_type
= prof_info
.device_type
;
193 goacc_save_and_set_bind (acc_device_host
);
195 goacc_restore_bind ();
198 else if (acc_device_type (acc_dev
->type
) == acc_device_host
)
204 /* Default: let the runtime choose. */
205 for (i
= 0; i
!= GOMP_DIM_MAX
; i
++)
208 va_start (ap
, kinds
);
209 /* TODO: This will need amending when device_type is implemented. */
210 while ((tag
= va_arg (ap
, unsigned)) != 0)
212 if (GOMP_LAUNCH_DEVICE (tag
))
213 gomp_fatal ("device_type '%d' offload parameters, libgomp is too old",
214 GOMP_LAUNCH_DEVICE (tag
));
216 switch (GOMP_LAUNCH_CODE (tag
))
218 case GOMP_LAUNCH_DIM
:
220 unsigned mask
= GOMP_LAUNCH_OP (tag
);
222 for (i
= 0; i
!= GOMP_DIM_MAX
; i
++)
223 if (mask
& GOMP_DIM_MASK (i
))
224 dims
[i
] = va_arg (ap
, unsigned);
228 case GOMP_LAUNCH_ASYNC
:
230 /* Small constant values are encoded in the operand. */
231 async
= GOMP_LAUNCH_OP (tag
);
233 if (async
== GOMP_LAUNCH_OP_MAX
)
234 async
= va_arg (ap
, unsigned);
238 prof_info
.async
= async
;
239 prof_info
.async_queue
= prof_info
.async
;
245 case GOMP_LAUNCH_WAIT
:
247 unsigned num_waits
= GOMP_LAUNCH_OP (tag
);
248 goacc_wait (async
, num_waits
, &ap
);
253 gomp_fatal ("unrecognized offload code '%d',"
254 " libgomp is too old", GOMP_LAUNCH_CODE (tag
));
259 if (!(acc_dev
->capabilities
& GOMP_OFFLOAD_CAP_NATIVE_EXEC
))
261 k
.host_start
= (uintptr_t) fn
;
262 k
.host_end
= k
.host_start
+ 1;
263 gomp_mutex_lock (&acc_dev
->lock
);
264 tgt_fn_key
= splay_tree_lookup (&acc_dev
->mem_map
, &k
);
265 gomp_mutex_unlock (&acc_dev
->lock
);
267 if (tgt_fn_key
== NULL
)
268 gomp_fatal ("target function wasn't mapped");
270 tgt_fn
= (void (*)) tgt_fn_key
->tgt_offset
;
273 tgt_fn
= (void (*)) fn
;
275 acc_event_info enter_exit_data_event_info
;
278 prof_info
.event_type
= acc_ev_enter_data_start
;
279 enter_exit_data_event_info
.other_event
.event_type
280 = prof_info
.event_type
;
281 enter_exit_data_event_info
.other_event
.valid_bytes
282 = _ACC_OTHER_EVENT_INFO_VALID_BYTES
;
283 enter_exit_data_event_info
.other_event
.parent_construct
284 = compute_construct_event_info
.other_event
.parent_construct
;
285 enter_exit_data_event_info
.other_event
.implicit
= 1;
286 enter_exit_data_event_info
.other_event
.tool_info
= NULL
;
287 goacc_profiling_dispatch (&prof_info
, &enter_exit_data_event_info
,
291 goacc_aq aq
= get_goacc_asyncqueue (async
);
293 tgt
= gomp_map_vars_async (acc_dev
, aq
, mapnum
, hostaddrs
, NULL
, sizes
, kinds
,
294 true, GOMP_MAP_VARS_OPENACC
);
297 prof_info
.event_type
= acc_ev_enter_data_end
;
298 enter_exit_data_event_info
.other_event
.event_type
299 = prof_info
.event_type
;
300 goacc_profiling_dispatch (&prof_info
, &enter_exit_data_event_info
,
304 devaddrs
= gomp_alloca (sizeof (void *) * mapnum
);
305 for (i
= 0; i
< mapnum
; i
++)
306 devaddrs
[i
] = (void *) gomp_map_val (tgt
, hostaddrs
, i
);
309 acc_dev
->openacc
.exec_func (tgt_fn
, mapnum
, hostaddrs
, devaddrs
, dims
,
312 acc_dev
->openacc
.async
.exec_func (tgt_fn
, mapnum
, hostaddrs
, devaddrs
,
317 prof_info
.event_type
= acc_ev_exit_data_start
;
318 enter_exit_data_event_info
.other_event
.event_type
= prof_info
.event_type
;
319 enter_exit_data_event_info
.other_event
.tool_info
= NULL
;
320 goacc_profiling_dispatch (&prof_info
, &enter_exit_data_event_info
,
324 /* If running synchronously, unmap immediately. */
326 gomp_unmap_vars (tgt
, true);
328 gomp_unmap_vars_async (tgt
, true, aq
);
332 prof_info
.event_type
= acc_ev_exit_data_end
;
333 enter_exit_data_event_info
.other_event
.event_type
= prof_info
.event_type
;
334 goacc_profiling_dispatch (&prof_info
, &enter_exit_data_event_info
,
341 prof_info
.event_type
= acc_ev_compute_construct_end
;
342 compute_construct_event_info
.other_event
.event_type
343 = prof_info
.event_type
;
344 goacc_profiling_dispatch (&prof_info
, &compute_construct_event_info
,
347 thr
->prof_info
= NULL
;
348 thr
->api_info
= NULL
;
352 /* Legacy entry point (GCC 5). Only provide host fallback execution. */
355 GOACC_parallel (int flags_m
, void (*fn
) (void *),
356 size_t mapnum
, void **hostaddrs
, size_t *sizes
,
357 unsigned short *kinds
,
358 int num_gangs
, int num_workers
, int vector_length
,
359 int async
, int num_waits
, ...)
361 goacc_save_and_set_bind (acc_device_host
);
363 goacc_restore_bind ();
367 GOACC_data_start (int flags_m
, size_t mapnum
,
368 void **hostaddrs
, size_t *sizes
, unsigned short *kinds
)
370 int flags
= GOACC_FLAGS_UNMARSHAL (flags_m
);
372 struct target_mem_desc
*tgt
;
374 #ifdef HAVE_INTTYPES_H
375 gomp_debug (0, "%s: mapnum=%"PRIu64
", hostaddrs=%p, size=%p, kinds=%p\n",
376 __FUNCTION__
, (uint64_t) mapnum
, hostaddrs
, sizes
, kinds
);
378 gomp_debug (0, "%s: mapnum=%lu, hostaddrs=%p, sizes=%p, kinds=%p\n",
379 __FUNCTION__
, (unsigned long) mapnum
, hostaddrs
, sizes
, kinds
);
382 goacc_lazy_initialize ();
384 struct goacc_thread
*thr
= goacc_thread ();
385 struct gomp_device_descr
*acc_dev
= thr
->dev
;
387 bool profiling_p
= GOACC_PROFILING_DISPATCH_P (true);
389 acc_prof_info prof_info
;
392 thr
->prof_info
= &prof_info
;
394 prof_info
.event_type
= acc_ev_enter_data_start
;
395 prof_info
.valid_bytes
= _ACC_PROF_INFO_VALID_BYTES
;
396 prof_info
.version
= _ACC_PROF_INFO_VERSION
;
397 prof_info
.device_type
= acc_device_type (acc_dev
->type
);
398 prof_info
.device_number
= acc_dev
->target_id
;
399 prof_info
.thread_id
= -1;
400 prof_info
.async
= acc_async_sync
; /* Always synchronous. */
401 prof_info
.async_queue
= prof_info
.async
;
402 prof_info
.src_file
= NULL
;
403 prof_info
.func_name
= NULL
;
404 prof_info
.line_no
= -1;
405 prof_info
.end_line_no
= -1;
406 prof_info
.func_line_no
= -1;
407 prof_info
.func_end_line_no
= -1;
409 acc_event_info enter_data_event_info
;
412 enter_data_event_info
.other_event
.event_type
413 = prof_info
.event_type
;
414 enter_data_event_info
.other_event
.valid_bytes
415 = _ACC_OTHER_EVENT_INFO_VALID_BYTES
;
416 enter_data_event_info
.other_event
.parent_construct
= acc_construct_data
;
417 for (int i
= 0; i
< mapnum
; ++i
)
418 if ((kinds
[i
] & 0xff) == GOMP_MAP_USE_DEVICE_PTR
)
420 /* If there is one such data mapping kind, then this is actually an
421 OpenACC 'host_data' construct. (GCC maps the OpenACC
422 'host_data' construct to the OpenACC 'data' construct.) Apart
423 from artificial test cases (such as an OpenACC 'host_data'
424 construct's (implicit) device initialization when there hasn't
425 been any device data be set up before...), there can't really
426 any meaningful events be generated from OpenACC 'host_data'
427 constructs, though. */
428 enter_data_event_info
.other_event
.parent_construct
429 = acc_construct_host_data
;
432 enter_data_event_info
.other_event
.implicit
= 0;
433 enter_data_event_info
.other_event
.tool_info
= NULL
;
435 acc_api_info api_info
;
438 thr
->api_info
= &api_info
;
440 api_info
.device_api
= acc_device_api_none
;
441 api_info
.valid_bytes
= _ACC_API_INFO_VALID_BYTES
;
442 api_info
.device_type
= prof_info
.device_type
;
443 api_info
.vendor
= -1;
444 api_info
.device_handle
= NULL
;
445 api_info
.context_handle
= NULL
;
446 api_info
.async_handle
= NULL
;
450 goacc_profiling_dispatch (&prof_info
, &enter_data_event_info
, &api_info
);
452 /* Host fallback or 'do nothing'. */
453 if ((acc_dev
->capabilities
& GOMP_OFFLOAD_CAP_SHARED_MEM
)
454 || (flags
& GOACC_FLAG_HOST_FALLBACK
))
456 prof_info
.device_type
= acc_device_host
;
457 api_info
.device_type
= prof_info
.device_type
;
458 tgt
= gomp_map_vars (NULL
, 0, NULL
, NULL
, NULL
, NULL
, true,
459 GOMP_MAP_VARS_OPENACC
);
460 tgt
->prev
= thr
->mapped_data
;
461 thr
->mapped_data
= tgt
;
466 gomp_debug (0, " %s: prepare mappings\n", __FUNCTION__
);
467 tgt
= gomp_map_vars (acc_dev
, mapnum
, hostaddrs
, NULL
, sizes
, kinds
, true,
468 GOMP_MAP_VARS_OPENACC
);
469 gomp_debug (0, " %s: mappings prepared\n", __FUNCTION__
);
470 tgt
->prev
= thr
->mapped_data
;
471 thr
->mapped_data
= tgt
;
476 prof_info
.event_type
= acc_ev_enter_data_end
;
477 enter_data_event_info
.other_event
.event_type
= prof_info
.event_type
;
478 goacc_profiling_dispatch (&prof_info
, &enter_data_event_info
, &api_info
);
480 thr
->prof_info
= NULL
;
481 thr
->api_info
= NULL
;
486 GOACC_data_end (void)
488 struct goacc_thread
*thr
= goacc_thread ();
489 struct gomp_device_descr
*acc_dev
= thr
->dev
;
490 struct target_mem_desc
*tgt
= thr
->mapped_data
;
492 bool profiling_p
= GOACC_PROFILING_DISPATCH_P (true);
494 acc_prof_info prof_info
;
497 thr
->prof_info
= &prof_info
;
499 prof_info
.event_type
= acc_ev_exit_data_start
;
500 prof_info
.valid_bytes
= _ACC_PROF_INFO_VALID_BYTES
;
501 prof_info
.version
= _ACC_PROF_INFO_VERSION
;
502 prof_info
.device_type
= acc_device_type (acc_dev
->type
);
503 prof_info
.device_number
= acc_dev
->target_id
;
504 prof_info
.thread_id
= -1;
505 prof_info
.async
= acc_async_sync
; /* Always synchronous. */
506 prof_info
.async_queue
= prof_info
.async
;
507 prof_info
.src_file
= NULL
;
508 prof_info
.func_name
= NULL
;
509 prof_info
.line_no
= -1;
510 prof_info
.end_line_no
= -1;
511 prof_info
.func_line_no
= -1;
512 prof_info
.func_end_line_no
= -1;
514 acc_event_info exit_data_event_info
;
517 exit_data_event_info
.other_event
.event_type
518 = prof_info
.event_type
;
519 exit_data_event_info
.other_event
.valid_bytes
520 = _ACC_OTHER_EVENT_INFO_VALID_BYTES
;
521 exit_data_event_info
.other_event
.parent_construct
= acc_construct_data
;
522 exit_data_event_info
.other_event
.implicit
= 0;
523 exit_data_event_info
.other_event
.tool_info
= NULL
;
525 acc_api_info api_info
;
528 thr
->api_info
= &api_info
;
530 api_info
.device_api
= acc_device_api_none
;
531 api_info
.valid_bytes
= _ACC_API_INFO_VALID_BYTES
;
532 api_info
.device_type
= prof_info
.device_type
;
533 api_info
.vendor
= -1;
534 api_info
.device_handle
= NULL
;
535 api_info
.context_handle
= NULL
;
536 api_info
.async_handle
= NULL
;
540 goacc_profiling_dispatch (&prof_info
, &exit_data_event_info
, &api_info
);
542 gomp_debug (0, " %s: restore mappings\n", __FUNCTION__
);
543 thr
->mapped_data
= tgt
->prev
;
544 gomp_unmap_vars (tgt
, true);
545 gomp_debug (0, " %s: mappings restored\n", __FUNCTION__
);
549 prof_info
.event_type
= acc_ev_exit_data_end
;
550 exit_data_event_info
.other_event
.event_type
= prof_info
.event_type
;
551 goacc_profiling_dispatch (&prof_info
, &exit_data_event_info
, &api_info
);
553 thr
->prof_info
= NULL
;
554 thr
->api_info
= NULL
;
559 GOACC_update (int flags_m
, size_t mapnum
,
560 void **hostaddrs
, size_t *sizes
, unsigned short *kinds
,
561 int async
, int num_waits
, ...)
563 int flags
= GOACC_FLAGS_UNMARSHAL (flags_m
);
567 goacc_lazy_initialize ();
569 struct goacc_thread
*thr
= goacc_thread ();
570 struct gomp_device_descr
*acc_dev
= thr
->dev
;
572 bool profiling_p
= GOACC_PROFILING_DISPATCH_P (true);
574 acc_prof_info prof_info
;
577 thr
->prof_info
= &prof_info
;
579 prof_info
.event_type
= acc_ev_update_start
;
580 prof_info
.valid_bytes
= _ACC_PROF_INFO_VALID_BYTES
;
581 prof_info
.version
= _ACC_PROF_INFO_VERSION
;
582 prof_info
.device_type
= acc_device_type (acc_dev
->type
);
583 prof_info
.device_number
= acc_dev
->target_id
;
584 prof_info
.thread_id
= -1;
585 prof_info
.async
= async
;
586 prof_info
.async_queue
= prof_info
.async
;
587 prof_info
.src_file
= NULL
;
588 prof_info
.func_name
= NULL
;
589 prof_info
.line_no
= -1;
590 prof_info
.end_line_no
= -1;
591 prof_info
.func_line_no
= -1;
592 prof_info
.func_end_line_no
= -1;
594 acc_event_info update_event_info
;
597 update_event_info
.other_event
.event_type
598 = prof_info
.event_type
;
599 update_event_info
.other_event
.valid_bytes
600 = _ACC_OTHER_EVENT_INFO_VALID_BYTES
;
601 update_event_info
.other_event
.parent_construct
= acc_construct_update
;
602 update_event_info
.other_event
.implicit
= 0;
603 update_event_info
.other_event
.tool_info
= NULL
;
605 acc_api_info api_info
;
608 thr
->api_info
= &api_info
;
610 api_info
.device_api
= acc_device_api_none
;
611 api_info
.valid_bytes
= _ACC_API_INFO_VALID_BYTES
;
612 api_info
.device_type
= prof_info
.device_type
;
613 api_info
.vendor
= -1;
614 api_info
.device_handle
= NULL
;
615 api_info
.context_handle
= NULL
;
616 api_info
.async_handle
= NULL
;
620 goacc_profiling_dispatch (&prof_info
, &update_event_info
, &api_info
);
622 if ((acc_dev
->capabilities
& GOMP_OFFLOAD_CAP_SHARED_MEM
)
623 || (flags
& GOACC_FLAG_HOST_FALLBACK
))
625 prof_info
.device_type
= acc_device_host
;
626 api_info
.device_type
= prof_info
.device_type
;
635 va_start (ap
, num_waits
);
636 goacc_wait (async
, num_waits
, &ap
);
640 bool update_device
= false;
641 for (i
= 0; i
< mapnum
; ++i
)
643 unsigned char kind
= kinds
[i
] & 0xff;
647 case GOMP_MAP_POINTER
:
648 case GOMP_MAP_TO_PSET
:
651 case GOMP_MAP_ALWAYS_POINTER
:
654 /* Save the contents of the host pointer. */
655 void *dptr
= acc_deviceptr (hostaddrs
[i
-1]);
656 uintptr_t t
= *(uintptr_t *) hostaddrs
[i
];
658 /* Update the contents of the host pointer to reflect
659 the value of the allocated device memory in the
661 *(uintptr_t *) hostaddrs
[i
] = (uintptr_t)dptr
;
662 /* TODO: verify that we really cannot use acc_update_device_async
664 acc_update_device (hostaddrs
[i
], sizeof (uintptr_t));
666 /* Restore the host pointer. */
667 *(uintptr_t *) hostaddrs
[i
] = t
;
668 update_device
= false;
673 if (!acc_is_present (hostaddrs
[i
], sizes
[i
]))
675 update_device
= false;
679 case GOMP_MAP_FORCE_TO
:
680 update_device
= true;
681 acc_update_device_async (hostaddrs
[i
], sizes
[i
], async
);
685 if (!acc_is_present (hostaddrs
[i
], sizes
[i
]))
687 update_device
= false;
691 case GOMP_MAP_FORCE_FROM
:
692 update_device
= false;
693 acc_update_self_async (hostaddrs
[i
], sizes
[i
], async
);
697 gomp_fatal (">>>> GOACC_update UNHANDLED kind 0x%.2x", kind
);
705 prof_info
.event_type
= acc_ev_update_end
;
706 update_event_info
.other_event
.event_type
= prof_info
.event_type
;
707 goacc_profiling_dispatch (&prof_info
, &update_event_info
, &api_info
);
709 thr
->prof_info
= NULL
;
710 thr
->api_info
= NULL
;
715 /* Legacy entry point (GCC 5). */
718 GOACC_get_num_threads (void)
723 /* Legacy entry point (GCC 5). */
726 GOACC_get_thread_num (void)
732 GOACC_declare (int flags_m
, size_t mapnum
,
733 void **hostaddrs
, size_t *sizes
, unsigned short *kinds
)
737 for (i
= 0; i
< mapnum
; i
++)
739 unsigned char kind
= kinds
[i
] & 0xff;
741 if (kind
== GOMP_MAP_POINTER
|| kind
== GOMP_MAP_TO_PSET
)
746 case GOMP_MAP_FORCE_ALLOC
:
747 case GOMP_MAP_FORCE_FROM
:
748 case GOMP_MAP_FORCE_TO
:
749 case GOMP_MAP_POINTER
:
750 case GOMP_MAP_RELEASE
:
751 case GOMP_MAP_DELETE
:
752 GOACC_enter_exit_data (flags_m
, 1, &hostaddrs
[i
], &sizes
[i
],
753 &kinds
[i
], GOMP_ASYNC_SYNC
, 0);
756 case GOMP_MAP_FORCE_DEVICEPTR
:
760 if (!acc_is_present (hostaddrs
[i
], sizes
[i
]))
761 GOACC_enter_exit_data (flags_m
, 1, &hostaddrs
[i
], &sizes
[i
],
762 &kinds
[i
], GOMP_ASYNC_SYNC
, 0);
766 GOACC_enter_exit_data (flags_m
, 1, &hostaddrs
[i
], &sizes
[i
],
767 &kinds
[i
], GOMP_ASYNC_SYNC
, 0);
772 GOACC_enter_exit_data (flags_m
, 1, &hostaddrs
[i
], &sizes
[i
],
773 &kinds
[i
], GOMP_ASYNC_SYNC
, 0);
776 case GOMP_MAP_FORCE_PRESENT
:
777 if (!acc_is_present (hostaddrs
[i
], sizes
[i
]))
778 gomp_fatal ("[%p,%ld] is not mapped", hostaddrs
[i
],
779 (unsigned long) sizes
[i
]);