Skip to content

Commit

Permalink
Print cache info and update Highway version for that
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 702318451
  • Loading branch information
jan-wassenberg authored and copybara-github committed Dec 3, 2024
1 parent f74d496 commit 6a34e9c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ cc_library(
"//compression:compress",
"@highway//:hwy",
"@highway//:nanobenchmark",
"@highway//:topology",
],
)

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG 0ca297227a373710e76dd45e0ad4d68adb6928fe EXCLUDE_FROM_ALL)
FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG 2b565e87d50b151660494624af532ac0b6076c79 EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(highway)

## Note: absl needs to be installed by sentencepiece. This will only happen if
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bazel_dep(name = "google_benchmark", version = "1.8.5")
# Require a more recent version.
git_override(
module_name = "highway",
commit = "0ca297227a373710e76dd45e0ad4d68adb6928fe",
commit = "2b565e87d50b151660494624af532ac0b6076c79",
remote = "https://github.com/google/highway",
)

Expand Down
28 changes: 24 additions & 4 deletions evals/benchmark_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "util/args.h"
#include "util/threading.h"
#include "hwy/base.h"
#include "hwy/contrib/thread_pool/topology.h"
#include "hwy/highway.h"
#include "hwy/per_target.h" // VectorBytes
#include "hwy/timer.h"
Expand Down Expand Up @@ -215,6 +216,25 @@ void LogSpeedStats(double time_start, size_t total_tokens) {
<< " [" << tok_sec << " tokens / sec" << "]\n";
}

std::string CacheString() {
const hwy::Cache* caches = hwy::DataCaches();
if (caches == nullptr) return "cache unknown";
char buf[200];
// Do not print cores_sharing because that is visible from the topology.
const int len =
snprintf(buf, sizeof(buf), "L1 %uK=%u*%u@%u, L2 %uK=%u*%u@%u ",
caches[1].size_kib, caches[1].sets, caches[1].bytes_per_line,
caches[1].associativity, caches[2].size_kib, caches[2].sets,
caches[2].bytes_per_line, caches[2].associativity);
HWY_ASSERT(len >= 24);
if (caches[3].size_kib != 0) {
snprintf(buf + len, sizeof(buf) - len, "L3 %uK=%u*%u@%u",
caches[3].size_kib, caches[3].sets, caches[3].bytes_per_line,
caches[3].associativity);
}
return buf;
}

void ShowConfig(LoaderArgs& loader, InferenceArgs& inference, AppArgs& app,
NestedPools& pools) {
loader.Print(app.verbosity);
Expand All @@ -230,15 +250,15 @@ void ShowConfig(LoaderArgs& loader, InferenceArgs& inference, AppArgs& app,
fprintf(stderr,
"Date & Time : %s" // dt includes \n
"CPU : %s\n"
"CPU topology : %s, %s\n"
"CPU topology : %s, %s, %s\n"
"Instruction set : %s (%zu bits)\n"
"Compiled config : %s\n"
"Weight Type : %s\n"
"EmbedderInput Type : %s\n",
dt, cpu100, pools.TopologyString(), pools.PinString(),
hwy::TargetName(hwy::DispatchedTarget()), hwy::VectorBytes() * 8,
CompiledConfig(), StringFromType(loader.Info().weight),
TypeName<EmbedderInputT>());
CacheString().c_str(), hwy::TargetName(hwy::DispatchedTarget()),
hwy::VectorBytes() * 8, CompiledConfig(),
StringFromType(loader.Info().weight), TypeName<EmbedderInputT>());
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/hello_world/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ project(hello_world)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)
FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG da250571a45826b21eebbddc1e50d0c1137dee5f)
FetchContent_Declare(highway GIT_REPOSITORY https://github.com/google/highway.git GIT_TAG 2b565e87d50b151660494624af532ac0b6076c79)
FetchContent_MakeAvailable(highway)
FetchContent_Declare(sentencepiece GIT_REPOSITORY https://github.com/google/sentencepiece GIT_TAG 53de76561cfc149d3c01037f0595669ad32a5e7c)
FetchContent_MakeAvailable(sentencepiece)
Expand Down

0 comments on commit 6a34e9c

Please sign in to comment.