Targeting multiple tiles#

In the previous example, the code targeted only a single tile. Most real applications will use two or more tiles. It is not possible to build an application for multiple tiles using the C language (as the tiles are independent processors).

To build a multi-tile application, a top-level, multi-tile XC file must be provided to specify the entry-point for each tile. The code running on a tile communicates with another tile using XCORE channels.

Note

The syntax of the multi-tile XC file is C language like. However, the grammar is not a pure super-set of the C language.

Providing a multi-tile file#

To place code onto both of the tiles on a XK-EVK-XU316, it is necessary to provide a file which we will call multitile.xc. An example is shown below:

Listing 2 multitile.xc#
#include <platform.h>

extern "C" {

void main_tile0();
void main_tile1();

}

int main(void)
{
  par {
    on tile[0]: main_tile0();
    on tile[1]: main_tile1();
  }

  return 0;
}

This multitile.xc references the two functions in main.c:

Listing 3 main.c#
#include <stdio.h>

void main_tile0()
{
  printf("Hello from tile 0\n");
}

void main_tile1()
{
  printf("Hello from tile 1\n");
}

Now build and execute this multi-tile application on real hardware to see the printed output:

$ xcc -target=XK-EVK-XU316 multitile.xc main.c
$ xrun --io a.xe
Hello from tile 0
Hello from tile 1

Summary#

In this example, you have written a multitile.xc using the declarative components of XC language to deploy two C functions onto the two tiles of an XCORE.AI processor.

See also

At this point, you might proceed to the next topic, or you might chose to explore this example further: