Skip to content

Commit

Permalink
Fix eth_coord hash dependency (#317)
Browse files Browse the repository at this point in the history
### Issue
A follow up of #306 

### Description
Adding a new boost dependency complicates things. The code, as is
currently on main, won't build in tt_metal.

### List of the changes
- Remove boost dependency, and use one liner hash function

### Testing
No testing

### API Changes
There are no API changes in this PR.
  • Loading branch information
broskoTT authored Nov 19, 2024
1 parent f749fc1 commit 6cf3bb0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ function(fetch_dependencies)
# boost::interprocess
############################################################################################################################
include(${PROJECT_SOURCE_DIR}/cmake/fetch_boost.cmake)
fetch_boost_library(container_hash)
fetch_boost_library(interprocess)

############################################################################################################################
Expand Down
17 changes: 11 additions & 6 deletions device/tt_cluster_descriptor_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#pragma once

#include <boost/container_hash/hash.hpp>
#include <functional>
#include <tuple>

Expand All @@ -29,16 +28,22 @@ struct eth_coord_t {
}
};

// Small performant hash combiner taken from boost library.
// Not using boost::hash_combine due to dependency complications.
inline void boost_hash_combine(std::size_t &seed, const int value) {
seed ^= value + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}

namespace std {
template <>
struct hash<eth_coord_t> {
std::size_t operator()(eth_coord_t const &c) const {
std::size_t seed = 0;
boost::hash_combine(seed, c.cluster_id);
boost::hash_combine(seed, c.x);
boost::hash_combine(seed, c.y);
boost::hash_combine(seed, c.rack);
boost::hash_combine(seed, c.shelf);
boost_hash_combine(seed, c.cluster_id);
boost_hash_combine(seed, c.x);
boost_hash_combine(seed, c.y);
boost_hash_combine(seed, c.rack);
boost_hash_combine(seed, c.shelf);
return seed;
}
};
Expand Down
1 change: 0 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ target_link_libraries(
gtest
pthread
fmt::fmt-header-only
Boost::container_hash
)
target_include_directories(
test_common
Expand Down

0 comments on commit 6cf3bb0

Please sign in to comment.