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

Slot limitations also depends with instructions with immediate values. #55

Open
utkarshyen opened this issue Mar 1, 2021 · 6 comments

Comments

@utkarshyen
Copy link

Hello @robcasloz

We would like your help in tackling a scenario where slot limitation also depends with instructions with immediates.

Please have a look below,
The VLIW target that we are trying to experiment can access immediates only through references where 1 packet can access three 8 bit immediate values.

Consider the following scenarios,

Scenario 1
BUNDLE {
%r1 = ADDri %r1, 20,
%r0 = ADDri %r0, 20,
}
Please check the allocation slots below,
Scenario_1

Scenario 2
BUNDLE {
%r1 = ADDri %r1, 20,
%r0 = ADDri %r0, 20,
%r2 = SUBri %r2, 20,
}
Please check the allocation slots below,
Scenario_2

Scenario 3
BUNDLE {
%r1 = ADDri %r1, 20,
%r3 = ADD %r3, %r5,
%r4 = SUB %r4, %r5,
}
Please check the allocation slots below,
Scenario_3

Scenario 4
BUNDLE {
%r1 = ADDri %r1, 20,
%r0 = ADDri %r0, 40,
%r2 = SUBri %r2, 60,
}
Please check the allocation slots below,
Scenario_4

Scenario 5
BUNDLE {
%r1 = ADDri %r1, 1200,
%r4 = ADDri %r4, 14,
}
Please check the allocation slots below,
Scenario_5

Scenario 6
BUNDLE {
%r1 = ADDri %r1, 1200,
%r0 = ADDri %r0, 4800,
%r4 = ADDri %r4, 1,
}
Please check the allocation slots below,
Scenario_6

We are facing issue with Scenario 6, as "1200" decimal is converted to two 8 byte decimal value. And considering scenario 6, we are accessing five 8 bit immediate values.

Can you please provide suggestion on how to make Unison aware of such restrictions so that such bundles are not generated.
In our case ADD instr has ALU_ALL slots, thus added in single bundle.

Regards,
Utkarsh

@robcasloz
Copy link
Contributor

Hi,

If I got your problem right, you need to define a IMM resource that models the 3 IMM slots (i.e. with capacity 3), and specialize the relevant instructions by number of IMM slots taken (i.e. units of the IMM resource used). For example, you could specialize ADDri into ADDri_1 (which uses 1 unit of IMM) and ADDri_2 (which uses 2 units of IMM), depending on the size of the immediate value. This specialization can be done either on Machine IR, or on Unison IR (during the import or augment phase).

BR,

Roberto

@utkarshyen
Copy link
Author

Hello @robcasloz ,

Thank you for the pointer.

As I'm new to the hashkell, it would be very much helpful if you could point out me more insights or info regarding the same.
However, I have explored the unison code for Hexagon and I could find the "C2mux_ii" instr which takes different operands.
I have also explored the "Transforms.hs" file for C2mux_ii instr marking "muxAlternatives" and "muxOperandType" code. So is this similar to what our case 6 is in above comment?

Regards,
Utkarsh

@utkarshyen
Copy link
Author

Hello @robcasloz

Please correct if our understanding is wrong..
For preparing a bundle, we consider instructions and ALU slots as a resource. Depending on the criteria of these two the bundle is prepared.
However, we thought to add a new resource "immediate value (IMM)" which will be consider for preparing a bundle. Like, instructions, ALU slots and IMM.

Exploring the unison documents, we found unison doc but the resource model section is not updated. Can you please provide us the updated document?

Regards,
Utkarsh

@robcasloz
Copy link
Contributor

I have also explored the "Transforms.hs" file for C2mux_ii instr marking "muxAlternatives" and "muxOperandType" code. So is this similar to what our case 6 is in above comment?

muxAlternatives generates instruction alternatives for the solver to consider together with the rest of register allocation and scheduling, because the instruction can be implemented in different ways involving different resource-latency trade-offs. Your case seems to be simpler, as each immediate instruction (e.g. ADDri would only be implemented by one specific version of ADDri, depending on its immediate value. You could even apply this specialization to each instruction before giving the input function to Unison, if that feels easier to do.

@robcasloz
Copy link
Contributor

Please correct if our understanding is wrong..
For preparing a bundle, we consider instructions and ALU slots as a resource. Depending on the criteria of these two the bundle is prepared.
However, we thought to add a new resource "immediate value (IMM)" which will be consider for preparing a bundle. Like, instructions, ALU slots and IMM.

Yes, this is my suggestion.

Exploring the unison documents, we found unison doc but the resource model section is not updated. Can you please provide us the updated document?

The chapter is unfortunately incomplete, and unlikely to be completed in the near future. In the meantime, you can have a look at Section 6 in this paper, and also read Section 4 in this paper for further background.

@utkarshyen
Copy link
Author

Hello @robcasloz ,

Thank you for the comment and update.
I shall look into this more and get back to you if anything.

Regards,
Utkarsh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants