How Can I assign Logical Core to a particular Function

If you have a simple question and just want an answer.
malbahri
Member++
Posts: 19
Joined: Sun Mar 23, 2014 9:51 pm

How Can I assign Logical Core to a particular Function

Post by malbahri »

In my program I need to have more control over the logical cores. In which I would like assign the logical core number for a particular functions and then running them in parallel in the main function. Currently when I am using par{} statement the logical core are assigned dynamically by the system. By the way I am using xmos stratKit

BR//
Mohammed
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

Hi Mohammed.

Have a look at this sample code:

https://www.xmos.com/zh/node/17653?version=B&page=18

Following syntax should work to manually select the desired CPU core for your requirements:

Code: Select all

  par {
    on tile[0].core[0]: game(i_game, i_led);
    on tile[0].core[0]: user_player(i_game[0],
                                    i_slider_x, i_slider_y, i_button);
    on tile[0].core[0]: computer_player(i_game[1]);
    on tile[0]: startkit_gpio_driver(i_led, i_button,
                                     i_slider_x, i_slider_y,
                                     gpio_ports);

  }

and worth a quick read:

https://www.xmos.com/zh/node/17653?version=B&page=23

Code: Select all

...

int main() {
  par {
    on tile[0]: task1();
    on tile[1].core[0]: task2();
    on tile[1].core[0]: task3();
  }
}
In this example, task2 and task3 have been placed on the same core.

Hope this helps.

Kumar
malbahri
Member++
Posts: 19
Joined: Sun Mar 23, 2014 9:51 pm

Post by malbahri »

Dear Kumar,

Thanks a lot for your help but I was trying ealier these steps unfortunately I am getting the following errors:
error: only local variables of type chan allowed in a multi-tile main
error: multi-tile main must consist of single non-empty par statement

any idea how to resolve it

BR//
Mohammed
User avatar
Ross
Verified
XCore Legend
Posts: 1185
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

This is not a valid program currently (int var in a multi-tile main)

Code: Select all

int main()
{
   int x;

   par
   {
     on tile[0] : a(x);
     on tile[0] : b();
   }
}
you could change it to something like this:

Code: Select all

int main()
{
 
   par
   {
     on tile[0] : {
                        int x;
                        par{
                            a(x);
                            b();
                        }
                      }
   }
}
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

Hi Mohammed. Please review this post:

http://www.xcore.com/forum/viewtopic.php?f=47&t=3739

to resolve the

error: only local variables of type chan allowed in a multi-tile main


and then this post:

http://www.xcore.com/forum/viewtopic.php?f=47&t=4017

to resolve the

error: multi-tile main must consist of single non-empty par statement

Ross - Sorry for the confusion. The above example was only a partial snippet of another XMOS article so it is not complete.
malbahri
Member++
Posts: 19
Joined: Sun Mar 23, 2014 9:51 pm

Post by malbahri »

One more error I am facing right now
441: error: invalid null argument

any idea how to resolve such error

I have a function contain of four argument and I need to put NULL in for the last argument but system reporting above error
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

Can you post that part of the code with the full error ?
malbahri
Member++
Posts: 19
Joined: Sun Mar 23, 2014 9:51 pm

Post by malbahri »

The function as below:

void ecdh_shared_secret(uint8_t p_secret[NUM_ECC_DIGITS], EccPoint *p_publicKey, uint8_t p_privateKey[NUM_ECC_DIGITS], uint8_t p_random[NUM_ECC_DIGITS])
{
EccPoint l_product;

EccPoint_mult(&l_product, p_publicKey, p_privateKey, p_random);

if(EccPoint_isZero(&l_product))
{
return 0;
}

vli_set(p_secret, l_product.x);

return 1;
}

I called it from the main fuction as below
main() {


ecdh_shared_secret(secret_0, &public_0, private_1, NULL);

}
argument 1,2,3 been provided but the fourth one need to be NULL

system reported :
../src/ECCGFp.xc:92: error: invalid null argument
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

Try with lower case keyword of "null".
malbahri
Member++
Posts: 19
Joined: Sun Mar 23, 2014 9:51 pm

Post by malbahri »

I tried null but reporting the same error
../src/ECCGFp.xc:92: error: invalid null argument