[Openmp-commits] [openmp] 2feafa2 - [libomptarget][NFC] Add comment explaining why we pass argument bases and

Georgios Rokos via Openmp-commits openmp-commits at lists.llvm.org
Mon Oct 25 14:55:18 PDT 2021


Author: Georgios Rokos
Date: 2021-10-25T14:51:14-07:00
New Revision: 2feafa2e460c09de25ca0f6f7bc594e9b2dc4796

URL: https://github.com/llvm/llvm-project/commit/2feafa2e460c09de25ca0f6f7bc594e9b2dc4796
DIFF: https://github.com/llvm/llvm-project/commit/2feafa2e460c09de25ca0f6f7bc594e9b2dc4796.diff

LOG: [libomptarget][NFC] Add comment explaining why we pass argument bases and
offsets as two separate entities to the plugins.

Added: 
    

Modified: 
    openmp/libomptarget/src/omptarget.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp
index 06370ac8a678..3e9f6427b472 100644
--- a/openmp/libomptarget/src/omptarget.cpp
+++ b/openmp/libomptarget/src/omptarget.cpp
@@ -1424,6 +1424,15 @@ int target(ident_t *loc, DeviceTy &Device, void *HostPtr, int32_t ArgNum,
   }
   assert(TargetTable && "Global data has not been mapped\n");
 
+  // We need to keep bases and offsets separate. Sometimes (e.g. in OpenCL) we
+  // need to manifest base pointers prior to launching a kernel. Even if we have
+  // mapped an object only partially, e.g. A[N:M], although the kernel is
+  // expected to access elements starting at address &A[N] and beyond, we still
+  // need to manifest the base of the array &A[0]. In other cases, e.g. the COI
+  // API, we need the begin address itself, i.e. &A[N], as the API operates on
+  // begin addresses, not bases. That's why we pass args and offsets as two
+  // separate entities so that each plugin can do what it needs. This behavior
+  // was introdued via https://reviews.llvm.org/D33028 and commit 1546d319244c.
   std::vector<void *> TgtArgs;
   std::vector<ptr
diff _t> TgtOffsets;
 


        


More information about the Openmp-commits mailing list