Repository navigation
Implement new vector types - #6353
Conversation
|
@0xdaryl @jdmpapin @Leonardo2718 @mstoodle @vijaysun-omr could you please review the common part? |
- see eclipse-omr/omr#6353 for the background - to enable VectorAPI support, VectorAPIExpansion::supportedOnPlatform needs to be modified correspondingly - to enable specific opcode getSupportsOpCodeForAutoSIMD needs to be modified correspondingly
b9d2695 to
76c0201
Compare
|
Updated commit message with a link to openj9 PR. |
|
Looking at macOS failures... |
76c0201 to
f4bc9ca
Compare
|
Fixed a typo which somehow only showed up in macOS build. |
|
The changes in the aarch64 code look good to me. |
| switch(node->getDataType().getVectorElementType()) | ||
| { | ||
| case TR::VectorInt8: | ||
| case TR::Int8: |
There was a problem hiding this comment.
The original code does not accept element types other than 8-bit integer, but there is no reason not to accept other integer types. Same for other logical bitwise operations (vor, vxor and vnot).
There was a problem hiding this comment.
Thanks for noticing! But I was thinking maybe we can limit this PR to only enabling new style vector types and preserve all the current functionality? We could open a separate issue to extend this particular code.
There was a problem hiding this comment.
I agree. I will extend those evaluators once this PR gets merged.
|
|
||
| bool | ||
| OMR::X86::CodeGenerator::getSupportsOpCodeForAutoSIMD(TR::ILOpCode opcode, TR::DataType dt) | ||
| OMR::X86::CodeGenerator::getSupportsOpCodeForAutoSIMD(TR::ILOpCode opcode, TR::DataType dt, int32_t length) |
There was a problem hiding this comment.
Shouldn't this accept VectorLength
There was a problem hiding this comment.
Yes, I agree. It would be better to accept VectorLength. I will change.
There was a problem hiding this comment.
Pushed commit with this change.
| @@ -4069,15 +4069,23 @@ static const TR::InstOpCode::Mnemonic BinaryArithmeticOpCodesForReg[TR::NumOMRTy | |||
| { TR::InstOpCode::bad, TR::InstOpCode::ADDSSRegReg, TR::InstOpCode::SUBSSRegReg, TR::InstOpCode::MULSSRegReg, TR::InstOpCode::DIVSSRegReg, TR::InstOpCode::bad, TR::InstOpCode::bad, TR::InstOpCode::bad }, // Float | |||
There was a problem hiding this comment.
These tables only have entries for float & double, perhaps this can be simplified.
There was a problem hiding this comment.
Sure, but is it ok if we open another PR? I would like to minimize changes in this PR and make sure nothing is functionally broken. The main danger is that if I missed some table or some other place that needs to be changed...
There was a problem hiding this comment.
Sure, I suppose that can wait
| bool OMR::Z::CodeGenerator::getSupportsOpCodeForAutoSIMD(TR::ILOpCode opcode, TR::DataType dt) | ||
| bool OMR::Z::CodeGenerator::getSupportsOpCodeForAutoSIMD(TR::ILOpCode opcode, TR::DataType dt, int32_t length) | ||
| { | ||
| if(length != 128) return false; |
There was a problem hiding this comment.
Pushed commit with this change.
| // TODO: exclude Float? | ||
| indexInArgRegistersArray = numVectorArgs; | ||
| argRegNum = getVectorArgumentRegister(indexInArgRegistersArray); | ||
| numVectorArgs ++; |
|
Jenkins build all Just running jenkins to smoke out any obvious failures or build issues. |
|
Jenkins build win |
|
Started 'win' test since there seemed to be environment failures. |
| if (paramCursor->getDataType().isVector()) | ||
| { | ||
| lri = numVRFArgs; | ||
| // TODO: exclude Float? |
There was a problem hiding this comment.
~Can you elaborate TODO bit more here? ~ NVM, I see your point. I have put TODO in #6353 (comment) to verify this.
There was a problem hiding this comment.
Right, please let me know what I should do in this PR.
There was a problem hiding this comment.
Will preserve current VectorFloat behavior with next push.
| generateVRScInstruction(cg, TR::InstOpCode::VLGV, node, returnReg, vectorReg, memRef, getVectorElementSizeMask(vectorChild)); | ||
|
|
||
| TR::DataType dt = vectorChild->getDataType(); | ||
| TR_ASSERT_FATAL_WITH_NODE(node, vectorChild->getDataType().getVectorLength() == TR::VectorLength128, |
There was a problem hiding this comment.
Should we move this Assert at the beginning of the function? Or at-least before using vectorChild togetVectorElementSizeMask?
There was a problem hiding this comment.
Sure, I will improve it after you finish your review. Thanks a lot!
There was a problem hiding this comment.
Will be fixed in next push.
| // if the FloatMAF option is not set and the node is not FP strict, we can't generate FMA operations | ||
| if ((addNode->getType().isFloatingPoint() || TR::VectorFloat == addNode->getType() || TR::VectorDouble == addNode->getType()) | ||
| if ((addNode->getType().isFloatingPoint() || | ||
| (addNode->getType().isVector() && TR::Float == addNode->getType().getVectorElementType()) || |
There was a problem hiding this comment.
Can we common out the addNode->getType().isVector() query?
| { | ||
| TR::DataType elementType = resDataType.getVectorElementType(); | ||
| if (elementType == TR::Int8 || elementType == TR::Int16 || | ||
| elementType == TR::Int32 || elementType == TR::Int64 || elementType == TR::Double) |
There was a problem hiding this comment.
I am trying to understand why we have omitted FloatVector originally from having in arguments (Probably as short and extended format support for Vector instructions were added later in to the architecture).
I am adding a TODO for myself here to double check and will confirm if that is the case, we might be able to remove check for element type here.
There was a problem hiding this comment.
Thanks! In some case above I already treat VectorFloat as all other vector types. Please let me know if should revert that.
There was a problem hiding this comment.
@r30shah just a reminder to let me know how to treat VectorFloat in Z linkages.
There was a problem hiding this comment.
Please NVM. I will preserve current behavior.
There was a problem hiding this comment.
Will preserve current behavior.
- see eclipse-omr/omr#6353 for the background - to enable VectorAPI support, VectorAPIExpansion::supportedOnPlatform needs to be modified correspondingly - to enable specific opcode getSupportsOpCodeForAutoSIMD needs to be modified correspondingly
0xdaryl
left a comment
There was a problem hiding this comment.
I did a quick one-pass review just to get a sense of the scope of these changes. I'll push out some initial comments now, but I do want to review this again in more detail.
| case TR::Int32: | ||
| case TR::Int64: return self()->getDataType(); | ||
| case TR::Float: return TR::DataType::createVectorType(TR::Int32, self()->getVectorLength()); | ||
| case TR::Double: return TR::DataType::createVectorType(TR::Int64, self()->getVectorLength()); |
There was a problem hiding this comment.
Why is this necessary only for float and double element types?
There was a problem hiding this comment.
I am not sure who uses this method but that's what it did originally: returned integral type of the same element size as the input type.
There was a problem hiding this comment.
If all vector element types are equally valid then this seems wrong to me. At the very least it should be understood why we can't simply return "self()->getDataType()" like the other element types rather than accepting that what's there now is correct.
| { | ||
| if (OMRDataTypeNames[dt] == NULL) | ||
| { | ||
| char *name = (char*) calloc(20, sizeof(char)); |
There was a problem hiding this comment.
Memory leak. Allocate from a region that will eventually be reclaimed rather than the global allocator.
There was a problem hiding this comment.
The names are cached in a static table so I think should be created only once per JIT execution.
There was a problem hiding this comment.
My main concern is with the use of calloc and not the fact that these are stored in a static table (in fact that re-use is encouraged). If these names will persist across compilations then they should be allocated with the persistent allocator and not the global allocator.
There was a problem hiding this comment.
Right. Changed to jitPersistentAlloc and solved potential race condition (in the next push)
| if (OMRDataTypeNames[dt] == NULL) | ||
| { | ||
| char *name = (char*) calloc(20, sizeof(char)); | ||
| sprintf(name, "Vector%d%s", getSize(dt)*8, getName(dt.getVectorElementType())); |
There was a problem hiding this comment.
You should be defensive against buffer overflows and use snprintf instead.
| VectorLength128, | ||
| VectorLength256, | ||
| VectorLength512, | ||
| VectorLength64, |
There was a problem hiding this comment.
Why aren't these vector lengths in order? i.e., put 64 first.
There was a problem hiding this comment.
oh, is it because of the need to set NumVectorLengths?
There was a problem hiding this comment.
Yes, I put most commonly used lengths first.
There was a problem hiding this comment.
From a code readability POV, my opinion is to order them by increasing length.
| NumOMRTypes, | ||
| #include "il/DataTypesEnum.hpp" | ||
| NumTypes | ||
| NumNonVectorTypes, |
There was a problem hiding this comment.
"Scalar" is a more conventional term to use here than "NonVector"
There was a problem hiding this comment.
I wanted to bring attention to the existence of the new vector types. But we can rename to scalar if that's more preferable.
There was a problem hiding this comment.
"Scalar" is the more preferable term to me. Others may have different opinions.
There was a problem hiding this comment.
Sure. Will make the change soon.
| { | ||
| TR_ASSERT_FATAL(isVector(), "getVectorElementType() is called on non-vector type\n"); | ||
|
|
||
| return (TR::DataTypes)((_type - TR::NumNonVectorTypes) % TR::NumVectorElementTypes + 1); |
There was a problem hiding this comment.
Please use static_cast rather than the C-style cast.
| } | ||
|
|
||
| TR_ASSERT(node->getDataType() == TR::VectorDouble, "unsupported splats type"); | ||
| TR_ASSERT(node->getDataType().getVectorElementType() == TR::Double, "unsupported splats type"); |
There was a problem hiding this comment.
May as well make this a fatal assert.
There was a problem hiding this comment.
I would like to keep functional changes to the minimum in this PR. It was not FATAL assert before and I just mapped old interface into the equivalent new one.
|
|
||
|
|
||
| bool OMR::Power::CodeGenerator::getSupportsOpCodeForAutoSIMD(TR::ILOpCode opcode, TR::DataType dt) | ||
| bool OMR::Power::CodeGenerator::getSupportsOpCodeForAutoSIMD(TR::ILOpCode opcode, TR::DataType dt, int32_t length) |
There was a problem hiding this comment.
Shouldn't the length parameter be a TR::VectorLength ? That's how you defined it elsewhere.
There was a problem hiding this comment.
That was already changed.
| virtual bool isDispInRange(int64_t disp); | ||
|
|
||
| bool getSupportsOpCodeForAutoSIMD(TR::ILOpCode, TR::DataType); | ||
| bool getSupportsOpCodeForAutoSIMD(TR::ILOpCode, TR::DataType, int32_t); |
There was a problem hiding this comment.
length should be TR::VectorLength
| void setSupportsAutoSIMD() { _flags4.set(SupportsAutoSIMD);} | ||
|
|
||
| bool getSupportsOpCodeForAutoSIMD(TR::ILOpCode, TR::DataType) { return false; } | ||
| bool getSupportsOpCodeForAutoSIMD(TR::ILOpCode, TR::DataType, int32_t) { return false; } |
There was a problem hiding this comment.
length should be TR::VectorLength ?
d90bb66 to
b950fc6
Compare
|
Addressed most of the comments and squashed. Please resolve or respond to my comments. |
b950fc6 to
0a0dcad
Compare
| { | ||
| switch (dt.getVectorElementType()) | ||
| { | ||
| case TR::Int8: return TR::vbRegLoad; |
There was a problem hiding this comment.
Why do we have all these different "vector register load" opcodes when we only have a single equivalent "vector load" opcode ?
There was a problem hiding this comment.
These are good questions. We will revise all the vector opcodes in the future. This PR is only introducing new vector types.
There was a problem hiding this comment.
Actually, "New Vector Opcodes" PR is coming soon. It introduces new infrastructure for vector opcodes. Then, we will gradually remove old opcodes and add new ones.
|
Since a lot of files have been changed, I wanted to mention that the single core change is in |
| /* .properties3 = */ 0, \ | ||
| /* .properties4 = */ 0, \ | ||
| /* .dataType = */ TR::VectorInt32, \ | ||
| /* .dataType = */ OMR::DataType::Vector128Int32, \ |
There was a problem hiding this comment.
Are these vector opcodes that may be re-designed in the future but are being left as per the original behavior in this PR ? Just wondering about the specific datatype in use for these (as opposed to the different approach for say a vadd opcode).
There was a problem hiding this comment.
Yes, in this file definitely all previous behavior is preserved. For example vmin had type TR::VectorInt32 and became OMR::DataType::Vector128Int32 since TR::VectorInt32 used to imply 128. This PR removed TR::VectorInt32 from the DataTypes enum. Next PR will start removing old opcodes and adding new vector opcodes that have type encoded inside them. So they will be implemented very differently.
There was a problem hiding this comment.
OMR::DataType::Vector128Int32 is a temporary static variable which will not be used.
There was a problem hiding this comment.
Thanks, I imagined this must be the case but wanted to double check with you. I have approved the PR since that was the last question I had from the review.
3a2cff2 to
7195056
Compare
|
Pushed a fix for OMR::DataType::getName() |
|
Reviewers: would those who requested changes or made comments please formally approve this PR if you are satisfied with @gita-omr's resolution of them? |
|
Jenkins build all |
- see eclipse-omr/omr#6353 for the background - to enable VectorAPI support, VectorAPIExpansion::supportedOnPlatform needs to be modified correspondingly - to enable specific opcode getSupportsOpCodeForAutoSIMD needs to be modified correspondingly
|
There is a The code was added by PR #6402, which was merged last week. |
Right. Let me rebase and hopefully it gets merged soon :) |
7195056 to
bd32cdd
Compare
- see eclipse-omr/omr#6353 for the background - to enable VectorAPI support, VectorAPIExpansion::supportedOnPlatform needs to be modified correspondingly - to enable specific opcode getSupportsOpCodeForAutoSIMD needs to be modified correspondingly
bd32cdd to
7e4e486
Compare
|
Fixed new code that was added while this PR was under review. |
|
Jenkins build all |
7e4e486 to
88bc288
Compare
|
Jenkins build all |
- see eclipse-omr/omr#6353 for the background - to enable VectorAPI support, VectorAPIExpansion::supportedOnPlatform needs to be modified correspondingly - to enable specific opcode getSupportsOpCodeForAutoSIMD needs to be modified correspondingly
- remove VectorInt8 - VectorDouble from OMR::DataTypes - allocate space for vector enums just before TR::NumAllTypes(former TR::NumTypes) - vector enums are generated at runtime using createVectorType() - value returned by createVectorType() can be used to dereference tables of size TR::NumAllTypes as before, but cannot be used to dereference tables of size TR::NumOMRTypes - typeless vector opcodes such as vsub, vadd, etc. (have ILTypeProp::HasNoDataType property) can start using the new types - codegen evaluators for those opcodes can use isVector(), getVectorElementType(), getVectorLength() on the node's DataType - note that getVectorElementType() and getVectorLength() can only be called on vector types, otherwise there will be an assert - to enable new vector length on specific platform, NumVectorLenghts must be defined corresponfingly in OMRDataTypes.hpp - TRIL and JITBuilder will use 128-bit vectors for now - ATTENTION: for safety reasons, renamed TR::NumTypes to TR::NumAllTypes. Please adjust your code correspondingly if it does not compile. In fact, any code that relies on specific values of TR::NumTypes, TR::NumOMRTypes, as well as vector opcodes being smaller than TR::NumOMRTypes will need to be adjusted. All that work is already done for openj9(eclipse-openj9/openj9#14513).
88bc288 to
a2e28e4
Compare
|
Fixed another use of an old vector type that was merged recently. |
|
Jenkins build all |
remove VectorInt8 - VectorDouble from OMR::DataTypes
allocate space for vector enums just before TR::NumAllTypes(former TR::NumTypes)
vector enums are generated at runtime using createVectorType()
value returned by createVectorType() can be used to dereference tables
of size TR::NumAllTypes as before, but cannot be used to dereference
tables of size TR::NumOMRTypes
typeless vector opcodes such as vsub, vadd, etc. (have ILTypeProp::HasNoDataType property)
can start using the new types
codegen evaluators for those opcodes can use isVector(), getVectorElementType(), getVectorLength()
on the node's DataType
note that getVectorElementType() and getVectorLength() can only be called on vector types, otherwise there will be an assert
to enable new vector length on specific platform, NumVectorLenghts must be defined corresponfingly in
OMRDataTypes.hpp
TRIL and JITBuilder will use 128-bit vectors for now
ATTENTION: for safety reasons, renamed TR::NumTypes to TR::NumAllTypes. Please adjust your code correspondingly if it does not compile. In fact, any code that relies on specific values of TR::NumTypes, TR::NumOMRTypes, as well as vector opcodes being smaller than TR::NumOMRTypes will need to be adjusted. All that work is already done for openj9(Implement new vector types eclipse-openj9/openj9#14513).