Reference doc question

Any technical questions about the Epiphany chip and Parallella HW Platform.

Moderator: aolofsson

Re: Reference doc question

Postby sebraa » Tue Jan 24, 2017 4:27 pm

Are you following the original ABI (from the SDK documentation), the new ABI (with the new images), or do you have your own?
sebraa
 
Posts: 495
Joined: Mon Jul 21, 2014 7:54 pm

Re: Reference doc question

Postby upcFrost » Wed Jan 25, 2017 5:00 pm

sebraa wrote:Are you following the original ABI (from the SDK documentation), the new ABI (with the new images), or do you have your own?


Original/new? Well, good question, thb. I'm using the arch reference from REV 14.03.11, not sure if it's old or new one. Most likely the old one. In any case, I'm not trying to invent my own stuff.

Small update - implemented branch optimization, now it doesn't spam useless jumps to the very next instruction at the end of the block.
Current LLVM backend for Epiphany: https://github.com/upcFrost/Epiphany. Commits and code reviews are welcome
upcFrost
 
Posts: 37
Joined: Wed May 28, 2014 6:37 am
Location: Moscow, Russia

Re: Reference doc question

Postby sebraa » Wed Jan 25, 2017 6:47 pm

For the new ABI, see the proposal and the eSDK changelog. Apart from that, good luck and my best wishes with your project. ;-)
sebraa
 
Posts: 495
Joined: Mon Jul 21, 2014 7:54 pm

Re: Reference doc question

Postby upcFrost » Thu Jan 26, 2017 10:15 am

sebraa wrote:For the new ABI, see the proposal and the eSDK changelog. Apart from that, good luck and my best wishes with your project. ;-)


Thanks for those links. Well, it seems that i use mixture of two ABIs, because i'm trying to keep compatibility with e-gcc from the latest image. So some parts, such as FP on R15, are already done.
Current LLVM backend for Epiphany: https://github.com/upcFrost/Epiphany. Commits and code reviews are welcome
upcFrost
 
Posts: 37
Joined: Wed May 28, 2014 6:37 am
Location: Moscow, Russia

Re: Reference doc question

Postby upcFrost » Wed Feb 22, 2017 3:54 pm

Got stuck once again with MOVTS.
Here's the sample code:
Code: Select all
void test(float a, float b)
{
  float c = a+b;
}

When switching the config flag, e-objdump report the following:
Code: Select all
010f 4002   movts config,r16

When i started digging out the command, i got the following result:
Code: Select all
010 000 0000 00   0010    000  000    0100001111
Rd = 010 000 = 16 = r16
Rn = 000 000 = 0 = config

Shouldn't it be the other way around, Rd = config, Rn = r16? guessing from following
Code: Select all
011f 4002   movfs r16,config
the reg order is exactly the same, while it should be reversed

Can someone plz check if it's only my version of e-sdk, or it holds for all versions? and what should be the correct reg order?

Also, just for the discussion - what'd be the best way to implement FPU config flag switch?
Atm i'm just looking through the function, and if it contains any FPU instructions, i add corresponding flag switch directives to the very first and very last blocks. Not the best way to handle it, imo, but at least simple and predictable (well, except the scheduler which sometimes gets into the way).
As IALU2 can run in parallel with IALU, it might be feasible to check the amount of IALU instructions between two FPU instructions, check if some of those can be actually converted to IALU2 instructions (ADD/SUB), convert them, and flip the flag more than once if the profit of saving those 3 cycles in the pipeline is greater than 10-16 cycles from flag set-reset.
Current LLVM backend for Epiphany: https://github.com/upcFrost/Epiphany. Commits and code reviews are welcome
upcFrost
 
Posts: 37
Joined: Wed May 28, 2014 6:37 am
Location: Moscow, Russia

Re: Reference doc question

Postby jar » Thu Feb 23, 2017 6:38 am

First, I'm glad to see you're working on this.

movfs copies a special register to a general purpose register.
movts copies a general purpose register to a special register

I don't think there's any great way to flip the config register.

Side note: These kinds of operations are so common that it would make sense to have a special instruction in the future to switch between int/float modes. Also, the circuitry to copy SR -> GPR and GPR -> SR uses the network in a loopback mechanism, so this would also make sense to optimize on future hardware.

GCC generates this code to switch to integer mode:
Code: Select all
mov r2, %low(#524288)
movfs r1,config
movt r2, %high(#524288)
gid
movfs r3,config
orr r3,r3,r2
movts config,r3
gie


And to reset:
Code: Select all
mov r2, %low(#-917506)
movt r2, %high(#-917506)
gid
movfs r3,config
eor r3,r3,r1
and r3,r3,r2
eor r3,r3,r1
movts config,r3
gie


GCC switching to floating point mode is similar:
Code: Select all
mov r2, %low(#-917506)
movt r2, %high(#-917506)
movfs r1,config
gid
movfs r3,config
and r3,r3,r2
movts config,r3
gie


Code: Select all
gid
movfs r3,config
eor r3,r3,r1
and r3,r3,r2
eor r3,r3,r1
movts config,r3
gie


If you wanted to live on the edge and could guarantee no interrupts, you could remove the gid/gie. Alternatively, you could use one set of gid/gie for the entire routine.

Also, I think resetting could be much simpler by just restoring r1 "movts config, r1". But that only might be valid if the config register wasn't changed during the routine, which could only be guaranteed if interrupts were disabled.

Another code size optimization for setting r2 = 0x80000 might be "mov r2, #1; lsl r2, r2, #19". Would save 2 bytes.

Aiming for optimal pipelining of instructions is good. For example, I've used the IALU2/FPU to zero data rather than using a mov instruction:
https://gist.github.com/jar/c6166366295 ... duct-s-L24 (see fsub instructions dual-issued with dword loads)
User avatar
jar
 
Posts: 295
Joined: Mon Dec 17, 2012 3:27 am

Re: Reference doc question

Postby sebraa » Fri Feb 24, 2017 5:18 pm

All assembly instructions follow the scheme of "instruction destination, source". So it is "MOVTS config, r16" (because it copies from r16 to config) and "MOVFS r16, config" (because it copies from config to r16).

The switchable instruction set is one of the more annoying ISA decisions in the Epiphany, because it interacts badly with interrupts. If you require ISRs to never change (or always restore) the whole config register, you could skip the gid/gie dance in normal code.
sebraa
 
Posts: 495
Joined: Mon Jul 21, 2014 7:54 pm

Re: Reference doc question

Postby olajep » Fri Feb 24, 2017 6:36 pm

upcFrost wrote:When switching the config flag, e-objdump report the following:
Code: Select all
010f 4002   movts config,r16

When i started digging out the command, i got the following result:
Code: Select all
010 000 0000 00   0010    000  000    0100001111
Rd = 010 000 = 16 = r16
Rn = 000 000 = 0 = config

Shouldn't it be the other way around, Rd = config, Rn = r16? guessing from following
Code: Select all
011f 4002   movfs r16,config
the reg order is exactly the same, while it should be reversed

Can someone plz check if it's only my version of e-sdk, or it holds for all versions? and what should be the correct reg order?

Hope this clarifies things:
movxsisa.png
movxsisa.png (15.31 KiB) Viewed 16032 times
_start = 266470723;
olajep
 
Posts: 140
Joined: Mon Dec 17, 2012 3:24 am
Location: Sweden

Re: Reference doc question

Postby upcFrost » Mon Mar 13, 2017 12:34 pm

olajep wrote:Hope this clarifies things


Thanks, yeah, that makes it clear. Sorry for misleading everyone with the word "Swap", i was talking about bits in the instruction encoding, not about asm.
Here's the basis of my misunderstanding. In the reference PDF, both MOVTS and MOVFS have Rd and Rn regs in the table, not Rd and MMR. As in most cases Rd is the dest reg, and Rn is a source reg (as in MOV Rd, Rn), i thought that it should be the same for MOVTS/MOVFS (MOVTS Rd=dest=MMR, Rn=src=GPR).

jar wrote:I've used the IALU2/FPU to zero data rather than using a mov instruction


Thanks for the example. I'm not using double loads atm, should implement them also.
Current LLVM backend for Epiphany: https://github.com/upcFrost/Epiphany. Commits and code reviews are welcome
upcFrost
 
Posts: 37
Joined: Wed May 28, 2014 6:37 am
Location: Moscow, Russia

Previous

Return to Epiphany and Parallella Q & A

Who is online

Users browsing this forum: No registered users and 11 guests

cron