From 0a77c7033ae4ed05a2f7e78600522610a8d82225 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 8 Jun 2021 17:15:19 +0200 Subject: [PATCH] Move 'libgomp/oacc-parallel.c:GOACC_declare' into 'libgomp/oacc-mem.c' This deals with data management, after all. Small fix-up for r230275 (commit 6e232ba4246ca324a663ec5ddf0ba4db5cf3fbad) "[OpenACC] declare directive". libgomp/ * oacc-parallel.c (GOACC_declare): Move... * oacc-mem.c: ... here. * libgomp_g.h: Adjust. --- libgomp/libgomp_g.h | 2 +- libgomp/oacc-mem.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ libgomp/oacc-parallel.c | 57 ------------------------------------------------- 3 files changed, 55 insertions(+), 58 deletions(-) diff --git a/libgomp/libgomp_g.h b/libgomp/libgomp_g.h index 3cbe0a4..b66b697 100644 --- a/libgomp/libgomp_g.h +++ b/libgomp/libgomp_g.h @@ -370,6 +370,7 @@ extern void GOACC_wait (int, int, ...); extern void GOACC_enter_exit_data (int, size_t, void **, size_t *, unsigned short *, int, int, ...); +extern void GOACC_declare (int, size_t, void **, size_t *, unsigned short *); /* oacc-parallel.c */ @@ -384,6 +385,5 @@ extern void GOACC_update (int, size_t, void **, size_t *, unsigned short *, int, int, ...); extern int GOACC_get_num_threads (void); extern int GOACC_get_thread_num (void); -extern void GOACC_declare (int, size_t, void **, size_t *, unsigned short *); #endif /* LIBGOMP_G_H */ diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c index 405574d..056600a 100644 --- a/libgomp/oacc-mem.c +++ b/libgomp/oacc-mem.c @@ -1461,3 +1461,57 @@ GOACC_enter_exit_data (int flags_m, size_t mapnum, void **hostaddrs, thr->api_info = NULL; } } + +void +GOACC_declare (int flags_m, size_t mapnum, + void **hostaddrs, size_t *sizes, unsigned short *kinds) +{ + for (size_t i = 0; i < mapnum; i++) + { + unsigned char kind = kinds[i] & 0xff; + + if (kind == GOMP_MAP_POINTER || kind == GOMP_MAP_TO_PSET) + continue; + + switch (kind) + { + case GOMP_MAP_FORCE_ALLOC: + case GOMP_MAP_FORCE_FROM: + case GOMP_MAP_FORCE_TO: + case GOMP_MAP_RELEASE: + case GOMP_MAP_DELETE: + GOACC_enter_exit_data (flags_m, 1, &hostaddrs[i], &sizes[i], + &kinds[i], GOMP_ASYNC_SYNC, 0); + break; + + case GOMP_MAP_FORCE_DEVICEPTR: + break; + + case GOMP_MAP_ALLOC: + if (!acc_is_present (hostaddrs[i], sizes[i])) + GOACC_enter_exit_data (flags_m, 1, &hostaddrs[i], &sizes[i], + &kinds[i], GOMP_ASYNC_SYNC, 0); + break; + + case GOMP_MAP_TO: + GOACC_enter_exit_data (flags_m, 1, &hostaddrs[i], &sizes[i], + &kinds[i], GOMP_ASYNC_SYNC, 0); + break; + + case GOMP_MAP_FROM: + GOACC_enter_exit_data (flags_m, 1, &hostaddrs[i], &sizes[i], + &kinds[i], GOMP_ASYNC_SYNC, 0); + break; + + case GOMP_MAP_FORCE_PRESENT: + if (!acc_is_present (hostaddrs[i], sizes[i])) + gomp_fatal ("[%p,%ld] is not mapped", hostaddrs[i], + (unsigned long) sizes[i]); + break; + + default: + assert (0); + break; + } + } +} diff --git a/libgomp/oacc-parallel.c b/libgomp/oacc-parallel.c index d05b3d8..939e09f 100644 --- a/libgomp/oacc-parallel.c +++ b/libgomp/oacc-parallel.c @@ -728,60 +728,3 @@ GOACC_get_thread_num (void) { return 0; } - -void -GOACC_declare (int flags_m, size_t mapnum, - void **hostaddrs, size_t *sizes, unsigned short *kinds) -{ - int i; - - for (i = 0; i < mapnum; i++) - { - unsigned char kind = kinds[i] & 0xff; - - if (kind == GOMP_MAP_POINTER || kind == GOMP_MAP_TO_PSET) - continue; - - switch (kind) - { - case GOMP_MAP_FORCE_ALLOC: - case GOMP_MAP_FORCE_FROM: - case GOMP_MAP_FORCE_TO: - case GOMP_MAP_RELEASE: - case GOMP_MAP_DELETE: - GOACC_enter_exit_data (flags_m, 1, &hostaddrs[i], &sizes[i], - &kinds[i], GOMP_ASYNC_SYNC, 0); - break; - - case GOMP_MAP_FORCE_DEVICEPTR: - break; - - case GOMP_MAP_ALLOC: - if (!acc_is_present (hostaddrs[i], sizes[i])) - GOACC_enter_exit_data (flags_m, 1, &hostaddrs[i], &sizes[i], - &kinds[i], GOMP_ASYNC_SYNC, 0); - break; - - case GOMP_MAP_TO: - GOACC_enter_exit_data (flags_m, 1, &hostaddrs[i], &sizes[i], - &kinds[i], GOMP_ASYNC_SYNC, 0); - - break; - - case GOMP_MAP_FROM: - GOACC_enter_exit_data (flags_m, 1, &hostaddrs[i], &sizes[i], - &kinds[i], GOMP_ASYNC_SYNC, 0); - break; - - case GOMP_MAP_FORCE_PRESENT: - if (!acc_is_present (hostaddrs[i], sizes[i])) - gomp_fatal ("[%p,%ld] is not mapped", hostaddrs[i], - (unsigned long) sizes[i]); - break; - - default: - assert (0); - break; - } - } -} -- 2.7.4