M and N.
Now we introduce compile time parameters to set M and N
while compiling our code, and show how our host code can read
these values from the compile output.
Learning Objectives
After completing this tutorial, you should know how to:- Define compile time parameters for your device code
- Set the value of compile time parameters when compiling
- Read the value of compile time parameters from compile output in your host code
Example Overview
Our program will run on a single processing element (PE). Like the previous tutorials, we will demonstrate the program with a simulated fabric consisting of an 8 x 3 block of PEs. Our problem steps are identical to the previous tutorial. We need to modify our device code to replace the constantsM and N with parameters, and modify our compile
command to set these parameter values.
Our host code must be modified to read these values from
compile output.
Modifying the CSL
How must we modify our layout code to support compile time parameters forM and N?
- We need to define top level parameters for
MandNthat will be set by the compile command - We need to pass these parameters along to our PE program
layout.csl:
@set_tile_code call:
pe_program.csl:
pe_program.csl must also contain parameter declarations for M and N.
When this file is compiled, it uses the values passed to it by layout.csl’s
@set_tile_code call to bind them.
M and N are no longer hard-coded in this file.
Compiling and Running the Program
We’ve shown how the device and host code use the compile time parameters, but how do we set them? Our compile command now includes a--params flag, which
specifies the values:
SUCCESS! message at the end of execution.
Exercises
A is stored row-major in the above code.
How would you rewrite A_dsd and the gemv function
if A were stored column major instead?