Skip to content

Commit

Permalink
#0: Add support for hashing global cbs, sems
Browse files Browse the repository at this point in the history
  • Loading branch information
tt-aho committed Dec 10, 2024
1 parent d4109d1 commit eb27fd7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tt_metal/impl/buffers/global_circular_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,12 @@ uint32_t GlobalCircularBuffer::size() const { return this->size_; }
} // namespace v1

} // namespace tt::tt_metal

namespace std {

std::size_t hash<tt::tt_metal::v1::experimental::GlobalCircularBuffer>::operator()(
const tt::tt_metal::v1::experimental::GlobalCircularBuffer& global_circular_buffer) const {
return tt::stl::hash::hash_objects_with_default_seed(global_circular_buffer);
}

} // namespace std
9 changes: 9 additions & 0 deletions tt_metal/impl/buffers/global_circular_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,12 @@ class GlobalCircularBuffer {
} // namespace v1

} // namespace tt::tt_metal

namespace std {

template <>
struct hash<tt::tt_metal::v1::experimental::GlobalCircularBuffer> {
std::size_t operator()(const tt::tt_metal::v1::experimental::GlobalCircularBuffer& global_circular_buffer) const;
};

} // namespace std
9 changes: 9 additions & 0 deletions tt_metal/impl/buffers/global_semaphore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,12 @@ void GlobalSemaphore::reset_semaphore_value() {
}

} // namespace tt::tt_metal

namespace std {

std::size_t hash<tt::tt_metal::GlobalSemaphore>::operator()(
const tt::tt_metal::GlobalSemaphore& global_semaphore) const {
return tt::stl::hash::hash_objects_with_default_seed(global_semaphore);
}

} // namespace std
12 changes: 12 additions & 0 deletions tt_metal/impl/buffers/global_semaphore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class GlobalSemaphore {

void reset_semaphore_value();

static constexpr auto attribute_names = std::forward_as_tuple("cores", "initial_value");
const auto attribute_values() const { return std::make_tuple(this->cores_, this->initial_value_); }

private:
void setup_buffer(BufferType buffer_type);

Expand All @@ -59,3 +62,12 @@ class GlobalSemaphore {
} // namespace v0

} // namespace tt::tt_metal

namespace std {

template <>
struct hash<tt::tt_metal::GlobalSemaphore> {
std::size_t operator()(const tt::tt_metal::GlobalSemaphore& global_semaphore) const;
};

} // namespace std

0 comments on commit eb27fd7

Please sign in to comment.