[Openmp-commits] [PATCH] D105121: [OpenMP] Avoid checking parent reference count in targetDataBegin

Narayanaswamy, Ravi via Openmp-commits openmp-commits at lists.llvm.org
Fri Jul 9 11:52:11 PDT 2021


#pragma omp target map(s1.p[0:10])

Memory and data copy will happened for p[0:10] and the device copy of s1 will be updated with the device pointer to p 

-----Original Message-----
From: George Rokos via Phabricator <reviews at reviews.llvm.org> 
Sent: Friday, July 09, 2021 8:40 AM
To: jdenny.ornl at gmail.com; Rokos, Georgios <georgios.rokos at intel.com>; Narayanaswamy, Ravi <ravi.narayanaswamy at intel.com>; jdoerfert at anl.gov; jhuber6 at vols.utk.edu
Cc: tianshilei1992 at gmail.com; clementval at gmail.com; protze.joachim at gmail.com; georgakoudis1 at llnl.gov; yaxun.liu at amd.com; zhang.guansong at gmail.com; stefomeister at gmail.com; openmp-commits at lists.llvm.org; bhuvanendra.kumarn at amd.com; lin32 at llnl.gov; pdhaliwal at amd.com; liao6 at llnl.gov; abidmuslim at gmail.com; sara.royuela at bsc.es; Saiyedul.Islam at amd.com; sourabhsingh.tomar at amd.com; deepak.eachempati <deepak.eachempati at hpe.com>; xw111luoye at gmail.com; ron.lieberman at amd.com; jatin.bhateja at gmail.com; greg63706 at gmail.com; a.bataev at hotmail.com; kuhnel at google.com
Subject: [PATCH] D105121: [OpenMP] Avoid checking parent reference count in targetDataBegin

grokos added a comment.

Just like in D104924 <https://reviews.llvm.org/D104924>, the code after this patch is equivalent to the original one with one exception. The question was raised at our telecon a couple of weeks ago but no one was sure what the right answer is:

What happens if a struct has a pointer member, we map the whole struct and later on we use the pointer member to map some attached object?

  struct S {
    int i;
    double d;
    float *p;
  } s1;
  ...
  s1.i = 1;
  s1.d = 2.0;
  s1.p = new float[10];
  #pragma omp enter data map(to:s1) // whole struct is mapped but the object pointed to by s1.p is not
  ...
  #pragma omp target map(s1.p[0:10]) // the attached object here has RefCount=1, but parent struct will have RefCount=2
  {...}

How should we handle this case? Does anyone know for sure? Do we copy s1.p to the device as its RefCount=1 or are we ignoring the motion clause because the parent struct's RefCount != 1?

If the answer is "we copy it", then we can commit both this patch and D104924 <https://reviews.llvm.org/D104924>. If the answer is "we need to look at the parent struct's RefCount" then both patches will have to be abandoned.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105121/new/

https://reviews.llvm.org/D105121



More information about the Openmp-commits mailing list