Check on which Core currently running

Technical questions regarding the XTC tools and programming with XMOS.
neon
Junior Member
Posts: 7
Joined: Tue Nov 02, 2010 9:56 am

Check on which Core currently running

Post by neon »

Hello,

I´m searching for an option to check at runtime on which core i am running

e.g: I start the same function on two cores and have to run different code for each core

Code: Select all

#ifdef core1
do something special for core 1
#endif

ifdef core2
do something special for core 2
#endif
Thanks for your help
Bernhard


m_y
Experienced Member
Posts: 69
Joined: Mon May 17, 2010 10:19 am

Post by m_y »

There a no facilities in the XC language to do this. One would need to pass a parameter in the top-level main which denotes which core it's being run on.

At the hardware level, you can read the NODE_ID register in the sswitch, or if you get a channel end, the node/core identifier is embedded in the identifier value.
User avatar
Jamie
Experienced Member
Posts: 99
Joined: Mon Dec 14, 2009 1:01 pm

Post by Jamie »

You could get a local channel identifier and inspect the core bits:

Code: Select all

unsigned getCore(unsigned resId) {
    return (resId >> 16) & 0xFF;
}
m_y
Experienced Member
Posts: 69
Joined: Mon May 17, 2010 10:19 am

Post by m_y »

Jamie wrote:You could get a local channel identifier and inspect the core bits:

Code: Select all

unsigned getCore(unsigned resId) {
    return (resId >> 16) & 0xFF;
}
That will get you the core number on a G4 (but this does not including the node id). On an L-series device it will get you only the lower half the node identifier (there is no core id). This may, but probably won't, get you something unique to a particular core.
richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

The top 16bits of the resource ID of any channel end on a core uniquely identifies the core on the network. The function get_core_id() in xs1.h can be used to get this value.
neon
Junior Member
Posts: 7
Joined: Tue Nov 02, 2010 9:56 am

Post by neon »

I apoligize for the late answer.
richard wrote:The top 16bits of the resource ID of any channel end on a core uniquely identifies the core on the network. The function get_core_id() in xs1.h can be used to get this value.
I tried this and it works fine

Thank you for your efforts!

Bernhard