Getting started with Spatial

54 views
Skip to first unread message

Rupak Kundu

unread,
Feb 3, 2021, 2:50:56 AM2/3/21
to Spatial Users
Hello everyone. 

I recently installed installed spatial on my computer. I have no prior experience with spatial but want to learn it for my project. 
I have installed all prerequisites and run spatial-quickstart.  My first step is to write a hello world like program in spatial. 

1)  How do I know that spatial is correctly installed ?
2 ) Can someone please help me with a basic program and also how to compile it.

Thanks, Rupak


Matt Feldman

unread,
Feb 3, 2021, 12:32:50 PM2/3/21
to Spatial Users

Hi.  In spatial-quickstart, there are two examples in src/main/scala.   They are HelloSpatial and GEMM.  If you navigate to the spatial-quickstart root dir, you should be able to run `bin/spatial GEMM` and it will compile the gemm app.  It puts the generated code into gen/GEMM.  You can navigate there and run `make` to compile it, and then run `bash run.sh 64 64 64` to do a 64x64 * 64x64 matrix multiply.  `bash run.sh -h` should work in any app's generated dir to describe what values it expects at the command line.  These steps will compile the scala backend, which is only good for simulation and checking data correctness.  If you want to compile for an FPGA, you need to add the flags to the `bin/spatial` command depending on the backend you want to target.  For example if you have a zc706 you want to run this on, `bin/spatial GEMM --synth --fpga=Zynq`.  If you have access to vcs (which is what I use 99% of the time and only run on the FPGA when I have a kernel that works in simulation that I need to scale up or benchmark), use the --fpga=VCS target.  When compiling with the --synth flag for any backend, you need to `make` first in the generated directory to get an executable or bitstream that you can run or transfer to the fpga.

If you try compiling GEMM for scala simulation (--sim which is the default if you don't specify) or synth (--synth --fpga=<something>), you should be able to flush out any installation problems.  We have a ton more app examples of varying complexity here https://github.com/stanford-ppl/spatial/tree/master/test/spatial/tests.  Just note that these are part of the regression/test infrastructure so they are classes that extend SpatialTest, whereas the apps in src of quickstart are objects that extend SpatialApp.  SpatialTest just gives some handles for things that we need for regression like default cli args, but is otherwise the same thing as SpatialApp.

Rupak Kundu

unread,
Feb 5, 2021, 1:27:37 PM2/5/21
to Spatial Users
thanks matt.
I could run the GEMM app using --sim. 

Reply all
Reply to author
Forward
0 new messages