XMTC Quick Reference - Paraleap FPGA
Compiled by Scott Watson, updated by Jonathan Speiser, George
Caragea
XMT specific commands to know:
- xmtcc - compiles XMTC code
- xmtfpga - Executes the compiled XMTC code on the Paraleap
FPGA computer.
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
Note that we pass the binary data file (binary_datafile.xbo) to the
compiler to include it in the binary output.
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.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<M;i++) {
printf("%d ", A[i]);
}
}
Compile the example:
$ xmtcc example.p.c -o myexample
Simulate the example:
$ xmtfpga myexample.b
Check how long that took.
Now, remove the for loop with the printf from the program. Recompile
and rerun the program. Do you notice a
difference?
(N.B: we access the process number with the special '$' variable)
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