Libgomp magic offset value self-documentation
2019-10-02 Julian Brown <julian@codesourcery.com> Cesar Philippidis <cesar@codesourcery.com> libgomp/ * libgomp.h (OFFSET_INLINED, OFFSET_POINTER, OFFSET_STRUCT): Define. * target.c (FIELD_TGT_EMPTY): Define. (gomp_map_val): Use OFFSET_* macros instead of magic constants. Write as switch instead of list of ifs. (gomp_map_vars_internal): Use OFFSET_* and FIELD_TGT_EMPTY macros. Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com> From-SVN: r276519
This commit is contained in:
parent
5dbe01a1ff
commit
6c7e076b74
@ -1,3 +1,12 @@
|
|||||||
|
2019-10-02 Julian Brown <julian@codesourcery.com>
|
||||||
|
Cesar Philippidis <cesar@codesourcery.com>
|
||||||
|
|
||||||
|
* libgomp.h (OFFSET_INLINED, OFFSET_POINTER, OFFSET_STRUCT): Define.
|
||||||
|
* target.c (FIELD_TGT_EMPTY): Define.
|
||||||
|
(gomp_map_val): Use OFFSET_* macros instead of magic constants. Write
|
||||||
|
as switch instead of list of ifs.
|
||||||
|
(gomp_map_vars_internal): Use OFFSET_* and FIELD_TGT_EMPTY macros.
|
||||||
|
|
||||||
2019-10-02 Andreas Tobler <andreast@gcc.gnu.org>
|
2019-10-02 Andreas Tobler <andreast@gcc.gnu.org>
|
||||||
|
|
||||||
* testsuite/libgomp.oacc-c-c++-common/loop-default.h: Remove alloca.h
|
* testsuite/libgomp.oacc-c-c++-common/loop-default.h: Remove alloca.h
|
||||||
|
@ -903,6 +903,11 @@ struct target_mem_desc {
|
|||||||
artificial pointer to "omp declare target link" object. */
|
artificial pointer to "omp declare target link" object. */
|
||||||
#define REFCOUNT_LINK (~(uintptr_t) 1)
|
#define REFCOUNT_LINK (~(uintptr_t) 1)
|
||||||
|
|
||||||
|
/* Special offset values. */
|
||||||
|
#define OFFSET_INLINED (~(uintptr_t) 0)
|
||||||
|
#define OFFSET_POINTER (~(uintptr_t) 1)
|
||||||
|
#define OFFSET_STRUCT (~(uintptr_t) 2)
|
||||||
|
|
||||||
struct splay_tree_key_s {
|
struct splay_tree_key_s {
|
||||||
/* Address of the host object. */
|
/* Address of the host object. */
|
||||||
uintptr_t host_start;
|
uintptr_t host_start;
|
||||||
|
@ -44,6 +44,8 @@
|
|||||||
#include "plugin-suffix.h"
|
#include "plugin-suffix.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define FIELD_TGT_EMPTY (~(size_t) 0)
|
||||||
|
|
||||||
static void gomp_target_init (void);
|
static void gomp_target_init (void);
|
||||||
|
|
||||||
/* The whole initialization code for offloading plugins is only run one. */
|
/* The whole initialization code for offloading plugins is only run one. */
|
||||||
@ -497,17 +499,25 @@ gomp_map_val (struct target_mem_desc *tgt, void **hostaddrs, size_t i)
|
|||||||
return tgt->list[i].key->tgt->tgt_start
|
return tgt->list[i].key->tgt->tgt_start
|
||||||
+ tgt->list[i].key->tgt_offset
|
+ tgt->list[i].key->tgt_offset
|
||||||
+ tgt->list[i].offset;
|
+ tgt->list[i].offset;
|
||||||
if (tgt->list[i].offset == ~(uintptr_t) 0)
|
|
||||||
return (uintptr_t) hostaddrs[i];
|
switch (tgt->list[i].offset)
|
||||||
if (tgt->list[i].offset == ~(uintptr_t) 1)
|
{
|
||||||
return 0;
|
case OFFSET_INLINED:
|
||||||
if (tgt->list[i].offset == ~(uintptr_t) 2)
|
return (uintptr_t) hostaddrs[i];
|
||||||
return tgt->list[i + 1].key->tgt->tgt_start
|
|
||||||
+ tgt->list[i + 1].key->tgt_offset
|
case OFFSET_POINTER:
|
||||||
+ tgt->list[i + 1].offset
|
return 0;
|
||||||
+ (uintptr_t) hostaddrs[i]
|
|
||||||
- (uintptr_t) hostaddrs[i + 1];
|
case OFFSET_STRUCT:
|
||||||
return tgt->tgt_start + tgt->list[i].offset;
|
return tgt->list[i + 1].key->tgt->tgt_start
|
||||||
|
+ tgt->list[i + 1].key->tgt_offset
|
||||||
|
+ tgt->list[i + 1].offset
|
||||||
|
+ (uintptr_t) hostaddrs[i]
|
||||||
|
- (uintptr_t) hostaddrs[i + 1];
|
||||||
|
|
||||||
|
default:
|
||||||
|
return tgt->tgt_start + tgt->list[i].offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __attribute__((always_inline)) struct target_mem_desc *
|
static inline __attribute__((always_inline)) struct target_mem_desc *
|
||||||
@ -575,7 +585,7 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep,
|
|||||||
|| (kind & typemask) == GOMP_MAP_FIRSTPRIVATE_INT)
|
|| (kind & typemask) == GOMP_MAP_FIRSTPRIVATE_INT)
|
||||||
{
|
{
|
||||||
tgt->list[i].key = NULL;
|
tgt->list[i].key = NULL;
|
||||||
tgt->list[i].offset = ~(uintptr_t) 0;
|
tgt->list[i].offset = OFFSET_INLINED;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if ((kind & typemask) == GOMP_MAP_USE_DEVICE_PTR)
|
else if ((kind & typemask) == GOMP_MAP_USE_DEVICE_PTR)
|
||||||
@ -596,7 +606,7 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep,
|
|||||||
cur_node.host_end = (uintptr_t) hostaddrs[last]
|
cur_node.host_end = (uintptr_t) hostaddrs[last]
|
||||||
+ sizes[last];
|
+ sizes[last];
|
||||||
tgt->list[i].key = NULL;
|
tgt->list[i].key = NULL;
|
||||||
tgt->list[i].offset = ~(uintptr_t) 2;
|
tgt->list[i].offset = OFFSET_STRUCT;
|
||||||
splay_tree_key n = splay_tree_lookup (mem_map, &cur_node);
|
splay_tree_key n = splay_tree_lookup (mem_map, &cur_node);
|
||||||
if (n == NULL)
|
if (n == NULL)
|
||||||
{
|
{
|
||||||
@ -629,7 +639,7 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep,
|
|||||||
else if ((kind & typemask) == GOMP_MAP_ALWAYS_POINTER)
|
else if ((kind & typemask) == GOMP_MAP_ALWAYS_POINTER)
|
||||||
{
|
{
|
||||||
tgt->list[i].key = NULL;
|
tgt->list[i].key = NULL;
|
||||||
tgt->list[i].offset = ~(uintptr_t) 1;
|
tgt->list[i].offset = OFFSET_POINTER;
|
||||||
has_firstprivate = true;
|
has_firstprivate = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -659,7 +669,7 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep,
|
|||||||
if (!n)
|
if (!n)
|
||||||
{
|
{
|
||||||
tgt->list[i].key = NULL;
|
tgt->list[i].key = NULL;
|
||||||
tgt->list[i].offset = ~(uintptr_t) 1;
|
tgt->list[i].offset = OFFSET_POINTER;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -884,12 +894,12 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep,
|
|||||||
size_t align = (size_t) 1 << (kind >> rshift);
|
size_t align = (size_t) 1 << (kind >> rshift);
|
||||||
tgt->list[i].key = k;
|
tgt->list[i].key = k;
|
||||||
k->tgt = tgt;
|
k->tgt = tgt;
|
||||||
if (field_tgt_clear != ~(size_t) 0)
|
if (field_tgt_clear != FIELD_TGT_EMPTY)
|
||||||
{
|
{
|
||||||
k->tgt_offset = k->host_start - field_tgt_base
|
k->tgt_offset = k->host_start - field_tgt_base
|
||||||
+ field_tgt_offset;
|
+ field_tgt_offset;
|
||||||
if (i == field_tgt_clear)
|
if (i == field_tgt_clear)
|
||||||
field_tgt_clear = ~(size_t) 0;
|
field_tgt_clear = FIELD_TGT_EMPTY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user