diff --git a/examples/mandelbrot_tasks3d/mandelbrot_tasks3d.ispc b/examples/mandelbrot_tasks3d/mandelbrot_tasks3d.ispc index 8bdf6f7a..395bdca4 100644 --- a/examples/mandelbrot_tasks3d/mandelbrot_tasks3d.ispc +++ b/examples/mandelbrot_tasks3d/mandelbrot_tasks3d.ispc @@ -59,10 +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[]) { - const uniform int xstart = taskIndex1 * xspan; + const uniform int xstart = taskIndex0 * xspan; const uniform int xend = min(xstart + xspan, width); - const uniform int ystart = taskIndex2 * yspan; + const uniform int ystart = taskIndex1 * yspan; const uniform int yend = min(ystart + yspan, height); diff --git a/examples/tasksys.cpp b/examples/tasksys.cpp index 4c85e119..6bc60129 100644 --- a/examples/tasksys.cpp +++ b/examples/tasksys.cpp @@ -171,8 +171,8 @@ // Signature of ispc-generated 'task' functions typedef void (*TaskFuncType)(void *data, int threadIndex, int threadCount, int taskIndex, int taskCount, - int taskIndex1, int taskIndex2, int taskIndex3, - int taskCount1, int taskCount2, int taskCount3); + int taskIndex0, int taskIndex1, int taskIndex2, + int taskCount0, int taskCount1, int taskCount2); // Small structure used to hold the data for each task struct TaskInfo { @@ -184,21 +184,21 @@ struct TaskInfo { event taskEvent; #endif int taskCount() const { return taskCount3d[0]*taskCount3d[1]*taskCount3d[2]; } - int taskIndex1() const + int taskIndex0() const { return taskIndex % taskCount3d[0]; } - int taskIndex2() const + int taskIndex1() const { return ( taskIndex / taskCount3d[0] ) % taskCount3d[1]; } - int taskIndex3() const + int taskIndex2() const { return taskIndex / ( taskCount3d[0]*taskCount3d[1] ); } - int taskCount1() const { return taskCount3d[0]; } - int taskCount2() const { return taskCount3d[1]; } - int taskCount3() const { return taskCount3d[2]; } + int taskCount0() const { return taskCount3d[0]; } + int taskCount1() const { return taskCount3d[1]; } + int taskCount2() const { return taskCount3d[2]; } TaskInfo() { assert(sizeof(TaskInfo) % 32 == 0); } } __attribute__((aligned(32))); @@ -539,8 +539,8 @@ lRunTask(void *ti) { // Actually run the task taskInfo->func(taskInfo->data, threadIndex, threadCount, taskInfo->taskIndex, taskInfo->taskCount(), - taskInfo->taskIndex1(), taskInfo->taskIndex2(), taskInfo->taskIndex3(), - taskInfo->taskCount1(), taskInfo->taskCount2(), taskInfo->taskCount3()); + taskInfo->taskIndex0(), taskInfo->taskIndex1(), taskInfo->taskIndex2(), + taskInfo->taskCount0(), taskInfo->taskCount1(), taskInfo->taskCount2()); } @@ -582,8 +582,8 @@ lRunTask(LPVOID param) { int threadIndex = 0; int threadCount = 1; ti->func(ti->data, threadIndex, threadCount, ti->taskIndex, ti->taskCount(), - ti->taskIndex1(), ti->taskIndex2(), ti->taskIndex3(), - ti->taskCount1(), ti->taskCount2(), ti->taskCount3()); + ti->taskIndex0(), ti->taskIndex1(), ti->taskIndex2(), + ti->taskCount0(), ti->taskCount1(), ti->taskCount2()); // Signal the event that this task is done ti->taskEvent.set(); @@ -685,8 +685,8 @@ lTaskEntry(void *arg) { TaskInfo *myTask = tg->GetTaskInfo(taskNumber); myTask->func(myTask->data, threadIndex, threadCount, myTask->taskIndex, myTask->taskCount(), - myTask->taskIndex1(), myTask->taskIndex2(), myTask->taskIndex3(), - myTask->taskCount1(), myTask->taskCount2(), myTask->taskCount3()); + myTask->taskIndex0(), myTask->taskIndex1(), myTask->taskIndex2(), + myTask->taskCount0(), myTask->taskCount1(), myTask->taskCount2()); // // Decrement the "number of unfinished tasks" counter in the task @@ -888,8 +888,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->taskIndex1(), myTask->taskIndex2(), myTask->taskIndex3(), - myTask->taskCount1(), myTask->taskCount2(), myTask->taskCount3()); + myTask->taskIndex0(), myTask->taskIndex1(), myTask->taskIndex2(), + myTask->taskCount0(), myTask->taskCount1(), myTask->taskCount2()); // // Decrement the number of unfinished tasks counter @@ -920,8 +920,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->taskIndex1(), ti->taskIndex2(), ti->taskIndex3(), - ti->taskCount1(), ti->taskCount2(), ti->taskCount3()); + ti->taskIndex0(), ti->taskIndex1(), ti->taskIndex2(), + ti->taskCount0(), ti->taskCount1(), ti->taskCount2()); } } @@ -951,8 +951,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->taskIndex1(), ti->taskIndex2(), ti->taskIndex3(), - ti->taskCount1(), ti->taskCount2(), ti->taskCount3()); + ti->taskIndex0(), ti->taskIndex1(), ti->taskIndex2(), + ti->taskCount0(), ti->taskCount1(), ti->taskCount2()); } } @@ -984,8 +984,8 @@ TaskGroup::Launch(int baseIndex, int count) { int threadCount = ti->taskCount; ti->func(ti->data, threadIndex, threadCount, ti->taskIndex, ti->taskCount(), - ti->taskIndex1(), ti->taskIndex2(), ti->taskIndex3(), - ti->taskCount1(), ti->taskCount2(), ti->taskCount3()); + ti->taskIndex0(), ti->taskIndex1(), ti->taskIndex2(), + ti->taskCount0(), ti->taskCount1(), ti->taskCount2()); }); } @@ -1013,8 +1013,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->taskIndex1(), ti->taskIndex2(), ti->taskIndex3(), - ti->taskCount1(), ti->taskCount2(), ti->taskCount3()); + ti->taskIndex0(), ti->taskIndex1(), ti->taskIndex2(), + ti->taskCount0(), ti->taskCount1(), ti->taskCount2()); }); } } @@ -1067,8 +1067,8 @@ FreeTaskGroup(TaskGroup *tg) { /////////////////////////////////////////////////////////////////////////// void -ISPCLaunch(void **taskGroupPtr, void *func, void *data, int count1, int count2, int count3) { - const int count = count1*count2*count3; +ISPCLaunch(void **taskGroupPtr, void *func, void *data, int count0, int count1, int count2) { + const int count = count0*count1*count2; TaskGroup *taskGroup; if (*taskGroupPtr == NULL) { InitTaskSystem(); @@ -1084,9 +1084,9 @@ ISPCLaunch(void **taskGroupPtr, void *func, void *data, int count1, int count2, ti->func = (TaskFuncType)func; ti->data = data; ti->taskIndex = i; - ti->taskCount3d[0] = count1; - ti->taskCount3d[1] = count2; - ti->taskCount3d[2] = count3; + ti->taskCount3d[0] = count0; + ti->taskCount3d[1] = count1; + ti->taskCount3d[2] = count2; } taskGroup->Launch(baseIndex, count); } diff --git a/func.cpp b/func.cpp index 086be6fe..af2cc05a 100644 --- a/func.cpp +++ b/func.cpp @@ -133,26 +133,26 @@ Function::Function(Symbol *s, Stmt *c) { taskCountSym = m->symbolTable->LookupVariable("taskCount"); Assert(taskCountSym); + taskIndexSym0 = m->symbolTable->LookupVariable("taskIndex0"); + Assert(taskIndexSym0); taskIndexSym1 = m->symbolTable->LookupVariable("taskIndex1"); Assert(taskIndexSym1); taskIndexSym2 = m->symbolTable->LookupVariable("taskIndex2"); Assert(taskIndexSym2); - taskIndexSym3 = m->symbolTable->LookupVariable("taskIndex3"); - Assert(taskIndexSym3); + taskCountSym0 = m->symbolTable->LookupVariable("taskCount0"); + Assert(taskCountSym0); 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; - taskIndexSym1 = taskIndexSym2 = taskIndexSym3 = NULL; - taskCountSym1 = taskCountSym2 = taskCountSym3 = NULL; + taskIndexSym0 = taskIndexSym1 = taskIndexSym2 = NULL; + taskCountSym0 = taskCountSym1 = taskCountSym2 = 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 *taskIndex0 = argIter++; llvm::Value *taskIndex1 = argIter++; llvm::Value *taskIndex2 = argIter++; - llvm::Value *taskIndex3 = argIter++; + llvm::Value *taskCount0 = 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); + taskIndexSym0->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskIndex0"); + ctx->StoreInst(taskIndex0, taskIndexSym0->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); + taskCountSym0->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount0"); + ctx->StoreInst(taskCount0, taskCountSym0->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 diff --git a/func.h b/func.h index 4181bba5..88a96dbc 100644 --- a/func.h +++ b/func.h @@ -61,9 +61,9 @@ private: Symbol *maskSymbol; Symbol *threadIndexSym, *threadCountSym; Symbol *taskIndexSym, *taskCountSym; + Symbol *taskIndexSym0, *taskCountSym0; Symbol *taskIndexSym1, *taskCountSym1; Symbol *taskIndexSym2, *taskCountSym2; - Symbol *taskIndexSym3, *taskCountSym3; }; #endif // ISPC_FUNC_H diff --git a/parse.yy b/parse.yy index 653bba62..9a0377c5 100644 --- a/parse.yy +++ b/parse.yy @@ -2276,20 +2276,20 @@ static void lAddThreadIndexCountToSymbolTable(SourcePos pos) { Symbol *taskCountSym = new Symbol("taskCount", pos, type); m->symbolTable->AddVariable(taskCountSym); + Symbol *taskIndexSym0 = new Symbol("taskIndex0", pos, type); + m->symbolTable->AddVariable(taskIndexSym0); 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 *taskCountSym0 = new Symbol("taskCount0", pos, type); + m->symbolTable->AddVariable(taskCountSym0); 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); } diff --git a/type.cpp b/type.cpp index 3ae0cab4..516276f0 100644 --- a/type.cpp +++ b/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); // taskIndex0 callTypes.push_back(LLVMTypes::Int32Type); // taskIndex1 callTypes.push_back(LLVMTypes::Int32Type); // taskIndex2 - callTypes.push_back(LLVMTypes::Int32Type); // taskIndex3 + callTypes.push_back(LLVMTypes::Int32Type); // taskCount0 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