This shows you the differences between two versions of the page.
schedule_code_generator_for_code_with_subsystem [2014/07/07 14:04] yun [Example program with subsystem] |
schedule_code_generator_for_code_with_subsystem [2017/04/19 13:31] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======Schedule Code Generator for SubSystem====== | ||
- | Given an affine system with subsystems/ | ||
- | ====Example program with subsystem==== | ||
- | |||
- | The following code is the alpha program for matrix matrix multiplication with dot-product subsystem. | ||
- | <sxh alphabets; gutter: | ||
- | affine matrix_product_SubSyst {N,K,M | N>0 && K>0 && M > 0} // Product between a N*K matrix and a K*M matrix | ||
- | input | ||
- | float A {i,k | 0< | ||
- | float B {k,j | 0< | ||
- | output | ||
- | float C {i,j | 0< | ||
- | let | ||
- | use {iP, | ||
- | . | ||
- | |||
- | affine dot_product {N| N>0} // Product between 2 vector of size N | ||
- | input | ||
- | float vect1 {i | 0< | ||
- | float vect2 {i | 0< | ||
- | output | ||
- | float Res; | ||
- | local | ||
- | float temp {i | 0< | ||
- | let | ||
- | temp[i] = case | ||
- | {i|i==0} | ||
- | {i |0< | ||
- | esac; | ||
- | Res[] = temp[N-1]; | ||
- | . | ||
- | |||
- | </ | ||
- | |||
- | The program contains two systems. The dot_product system takes two vectors as inputs and computes the doc product of these two vectors. The matrix_product_SubSyst computes matrix C=A*B, the (ip,jp)th element for the answer matrix C is computed by calling the dot product subsystem, and the (ip)th row of A, and (jp)th column of B is passed as input to the subsystem call. | ||
- | |||
- | |||