launch now passes the right info into tasking
This commit is contained in:
3
ast.cpp
3
ast.cpp
@@ -223,7 +223,8 @@ WalkAST(ASTNode *node, ASTPreCallBackFunc preFunc, ASTPostCallBackFunc postFunc,
|
||||
else if ((fce = dynamic_cast<FunctionCallExpr *>(node)) != NULL) {
|
||||
fce->func = (Expr *)WalkAST(fce->func, preFunc, postFunc, data);
|
||||
fce->args = (ExprList *)WalkAST(fce->args, preFunc, postFunc, data);
|
||||
fce->launchCountExpr = (Expr *)WalkAST(fce->launchCountExpr, preFunc,
|
||||
for (int k = 0; k < 3; k++)
|
||||
fce->launchCountExpr[0] = (Expr *)WalkAST(fce->launchCountExpr[0], preFunc,
|
||||
postFunc, data);
|
||||
}
|
||||
else if ((ie = dynamic_cast<IndexExpr *>(node)) != NULL) {
|
||||
|
||||
@@ -1813,7 +1813,7 @@ define(`stdlib_core', `
|
||||
declare i32 @__fast_masked_vload()
|
||||
|
||||
declare i8* @ISPCAlloc(i8**, i64, i32) nounwind
|
||||
declare void @ISPCLaunch(i8**, i8*, i8*, i32) nounwind
|
||||
declare void @ISPCLaunch(i8**, i8*, i8*, i32,i32,i32) nounwind
|
||||
declare void @ISPCSync(i8*) nounwind
|
||||
declare void @ISPCInstrument(i8*, i8*, i32, i64) nounwind
|
||||
|
||||
|
||||
6
ctx.cpp
6
ctx.cpp
@@ -3502,7 +3502,7 @@ FunctionEmitContext::ReturnInst() {
|
||||
llvm::Value *
|
||||
FunctionEmitContext::LaunchInst(llvm::Value *callee,
|
||||
std::vector<llvm::Value *> &argVals,
|
||||
llvm::Value *launchCount) {
|
||||
llvm::Value *launchCount[3]){
|
||||
if (callee == NULL) {
|
||||
AssertPos(currentPos, m->errorCount > 0);
|
||||
return NULL;
|
||||
@@ -3563,7 +3563,9 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
|
||||
args.push_back(launchGroupHandlePtr);
|
||||
args.push_back(fptr);
|
||||
args.push_back(voidmem);
|
||||
args.push_back(launchCount);
|
||||
args.push_back(launchCount[0]);
|
||||
args.push_back(launchCount[1]);
|
||||
args.push_back(launchCount[2]);
|
||||
return CallInst(flaunch, NULL, args, "");
|
||||
}
|
||||
|
||||
|
||||
2
ctx.h
2
ctx.h
@@ -542,7 +542,7 @@ public:
|
||||
he given argument values. */
|
||||
llvm::Value *LaunchInst(llvm::Value *callee,
|
||||
std::vector<llvm::Value *> &argVals,
|
||||
llvm::Value *launchCount);
|
||||
llvm::Value *launchCount[3]);
|
||||
|
||||
void SyncInst();
|
||||
|
||||
|
||||
31
expr.cpp
31
expr.cpp
@@ -3540,11 +3540,13 @@ 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;
|
||||
launchCountExpr[0] = lce[0];
|
||||
launchCountExpr[1] = lce[1];
|
||||
launchCountExpr[2] = lce[2];
|
||||
}
|
||||
|
||||
|
||||
@@ -3662,9 +3664,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
|
||||
@@ -3787,14 +3793,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) {
|
||||
@@ -3802,7 +3811,7 @@ FunctionCallExpr::TypeCheck() {
|
||||
"qualified function.");
|
||||
return NULL;
|
||||
}
|
||||
AssertPos(pos, launchCountExpr == NULL);
|
||||
AssertPos(pos, launchCountExpr[0] == NULL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
5
expr.h
5
expr.h
@@ -246,7 +246,8 @@ public:
|
||||
class FunctionCallExpr : public Expr {
|
||||
public:
|
||||
FunctionCallExpr(Expr *func, ExprList *args, SourcePos p,
|
||||
bool isLaunch = false, Expr *launchCountExpr = NULL);
|
||||
bool isLaunch = false,
|
||||
Expr *launchCountExpr[3] = (Expr*[3]){NULL, NULL, NULL});
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
|
||||
@@ -261,7 +262,7 @@ public:
|
||||
Expr *func;
|
||||
ExprList *args;
|
||||
bool isLaunch;
|
||||
Expr *launchCountExpr;
|
||||
Expr *launchCountExpr[3];
|
||||
};
|
||||
|
||||
|
||||
|
||||
7
lex.ll
7
lex.ll
@@ -76,6 +76,7 @@ static int allTokens[] = {
|
||||
TOKEN_TASK, TOKEN_TRUE, TOKEN_TYPEDEF, TOKEN_UNIFORM, TOKEN_UNMASKED,
|
||||
TOKEN_UNSIGNED, TOKEN_VARYING, TOKEN_VOID, TOKEN_WHILE,
|
||||
TOKEN_STRING_C_LITERAL, TOKEN_DOTDOTDOT,
|
||||
TOKEN_TRIPLECHEVRON_OPEN, TOKEN_TRIPLECHEVRON_CLOSE,
|
||||
TOKEN_FLOAT_CONSTANT, TOKEN_DOUBLE_CONSTANT,
|
||||
TOKEN_INT8_CONSTANT, TOKEN_UINT8_CONSTANT,
|
||||
TOKEN_INT16_CONSTANT, TOKEN_UINT16_CONSTANT,
|
||||
@@ -151,6 +152,8 @@ void ParserInit() {
|
||||
tokenToName[TOKEN_WHILE] = "while";
|
||||
tokenToName[TOKEN_STRING_C_LITERAL] = "\"C\"";
|
||||
tokenToName[TOKEN_DOTDOTDOT] = "...";
|
||||
tokenToName[TOKEN_TRIPLECHEVRON_OPEN] = "<<<";
|
||||
tokenToName[TOKEN_TRIPLECHEVRON_CLOSE] = ">>>";
|
||||
tokenToName[TOKEN_FLOAT_CONSTANT] = "TOKEN_FLOAT_CONSTANT";
|
||||
tokenToName[TOKEN_DOUBLE_CONSTANT] = "TOKEN_DOUBLE_CONSTANT";
|
||||
tokenToName[TOKEN_INT8_CONSTANT] = "TOKEN_INT8_CONSTANT";
|
||||
@@ -266,6 +269,8 @@ void ParserInit() {
|
||||
tokenNameRemap["TOKEN_WHILE"] = "\'while\'";
|
||||
tokenNameRemap["TOKEN_STRING_C_LITERAL"] = "\"C\"";
|
||||
tokenNameRemap["TOKEN_DOTDOTDOT"] = "\'...\'";
|
||||
tokenNameRemap["TOKEN_TRIPLECHEVRON_OPEN"] = "\'<<<\'";
|
||||
tokenNameRemap["TOKEN_TRIPLECHEVRON_CLOSE"] = "\'>>>\'";
|
||||
tokenNameRemap["TOKEN_FLOAT_CONSTANT"] = "float constant";
|
||||
tokenNameRemap["TOKEN_DOUBLE_CONSTANT"] = "double constant";
|
||||
tokenNameRemap["TOKEN_INT8_CONSTANT"] = "int8 constant";
|
||||
@@ -418,6 +423,8 @@ void { RT; return TOKEN_VOID; }
|
||||
while { RT; return TOKEN_WHILE; }
|
||||
\"C\" { RT; return TOKEN_STRING_C_LITERAL; }
|
||||
\.\.\. { RT; return TOKEN_DOTDOTDOT; }
|
||||
\<\<\< { RT; return TOKEN_TRIPLECHEVRON_OPEN; }
|
||||
\>\>\> { RT; return TOKEN_TRIPLECHEVRON_CLOSE; }
|
||||
|
||||
"operator*" { return TOKEN_IDENTIFIER; }
|
||||
"operator+" { return TOKEN_IDENTIFIER; }
|
||||
|
||||
56
parse.yy
56
parse.yy
@@ -204,6 +204,7 @@ struct ForeachDimension {
|
||||
%token TOKEN_CASE TOKEN_DEFAULT TOKEN_IF TOKEN_ELSE TOKEN_SWITCH
|
||||
%token TOKEN_WHILE TOKEN_DO TOKEN_LAUNCH TOKEN_FOREACH TOKEN_FOREACH_TILED
|
||||
%token TOKEN_FOREACH_UNIQUE TOKEN_FOREACH_ACTIVE TOKEN_DOTDOTDOT
|
||||
%token TOKEN_TRIPLECHEVRON_OPEN TOKEN_TRIPLECHEVRON_CLOSE
|
||||
%token TOKEN_FOR TOKEN_GOTO TOKEN_CONTINUE TOKEN_BREAK TOKEN_RETURN
|
||||
%token TOKEN_CIF TOKEN_CDO TOKEN_CFOR TOKEN_CWHILE
|
||||
%token TOKEN_SYNC TOKEN_PRINT TOKEN_ASSERT
|
||||
@@ -353,17 +354,64 @@ launch_expression
|
||||
: TOKEN_LAUNCH postfix_expression '(' argument_expression_list ')'
|
||||
{
|
||||
ConstExpr *oneExpr = new ConstExpr(AtomicType::UniformInt32, (int32_t)1, @2);
|
||||
$$ = new FunctionCallExpr($2, $4, Union(@2, @5), true, oneExpr);
|
||||
Expr *launchCount[3] = {oneExpr, oneExpr, oneExpr};
|
||||
$$ = new FunctionCallExpr($2, $4, Union(@2, @5), true, launchCount);
|
||||
}
|
||||
| TOKEN_LAUNCH postfix_expression '(' ')'
|
||||
{
|
||||
ConstExpr *oneExpr = new ConstExpr(AtomicType::UniformInt32, (int32_t)1, @2);
|
||||
$$ = new FunctionCallExpr($2, new ExprList(Union(@3,@4)), Union(@2, @4), true, oneExpr);
|
||||
Expr *launchCount[3] = {oneExpr, oneExpr, oneExpr};
|
||||
$$ = new FunctionCallExpr($2, new ExprList(Union(@3,@4)), Union(@2, @4), true, launchCount);
|
||||
}
|
||||
| TOKEN_LAUNCH '[' expression ']' postfix_expression '(' argument_expression_list ')'
|
||||
{ $$ = new FunctionCallExpr($5, $7, Union(@5,@8), true, $3); }
|
||||
{
|
||||
ConstExpr *oneExpr = new ConstExpr(AtomicType::UniformInt32, (int32_t)1, @5);
|
||||
Expr *launchCount[3] = {$3, oneExpr, oneExpr};
|
||||
$$ = new FunctionCallExpr($5, $7, Union(@5,@8), true, launchCount);
|
||||
}
|
||||
| TOKEN_LAUNCH TOKEN_TRIPLECHEVRON_OPEN assignment_expression TOKEN_TRIPLECHEVRON_CLOSE postfix_expression '(' argument_expression_list ')'
|
||||
{
|
||||
ConstExpr *oneExpr = new ConstExpr(AtomicType::UniformInt32, (int32_t)1, @5);
|
||||
Expr *launchCount[3] = {$3, oneExpr, oneExpr};
|
||||
$$ = new FunctionCallExpr($5, $7, Union(@5,@8), true, launchCount);
|
||||
}
|
||||
| TOKEN_LAUNCH '[' expression ']' postfix_expression '(' ')'
|
||||
{ $$ = new FunctionCallExpr($5, new ExprList(Union(@5,@6)), Union(@5,@7), true, $3); }
|
||||
{
|
||||
ConstExpr *oneExpr = new ConstExpr(AtomicType::UniformInt32, (int32_t)1, @5);
|
||||
Expr *launchCount[3] = {$3, oneExpr, oneExpr};
|
||||
$$ = new FunctionCallExpr($5, new ExprList(Union(@5,@6)), Union(@5,@7), true, launchCount);
|
||||
}
|
||||
| TOKEN_LAUNCH TOKEN_TRIPLECHEVRON_OPEN assignment_expression TOKEN_TRIPLECHEVRON_CLOSE postfix_expression '(' ')'
|
||||
{
|
||||
ConstExpr *oneExpr = new ConstExpr(AtomicType::UniformInt32, (int32_t)1, @5);
|
||||
Expr *launchCount[3] = {$3, oneExpr, oneExpr};
|
||||
$$ = new FunctionCallExpr($5, new ExprList(Union(@5,@6)), Union(@5,@7), true, launchCount);
|
||||
}
|
||||
|
||||
| TOKEN_LAUNCH TOKEN_TRIPLECHEVRON_OPEN assignment_expression ',' assignment_expression TOKEN_TRIPLECHEVRON_CLOSE postfix_expression '(' argument_expression_list ')'
|
||||
{
|
||||
ConstExpr *oneExpr = new ConstExpr(AtomicType::UniformInt32, (int32_t)1, @7);
|
||||
Expr *launchCount[3] = {$3, $5, oneExpr};
|
||||
$$ = new FunctionCallExpr($7, $9, Union(@7,@10), true, launchCount);
|
||||
}
|
||||
| TOKEN_LAUNCH TOKEN_TRIPLECHEVRON_OPEN assignment_expression ',' assignment_expression TOKEN_TRIPLECHEVRON_CLOSE postfix_expression '(' ')'
|
||||
{
|
||||
ConstExpr *oneExpr = new ConstExpr(AtomicType::UniformInt32, (int32_t)1, @7);
|
||||
Expr *launchCount[3] = {$3, $5, oneExpr};
|
||||
$$ = new FunctionCallExpr($7, new ExprList(Union(@7,@8)), Union(@7,@9), true, launchCount);
|
||||
}
|
||||
|
||||
| TOKEN_LAUNCH TOKEN_TRIPLECHEVRON_OPEN assignment_expression ',' assignment_expression ',' assignment_expression TOKEN_TRIPLECHEVRON_CLOSE postfix_expression '(' argument_expression_list ')'
|
||||
{
|
||||
Expr *launchCount[3] = {$3, $5, $7};
|
||||
$$ = new FunctionCallExpr($9, $11, Union(@9,@12), true, launchCount);
|
||||
}
|
||||
| TOKEN_LAUNCH TOKEN_TRIPLECHEVRON_OPEN assignment_expression ',' assignment_expression ',' assignment_expression TOKEN_TRIPLECHEVRON_CLOSE postfix_expression '(' ')'
|
||||
{
|
||||
Expr *launchCount[3] = {$3, $5, $7};
|
||||
$$ = new FunctionCallExpr($9, new ExprList(Union(@9,@10)), Union(@9,@11), true, launchCount);
|
||||
}
|
||||
|
||||
|
||||
| TOKEN_LAUNCH '<' postfix_expression '(' argument_expression_list ')' '>'
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user