User Tools

Site Tools


This is an old revision of the document!

Schedule Code Generator for SubSystem

Given an affine system with subsystems/useEquations, this page shows how to specify the targetmapping for the system and generate the code.

Matrix Multiplication with subsystem

The following code is the alpha program for matrix matrix multiplication with dot-product subsystem.

affine matrix_product_SubSyst {N,K,M | N>0 && K>0 && M > 0}	// Product between a N*K matrix and a K*M matrix
	float A {i,k | 0<=i<N && 0<=k<K};
	float B {k,j | 0<=k<K && 0<=j<M};
	float C {i,j | 0<=i<N && 0<=j<M};
	use {iP,jP|0<=iP<N && 0<=jP<M} dot_product[K] ((pi,pj,k->pi,k)@A,(pi,pj,k->k,pj)@B) returns (C);

affine dot_product {N| N>0}	// Product between 2 vector of size N
	float vect1 {i | 0<=i<N };
	float vect2 {i | 0<=i<N };
	float Res;
	float temp {i | 0<=i<N};
	temp[i] = case
		{i|i==0}   : vect1[0] * vect2[0];
		{i |0<i<N} : temp[i-1] + vect1[i]*vect2[i]; 
	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.

TargetMapping for the Matrix Multiplication Example

schedule_code_generator_for_code_with_subsystem.1404763541.txt.gz · Last modified: 2014/07/07 14:05 by yun