M and N.
This tutorial introduces compile time parameters to set M and N
while compiling the code, and shows how your 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
Your program will run on a single processing element (PE). Like the previous tutorials, this tutorial demonstrates the program with a simulated fabric consisting of an 8 x 3 block of PEs. The problem steps are identical to the previous tutorial. The device code needs to be modified to replace the constantsM and N with parameters, and the compile
command needs to be modified to set these parameter values.
The host code must be modified to read these values from
compile output.
Modify the CSL
How must the layout code be modified to support compile time parameters forM and N?
- Define top-level parameters for
MandNthat will be set by the compile command - Pass these parameters along to the 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.
Compile and Run the Program
The device and host code now use the compile time parameters, but how are they set? The 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?