Skip to content

Commit

Permalink
#0: addressing austin PR review changes on 15572 PR
Browse files Browse the repository at this point in the history
  • Loading branch information
jvegaTT committed Dec 4, 2024
1 parent 66a28c1 commit 0e411b0
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions ttnn/cpp/ttnn/operations/data_movement/common/kernels/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@

namespace tt::data_movement::common {

#define max_packet_size 8192

template <uint32_t max_transfer_size, bool only_reads>
FORCE_INLINE void enhanced_noc_async_read(
const uint64_t src_noc_addr, const uint32_t dst_l1_addr, const uint32_t bytes) {
// If you do not know the max_transfer_size at compile time write 0 to it.
// only reads is true if we ONLY use noc_async_read and all calls to tt_memmove have use_read_datamover as True
if constexpr (((max_transfer_size < max_packet_size) && (max_transfer_size != 0)) || only_reads) {
if constexpr (((max_transfer_size < NOC_MAX_BURST_SIZE) && (max_transfer_size != 0)) || only_reads) {
noc_async_read_one_packet(src_noc_addr, dst_l1_addr, bytes);
} else {
noc_async_read(src_noc_addr, dst_l1_addr, bytes);
Expand All @@ -34,21 +32,22 @@ FORCE_INLINE void enhanced_noc_async_write(
const uint32_t src_l1_addr, const uint64_t dst_noc_addr, const uint32_t bytes) {
// If you do not know the max_transfer_size at compile time write 0 to it.
// only writes is true if we ONLY use noc_async_read and all calls to tt_memmove have use_read_datamover as False
if constexpr (((max_transfer_size < max_packet_size) && (max_transfer_size != 0)) || only_writes) {
if constexpr (((max_transfer_size < NOC_MAX_BURST_SIZE) && (max_transfer_size != 0)) || only_writes) {
noc_async_write_one_packet(src_l1_addr, dst_noc_addr, bytes);
} else {
noc_async_write(src_l1_addr, dst_noc_addr, bytes);
}
}

template <bool guaranteed_16B_alligned, bool copy_async, bool use_read_datamover, uint32_t max_transfer_size>
template <bool guaranteed_16B_aligned, bool copy_async, bool use_read_datamover, uint32_t max_transfer_size>
FORCE_INLINE void tt_memmove(const uint32_t dst_l1_addr, const uint32_t src_l1_addr, const uint32_t bytes) {
//Function performs a memory copy between two l1 addresses in the local core
//Uses noc_async_read when possible to copy the data over
//Set guaranteed 16B alligned to true if the source and destination are externally guaranteed to be 16B alligned (dangerous)
//Set copy_async to true if you wish to perform the operation asynchronously, in this case you can add a noc_async_read_barrier to synchronize later
// Function performs a memory copy between two l1 addresses in the local core
// Uses noc_async_read when possible to copy the data over
// Set guaranteed 16B aligned to true if the source and destination are externally guaranteed to be 16B aligned
// (dangerous) Set copy_async to true if you wish to perform the operation asynchronously, in this case you can add
// a noc_async_read_barrier to synchronize later
if constexpr (use_read_datamover) {
if constexpr (guaranteed_16B_alligned) {
if constexpr (guaranteed_16B_aligned) {
enhanced_noc_async_read<max_transfer_size, false>(get_noc_addr(src_l1_addr), dst_l1_addr, bytes);
if constexpr (!copy_async) {
noc_async_read_barrier();
Expand All @@ -64,7 +63,7 @@ FORCE_INLINE void tt_memmove(const uint32_t dst_l1_addr, const uint32_t src_l1_a
}
}
} else {
if constexpr (guaranteed_16B_alligned) {
if constexpr (guaranteed_16B_aligned) {
enhanced_noc_async_write<max_transfer_size, false>(src_l1_addr, get_noc_addr(dst_l1_addr), bytes);
if constexpr (!copy_async) {
noc_async_write_barrier();
Expand Down

0 comments on commit 0e411b0

Please sign in to comment.