Merge pull request #642 from egaburov/launch3d

concept of 3d tasking
This commit is contained in:
Dmitry Babokin
2013-12-17 08:40:07 -08:00
17 changed files with 386 additions and 69 deletions

View File

@@ -3551,11 +3551,18 @@ SelectExpr::Print() const {
// FunctionCallExpr
FunctionCallExpr::FunctionCallExpr(Expr *f, ExprList *a, SourcePos p,
bool il, Expr *lce)
bool il, Expr *lce[3])
: Expr(p), isLaunch(il) {
func = f;
args = a;
launchCountExpr = lce;
if (lce != NULL)
{
launchCountExpr[0] = lce[0];
launchCountExpr[1] = lce[1];
launchCountExpr[2] = lce[2];
}
else
launchCountExpr[0] = launchCountExpr[1] = launchCountExpr[2] = NULL;
}
@@ -3673,9 +3680,13 @@ FunctionCallExpr::GetValue(FunctionEmitContext *ctx) const {
llvm::Value *retVal = NULL;
ctx->SetDebugPos(pos);
if (ft->isTask) {
AssertPos(pos, launchCountExpr != NULL);
llvm::Value *launchCount = launchCountExpr->GetValue(ctx);
if (launchCount != NULL)
AssertPos(pos, launchCountExpr[0] != NULL);
llvm::Value *launchCount[3] =
{ launchCountExpr[0]->GetValue(ctx),
launchCountExpr[1]->GetValue(ctx),
launchCountExpr[2]->GetValue(ctx) };
if (launchCount[0] != NULL)
ctx->LaunchInst(callee, argVals, launchCount);
}
else
@@ -3798,14 +3809,17 @@ FunctionCallExpr::TypeCheck() {
if (!isLaunch)
Error(pos, "\"launch\" expression needed to call function "
"with \"task\" qualifier.");
if (!launchCountExpr)
for (int k = 0; k < 3; k++)
{
if (!launchCountExpr[k])
return NULL;
launchCountExpr =
TypeConvertExpr(launchCountExpr, AtomicType::UniformInt32,
"task launch count");
if (launchCountExpr == NULL)
launchCountExpr[k] =
TypeConvertExpr(launchCountExpr[k], AtomicType::UniformInt32,
"task launch count");
if (launchCountExpr[k] == NULL)
return NULL;
}
}
else {
if (isLaunch) {
@@ -3813,7 +3827,7 @@ FunctionCallExpr::TypeCheck() {
"qualified function.");
return NULL;
}
AssertPos(pos, launchCountExpr == NULL);
AssertPos(pos, launchCountExpr[0] == NULL);
}
}
else {