diff options
author | Tim Rowley <[email protected]> | 2017-02-06 15:25:57 -0800 |
---|---|---|
committer | Tim Rowley <[email protected]> | 2017-03-20 18:04:53 -0500 |
commit | 7b94e5e1faccff1bab08b359d800b7ede9d63be6 (patch) | |
tree | b9cf379ae95440d49311175f2cc1db867a613c6f /src/gallium/drivers | |
parent | 5e29af5f772c1e1b02a4cc46d2f7d3b5d2151ad8 (diff) |
swr: [rasterizer core] Support sparse numa id values on all OSes
Reviewed-by: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/swr/rasterizer/core/threads.cpp | 80 |
1 files changed, 53 insertions, 27 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/core/threads.cpp b/src/gallium/drivers/swr/rasterizer/core/threads.cpp index f1c3030b851..e11291bb83e 100644 --- a/src/gallium/drivers/swr/rasterizer/core/threads.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/threads.cpp @@ -56,6 +56,7 @@ struct Core struct NumaNode { + uint32_t numaId; std::vector<Core> cores; }; @@ -134,8 +135,12 @@ void CalculateProcessorTopology(CPUNumaNodes& out_nodes, uint32_t& out_numThread SWR_ASSERT(ret); // Store data - if (out_nodes.size() <= numaId) out_nodes.resize(numaId + 1); + if (out_nodes.size() <= numaId) + { + out_nodes.resize(numaId + 1); + } auto& numaNode = out_nodes[numaId]; + numaNode.numaId = numaId; uint32_t coreId = 0; @@ -175,11 +180,18 @@ void CalculateProcessorTopology(CPUNumaNodes& out_nodes, uint32_t& out_numThread if (threadId != uint32_t(-1)) { // Save information. - if (out_nodes.size() <= numaId) out_nodes.resize(numaId + 1); + if (out_nodes.size() <= numaId) + { + out_nodes.resize(numaId + 1); + } + auto& numaNode = out_nodes[numaId]; - if (numaNode.cores.size() <= coreId) numaNode.cores.resize(coreId + 1); - auto& core = numaNode.cores[coreId]; + if (numaNode.cores.size() <= coreId) + { + numaNode.cores.resize(coreId + 1); + } + auto& core = numaNode.cores[coreId]; core.procGroup = coreId; core.threadIds.push_back(threadId); @@ -207,9 +219,16 @@ void CalculateProcessorTopology(CPUNumaNodes& out_nodes, uint32_t& out_numThread if (threadId != uint32_t(-1)) { // Save information. - if (out_nodes.size() <= numaId) out_nodes.resize(numaId + 1); + if (out_nodes.size() <= numaId) + { + out_nodes.resize(numaId + 1); + } auto& numaNode = out_nodes[numaId]; - if (numaNode.cores.size() <= coreId) numaNode.cores.resize(coreId + 1); + numaNode.numaId = numaId; + if (numaNode.cores.size() <= coreId) + { + numaNode.cores.resize(coreId + 1); + } auto& core = numaNode.cores[coreId]; core.procGroup = coreId; @@ -217,31 +236,38 @@ void CalculateProcessorTopology(CPUNumaNodes& out_nodes, uint32_t& out_numThread out_numThreadsPerProcGroup++; } - /* Prune empty numa nodes */ - for (auto it = out_nodes.begin(); it != out_nodes.end(); ) { - if ((*it).cores.size() == 0) - it = out_nodes.erase(it); - else - ++it; - } - - /* Prune empty core nodes */ - for (uint32_t node = 0; node < out_nodes.size(); node++) { - auto& numaNode = out_nodes[node]; - auto it = numaNode.cores.begin(); - for ( ; it != numaNode.cores.end(); ) { - if (it->threadIds.size() == 0) - numaNode.cores.erase(it); - else - ++it; - } - } - #else #error Unsupported platform #endif + + // Prune empty cores and numa nodes + for (auto node_it = out_nodes.begin(); node_it != out_nodes.end(); ) + { + // Erase empty cores (first) + for (auto core_it = node_it->cores.begin(); core_it != node_it->cores.end(); ) + { + if (core_it->threadIds.size() == 0) + { + core_it = node_it->cores.erase(core_it); + } + else + { + ++core_it; + } + } + + // Erase empty numa nodes (second) + if (node_it->cores.size() == 0) + { + node_it = out_nodes.erase(node_it); + } + else + { + ++node_it; + } + } } @@ -1022,7 +1048,7 @@ void CreateThreadPool(SWR_CONTEXT* pContext, THREAD_POOL* pPool) pPool->pThreadData[workerId].workerId = workerId; pPool->pThreadData[workerId].procGroupId = core.procGroup; pPool->pThreadData[workerId].threadId = core.threadIds[t]; - pPool->pThreadData[workerId].numaId = n; + pPool->pThreadData[workerId].numaId = node.numaId; pPool->pThreadData[workerId].coreId = c; pPool->pThreadData[workerId].htId = t; pPool->pThreadData[workerId].pContext = pContext; |