From: Tim Rowley Date: Mon, 4 Apr 2016 18:42:00 +0000 (-0600) Subject: swr: [rasterizer core] Fix thread binding for 32-bit windows X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e42f00ee39acf6e88200c36b5ea6a8da6b69dd0f;p=mesa.git swr: [rasterizer core] Fix thread binding for 32-bit windows Reviewed-by: Bruce Cherniak --- 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);