From 3f410eda719b41027bf238c55cb04b36ac7bec88 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Fri, 5 Jun 2020 20:44:16 +0100 Subject: [PATCH] HACK: Log the affinity masks. Something isn't working with the kokoro bot. Maybe this will tell us why. --- src/thread.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/thread.cpp b/src/thread.cpp index 80ce77f..5c97b9c 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -103,6 +103,12 @@ const ProcessorGroups& getProcessorGroups() { } } } + printf("*** Processor groups ***\n"); + for (size_t i = 0; i < out.count; i++) { + printf("** Group %d\n", (int)i); + printf(" Count: %d\n", (int)out.groups[i].count); + printf(" Mask: 0x%8llx\n", (uint64_t)out.groups[i].affinity); + } return out; }(); return groups; @@ -138,13 +144,19 @@ Thread::Affinity Thread::Affinity::all( const auto& group = groups.groups[groupIdx]; Core core; core.windows.group = static_cast(groupIdx); - for (size_t coreIdx = 0; coreIdx < sizeof(KAFFINITY) * 8; coreIdx++) { + for (unsigned int coreIdx = 0; coreIdx < group.count; coreIdx++) { if ((group.affinity >> coreIdx) & 1) { core.windows.index = static_cast(coreIdx); affinity.cores.emplace_back(std::move(core)); } } } + + printf("*** all() - count: %d***\n", (int)affinity.cores.size()); + for (auto core : affinity.cores) { + printf("- g:%d i:%d\n", (int)core.windows.group, (int)core.windows.index); + } + #elif defined(__linux__) auto thread = pthread_self(); cpu_set_t cpuset; @@ -199,6 +211,14 @@ std::shared_ptr Thread::Affinity::Policy::anyOf( out.cores.push_back(core); } } + + printf("*** anyOf(threadId: %d, affinty: %d) ***\n", (int)threadId, + (int)affinity.cores.size()); + for (auto core : out.cores) { + printf("- g:%d i:%d\n", (int)core.windows.group, + (int)core.windows.index); + } + return out; #else return Affinity(affinity, allocator);