generating proper tasking function for nvptx
This commit is contained in:
24
func.cpp
24
func.cpp
@@ -240,16 +240,6 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
|
||||
// thread index, and the thread count variables.
|
||||
llvm::Function::arg_iterator argIter = function->arg_begin();
|
||||
llvm::Value *structParamPtr = argIter++;
|
||||
llvm::Value *threadIndex = argIter++;
|
||||
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 *taskCount0 = argIter++;
|
||||
llvm::Value *taskCount1 = argIter++;
|
||||
llvm::Value *taskCount2 = argIter++;
|
||||
|
||||
// Copy the function parameter values from the structure into local
|
||||
// storage
|
||||
@@ -266,6 +256,19 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
|
||||
ctx->SetFunctionMask(ptrval);
|
||||
}
|
||||
|
||||
if (g->target->getISA() != Target::NVPTX64)
|
||||
{
|
||||
llvm::Value *threadIndex = argIter++;
|
||||
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 *taskCount0 = argIter++;
|
||||
llvm::Value *taskCount1 = argIter++;
|
||||
llvm::Value *taskCount2 = argIter++;
|
||||
|
||||
// Copy threadIndex and threadCount into stack-allocated storage so
|
||||
// that their symbols point to something reasonable.
|
||||
threadIndexSym->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "threadIndex");
|
||||
@@ -313,6 +316,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
|
||||
taskCountSym2->storagePtr = ctx->AllocaInst(LLVMTypes::Int32Type, "taskCount2");
|
||||
ctx->StoreInst(taskCount2, taskCountSym2->storagePtr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Regular, non-task function
|
||||
llvm::Function::arg_iterator argIter = function->arg_begin();
|
||||
|
||||
3
type.cpp
3
type.cpp
@@ -2957,6 +2957,8 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const {
|
||||
// hold them until the task actually runs.)
|
||||
llvm::Type *st = llvm::StructType::get(*ctx, llvmArgTypes);
|
||||
callTypes.push_back(llvm::PointerType::getUnqual(st));
|
||||
if (g->target->getISA() != Target::NVPTX64)
|
||||
{
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // threadIndex
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // threadCount
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskIndex
|
||||
@@ -2968,6 +2970,7 @@ FunctionType::LLVMFunctionType(llvm::LLVMContext *ctx, bool removeMask) const {
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskCount1
|
||||
callTypes.push_back(LLVMTypes::Int32Type); // taskCount2
|
||||
}
|
||||
}
|
||||
else
|
||||
// Otherwise we already have the types of the arguments
|
||||
callTypes = llvmArgTypes;
|
||||
|
||||
Reference in New Issue
Block a user