[Openmp-commits] [PATCH] D74092: Changed omp_get_max_threads() implementation to more closely match spec description: "The omp_get_max_threads routine returns an upper bound on the number of threads that could be used to form a new team if a parallel construct without a...

Ethan Stewart via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Feb 5 14:16:42 PST 2020


estewart08 created this revision.
estewart08 added reviewers: jdoerfert, ABataev, grokos, JonChesterfield.
Herald added a project: OpenMP.
Herald added a subscriber: openmp-commits.

...num_threads clause were encountered after execution returns from this routine." The attached test shows a Max Threads: 96, Num Threads: 128 without the proposed change. The number of threads should not exceed the (max) nthreads ICV. This change does fail the api test, max_threads.c, because now it would return 64 instead of 32.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74092

Files:
  openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
  openmp/libomptarget/deviceRTLs/nvptx/test/api/get_max_threads.c


Index: openmp/libomptarget/deviceRTLs/nvptx/test/api/get_max_threads.c
===================================================================
--- /dev/null
+++ openmp/libomptarget/deviceRTLs/nvptx/test/api/get_max_threads.c
@@ -0,0 +1,22 @@
+// RUN: %compile-run-and-check
+#include <omp.h>
+#include <stdio.h>
+
+int main(){
+  int max_threads = -1;
+  int num_threads = -1;
+
+  #pragma omp target map(tofrom: max_threads)
+    max_threads = omp_get_max_threads();
+
+  #pragma omp target parallel map(tofrom: num_threads)
+  {
+    #pragma omp master
+      num_threads = omp_get_num_threads();
+  }
+  
+  // CHECK: Max Threads: 128, Num Threads: 128
+  printf("Max Threads: %d, Num Threads: %d\n", max_threads, num_threads);
+
+  return 0;
+}
Index: openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
===================================================================
--- openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
+++ openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
@@ -68,7 +68,7 @@
   // set number of threads and thread limit in team to started value
   omptarget_nvptx_TaskDescr *currTaskDescr =
       omptarget_nvptx_threadPrivateContext->GetTopLevelTaskDescr(threadId);
-  nThreads = GetNumberOfWorkersInTeam();
+  nThreads = GetNumberOfThreadsInBlock();
   threadLimit = ThreadLimit;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74092.242751.patch
Type: text/x-patch
Size: 1324 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200205/2f709643/attachment.bin>


More information about the Openmp-commits mailing list