swr: [rasterizer core] Fix thread binding for 32-bit windows
authorTim Rowley <timothy.o.rowley@intel.com>
Mon, 4 Apr 2016 18:42:00 +0000 (12:42 -0600)
committerTim Rowley <timothy.o.rowley@intel.com>
Fri, 22 Apr 2016 23:47:59 +0000 (18:47 -0500)
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/core/threads.cpp

index 4b7a207f366d32d1b3963f35cbb5bdf942204d24..21bff4ec082f5f553fe8c6794b27dff1dd876a67 100644 (file)
@@ -120,7 +120,7 @@ void CalculateProcessorTopology(CPUNumaNodes& out_nodes, uint32_t& out_numThread
                     pCore->procGroup = procGroup;
 #if !defined(_WIN64)
                     coreId = (uint32_t)numaNode.cores.size();
-                    if ((coreId * numThreads) >= 32)
+                    if ((coreId * numThreads) > 32)
                     {
                         // Windows doesn't return threadIds >= 32 for a processor group correctly
                         // when running a 32-bit application.
@@ -234,6 +234,9 @@ void bindThread(uint32_t threadId, uint32_t procGroupId = 0, bool bindProcGroup=
 #if !defined(_WIN64)
         if (threadId >= 32)
         {
+            // Hopefully we don't get here.  Logic in CreateThreadPool should prevent this.
+            SWR_REL_ASSERT(false, "Shouldn't get here");
+
             // In a 32-bit process on Windows it is impossible to bind
             // to logical processors 32-63 within a processor group.
             // In this case set the mask to 0 and let the system assign
@@ -731,6 +734,17 @@ void CreateThreadPool(SWR_CONTEXT *pContext, THREAD_POOL *pPool)
         numHyperThreads = std::min(numHyperThreads, KNOB_MAX_THREADS_PER_CORE);
     }
 
+#if defined(_WIN32) && !defined(_WIN64)
+    if (!KNOB_MAX_WORKER_THREADS)
+    {
+        // Limit 32-bit windows to bindable HW threads only
+        if ((numCoresPerNode * numHWHyperThreads) > 32)
+        {
+            numCoresPerNode = 32 / numHWHyperThreads;
+        }
+    }
+#endif
+
     if (numHyperThreads < 2)
     {
         SET_KNOB(HYPERTHREADED_FE, false);