Skip to content

Commit

Permalink
Enable UInt8 math (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdjogoTT authored Aug 2, 2024
1 parent 136f561 commit 545b798
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion common/inc/cpack_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ namespace ckernel::packer
(pack_output_src_format == (uint)DataFormat::Int32) |
(pack_output_src_format == (uint)DataFormat::Float32) |
(is_fp32_dest_acc_en ? 1 : 0);
if (pack_dst_format == (uint)DataFormat::UInt8) {
dest_rd_ctrl.f.PCK_DEST_RD_CTRL_Read_unsigned = 1;
}

//Round to 10 bit mantissa from fp32 dest
if(is_fp32_dest_acc_en && (pack_output_src_format == (uint)DataFormat::Float16)) {
Expand Down Expand Up @@ -349,7 +352,7 @@ namespace ckernel::packer

t6_mutex_release(mutex::REG_RMW);

set_packer_config<is_fp32_dest_acc_en>(pack_output_src_format, pack_output_dst_format, num_faces, partial_face);
set_packer_config<is_fp32_dest_acc_en>(pack_src_format, pack_dst_format, num_faces, partial_face);

// PACK_COUNTERS_SEC0_pack_per_xy_plane = cfg_reg_array[3][0 +: 8];
// PACK_COUNTERS_SEC0_pack_reads_per_xy_plane = cfg_reg_array[3][8 +: 8];
Expand Down
10 changes: 9 additions & 1 deletion common/inc/cunpack_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,18 @@ namespace ckernel::unpacker
((uint)unpA_dst_format_masked == (uint)DataFormat::Int32) ||
((uint)unpB_dst_format_masked == (uint)DataFormat::Int32);

constexpr uint alu_format_mask = ALU_FORMAT_SPEC_REG0_SrcA_MASK | ALU_FORMAT_SPEC_REG1_SrcB_MASK;
constexpr uint alu_format_mask = ALU_FORMAT_SPEC_REG0_SrcA_MASK | ALU_FORMAT_SPEC_REG1_SrcB_MASK |
ALU_FORMAT_SPEC_REG0_SrcAUnsigned_MASK | ALU_FORMAT_SPEC_REG0_SrcBUnsigned_MASK;
alu_payload.f.ALU_FORMAT_SPEC_REG0_SrcA = unpA_dst_format_masked;
alu_payload.f.ALU_FORMAT_SPEC_REG1_SrcB = row_pool ? ((uint) DataFormat::Float16 | (exp_width<<2)) : unpB_dst_format_masked;

if ((uint)unpA_src_format == (uint)DataFormat::UInt8) {
alu_payload.f.ALU_FORMAT_SPEC_REG0_SrcAUnsigned = 1;
}
if ((uint)unpB_src_format == (uint)DataFormat::UInt8) {
alu_payload.f.ALU_FORMAT_SPEC_REG0_SrcBUnsigned = 1;
}

// FP32 accumulation and SFPU to read dest as FP32
// NOTE: This assumes these config fields are adjacent and in same register!!
static_assert(ALU_ACC_CTRL_Fp32_enabled_ADDR32 == ALU_FORMAT_SPEC_REG0_SrcA_ADDR32);
Expand Down

0 comments on commit 545b798

Please sign in to comment.