-
Notifications
You must be signed in to change notification settings - Fork 20
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
Full SME(1) instruction support and STREAMING Groups #415
base: dev
Are you sure you want to change the base?
Conversation
#rerun tests |
531ebd0
to
7974237
Compare
CHECK_MAT_COL(ARM64_REG_ZAS3, i, uint32_t, | ||
fillNeon<uint32_t>(inter32, (SVL / 8))); | ||
} else { | ||
// Even cols, all elements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Odd cols?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several occurrences of the possible same issue throughout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, throughout the test file some SME tests use the same predicate patterns. Two predicates are always used: p0
and p1
.
p0
is always set to all true usingptrue p0.d
(for example)p1
is always set to the pattern {ON, OFF, ON, OFF...} usingzip1 p1.s, p0.s, p1.s
(for example)
Hence, when using p1
as the predicate the rows, columns, or individual elements per row/col updated will always be even ones. This should also be reflected in the test initialisation with inter32[i] = (i % 2 == 0) ? i : 65;
where only the even vector elements are set to increasing values, and odd values to the test-default of 66.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what does i
represent here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i
is the row or column element index (i.e. from something like int i = 0; i < sliceElements; i++
with sliceElements
sometimes fixed to a constant representing the number of elements for the max SVL of 2048-bits) depending on if the Horizontal or Vertical instruction variant is being used.
So in the above, if i
is even (index 0, 2, 4 etc) then the row/column element is set to i
to reflect the use of index z1.s, #0, #1
in the test. If i
is odd then the value remains unchanged; for this test a value of 65
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy, but leaving for @jj16791 to resolve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments and I agree with several of Alex's comments. I think it would be good to get the ARM SME/SVE loops as part of our functional verification checks to help test these new instructions. I assume it would have to be done somewhere private though (not sure if we already have that guarantee in the upcoming CI/CD pipelines)?
@@ -188,6 +188,20 @@ uint8_t Architecture::predecode(const uint8_t* ptr, uint16_t bytesAvailable, | |||
newInsn.setExecutionInfo(getExecutionInfo(newInsn)); | |||
// Cache the instruction | |||
iter = decodeCache_.insert({insn, newInsn}).first; | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no data on this but doing this process for every AArch64 instruction may have a detrimental effect on performance. Will need to run through the new CI/CD when it's ready to determine this. Would argue that such a change shouldn't be merged until we know there's no significant performance regression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For non Predicate / SVE instructions the overhead is 3 if statements and a function call which should be minor. But yes, a performance regression test for this would be good.
Not sure on what an alternative solution could be though if the performance impact is significant...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave this comment unresolved so we remember to look into this
@@ -568,9 +568,14 @@ RegisterValue vecUMaxP(srcValContainer& sourceValues) { | |||
const T* n = sourceValues[0].getAsVector<T>(); | |||
const T* m = sourceValues[1].getAsVector<T>(); | |||
|
|||
// Concatenate the vectors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you double-checked the ordering of the concatenation? Ran it on ookami and I think these may be the wrong way round but worth double checking in case I've made a mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per the spec:
This instruction creates a vector by concatenating the vector elements of the first source SIMD&FP register after the vector elements of the second source SIMD&FP register...
i.e. N is concatonated onto the end of M (M:N)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think with "what the spec says" vs "observed values", the latter should probably be taken as the truth. So it's worth someone else double-checking that the values I've observed do go against what the spec says
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very odd and confusing... I've also checked on Ookami and Isambard-AI with the following asm programme:
movi v0.16b, #0
movi v1.16b, #1
movi v2.16b, #2
umaxp v0.16b, v1.16b, v2.16b
mov w12, v0.s[0]
mov w13, v0.s[3]
Which after executing yields the following:
v0.b
={1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2}
v0.s
={16843009, 16843009, 33686018, 33686018}
Which means the concatonation is v1:v2
, NOT v2:v1
.
I double checked that gdb doesn't display vector registers "in reverse" (i.e. left-hand most element is in fact v0[0]
and not v0[15]
) using the final two instructions. Their results were:
w12
= 16843009w13
= 33686018
So yes, on hardware the concatonation is seemingly vn:vm
.
However, the spec and its pseudo code for UMAXP
doesn't align with this... From this page, the pseudo code is as follows:
CheckFPAdvSIMDEnabled64();
constant bits(datasize) operand1 = V[n, datasize];
constant bits(datasize) operand2 = V[m, datasize];
bits(datasize) result;
constant bits(2*datasize) concat = operand2:operand1;
integer element1;
integer element2;
integer max;
for e = 0 to elements-1
element1 = UInt(Elem[concat, 2*e, esize]);
element2 = UInt(Elem[concat, (2*e)+1, esize]);
max = Max(element1, element2);
Elem[result, e, esize] = max<esize-1:0>;
V[d, datasize] = result;
Where it is clear that the concatonation according to this is vm:vn
....
In this instance, we should probably go with hardware. But it is quite annoying that the spec doesn't align with hardware on this, and that updating our code in-line with the spec still fixed the issue that was occuring!
CHECK_MAT_COL(ARM64_REG_ZAS3, i, uint32_t, | ||
fillNeon<uint32_t>(inter32, (SVL / 8))); | ||
} else { | ||
// Even cols, all elements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several occurrences of the possible same issue throughout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't finished the review but posting comments to prevent overlaps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOOTS of new instructions, well done for grinding through them. Bring on SAIL
// Identify subgroup type | ||
if (isInstruction(InsnType::isBranch)) | ||
group = InstructionGroups::BRANCH; | ||
else if (isInstruction(InsnType::isLoad)) | ||
group += 8; | ||
else if (isInstruction(InsnType::isStore)) | ||
group += 9; | ||
else if (isInstruction(InsnType::isDivide)) | ||
group += 7; | ||
else if (isInstruction(InsnType::isMultiply)) | ||
group += 6; | ||
else if (isInstruction(InsnType::isShift) || | ||
isInstruction(InsnType::isConvert)) | ||
group += 5; | ||
else if (isInstruction(InsnType::isLogical)) | ||
group += 4; | ||
else if (isInstruction(InsnType::isCompare)) | ||
group += 3; | ||
else | ||
group += 2; // Default return is {Data type}_SIMPLE_ARTH | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a switch statement on instructionIdentifier
not be viable? Would be slightly nicer to read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't this a switch would work here, or would decrease readability if it did. instructionIdentifier
is just an uint32_t
and so the associated value used in the switch has no meaning. With the current implementation the if
clause contains what is being checked against (i.e. isMultiply
)
} | ||
results_[row] = {outRow, 256}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be misremembering but I think we said we would stop using this implicit registerValue initialisation in favour of an explicit one. If that is the case this should be updated throughout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. results_[row] = RegisterValue(outRow, 256)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 158 instances of using {...}
to initialise a RegisterValue. Possibly more if they contain a line break due to a long-names helper function being used.
If this is something we want to move away from then I think it should be a seperate PR, and the {...}
constructor should be prohibited for this class (if possible)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate PR is sensible. Something to discuss as a team when we next meet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To add to this, there will also be 10s-100s of extra uses inside helper functions and possibly RV64 also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a problem in RV as I was requested not to use full explicit initialisation. Although it was in a worse state 5a1652f
This isn't a big deal, would just be nice to have a consistent style
memoryData_[index] = | ||
RegisterValue((char*)mdata.data(), md_size * 4); | ||
md_size = 0; | ||
RegisterValue((char*)memData.data(), memData.size() * 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sizeof(uint32_t)
might be better than 4
but not that important. Applied throughout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, if this is something we want to enforce then it should be its own PR as this occurs extremely often in this file. An instruction's opcode defines the data type used so we know what the multiplicand should be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar also occurs in instruction_address
4ad3b6e
to
aa40d88
Compare
…e instruction group to STREAMING if SM mode is different to when instruction was first decoded.
…ssion test (B, H, S, D)
…ion test (B, H, S, D)
…n alias and regression tests (B, H, S, D)
…uctions and aliases and regression tests (B, H, S, D)
…regression tests.
91c4336
to
5945bae
Compare
This PR implements all available SME (version 1) instructions that are contained within LLVM 14.0.5. Specifically, this is Version 2021-06 of the Armv9-A A64 ISA.
No FP16 or BF16 instructions have been supported due to lacking C++17 types. All Quad-Word instruction variants have been emulated using 64-bit data-types.
In addition to this, new STREAMING_SVE and STREAMING_PREDICATE groups have been introduced (along with corresponding decode logic) to allow for a different pipeline / latency configuration for these instructions when SVE Streaming Mode (the context mode which SME instructions are executed in) is enabled. This can allow for a co-processor style implementation of SME to be implemented within SimEng; with additional latency / reduced throughput being configured to mimic an offload penalty, and different execution or LD/STR hardware being modelled for said co-processor compared to the main core.