stdcore[x] type or labelling?

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

stdcore[x] type or labelling?

Post by Folknology »

Not being able to see inside platform.h we have no way of knowing what stdcore[] is an array of. it would be handy to be able to use names sometimes instead of the stdcore[x] notation.

so for example:

Code: Select all

....
stdcoretype networkcore = stdcore[0];
stdcoretype monitorcore = stdcore[1];
...

main(void){
  chan c;
  ..
  on networkcore : start_eth(c);
  on monitorcore : fetch_data(c);
  ..
}
Just for readability reasons more than anything, is it possible to do this?


User avatar
f_petrini
Active Member
Posts: 43
Joined: Fri Dec 11, 2009 8:20 am

Post by f_petrini »

Well, almost...

Code: Select all

#define networkcore 0
#define monitorcore 1

main(void){
  chan c;
  ..
  on stdcore[networkcore]: start_eth(c);
  on stdcore[monitorcore] : fetch_data(c);
  ..
}
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

Post by Folknology »

Yeah I had thought of that one, great minds..

I was hoping for something less verbose ;-)
m_y
Experienced Member
Posts: 69
Joined: Mon May 17, 2010 10:19 am

Post by m_y »

Assuming a G4...

Code: Select all

#include <platform.h>

core c0 = stdcore[0];
core c1 = stdcore[1];
core c2 = stdcore[2];
core c3 = stdcore[3];

void nothing()
{
}

int main()
{
  par
  {
  on c0: nothing();
  on c1: nothing();
  on c2: nothing();
  on c3: nothing();
  }
  return(0);
}
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

Post by Folknology »

Cool thanks M_Y that's perfect.

Assuming this technique will also work with L2s and 2 cores rather than 4?
m_y
Experienced Member
Posts: 69
Joined: Mon May 17, 2010 10:19 am

Post by m_y »

Folknology wrote:Assuming this technique will also work with L2s and 2 cores rather than 4?
It should work in all cases.
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

Post by Folknology »

Thank you

it is exactly what I needed....

regards
Al
User avatar
lilltroll
XCore Expert
Posts: 956
Joined: Fri Dec 11, 2009 3:53 am
Location: Sweden, Eskilstuna

Post by lilltroll »

m_y:s example should be added in the wiki!

It's useful and clean but I have missed it. Just some info about the core as an ingress.

I know that core is a reseved word, but is it correct to call it a type
Probably not the most confused programmer anymore on the XCORE forum.
User avatar
lilltroll
XCore Expert
Posts: 956
Joined: Fri Dec 11, 2009 3:53 am
Location: Sweden, Eskilstuna

Post by lilltroll »

m_y wrote:Assuming a G4...

Code: Select all

#include <platform.h>

core c0 = stdcore[0];
core c1 = stdcore[1];
core c2 = stdcore[2];
core c3 = stdcore[3];

void nothing()
{
}

int main()
{
  par
  {
  on c0: nothing();
  on c1: nothing();
  on c2: nothing();
  on c3: nothing();
  }
  return(0);
}
I tried it on my XDK and it works fine - but, it doesn't seems to be supported by the spell-checker yet. The compiler likes it, but the spell-checker reports Syntax Error.

If this is a "XMOS supported" way to write code, and I do not misunderstand things, it would be nice to add it in the 10.4.1 release.
Probably not the most confused programmer anymore on the XCORE forum.
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

Post by Folknology »

Hehe, thats one advantage of using the command line tools, I just added 'core' as a new additional identifier in my .emacs for XC and bingo ;-)