Hi Jakub! OpenACC 2.6 adds a new clause to the "host_data" construct: 2.8.3. "if_present clause". Gergő (in CC) is working on that.
When an 'if_present' clause appears on the directive, the compiler will only change the address of any variable or array which appears in _var-list_ that is present on the current device. So, basically: --- a/libgomp/target.c +++ b/libgomp/target.c @@ -1130,13 +1130,17 @@ gomp_map_vars_async (struct gomp_device_descr *devicep, else if ((kind & typemask) == GOMP_MAP_USE_DEVICE_PTR) { cur_node.host_start = (uintptr_t) hostaddrs[i]; cur_node.host_end = cur_node.host_start; splay_tree_key n = gomp_map_lookup (mem_map, &cur_node); if (n == NULL) { + if ([...]) + /* No error, continue using the host address. */ + continue; gomp_mutex_unlock (&devicep->lock); gomp_fatal ("use_device_ptr pointer wasn't mapped"); } Note that this clause applies to *all* "use_device" ("GOMP_MAP_USE_DEVICE_PTR") clauses present on the "host_data" construct, so it's just a single bit flag for the construct. Do you suggest we yet add a new mapping kind "GOMP_MAP_USE_DEVICE_PTR_IF_PRESENT" for that? And, any preference about the specific value to use? Gergő proposed: --- a/include/gomp-constants.h +++ b/include/gomp-constants.h @@ -80,6 +80,10 @@ enum gomp_map_kind GOMP_MAP_DEVICE_RESIDENT = (GOMP_MAP_FLAG_SPECIAL_1 | 1), /* OpenACC link. */ GOMP_MAP_LINK = (GOMP_MAP_FLAG_SPECIAL_1 | 2), + /* Like GOMP_MAP_USE_DEVICE_PTR below, translate a host to a device + address. If translation fails because the target is not mapped, + continue using the host address. */ + GOMP_MAP_USE_DEVICE_PTR_IF_PRESENT = (GOMP_MAP_FLAG_SPECIAL_1 | 3), /* Allocate. */ GOMP_MAP_FIRSTPRIVATE = (GOMP_MAP_FLAG_SPECIAL | 0), /* Similarly, but store the value in the pointer rather than Or, I had the idea that we could avoid that, instead continue using "GOMP_MAP_USE_DEVICE_PTR", and transmit the "if_present" flag through the "int device" argument of "GOACC_data_start" (making sure that old executables continue to function as before). For OpenACC, that argument is only ever set to "GOMP_DEVICE_ICV" or "GOMP_DEVICE_HOST_FALLBACK" (for "if" clause evaluating to "false"), so has some bits to spare for that. However, I've not been able to convince myself that this solution would be any much prettier than adding a new mapping kind... ;-) Grüße Thomas