fixed sync

This commit is contained in:
Evghenii
2014-01-06 15:51:14 +01:00
parent 91d4ae46f6
commit 7fbe2eba59
2 changed files with 36 additions and 20 deletions

52
ctx.cpp
View File

@@ -3684,29 +3684,43 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
void void
FunctionEmitContext::SyncInst() { FunctionEmitContext::SyncInst() {
llvm::Value *launchGroupHandle = LoadInst(launchGroupHandlePtr); if (g->target->getISA() != Target::NVPTX)
llvm::Value *nullPtrValue = {
llvm::Constant::getNullValue(LLVMTypes::VoidPointerType); llvm::Value *launchGroupHandle = LoadInst(launchGroupHandlePtr);
llvm::Value *nonNull = CmpInst(llvm::Instruction::ICmp, llvm::Value *nullPtrValue =
llvm::CmpInst::ICMP_NE, llvm::Constant::getNullValue(LLVMTypes::VoidPointerType);
launchGroupHandle, nullPtrValue); llvm::Value *nonNull = CmpInst(llvm::Instruction::ICmp,
llvm::BasicBlock *bSync = CreateBasicBlock("call_sync"); llvm::CmpInst::ICMP_NE,
llvm::BasicBlock *bPostSync = CreateBasicBlock("post_sync"); launchGroupHandle, nullPtrValue);
BranchInst(bSync, bPostSync, nonNull); llvm::BasicBlock *bSync = CreateBasicBlock("call_sync");
llvm::BasicBlock *bPostSync = CreateBasicBlock("post_sync");
BranchInst(bSync, bPostSync, nonNull);
SetCurrentBasicBlock(bSync); SetCurrentBasicBlock(bSync);
llvm::Function *fsync = m->module->getFunction("ISPCSync"); llvm::Function *fsync = m->module->getFunction("ISPCSync");
if (fsync == NULL) if (fsync == NULL)
FATAL("Couldn't find ISPCSync declaration?!"); FATAL("Couldn't find ISPCSync declaration?!");
CallInst(fsync, NULL, launchGroupHandle, ""); CallInst(fsync, NULL, launchGroupHandle, "");
// zero out the handle so that if ISPCLaunch is called again in this // zero out the handle so that if ISPCLaunch is called again in this
// function, it knows it's starting out from scratch // function, it knows it's starting out from scratch
StoreInst(nullPtrValue, launchGroupHandlePtr); StoreInst(nullPtrValue, launchGroupHandlePtr);
BranchInst(bPostSync); BranchInst(bPostSync);
SetCurrentBasicBlock(bPostSync); SetCurrentBasicBlock(bPostSync);
}
else /* NVPTX: don't do test, just call sync */
{
llvm::Value *launchGroupHandle = LoadInst(launchGroupHandlePtr);
llvm::Value *nullPtrValue =
llvm::Constant::getNullValue(LLVMTypes::VoidPointerType);
llvm::Function *fsync = m->module->getFunction("ISPCSync");
if (fsync == NULL)
FATAL("Couldn't find ISPCSync declaration?!");
CallInst(fsync, NULL, launchGroupHandle, "");
StoreInst(nullPtrValue, launchGroupHandlePtr);
}
} }

View File

@@ -531,9 +531,11 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) {
returnType = returnType->ResolveUnboundVariability(Variability::Varying); returnType = returnType->ResolveUnboundVariability(Variability::Varying);
bool isTask = ds && ((ds->typeQualifiers & TYPEQUAL_TASK) != 0); bool isTask = ds && ((ds->typeQualifiers & TYPEQUAL_TASK) != 0);
/* evghenii: without this, PTX fails on some examples, like deferred */
#if 1 /* evghenii: without this, PTX fails on some examples, like deferred, with #if 0 */
if (isTask && g->target->getISA() == Target::NVPTX) if (isTask && g->target->getISA() == Target::NVPTX)
ds->typeQualifiers |= TYPEQUAL_UNMASKED; ds->typeQualifiers |= TYPEQUAL_UNMASKED;
#endif
bool isExternC = ds && (ds->storageClass == SC_EXTERN_C); bool isExternC = ds && (ds->storageClass == SC_EXTERN_C);
bool isExported = ds && ((ds->typeQualifiers & TYPEQUAL_EXPORT) != 0); bool isExported = ds && ((ds->typeQualifiers & TYPEQUAL_EXPORT) != 0);