changeset 16668:f1d1ec9bcf24

HSAIL: reset TLAB in donor thread to detect allocation in donor while kernel was active Contributed-by: Tom Deneau <tom.deneau@amd.com>
author Doug Simon <doug.simon@oracle.com>
date Thu, 31 Jul 2014 17:53:06 +0200
parents 1d4313c3ab38
children ac6cbf6570dd
files src/gpu/hsail/vm/gpu_hsail_Tlab.hpp src/share/vm/memory/threadLocalAllocBuffer.hpp
diffstat 2 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/gpu/hsail/vm/gpu_hsail_Tlab.hpp	Thu Jul 31 17:52:13 2014 +0200
+++ b/src/gpu/hsail/vm/gpu_hsail_Tlab.hpp	Thu Jul 31 17:53:06 2014 +0200
@@ -138,6 +138,12 @@
       HSAILTlabInfo* pTlabInfo = &_tlab_infos_pool_start[i];
       _cur_tlab_infos[i] = pTlabInfo;
       pTlabInfo->initialize(tlab->start(), tlab->top(), tlab->end(), donorThread, this);
+
+      // reset the real tlab fields to zero so we are sure the thread doesn't use it
+      tlab->set_start(NULL);
+      tlab->set_top(NULL);
+      tlab->set_pf_top(NULL);
+      tlab->set_end(NULL);
     }
   }
 
@@ -182,6 +188,16 @@
           tlabInfo->_top = tlabInfo->last_good_top();
         }
 
+        // if the donor thread allocated anything while we were running
+        // we will retire its tlab before overwriting with our new one
+        if (tlab->top() != NULL) {
+          if (TraceGPUInteraction) {
+            tty->print("Donor Thread allocated new tlab");
+            printTlabInfoFromThread(tlab);
+          }
+          tlab->make_parsable(true);
+        }
+
         // fill the donor thread tlab with the tlabInfo information
         // we do this even if it will get overwritten by a later tlabinfo
         // because it helps with tlab statistics for that donor thread
--- a/src/share/vm/memory/threadLocalAllocBuffer.hpp	Thu Jul 31 17:52:13 2014 +0200
+++ b/src/share/vm/memory/threadLocalAllocBuffer.hpp	Thu Jul 31 17:53:06 2014 +0200
@@ -38,6 +38,9 @@
 //            used to make it available for such multiplexing.
 class ThreadLocalAllocBuffer: public CHeapObj<mtThread> {
   friend class VMStructs;
+#ifdef GRAAL
+  friend class HSAILAllocationInfo;
+#endif
 private:
   HeapWord* _start;                              // address of TLAB
   HeapWord* _top;                                // address after last allocation