On Thu, 14 Nov 2019 12:08:45 +0100 Thomas Schwinge <tho...@codesourcery.com> wrote:
> Hi! > > In context of reviewing Julian's "OpenACC reference count overhaul", > I'm generally reviewing (also known as: trying to understand) the > libgomp OpenMP 'target' "refcount"ing , and I noticed something > strange (?): > > On 2015-07-30T22:44:33+0300, Ilya Verbin <iver...@gmail.com> wrote: > > make check-target-libgomp passed. ok? > > (This eventually got into trunk in r228777 "Merge from > gomp-4_1-branch to trunk".) > > > libgomp/ > > > * target.c > > > (gomp_offload_image_to_device): Set tgt's refcount to > > infinity. > > > --- a/libgomp/target.c > > +++ b/libgomp/target.c > > > @@ -794,7 +807,7 @@ gomp_offload_image_to_device (struct > > gomp_device_descr *devicep, /* Insert host-target address mapping > > into splay tree. */ struct target_mem_desc *tgt = gomp_malloc > > (sizeof (*tgt)); tgt->array = gomp_malloc ((num_funcs + num_vars) * > > sizeof (*tgt->array)); > > - tgt->refcount = 1; > > + tgt->refcount = REFCOUNT_INFINITY; > > tgt->tgt_start = 0; > > tgt->tgt_end = 0; > > tgt->to_free = NULL; > > I had understood that 'REFCOUNT_INFINITY' is only meant to be used for > the 'refcount' in 'struct splay_tree_key_s', but here it's used for > the 'refcount' in 'struct target_mem_desc'. However, all the other > 'struct target_mem_desc' 'refcount' handling doesn't seem to take > care of the special 'REFCOUNT_INFINITY' value. > > This might not be an actually observable bug (I have not verified, > have not tried to construct a test case), but should this be changed > anyway? (Back to 'tgt->refcount = 1'; not yet tested?) These function- or variable-mapping blocks will never interact with the rest of the reference-counting machinery, I don't think, so it's possibly a bit weird but it's unlikely to cause a problem in practice. Just IMO. Julian