pulp-platform / pulp-sdk

Apache License 2.0
99 stars 73 forks source link

Cluster task example #116

Open SaraNassef opened 2 years ago

SaraNassef commented 2 years ago

Hi, I want to ask if there is a cluster task example like the one available in pulp-rt-examples https://github.com/pulp-platform/pulp-rt-examples/blob/master/cluster/task/test.c as I can't find one in those examples https://github.com/GreenWaves-Technologies/pmsis_tests. If not, can someone help me with what are the functions available in the SDK to perform such functionality or where I can find them. Thanks in advance

NBruschi commented 2 years ago

Hi @SaraNassef,

The test you have referred to is part of legacy software support, which is no longer maintained and supported by the PULP team. You can now find the last commit and all the previous history of those runtime functions in the v1(https://github.com/pulp-platform/pulp-sdk/tree/v1) branch of the current pulp-sdk(https://github.com/pulp-platform/pulp-sdk) repository. What you can find in the main(https://github.com/pulp-platform/pulp-sdk/tree/main) branch is an upgraded and maintained version of the pulp-runtime based on PMSIS, which is not compatible with the previous one based on PULP-RT. My suggestion is to use the main branch if you want to develop new applications and test them on GVSoC simulator. Porting the code to the PMSIS APIs should not be a demanding job, especially if you are using standard cluster's tasking. You can use examples like these(https://github.com/pulp-platform/pulp-sdk/tree/main/tests/cluster) to port your code. Otherwise, if you want to use the old PULP-RT APIs and runtime based on those you can checkout to v1 branch.

Best regards,

Nazareno

SaraNassef commented 2 years ago

Thanks @NBruschi for your reply and clarifying things,

Upon your suggestion, I am using the main branch and have checked the examples you referred to, what I want to do is to send different tasks to different cluster cores to be executed simultaneously, I thought at first that the example I mentioned does so. To be clear, my question is if there is an example or certain functions that send different tasks to different cluster cores to be executed simultaneously.

NBruschi commented 2 years ago

Dear @SaraNassef,

the test notation that you are referring to uses "task" to define a cluster job. So, there could be different simultaneous cluster tasks and the cores could do different jobs but they can not execute different tasks. What you should do is write a cluster task where the program flow is different between cores using control flow statements such as if-else or switch-case and where the control variable is the core id, which you can easily extract using pi_core_id() API. To do so you should firstly open a "parallel section" using pi_cl_team_fork() API. At the end of your control flow statement, you should put a barrier using pi_cl_team_barrier() in order to synchronize the cores. The examples to something similar are the ones that I pointed you in the previous message.

Best regards,

Nazareno

SaraNassef commented 2 years ago

Thanks @NBruschi for your suggestion, I tried something similar and it worked.

I have another question, I'm trying to use a semaphore but when using the struct pi_sem_t, it gives an error that the storage size is not known, also using the semaphore functions such as pi_sem_init gives an error that it's not defined, so am I missing certain defines or flags or what should I do to be able too use these semaphore functions?