From fea9a07d9bce8271635691e81b3fb7b3aaae5395 Mon Sep 17 00:00:00 2001 From: Jan Wassenberg Date: Thu, 3 Jul 2025 08:21:52 -0700 Subject: [PATCH] Avoid affinity related warnings on Apple. Refs #625 PiperOrigin-RevId: 778895832 --- util/threading.cc | 9 ++++++--- util/topology.cc | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/util/threading.cc b/util/threading.cc index e199b13..6930612 100644 --- a/util/threading.cc +++ b/util/threading.cc @@ -77,9 +77,12 @@ class Pinning { if (HWY_LIKELY(want_pin_)) { if (HWY_UNLIKELY(!hwy::PinThreadToLogicalProcessor(lps[task]))) { - fprintf( - stderr, "Pinning failed for task %d of %zu to %zu (size %zu)\n", - static_cast(task), pool.NumWorkers(), lps[task], lps.size()); + // Apple does not support pinning, hence do not warn there. + if (!HWY_OS_APPLE) { + HWY_WARN("Pinning failed for task %d of %zu to %zu (size %zu)\n", + static_cast(task), pool.NumWorkers(), lps[task], + lps.size()); + } (void)any_error_.test_and_set(); } } diff --git a/util/topology.cc b/util/topology.cc index 46b84d5..0d32f22 100644 --- a/util/topology.cc +++ b/util/topology.cc @@ -59,8 +59,11 @@ static LPS EnabledLPs(const BoundedSlice& lp_slice) { }); } else { const size_t num_lps = hwy::TotalLogicalProcessors(); - HWY_WARN("unknown OS affinity, max %zu LPs and slice %zu.", num_lps, - lp_slice.Num(num_lps)); + // Do not warn on Apple, where affinity is not supported. + if (!HWY_OS_APPLE) { + HWY_WARN("unknown OS affinity, max %zu LPs and slice %zu.", num_lps, + lp_slice.Num(num_lps)); + } for (size_t lp = 0; lp < num_lps; ++lp) { if (lp_slice.Contains(num_lps, lp)) { enabled_lps.Set(lp);