Add foreach and foreach_tiled looping constructs

These make it easier to iterate over arbitrary amounts of data
elements; specifically, they automatically handle the "ragged
extra bits" that come up when the number of elements to be
processed isn't evenly divided by programCount.

TODO: documentation
This commit is contained in:
Matt Pharr
2011-11-30 13:17:31 -08:00
parent b48775a549
commit 8bc7367109
32 changed files with 1120 additions and 78 deletions

25
stmt.h
View File

@@ -241,6 +241,31 @@ private:
};
/** @brief Statement implementation for parallel 'foreach' loops.
*/
class ForeachStmt : public Stmt {
public:
ForeachStmt(const std::vector<Symbol *> &loopVars,
const std::vector<Expr *> &startExprs,
const std::vector<Expr *> &endExprs,
Stmt *bodyStatements, bool tiled, SourcePos pos);
void EmitCode(FunctionEmitContext *ctx) const;
void Print(int indent) const;
Stmt *Optimize();
Stmt *TypeCheck();
int EstimateCost() const;
std::vector<Symbol *> dimVariables;
std::vector<Expr *> startExprs;
std::vector<Expr *> endExprs;
bool isTiled;
Stmt *stmts;
};
/** @brief Statement implementation for a 'return' or 'coherent' return
statement in the program. */
class ReturnStmt : public Stmt {