"multi-tile main must consist of single non-empty par statem

If you have a simple question and just want an answer.
Post Reply
User avatar
jeevanicherukuri
Member++
Posts: 17
Joined: Fri Dec 26, 2014 4:41 pm

"multi-tile main must consist of single non-empty par statem

Post by jeevanicherukuri »

My program is-

#include<platform.h>
#include<stdio.h>
#include<xs1.h>
 
void task1()
{
printf("Hello1");
}
void task2()
{
printf("Hello2");
}
void task3()
{
printf("Hello3");
}
 
 int main () {
    while(1){
par
{
on tile[0]:task1();
on tile[0].core[1]:task2();
on tile[0].core[3]:task3();
}
    }
return 0;
 
}
How can i rectify this error? I am running it on xTime composer Studio. 
 


User avatar
larry
Respected Member
Posts: 275
Joined: Fri Mar 12, 2010 6:03 pm

Post by larry »

Make sure your multi-tile par is the top level statement of the application's main. Removing the endless while loop will do that in this case.

srinie
XCore Addict
Posts: 158
Joined: Thu Mar 20, 2014 8:04 am

Post by srinie »

Hi,

A couple of questions:

1. Any specific requirement that you need to assign "core 1 to task 2" and "core 3 to task 3"? This does not make much sense because the par statment is similar to a fork() function which spawns a task on a core by itself; so having a statement like below would be sufficient:

    par {
      on tile[0]:task1();
      on tile[0]:task2();
      on tile[0]:task3();
    }
 

=============

2. Not able to appreciate the need for "while (1)" in main() function, with a 'par' statement; as mentioned above, par spwans the tasks and main() joins when all its threads are exited; As an example, for the same program modified as below:

-----------------------

#include<platform.h>
#include<stdio.h>
#include<xs1.h>

void task2()
{
  printf("Hello2");
}
void task3()
{
  printf("Hello3");
}


void task1()
{
  printf("Hello1");
  while (1) {
  par {
    task2();
    task3();
  }
  }
}
int main () {
    par {
      on tile[0]:task1();
    }
  return 0;
}

-------------------------------

- main() goes with task1(), and joins when the task1() is exited; similarly task1() spawns task2() and task3(); there will be two tasks active here; of which one of the task joins with task1() again

 

==========

Hope this helps.

Post Reply