pulp-platform / snitch_cluster

An energy-efficient RISC-V floating-point compute cluster.
https://pulp-platform.github.io/snitch_cluster/
Apache License 2.0
48 stars 46 forks source link

stack pointers in the snitch cluster #183

Closed jorendumoulin closed 3 weeks ago

jorendumoulin commented 3 weeks ago

I am running into some interesting bugs when simulating stuff on a multi-core snitch cluster setup, and I'm thinking it is related to the stack pointers of every core in the cluster. From the traces, it seems the data mover core gets assigned the same stack pointer as core 0.

If my understanding is correct, in the code below in start.S, every core gets assigned a unique stack pointer, at line 143. The offset is determined by the cluster local core id, calculated on line 105. The cluster local core id is the result of (hart_id - hart_offset) % num_cores. As num_cores does not include the dm core, the local core id for the dm core and core 0 is equal.

https://github.com/pulp-platform/snitch_cluster/blob/5928ffadc18c63cc0cc4eb5025a1c1da88d5d07d/sw/snRuntime/src/start.S#L93-L143

Is this by design somehow? I can't seem to otherwise understand the reasoning behind line 105. Or is this a bug?

colluca commented 3 weeks ago

Dear @jorendumoulin,

Definitely the DM core and compute core 0 should not be assigned the same stack pointer. However, I fail to see the issue in the code, as SNRT_CLUSTER_CORE_NUM does count all cores in the cluster, including the DM core.

jorendumoulin commented 3 weeks ago

oh, so maybe in my cfg this value is wrong, I'll double check thank you for the swift reply!

colluca commented 3 weeks ago

No problem :)