gpu-compute: Adding ioctl for HW context size
authorAlexandru Dutu <alexandru.dutu@amd.com>
Fri, 16 Sep 2016 16:27:56 +0000 (12:27 -0400)
committerAlexandru Dutu <alexandru.dutu@amd.com>
Fri, 16 Sep 2016 16:27:56 +0000 (12:27 -0400)
Adding runtime support for determining the memory required by a SIMD engine
when executing a particular wavefront.

src/gpu-compute/cl_driver.cc
src/gpu-compute/dispatcher.cc
src/gpu-compute/dispatcher.hh
src/gpu-compute/hsa_kernel_info.hh
src/gpu-compute/wavefront.cc
src/gpu-compute/wavefront.hh

index 6bb6be102a160c542e6337621c307bb11f0440ae..d3950ec04d82647c32de92cad860af1b80c4ed03 100644 (file)
@@ -242,6 +242,13 @@ ClDriver::ioctl(LiveProcess *process, ThreadContext *tc, unsigned req)
             buf.copyOut(tc->getMemProxy());
         }
         break;
+      case HSA_GET_HW_STATIC_CONTEXT_SIZE:
+        {
+            BufferArg buf(buf_addr, sizeof(uint32_t));
+            *((uint32_t*)buf.bufferPtr()) = dispatcher->getStaticContextSize();
+            buf.copyOut(tc->getMemProxy());
+        }
+        break;
 
       default:
         fatal("ClDriver: bad ioctl %d\n", req);
index adc1f51bd55973af502c4226082f0cd9a224f08b..79eb46bbf98d6b9c274bcaa2a6000731cdc9980a 100644 (file)
@@ -398,3 +398,9 @@ GpuDispatcher::setFuncargsSize(int funcargs_size)
 {
     shader->funcargs_size = funcargs_size;
 }
+
+uint32_t
+GPUDispatcher::getStaticContextSize() const
+{
+    return shader->cuList[0]->wfList[0][0]->getStaticContextSize();
+}
index e984af494dc7c541ead46ef3ad8a21f0d6c542bb..f5e89e8aa67a65cb1327113f8d4c1a0f05c3c14f 100644 (file)
@@ -159,6 +159,9 @@ class GpuDispatcher : public DmaDevice
         int getNumCUs();
         int wfSize() const;
         void setFuncargsSize(int funcargs_size);
+
+        /** Returns the size of the static hardware context of a wavefront */
+        uint32_t getStaticContextSize() const;
 };
 
 #endif // __GPU_DISPATCHER_HH__
index 396913dac4c8eb26fb0883000a112115bb5e466b..4151695ebeb32396caa3c378783de9bfb78c2889 100644 (file)
@@ -48,6 +48,7 @@ static const int HSA_GET_CODE = 0x4804;
 static const int HSA_GET_READONLY_DATA = 0x4805;
 static const int HSA_GET_CU_CNT = 0x4806;
 static const int HSA_GET_VSZ = 0x4807;
+static const int HSA_GET_HW_STATIC_CONTEXT_SIZE = 0x4808;
 
 // Return value (via buffer ptr) for HSA_GET_SIZES
 struct HsaDriverSizes
index c73307ac4d7e7b946faf58f6e83a874c3370e9d7..76a0bdf9ebeeb39dba96ed5a2f4d9bb0e01ca4cd 100644 (file)
@@ -155,9 +155,9 @@ Wavefront::~Wavefront()
 }
 
 void
-Wavefront::start(uint64_t _wfDynId,uint64_t _base_ptr)
+Wavefront::start(uint64_t _wf_dyn_id,uint64_t _base_ptr)
 {
-    wfDynId = _wfDynId;
+    wfDynId = _wf_dyn_id;
     basePtr = _base_ptr;
     status = S_RUNNING;
 }
@@ -931,3 +931,13 @@ Wavefront::pc(uint32_t new_pc)
 {
     reconvergenceStack.top()->pc = new_pc;
 }
+
+uint32_t
+Wavefront::getStaticContextSize() const
+{
+    return barCnt.size() * sizeof(int) + sizeof(dynWaveId) + sizeof(maxBarCnt) +
+           sizeof(oldBarrierCnt) + sizeof(barrierCnt) + sizeof(wgId) +
+           sizeof(computeUnit->cu_id) + sizeof(barrierId) + sizeof(initMask) +
+           sizeof(privBase) + sizeof(spillBase) + sizeof(ldsChunk) +
+           computeUnit->wfSize() * sizeof(ReconvergenceStackEntry);
+}
index db2e434a941fd22ef635849febdfdd1b026d46a8..4fe66ecfe855d9cfde11c9be42f6bcb8001d6fe8 100644 (file)
@@ -354,6 +354,12 @@ class Wavefront : public SimObject
 
     void discardFetch();
 
+    /**
+     * Returns the size of the static hardware context of a particular wavefront
+     * This should be updated everytime the context is changed
+     */
+    uint32_t getStaticContextSize() const;
+
   private:
     /**
      * Stack containing Control Flow Graph nodes (i.e., kernel instructions)