Skip to content

Commit

Permalink
HACK: Log the affinity masks.
Browse files Browse the repository at this point in the history
Something isn't working with the kokoro bot. Maybe this will tell us why.
  • Loading branch information
ben-clayton committed Jun 5, 2020
1 parent b0280cb commit 3f410ed
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -138,13 +144,19 @@ Thread::Affinity Thread::Affinity::all(
const auto& group = groups.groups[groupIdx];
Core core;
core.windows.group = static_cast<decltype(Core::windows.group)>(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<decltype(core.windows.index)>(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;
Expand Down Expand Up @@ -199,6 +211,14 @@ std::shared_ptr<Thread::Affinity::Policy> 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);
Expand Down

0 comments on commit 3f410ed

Please sign in to comment.