Fix topology display for platforms where it fails (Apple)

PiperOrigin-RevId: 677800053
This commit is contained in:
Jan Wassenberg 2024-09-23 08:14:11 -07:00 committed by Copybara-Service
parent cdbfebb10f
commit c6c10e0a53
2 changed files with 8 additions and 3 deletions

View File

@ -326,6 +326,7 @@ cc_library(
"@hwy//:hwy",
"@hwy//:nanobenchmark",
"@hwy//:thread_pool",
"@hwy//:topology",
],
)

View File

@ -39,6 +39,7 @@
#include "util/threading.h"
#include "hwy/base.h"
#include "hwy/contrib/thread_pool/thread_pool.h"
#include "hwy/contrib/thread_pool/topology.h"
#include "hwy/highway.h"
#include "hwy/per_target.h"
#include "hwy/timer.h"
@ -231,6 +232,10 @@ void ShowConfig(LoaderArgs& loader, InferenceArgs& inference, AppArgs& app,
char cpu100[100] = "unknown";
(void)hwy::platform::GetCpuString(cpu100);
const std::vector<hwy::LogicalProcessorSet>& clusters =
pools.CoresPerCluster();
const size_t per_cluster =
clusters.empty() ? 0 : pools.CoresPerCluster().front().Count();
fprintf(stderr,
"Date & Time : %s" // dt includes \n
"CPU : %s\n"
@ -239,9 +244,8 @@ void ShowConfig(LoaderArgs& loader, InferenceArgs& inference, AppArgs& app,
"Compiled config : %s\n"
"Weight Type : %s\n"
"EmbedderInput Type : %s\n",
dt, cpu100, pools.CoresPerCluster().size(),
pools.CoresPerCluster()[0].Count(), pools.Outer().NumWorkers(),
pools.Inner(0).NumWorkers(),
dt, cpu100, pools.CoresPerCluster().size(), per_cluster,
pools.Outer().NumWorkers(), pools.Inner(0).NumWorkers(),
hwy::TargetName(hwy::DispatchedTarget()), hwy::VectorBytes() * 8,
CompiledConfig(), StringFromType(loader.Info().weight),
TypeName<EmbedderInputT>());