Warning: Declaration of action_plugin_syntaxhighlighter3_action::register(Doku_Event_Handler &$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /s/chopin/e/proj/AlphaZ/public_html/wiki/lib/plugins/syntaxhighlighter3/action/action.php on line 112
schedule_code_generator [AlphaZ]

User Tools

Site Tools


schedule_code_generator

Warning: Declaration of syntax_plugin_syntaxhighlighter3_syntax::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /s/chopin/e/proj/AlphaZ/public_html/wiki/lib/plugins/syntaxhighlighter3/syntax/syntax.php on line 26

Warning: Declaration of syntax_plugin_syntaxhighlighter3_syntax::render($mode, &$renderer, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /s/chopin/e/proj/AlphaZ/public_html/wiki/lib/plugins/syntaxhighlighter3/syntax/syntax.php on line 26

Schedule Code Generator

Given an affine system and a target mapping, this page shows how to generate the scheduled code based on the given target mapping.

Usage

For the Alphabets program for matrix product.

affine matrix_product {P, Q, R|P>0 && Q>0 && R>0}
       given  float A {i,k| 0<=i<P && 0<=k<Q};
              float B {k,j| 0<=k<Q && 0<=j<R}; 
     returns  float C {i,j,k| 0<=i<P && 0<=j<R && k==Q};
using
   float temp_C {i,j,k|0<=i<P && 0<=j<R && 0<=k<=Q};
through
   temp_C[i,j,k] = case
                      {|k>0}  : temp_C[i,j,k-1] + A[i,k-1]*B[k-1,j];
                      {|k==0} : 0; 
                   esac;
   C      = temp_C;
.

The following commands will generate the scheduled code based on the given target mapping.

# Load an alphabets program and store as 'program'
program = ReadAlphabets("../../alphabets/matrix_product.ab");
# Define a variable 'system' to store the system name
system = "matrix_product";
# Specify the output directory
outDir = "../../test-out/scheduleC/";

# Set the target mapping as described in the target mapping section[[Target Mapping]]
setSpaceTimeMap(program, system, "temp_C",  "(i,j,k->i,j,k)");
setSpaceTimeMap(program, system, "C",  "(i,j,k->i,j,k)");
# Set first and second dimension to be parallel (or generate sequential code by no parallel specification)
setParallel(program, system, "", "0,1");


# Set the statement ordering
setStatementOrdering(program, system, "temp_C", "C");

# Set the memory map
setMemoryMap(program, system, "temp_C", "inner_product",  "(i,j,k->i,j)");

# Generate scheduled code according to the target mapping
generateScheduledCode(program, system, outDir);

# Generate the makefile
generateMakefile(program, system, outDir);

# Generate the wrapper to call the generated program
generateWrapper(program, system, outDir);
A Makefile, matrix_product.c and matrix_product-wrapper.c are generated for the above example.
Use the Makefile to compile the 'C' files.

schedule_code_generator.txt · Last modified: 2020/06/10 07:34 by lnarmour