changed notation, task[Index,Count]_[x,y,z] -> task[Index,Count][1,2,3]. Change launch <<< nx,ny,nz >>> into launch [nx,ny,nz] or equivalent launch [nz][ny][nx]. Programmer can pick the one the is liked the most
This commit is contained in:
@@ -59,16 +59,10 @@ mandelbrot_scanline(uniform float x0, uniform float dx,
|
||||
uniform int width, uniform int height,
|
||||
uniform int xspan, uniform int yspan,
|
||||
uniform int maxIterations, uniform int output[]) {
|
||||
#if 0
|
||||
print("taskIndex = % : % \n", taskIndex);
|
||||
print("taskIndex_x= % : % \n", taskIndex_x);
|
||||
print("taskIndex_y= % : % \n", taskIndex_y);
|
||||
print(" --- \n");
|
||||
#endif
|
||||
const uniform int xstart = taskIndex_x * xspan;
|
||||
const uniform int xstart = taskIndex1 * xspan;
|
||||
const uniform int xend = min(xstart + xspan, width);
|
||||
|
||||
const uniform int ystart = taskIndex_y * yspan;
|
||||
const uniform int ystart = taskIndex2 * yspan;
|
||||
const uniform int yend = min(ystart + yspan, height);
|
||||
|
||||
|
||||
@@ -90,10 +84,15 @@ mandelbrot_ispc(uniform float x0, uniform float y0,
|
||||
uniform int maxIterations, uniform int output[]) {
|
||||
uniform float dx = (x1 - x0) / width;
|
||||
uniform float dy = (y1 - y0) / height;
|
||||
const uniform int xspan = 16;
|
||||
const uniform int xspan = 16; /* make sure it is big enough to avoid false-sharing */
|
||||
const uniform int yspan = 16;
|
||||
|
||||
launch <<<width/xspan, height/yspan>>>
|
||||
|
||||
#if 1
|
||||
launch [width/xspan, height/yspan]
|
||||
#else
|
||||
launch [height/yspan][width/xspan]
|
||||
#endif
|
||||
mandelbrot_scanline(x0, dx, y0, dy, width, height, xspan, yspan,
|
||||
maxIterations, output);
|
||||
}
|
||||
|
||||
@@ -171,8 +171,8 @@
|
||||
// Signature of ispc-generated 'task' functions
|
||||
typedef void (*TaskFuncType)(void *data, int threadIndex, int threadCount,
|
||||
int taskIndex, int taskCount,
|
||||
int taskIndex_x, int taskIndex_y, int taskIndex_z,
|
||||
int taskCount_x, int taskCount_y, int taskCount_z);
|
||||
int taskIndex1, int taskIndex2, int taskIndex3,
|
||||
int taskCount1, int taskCount2, int taskCount3);
|
||||
|
||||
// Small structure used to hold the data for each task
|
||||
struct TaskInfo {
|
||||
@@ -183,21 +183,21 @@ struct TaskInfo {
|
||||
#if defined(ISPC_IS_WINDOWS)
|
||||
event taskEvent;
|
||||
#endif
|
||||
int taskIndex_x() const
|
||||
int taskIndex1() const
|
||||
{
|
||||
return taskIndex % taskCount3d[0];
|
||||
}
|
||||
int taskIndex_y() const
|
||||
int taskIndex2() const
|
||||
{
|
||||
return ( taskIndex / taskCount3d[0] ) % taskCount3d[1];
|
||||
}
|
||||
int taskIndex_z() const
|
||||
int taskIndex3() const
|
||||
{
|
||||
return taskIndex / ( taskCount3d[0]*taskCount3d[1] );
|
||||
}
|
||||
int taskCount_x() const { return taskCount3d[0]; }
|
||||
int taskCount_y() const { return taskCount3d[1]; }
|
||||
int taskCount_z() const { return taskCount3d[2]; }
|
||||
int taskCount1() const { return taskCount3d[0]; }
|
||||
int taskCount2() const { return taskCount3d[1]; }
|
||||
int taskCount3() const { return taskCount3d[2]; }
|
||||
};
|
||||
|
||||
// ispc expects these functions to have C linkage / not be mangled
|
||||
@@ -537,8 +537,8 @@ lRunTask(void *ti) {
|
||||
// Actually run the task
|
||||
taskInfo->func(taskInfo->data, threadIndex, threadCount,
|
||||
taskInfo->taskIndex, taskInfo->taskCount,
|
||||
taskInfo->taskIndex_x(), taskInfo->taskIndex_y(), taskInfo->taskIndex_z(),
|
||||
taskInfo->taskCount_x(), taskInfo->taskCount_y(), taskInfo->taskCount_z());
|
||||
taskInfo->taskIndex1(), taskInfo->taskIndex2(), taskInfo->taskIndex3(),
|
||||
taskInfo->taskCount1(), taskInfo->taskCount2(), taskInfo->taskCount3());
|
||||
}
|
||||
|
||||
|
||||
@@ -580,8 +580,8 @@ lRunTask(LPVOID param) {
|
||||
int threadIndex = 0;
|
||||
int threadCount = 1;
|
||||
ti->func(ti->data, threadIndex, threadCount, ti->taskIndex, ti->taskCount,
|
||||
ti->taskIndex_x(), ti->taskIndex_y(), ti->taskIndex_z(),
|
||||
ti->taskCount_x(), ti->taskCount_y(), ti->taskCount_z());
|
||||
ti->taskIndex1(), ti->taskIndex2(), ti->taskIndex3(),
|
||||
ti->taskCount1(), ti->taskCount2(), ti->taskCount3());
|
||||
|
||||
// Signal the event that this task is done
|
||||
ti->taskEvent.set();
|
||||
@@ -683,8 +683,8 @@ lTaskEntry(void *arg) {
|
||||
TaskInfo *myTask = tg->GetTaskInfo(taskNumber);
|
||||
myTask->func(myTask->data, threadIndex, threadCount, myTask->taskIndex,
|
||||
myTask->taskCount,
|
||||
myTask->taskIndex_x(), myTask->taskIndex_y(), myTask->taskIndex_z(),
|
||||
myTask->taskCount_x(), myTask->taskCount_y(), myTask->taskCount_z());
|
||||
myTask->taskIndex1(), myTask->taskIndex2(), myTask->taskIndex3(),
|
||||
myTask->taskCount1(), myTask->taskCount2(), myTask->taskCount3());
|
||||
|
||||
//
|
||||
// Decrement the "number of unfinished tasks" counter in the task
|
||||
@@ -886,8 +886,8 @@ TaskGroup::Sync() {
|
||||
//
|
||||
// FIXME: bogus values for thread index/thread count here as well..
|
||||
myTask->func(myTask->data, 0, 1, myTask->taskIndex, myTask->taskCount,
|
||||
myTask->taskIndex_x(), myTask->taskIndex_y(), myTask->taskIndex_z(),
|
||||
myTask->taskCount_x(), myTask->taskCount_y(), myTask->taskCount_z());
|
||||
myTask->taskIndex1(), myTask->taskIndex2(), myTask->taskIndex3(),
|
||||
myTask->taskCount1(), myTask->taskCount2(), myTask->taskCount3());
|
||||
|
||||
//
|
||||
// Decrement the number of unfinished tasks counter
|
||||
@@ -918,8 +918,8 @@ TaskGroup::Launch(int baseIndex, int count) {
|
||||
// Actually run the task.
|
||||
// Cilk does not expose the task -> thread mapping so we pretend it's 1:1
|
||||
ti->func(ti->data, ti->taskIndex, ti->taskCount, ti->taskIndex, ti->taskCount,
|
||||
ti->taskIndex_x(), ti->taskIndex_y(), ti->taskIndex_z(),
|
||||
ti->taskCount_x(), ti->taskCount_y(), ti->taskCount_z());
|
||||
ti->taskIndex1(), ti->taskIndex2(), ti->taskIndex3(),
|
||||
ti->taskCount1(), ti->taskCount2(), ti->taskCount3());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -949,8 +949,8 @@ TaskGroup::Launch(int baseIndex, int count) {
|
||||
int threadIndex = omp_get_thread_num();
|
||||
int threadCount = omp_get_num_threads();
|
||||
ti->func(ti->data, threadIndex, threadCount, ti->taskIndex, ti->taskCount,
|
||||
ti->taskIndex_x(), ti->taskIndex_y(), ti->taskIndex_z(),
|
||||
ti->taskCount_x(), ti->taskCount_y(), ti->taskCount_z());
|
||||
ti->taskIndex1(), ti->taskIndex2(), ti->taskIndex3(),
|
||||
ti->taskCount1(), ti->taskCount2(), ti->taskCount3());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -982,8 +982,8 @@ TaskGroup::Launch(int baseIndex, int count) {
|
||||
int threadCount = ti->taskCount;
|
||||
|
||||
ti->func(ti->data, threadIndex, threadCount, ti->taskIndex, ti->taskCount,
|
||||
ti->taskIndex_x(), ti->taskIndex_y(), ti->taskIndex_z(),
|
||||
ti->taskCount_x(), ti->taskCount_y(), ti->taskCount_z());
|
||||
ti->taskIndex1(), ti->taskIndex2(), ti->taskIndex3(),
|
||||
ti->taskCount1(), ti->taskCount2(), ti->taskCount3());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1011,8 +1011,8 @@ TaskGroup::Launch(int baseIndex, int count) {
|
||||
int threadIndex = ti->taskIndex;
|
||||
int threadCount = ti->taskCount;
|
||||
ti->func(ti->data, threadIndex, threadCount, ti->taskIndex, ti->taskCount,
|
||||
ti->taskIndex_x(), ti->taskIndex_y(), ti->taskIndex_z(),
|
||||
ti->taskCount_x(), ti->taskCount_y(), ti->taskCount_z());
|
||||
ti->taskIndex1(), ti->taskIndex2(), ti->taskIndex3(),
|
||||
ti->taskCount1(), ti->taskCount2(), ti->taskCount3());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1065,8 +1065,8 @@ FreeTaskGroup(TaskGroup *tg) {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void
|
||||
ISPCLaunch(void **taskGroupPtr, void *func, void *data, int countx, int county, int countz) {
|
||||
const int count = countx*county*countz;
|
||||
ISPCLaunch(void **taskGroupPtr, void *func, void *data, int count1, int count2, int count3) {
|
||||
const int count = count1*count2*count3;
|
||||
TaskGroup *taskGroup;
|
||||
if (*taskGroupPtr == NULL) {
|
||||
InitTaskSystem();
|
||||
@@ -1083,9 +1083,9 @@ ISPCLaunch(void **taskGroupPtr, void *func, void *data, int countx, int county,
|
||||
ti->data = data;
|
||||
ti->taskIndex = i;
|
||||
ti->taskCount = count;
|
||||
ti->taskCount3d[0] = countx;
|
||||
ti->taskCount3d[1] = county;
|
||||
ti->taskCount3d[2] = countz;
|
||||
ti->taskCount3d[0] = count1;
|
||||
ti->taskCount3d[1] = count2;
|
||||
ti->taskCount3d[2] = count3;
|
||||
}
|
||||
taskGroup->Launch(baseIndex, count);
|
||||
}
|
||||
|
||||
64
func.cpp
64
func.cpp
@@ -133,26 +133,26 @@ Function::Function(Symbol *s, Stmt *c) {
|
||||
taskCountSym = m->symbolTable->LookupVariable("taskCount");
|
||||
Assert(taskCountSym);
|
||||
|
||||
taskIndexSym_x = m->symbolTable->LookupVariable("taskIndex_x");
|
||||
Assert(taskIndexSym_x);
|
||||
taskIndexSym_y = m->symbolTable->LookupVariable("taskIndex_y");
|
||||
Assert(taskIndexSym_y);
|
||||
taskIndexSym_z = m->symbolTable->LookupVariable("taskIndex_z");
|
||||
Assert(taskIndexSym_z);
|
||||
taskIndexSym1 = m->symbolTable->LookupVariable("taskIndex1");
|
||||
Assert(taskIndexSym1);
|
||||
taskIndexSym2 = m->symbolTable->LookupVariable("taskIndex2");
|
||||
Assert(taskIndexSym2);
|
||||
taskIndexSym3 = m->symbolTable->LookupVariable("taskIndex3");
|
||||
Assert(taskIndexSym3);
|
||||
|
||||
|
||||
taskCountSym_x = m->symbolTable->LookupVariable("taskCount_x");
|
||||
Assert(taskCountSym_x);
|
||||
taskCountSym_y = m->symbolTable->LookupVariable("taskCount_y");
|
||||
Assert(taskCountSym_y);
|
||||
taskCountSym_z = m->symbolTable->LookupVariable("taskCount_z");
|
||||
Assert(taskCountSym_z);
|
||||
taskCountSym1 = m->symbolTable->LookupVariable("taskCount1");
|
||||
Assert(taskCountSym1);
|
||||
taskCountSym2 = m->symbolTable->LookupVariable("taskCount2");
|
||||
Assert(taskCountSym2);
|
||||
taskCountSym3 = m->symbolTable->LookupVariable("taskCount3");
|
||||
Assert(taskCountSym3);
|
||||
}
|
||||
else
|
||||
{
|
||||
threadIndexSym = threadCountSym = taskIndexSym = taskCountSym = NULL;
|
||||
taskIndexSym_x = taskIndexSym_y = taskIndexSym_z = NULL;
|
||||
taskCountSym_x = taskCountSym_y = taskCountSym_z = NULL;
|
||||
taskIndexSym1 = taskIndexSym2 = taskIndexSym3 = NULL;
|
||||
taskCountSym1 = taskCountSym2 = taskCountSym3 = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,12 +244,12 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
|
||||
llvm::Value *threadCount = argIter++;
|
||||
llvm::Value *taskIndex = argIter++;
|
||||
llvm::Value *taskCount = argIter++;
|
||||
llvm::Value *taskIndex_x = argIter++;
|
||||
llvm::Value *taskIndex_y = argIter++;
|
||||
llvm::Value *taskIndex_z = argIter++;
|
||||
llvm::Value *taskCount_x = argIter++;
|
||||
llvm::Value *taskCount_y = argIter++;
|
||||
llvm::Value *taskCount_z = argIter++;
|
||||
llvm::Value *taskIndex1 = argIter++;
|
||||
llvm::Value *taskIndex2 = argIter++;
|
||||
llvm::Value *taskIndex3 = argIter++;
|
||||
llvm::Value *taskCount1 = argIter++;
|
||||
llvm::Value *taskCount2 = argIter++;
|
||||
llvm::Value *taskCount3 = argIter++;
|
||||
|
||||
// Copy the function parameter values from the structure into local
|
||||
// storage
|
||||
@@ -282,19 +282,19 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
|
||||
taskCountSym->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount");
|
||||
ctx->StoreInst(taskCount, taskCountSym->storagePtr);
|
||||
|
||||
taskIndexSym_x->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskIndex_x");
|
||||
ctx->StoreInst(taskIndex_x, taskIndexSym_x->storagePtr);
|
||||
taskIndexSym_y->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskIndex_y");
|
||||
ctx->StoreInst(taskIndex_y, taskIndexSym_y->storagePtr);
|
||||
taskIndexSym_z->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskIndex_z");
|
||||
ctx->StoreInst(taskIndex_z, taskIndexSym_z->storagePtr);
|
||||
taskIndexSym1->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskIndex1");
|
||||
ctx->StoreInst(taskIndex1, taskIndexSym1->storagePtr);
|
||||
taskIndexSym2->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskIndex2");
|
||||
ctx->StoreInst(taskIndex2, taskIndexSym2->storagePtr);
|
||||
taskIndexSym3->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskIndex3");
|
||||
ctx->StoreInst(taskIndex3, taskIndexSym3->storagePtr);
|
||||
|
||||
taskCountSym_x->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount_x");
|
||||
ctx->StoreInst(taskCount_x, taskCountSym_x->storagePtr);
|
||||
taskCountSym_y->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount_y");
|
||||
ctx->StoreInst(taskCount_y, taskCountSym_y->storagePtr);
|
||||
taskCountSym_z->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount_z");
|
||||
ctx->StoreInst(taskCount_z, taskCountSym_z->storagePtr);
|
||||
taskCountSym1->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount1");
|
||||
ctx->StoreInst(taskCount1, taskCountSym1->storagePtr);
|
||||
taskCountSym2->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount2");
|
||||
ctx->StoreInst(taskCount2, taskCountSym2->storagePtr);
|
||||
taskCountSym3->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount3");
|
||||
ctx->StoreInst(taskCount3, taskCountSym3->storagePtr);
|
||||
}
|
||||
else {
|
||||
// Regular, non-task function
|
||||
|
||||
6
func.h
6
func.h
@@ -61,9 +61,9 @@ private:
|
||||
Symbol *maskSymbol;
|
||||
Symbol *threadIndexSym, *threadCountSym;
|
||||
Symbol *taskIndexSym, *taskCountSym;
|
||||
Symbol *taskIndexSym_x, *taskCountSym_x;
|
||||
Symbol *taskIndexSym_y, *taskCountSym_y;
|
||||
Symbol *taskIndexSym_z, *taskCountSym_z;
|
||||
Symbol *taskIndexSym1, *taskCountSym1;
|
||||
Symbol *taskIndexSym2, *taskCountSym2;
|
||||
Symbol *taskIndexSym3, *taskCountSym3;
|
||||
};
|
||||
|
||||
#endif // ISPC_FUNC_H
|
||||
|
||||
7
lex.ll
7
lex.ll
@@ -76,7 +76,6 @@ 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,
|
||||
@@ -152,8 +151,6 @@ 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";
|
||||
@@ -269,8 +266,6 @@ 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";
|
||||
@@ -423,8 +418,6 @@ 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; }
|
||||
|
||||
76
parse.yy
76
parse.yy
@@ -204,7 +204,6 @@ 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
|
||||
@@ -363,54 +362,65 @@ launch_expression
|
||||
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 ')'
|
||||
|
||||
| TOKEN_LAUNCH '[' assignment_expression ']' 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 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 '(' ')'
|
||||
{
|
||||
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 '(' ')'
|
||||
| TOKEN_LAUNCH '[' assignment_expression ']' 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 ')'
|
||||
| TOKEN_LAUNCH '[' assignment_expression ',' assignment_expression ']' 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 '(' ')'
|
||||
| TOKEN_LAUNCH '[' assignment_expression ',' assignment_expression ']' 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 '[' assignment_expression ']' '[' assignment_expression ']' postfix_expression '(' argument_expression_list ')'
|
||||
{
|
||||
ConstExpr *oneExpr = new ConstExpr(AtomicType::UniformInt32, (int32_t)1, @8);
|
||||
Expr *launchCount[3] = {$6, $3, oneExpr};
|
||||
$$ = new FunctionCallExpr($8, $10, Union(@8,@11), true, launchCount);
|
||||
}
|
||||
| TOKEN_LAUNCH '[' assignment_expression ']' '[' assignment_expression ']' postfix_expression '(' ')'
|
||||
{
|
||||
ConstExpr *oneExpr = new ConstExpr(AtomicType::UniformInt32, (int32_t)1, @8);
|
||||
Expr *launchCount[3] = {$6, $3, oneExpr};
|
||||
$$ = new FunctionCallExpr($8, new ExprList(Union(@8,@9)), Union(@8,@10), true, launchCount);
|
||||
}
|
||||
|
||||
| TOKEN_LAUNCH TOKEN_TRIPLECHEVRON_OPEN assignment_expression ',' assignment_expression ',' assignment_expression TOKEN_TRIPLECHEVRON_CLOSE postfix_expression '(' argument_expression_list ')'
|
||||
| TOKEN_LAUNCH '[' assignment_expression ',' assignment_expression ',' assignment_expression ']' 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 '(' ')'
|
||||
| TOKEN_LAUNCH '[' assignment_expression ',' assignment_expression ',' assignment_expression ']' postfix_expression '(' ')'
|
||||
{
|
||||
Expr *launchCount[3] = {$3, $5, $7};
|
||||
$$ = new FunctionCallExpr($9, new ExprList(Union(@9,@10)), Union(@9,@11), true, launchCount);
|
||||
}
|
||||
| TOKEN_LAUNCH '[' assignment_expression ']' '[' assignment_expression ']' '[' assignment_expression ']' postfix_expression '(' argument_expression_list ')'
|
||||
{
|
||||
Expr *launchCount[3] = {$9, $6, $3};
|
||||
$$ = new FunctionCallExpr($11, $13, Union(@11,@14), true, launchCount);
|
||||
}
|
||||
| TOKEN_LAUNCH '[' assignment_expression ']' '[' assignment_expression ']' '[' assignment_expression ']' postfix_expression '(' ')'
|
||||
{
|
||||
Expr *launchCount[3] = {$9, $6, $3};
|
||||
$$ = new FunctionCallExpr($11, new ExprList(Union(@11,@12)), Union(@11,@13), true, launchCount);
|
||||
}
|
||||
|
||||
|
||||
| TOKEN_LAUNCH '<' postfix_expression '(' argument_expression_list ')' '>'
|
||||
@@ -425,13 +435,13 @@ launch_expression
|
||||
"around function call expression.");
|
||||
$$ = NULL;
|
||||
}
|
||||
| TOKEN_LAUNCH '[' expression ']' '<' postfix_expression '(' argument_expression_list ')' '>'
|
||||
| TOKEN_LAUNCH '[' assignment_expression ']' '<' postfix_expression '(' argument_expression_list ')' '>'
|
||||
{
|
||||
Error(Union(@5, @10), "\"launch\" expressions no longer take '<' '>' "
|
||||
"around function call expression.");
|
||||
$$ = NULL;
|
||||
}
|
||||
| TOKEN_LAUNCH '[' expression ']' '<' postfix_expression '(' ')' '>'
|
||||
| TOKEN_LAUNCH '[' assignment_expression ']' '<' postfix_expression '(' ')' '>'
|
||||
{
|
||||
Error(Union(@5, @9), "\"launch\" expressions no longer take '<' '>' "
|
||||
"around function call expression.");
|
||||
@@ -2266,20 +2276,20 @@ static void lAddThreadIndexCountToSymbolTable(SourcePos pos) {
|
||||
Symbol *taskCountSym = new Symbol("taskCount", pos, type);
|
||||
m->symbolTable->AddVariable(taskCountSym);
|
||||
|
||||
Symbol *taskIndexSym_x = new Symbol("taskIndex_x", pos, type);
|
||||
m->symbolTable->AddVariable(taskIndexSym_x);
|
||||
Symbol *taskIndexSym_y = new Symbol("taskIndex_y", pos, type);
|
||||
m->symbolTable->AddVariable(taskIndexSym_y);
|
||||
Symbol *taskIndexSym_z = new Symbol("taskIndex_z", pos, type);
|
||||
m->symbolTable->AddVariable(taskIndexSym_z);
|
||||
Symbol *taskIndexSym1 = new Symbol("taskIndex1", pos, type);
|
||||
m->symbolTable->AddVariable(taskIndexSym1);
|
||||
Symbol *taskIndexSym2 = new Symbol("taskIndex2", pos, type);
|
||||
m->symbolTable->AddVariable(taskIndexSym2);
|
||||
Symbol *taskIndexSym3 = new Symbol("taskIndex3", pos, type);
|
||||
m->symbolTable->AddVariable(taskIndexSym3);
|
||||
|
||||
|
||||
Symbol *taskCountSym_x = new Symbol("taskCount_x", pos, type);
|
||||
m->symbolTable->AddVariable(taskCountSym_x);
|
||||
Symbol *taskCountSym_y = new Symbol("taskCount_y", pos, type);
|
||||
m->symbolTable->AddVariable(taskCountSym_y);
|
||||
Symbol *taskCountSym_z = new Symbol("taskCount_z", pos, type);
|
||||
m->symbolTable->AddVariable(taskCountSym_z);
|
||||
Symbol *taskCountSym1 = new Symbol("taskCount1", pos, type);
|
||||
m->symbolTable->AddVariable(taskCountSym1);
|
||||
Symbol *taskCountSym2 = new Symbol("taskCount2", pos, type);
|
||||
m->symbolTable->AddVariable(taskCountSym2);
|
||||
Symbol *taskCountSym3 = new Symbol("taskCount3", pos, type);
|
||||
m->symbolTable->AddVariable(taskCountSym3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
12
type.cpp
12
type.cpp
@@ -2961,12 +2961,12 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const {
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // threadCount
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskIndex
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskCount
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskIndex_x
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskIndex_y
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskIndex_z
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskCount_x
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskCount_y
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskCount_z
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskIndex1
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskIndex2
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskIndex3
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskCount1
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskCount2
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskCount3
|
||||
}
|
||||
else
|
||||
// Otherwise we already have the types of the arguments
|
||||
|
||||
Reference in New Issue
Block a user