XMTC Quick Reference

Compiled by Scott Watson, updated by Jonathan Speiser


XMT specific commands to know:

Examples

Compile the source code file program.s.c
xmtcc program.s.c
Compile program with #define and #include options
xmtcc -d START=0 -include data/dataset_header.h program.p.c
Compile program with data file
xmtcc program.p.c -o outputname -include data/dataset_header.h data/binary_datafile.xbo

Text editors:
nano, emacs, vi,

XMTC highlights:

Include directive is required to use XMTC specific C functions
#include <xmtc.h>
'Spawn' (last-first+1) processes numbered first to last
spawn(first,last){ }

Example Program

example.p.c: takes an array and in parallel assigns each item in the array the value 3 times its index number
#include <xmtc.h>
#define N 5

int main() {
  int A[N] = {0,0,0,0,0};
  spawn(0, N-1) {
    A[$] = $ * 3;
  }
  /* Check if it worked */
  int i;
  for (i=0;i<N;i++) {
    printf("%d ", A[i]);
  }
}

(N.B: we access the process number with the special '$' variable)

Compile the example:
$ xmtcc example.p.c -o myexample
Simulate the example:
$ xmtsim myexample.sim

To check how long that took, type: xmtsim myexample.sim -cycle -count Now, remove the for loop with the printf from the program. Recompile and rerun the simulator with -cycle and -count. Do you notice a difference?

ps(int local_integer, psBaseReg ps_base);
ps is a sort of a global increment function that returns a current value without having to worry about concurrency issues. It is only called within a spawn block

Also see sspawn and psm in the manual