How to re-route channel to different destination?

Technical questions regarding the XTC tools and programming with XMOS.
jerryXCORE
Experienced Member
Posts: 65
Joined: Tue Apr 30, 2013 10:41 pm

How to re-route channel to different destination?

Post by jerryXCORE »

If two channels connect to same tile, I know how to re-route as follows:

Code: Select all

processTile_n(chanend c1, chanend c2)
{    int dest1, dest2;
     asm("getd %0,res[%1]" : "=r" (dest1) : "r" (c1));
     asm("getd %0,res[%1]" : "=r" (dest2) : "r" (c2));

     asm("setd res[%0],%1" :: "r" (c1), "r" (dest2));
     asm("setd res[%0],%1" :: "r" (c2), "r" (dest1));
}
What if the two channels do NOT connect to same tile, how to re-route? is it possible?

Code: Select all

processTile_0(chanend c1){   //can NOT refer the destination of c2, right?}
processTile_1(chanend c1){   //can NOT refer the destination of c2, right?}

processTile_2(chanend c2){   //can NOT refer the destination of c1, right?}
processTile_3(chanend c2){   //can NOT refer the destination of c1, right? }
As we see, we can NOT refer the destination of c2 from Tile_0 or Tile_1, right?
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

In your code example you have two chanends on one tile with a certain destination and you swap their destinations. It does not matter whether these destinations are on the same tile or not.

If you have two chanends on two tiles and you want to swap their destinations you somehow first need to know the destination of the opposite side. You can use another channel to exchange this information.
jerryXCORE
Experienced Member
Posts: 65
Joined: Tue Apr 30, 2013 10:41 pm

Post by jerryXCORE »

Bianco wrote: If you have two chanends on two tiles and you want to swap their destinations you somehow first need to know the destination of the opposite side. You can use another channel to exchange this information.
My purpose of re-routing is to avoid using extra channels (streaming channels already used up!)
Is it possible to use something similar to "global variables", or maybe program in Assembly language?

Thanks!
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

And there is no channel between the two tiles of which you want to swap chanend destinations?
Otherwise you can use an existing channel.
jerryXCORE
Experienced Member
Posts: 65
Joined: Tue Apr 30, 2013 10:41 pm

Post by jerryXCORE »

Bianco wrote:And there is no channel between the two tiles of which you want to swap chanend destinations?
Otherwise you can use an existing channel.
Yes, thanks for reminding: I do have existing channel to pass the destinations before enter while-loop. And inside while-loop, I can change to the destination being passed.

(Unfortunately, changing destinations back/forth takes many clock cycles, affecting other time-sensitive processing tasks.)