Page 1 of 1

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

Posted: Wed Feb 18, 2015 6:46 pm
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. 
 

Answer

Posted: Wed Feb 18, 2015 7:23 pm
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.


Answer

Posted: Thu Feb 19, 2015 7:00 am
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.