Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect odd parity calculation in control packet header #1122

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module attributes {hal.executable.target = #executable_target_amdaie_xclbin_fb}

// -----

// CHECK: 0x80032000
// CHECK: 0x00032000
// CHECK: 0x00000000
// CHECK-LABEL: @write_one_word_data
// CHECK: %[[C0:.*]] = arith.constant 0 : index
Expand Down Expand Up @@ -130,94 +130,94 @@ module attributes {hal.executable.target = #executable_target_amdaie_xclbin_fb}
%1 = amdaie.logicalobjectfifo.placeholder{%tile_0_2} : !amdaie.logicalobjectfifo<memref<?xi32>>
%2 = amdaie.connection(%1 {%channel_0}, %0 {%channel}) {connection_type = #amdaie<connection_type Packet>} : (!amdaie.logicalobjectfifo<memref<?xi32>>, !amdaie.logicalobjectfifo<memref<?xi32>>)
amdaie.controlcode {
// CHECK: 0x80032000
// CHECK: 0x00032000
// CHECK: 0x00000000
amdaie.npu.control_packet write {address = 2301952 : ui32, data = array<i32: 0>, length = 1 : ui32, stream_id = 0 : ui32}
// CHECK: 0x0001DE10
// CHECK: 0x8001DE10
// CHECK: 0x00000002
amdaie.npu.control_packet write {address = 2219536 : ui32, data = array<i32: 2>, length = 1 : ui32, stream_id = 0 : ui32}
// CHECK: 0x8001DE18
// CHECK: 0x0001DE18
// CHECK: 0x00000002
amdaie.npu.control_packet write {address = 2219544 : ui32, data = array<i32: 2>, length = 1 : ui32, stream_id = 0 : ui32}
// CHECK: 0x8001DE00
// CHECK: 0x0001DE00
// CHECK: 0x00000002
amdaie.npu.control_packet write {address = 2219520 : ui32, data = array<i32: 2>, length = 1 : ui32, stream_id = 0 : ui32}
// CHECK: 0x0001DE08
// CHECK: 0x8001DE08
// CHECK: 0x00000002
amdaie.npu.control_packet write {address = 2219528 : ui32, data = array<i32: 2>, length = 1 : ui32, stream_id = 0 : ui32}
// CHECK: 0x80320000
// CHECK: 0x00320000
// CHECK: 0x20000115
// CHECK: 0x00550000
// CHECK: 0x00070CE0
// CHECK: 0x00010001
amdaie.npu.control_packet write {address = 2228224 : ui32, data = array<i32: 536871189, 5570560, 462048, 65537>, length = 4 : ui32, stream_id = 0 : ui32}
// CHECK: 0x00320010
// CHECK: 0x80320010
// CHECK: 0x00010001
// CHECK: 0x00038837
// CHECK: 0x00000000
// CHECK: 0x00000000
amdaie.npu.control_packet write {address = 2228240 : ui32, data = array<i32: 65537, 231479, 0, 0>, length = 4 : ui32, stream_id = 0 : ui32}
// CHECK: 0x00320020
// CHECK: 0x80320020
// CHECK: 0x000388B7
// CHECK: 0x000000C0
// CHECK: 0x00000000
// CHECK: 0x00010001
amdaie.npu.control_packet write {address = 2228256 : ui32, data = array<i32: 231607, 192, 0, 65537>, length = 4 : ui32, stream_id = 0 : ui32}
// CHECK: 0x80320030
// CHECK: 0x00320030
// CHECK: 0x180010BB
// CHECK: 0x080001C0
// CHECK: 0x80190000
// CHECK: 0x00010802
amdaie.npu.control_packet write {address = 2228272 : ui32, data = array<i32: 402657467, 134218176, -2145845248, 67586>, length = 4 : ui32, stream_id = 0 : ui32}
// CHECK: 0x00320040
// CHECK: 0x80320040
// CHECK: 0x10000115
// CHECK: 0x20190000
// CHECK: 0x7E993803
// CHECK: 0xC2990FFC
amdaie.npu.control_packet write {address = 2228288 : ui32, data = array<i32: 268435733, 538509312, 2123970563, -1030156292>, length = 4 : ui32, stream_id = 0 : ui32}
// CHECK: 0x80320050
// CHECK: 0x00320050
// CHECK: 0xF6590FFC
// CHECK: 0x48BB1F3C
// CHECK: 0x10081803
// CHECK: 0xFFC67000
amdaie.npu.control_packet write {address = 2228304 : ui32, data = array<i32: -161935364, 1220222780, 268965891, -3772416>, length = 4 : ui32, stream_id = 0 : ui32}
// CHECK: 0x80320060
// CHECK: 0x00320060
// CHECK: 0x10000819
// CHECK: 0x00010001
// CHECK: 0x00010001
// CHECK: 0xC2D90001
amdaie.npu.control_packet write {address = 2228320 : ui32, data = array<i32: 268437529, 65537, 65537, -1025966079>, length = 4 : ui32, stream_id = 0 : ui32}
// CHECK: 0x00320070
// CHECK: 0x80320070
// CHECK: 0x000107FC
// CHECK: 0x00010001
// CHECK: 0x00010001
// CHECK: 0x07FC7ED9
amdaie.npu.control_packet write {address = 2228336 : ui32, data = array<i32: 67580, 65537, 65537, 133988057>, length = 4 : ui32, stream_id = 0 : ui32}
// CHECK: 0x00320080
// CHECK: 0x80320080
// CHECK: 0x10001819
// CHECK: 0x00010001
// CHECK: 0x00010001
// CHECK: 0x3FFFE019
amdaie.npu.control_packet write {address = 2228352 : ui32, data = array<i32: 268441625, 65537, 65537, 1073733657>, length = 4 : ui32, stream_id = 0 : ui32}
// CHECK: 0x0001DE10
// CHECK: 0x8001DE10
// CHECK: 0x00000000
amdaie.npu.control_packet write {address = 2219536 : ui32, data = array<i32: 0>, length = 1 : ui32, stream_id = 0 : ui32}
// CHECK: 0x8001DE18
// CHECK: 0x0001DE18
// CHECK: 0x00000000
amdaie.npu.control_packet write {address = 2219544 : ui32, data = array<i32: 0>, length = 1 : ui32, stream_id = 0 : ui32}
// CHECK: 0x8001DE00
// CHECK: 0x0001DE00
// CHECK: 0x00000000
amdaie.npu.control_packet write {address = 2219520 : ui32, data = array<i32: 0>, length = 1 : ui32, stream_id = 0 : ui32}
// CHECK: 0x0001DE08
// CHECK: 0x8001DE08
// CHECK: 0x00000000
amdaie.npu.control_packet write {address = 2219528 : ui32, data = array<i32: 0>, length = 1 : ui32, stream_id = 0 : ui32}
// CHECK: 0x80032000
// CHECK: 0x00032000
// CHECK: 0x00000002
amdaie.npu.control_packet write {address = 2301952 : ui32, data = array<i32: 2>, length = 1 : ui32, stream_id = 0 : ui32}
// CHECK: 0x80032000
// CHECK: 0x00032000
// CHECK: 0x00000000
amdaie.npu.control_packet write {address = 2301952 : ui32, data = array<i32: 0>, length = 1 : ui32, stream_id = 0 : ui32}
// CHECK: 0x80032000
// CHECK: 0x00032000
// CHECK: 0x00000001
amdaie.npu.control_packet write {address = 2301952 : ui32, data = array<i32: 1>, length = 1 : ui32, stream_id = 0 : ui32}
amdaie.end
Expand Down
6 changes: 4 additions & 2 deletions runtime/src/iree-amd-aie/aie_runtime/iree_aie_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,10 @@ FailureOr<uint32_t> AMDAIEDeviceModel::getCtrlPktHeader(
(address << ctrlPktHeaderFormat.addressShift);
// Mask to keep the lower 31 bits (bits 30:0).
uint32_t lower31Bits = header & 0x7FFFFFFF;
// Compute the odd parity bit (1 if the count of 1's is odd, 0 if even).
uint32_t parity = llvm::popcount(lower31Bits) % 2;
// Compute the odd parity bit. It is set to 1 if the number of 1's in
// lower31Bits is even, ensuring the total count (including this bit) becomes
// odd. Otherwise, it is set to 0.
uint32_t parity = (llvm::popcount(lower31Bits) + 1) % 2;
// Set the parity bit in the most significant bit (bit 31).
return (parity << 31) | lower31Bits;
}
Expand Down
Loading