commit bbf990a35ab5a7b5100b03c5c5aca11ef0729e7b
Author: Julian Brown <julian@codesourcery.com>
Date: Fri Oct 18 11:47:37 2019 -0700
Remove vars before TLS data during OpenACC shutdown
libgomp/
* oacc-init.c (acc_shutdown_1): Remove variable mappings before TLS
data during OpenACC shutdown.
@@ -334,6 +334,20 @@ acc_shutdown_1 (acc_device_t d)
/* Free target-specific TLS data and close all devices. */
for (walk = goacc_threads; walk != NULL; walk = walk->next)
{
+ if (walk->dev)
+ {
+ /* Free the splay tree before the TLS data below: the nvptx plugin
+ uses the lack of TLS data as an indicator that device memory is
+ being freed from (CUDA) callback context. */
+ while (walk->dev->mem_map.root)
+ {
+ splay_tree_key k = &walk->dev->mem_map.root->key;
+ if (k->virtual_refcount == VREFCOUNT_LINK_KEY)
+ k->u.link_key = NULL;
+ gomp_remove_var (walk->dev, k);
+ }
+ }
+
if (walk->target_tls)
base_dev->openacc.destroy_thread_data_func (walk->target_tls);
@@ -354,19 +368,8 @@ acc_shutdown_1 (acc_device_t d)
gomp_fatal ("shutdown during host fallback");
}
- if (walk->dev)
- {
- while (walk->dev->mem_map.root)
- {
- splay_tree_key k = &walk->dev->mem_map.root->key;
- if (k->virtual_refcount == VREFCOUNT_LINK_KEY)
- k->u.link_key = NULL;
- gomp_remove_var (walk->dev, k);
- }
-
- walk->dev = NULL;
- walk->base_dev = NULL;
- }
+ walk->dev = NULL;
+ walk->base_dev = NULL;
}
gomp_mutex_unlock (&goacc_thread_lock);