From e42f00ee39acf6e88200c36b5ea6a8da6b69dd0f Mon Sep 17 00:00:00 2001 From: Tim Rowley Date: Mon, 4 Apr 2016 12:42:00 -0600 Subject: swr: [rasterizer core] Fix thread binding for 32-bit windows Reviewed-by: Bruce Cherniak --- src/gallium/drivers/swr/rasterizer/core/threads.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gallium/drivers/swr/rasterizer/core/threads.cpp b/src/gallium/drivers/swr/rasterizer/core/threads.cpp index 4b7a207f366..21bff4ec082 100644 --- a/src/gallium/drivers/swr/rasterizer/core/threads.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/threads.cpp @@ -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); -- cgit v1.2.3