-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SFPU binary bitwise, int32 add, div
- Loading branch information
Showing
4 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include "ckernel.h" | ||
#include "ckernel_defs.h" | ||
#include "noc_nonblocking_api.h" | ||
#include "sfpi.h" | ||
#include <limits.h> | ||
|
||
using namespace sfpi; | ||
|
||
namespace ckernel | ||
{ | ||
namespace sfpu | ||
{ | ||
|
||
enum { | ||
AND_BINARY = 0, | ||
OR_BINARY = 1, | ||
XOR_BINARY = 2, | ||
}; // BITWISE_MODE | ||
|
||
template <bool APPROXIMATION_MODE, int BITWISE_MODE, int ITERATIONS = 8> | ||
inline void _calculate_sfpu_binary_bitwise_(const uint dst_offset) | ||
{ | ||
// SFPU microcode | ||
for (int d = 0; d < ITERATIONS; d++) { | ||
constexpr uint dst_tile_size = 64; | ||
|
||
TTI_SFPLOAD(0,12,ADDR_MOD_7,0); | ||
TT_SFPLOAD(1,12,ADDR_MOD_7,dst_offset*dst_tile_size); | ||
|
||
if constexpr (BITWISE_MODE == AND_BINARY) { | ||
TTI_SFPAND(0,1,0,0); | ||
} else if constexpr (BITWISE_MODE == OR_BINARY) { | ||
TTI_SFPOR(0,1,0,0); | ||
} else if constexpr (BITWISE_MODE == XOR_BINARY) { | ||
TTI_SFPXOR(0,1,0,0); | ||
} | ||
|
||
TTI_SFPSTORE(0,12,ADDR_MOD_7,0); | ||
dst_reg++; | ||
} | ||
} | ||
|
||
} // namespace sfpu | ||
} // namespace ckernel |