Download Sequoia++ User Manual
Transcript
5.1.4
Unsupported Features of C++
There are some features of C++ that are not supported.
• Global variables have no meaning in Sequoia, as every value is local to some task.
• Type unions are not currently part of the language.
• Virtual tasks are not supported, but Sequoia does support ordinary virtual functions. Disallowing
virtual tasks makes the task-call hierarchy completely static, enabling many optimizations that would
be much more difficult to implement otherwise.
• Multiple inheritance is not supported.
• extern functions are not supported. The compiler currently has no linker, therefore all functions must
be in scope when compiling a Sequoia file. For more information see Section 9.1.
5.2
Tasks and Task Argument Type Qualifiers
A task is a function marked with the task keyword. Tasks are restricted in that they the can only modify
data local to the task; externally, a task is a pure function. Task arguments are passed call-by-value-result,
which means that the arguments are copied to the task’s formal parameters the task’s return values are
copied back. Sequoia currently distinguishes between inner and leaf tasks. Inner tasks are used to break
up the work that is to be done at lower levels of the machine; inner tasks can call subtasks. Leaf tasks are
compute kernels that carry out the bulk computation of the algorithm; leaf tasks may not invoke subtasks.
Below are examples of an inner task and a leaf task declarations for matrix-matrix multiplication:
task<inner> void matrixmult(in float a[M][P], in float b[P][N], out float c[M][N]);
task<leaf> void matrixmult(in float a[M][P], in float b[P][N], out float c[M][N]);
The inner task is used to recursively divide up the matrices a, b, and c. These three matrices, together with
the variables M, P, and N, which give the sizes of the arrays, are the arguments to the tasks. The arguments
are labeled in (read only, only copied to the task) or out (write only, only copied back from the task’s
final state on exit to the position of the argument array in the caller). There is also an inout keyword for
arguments that are both read and written (not used in this example). Below are possible implementations
of both the inner and leaf tasks:
task<inner>
{
tunable
tunable
tunable
void matrixmult(in float a[M][P], in float b[P][N], out float c[M][N])
mBlock;
pBlock;
nBlock;
mappar ( int i = 0 : M/mBlock, int j = 0 : N/nBlock )
mapseq ( int k = 0 : P/pBlock )
matrixmult(a[i*mBlock;mBlock][k*pBlock;pBlock],
b[k*pBlock;pBlock][j*nBlock;nBlock],
c[i*mBlock;mBlock][j*nBlock;nBlock]);
}
task<leaf> void matrixmult(in float a[M][P], in float b[P][N], out float c[M][N])
{
for ( unsigned int i = 0; i < M; i++ )
for ( unsigned int j = 0; j < N; j++ )
10