[Openmp-commits] [PATCH] D72576: [OpenMP][Offloading] Reverted the change that ignores empty target descriptors to fix the issue which the runtime returns wrong device number when no target region.

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sun Jan 12 11:52:23 PST 2020


tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, ABataev.
tianshilei1992 added a project: OpenMP.
Herald added subscribers: openmp-commits, guansong.
tianshilei1992 edited the summary of this revision.

This patch is to fix issue in the following simple case:

  #include <omp.h>
  #include <stdio.h>
  
  int main(int argc, char *argv[]) {
    int num = omp_get_num_devices();
    printf("%d\n", num);
  
    return 0;
  }

Currently it returns 0 even devices exist. Since this file doesn't contain any
 target region, the target descriptor is empty so further actions like
 initialization will not be proceeded, leading to wrong device number returned
 by runtime function call.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72576

Files:
  openmp/libomptarget/src/rtl.cpp


Index: openmp/libomptarget/src/rtl.cpp
===================================================================
--- openmp/libomptarget/src/rtl.cpp
+++ openmp/libomptarget/src/rtl.cpp
@@ -234,8 +234,6 @@
   // Attempt to load all plugins available in the system.
   std::call_once(initFlag, &RTLsTy::LoadRTLs, this);
 
-  if (desc->HostEntriesBegin == desc->HostEntriesEnd)
-    return;
   RTLsMtx.lock();
   // Register the images with the RTLs that understand them, if any.
   for (int32_t i = 0; i < desc->NumDeviceImages; ++i) {
@@ -322,8 +320,6 @@
 void RTLsTy::UnregisterLib(__tgt_bin_desc *desc) {
   DP("Unloading target library!\n");
 
-  if (desc->HostEntriesBegin == desc->HostEntriesEnd)
-    return;
   RTLsMtx.lock();
   // Find which RTL understands each image, if any.
   for (int32_t i = 0; i < desc->NumDeviceImages; ++i) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72576.237555.patch
Type: text/x-patch
Size: 837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200112/31cf73d2/attachment.bin>


More information about the Openmp-commits mailing list