diff --git a/include/clang/Basic/OpenMPKinds.def b/include/clang/Basic/OpenMPKinds.def index 6d869604c268918c74a9cfcd3d375c99c08deb48..b381653428bd96939e50670b1935304eeedfdf59 100644 --- a/include/clang/Basic/OpenMPKinds.def +++ b/include/clang/Basic/OpenMPKinds.def @@ -349,6 +349,9 @@ OPENMP_AFFINITY_KIND(task) OPENMP_DEPEND_KIND(in) OPENMP_DEPEND_KIND(out) OPENMP_DEPEND_KIND(inout) +OPENMP_DEPEND_KIND(concurrent) +OPENMP_DEPEND_KIND(commute) +OPENMP_DEPEND_KIND(cw) OPENMP_DEPEND_KIND(source) OPENMP_DEPEND_KIND(sink) diff --git a/lib/CodeGen/CGOpenMPRuntime.cpp b/lib/CodeGen/CGOpenMPRuntime.cpp index c6f0e85e4cb291c649f57efc50a462f97f0b51ef..4a6fff246a98bbec3ab9dfdca5ef93fe99d010f3 100644 --- a/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/lib/CodeGen/CGOpenMPRuntime.cpp @@ -570,7 +570,7 @@ enum OpenMPRTLFunction { OMPRTL__kmpc_end_single, // Call to kmp_task_t * __kmpc_omp_task_alloc(ident_t *, kmp_int32 gtid, // kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds, - // kmp_routine_entry_t *task_entry); + // kmp_routine_entry_t *task_entry, kmp_int32 ndeps, kmp_int32 ndeps_noalias); OMPRTL__kmpc_omp_task_alloc, // Call to kmp_int32 __kmpc_omp_task(ident_t *, kmp_int32 gtid, kmp_task_t * // new_task); @@ -1276,7 +1276,8 @@ CGOpenMPRuntime::createRuntimeFunction(unsigned Function) { assert(KmpRoutineEntryPtrTy != nullptr && "Type kmp_routine_entry_t must be created."); llvm::Type *TypeParams[] = {getIdentTyPointerTy(), CGM.Int32Ty, CGM.Int32Ty, - CGM.SizeTy, CGM.SizeTy, KmpRoutineEntryPtrTy}; + CGM.SizeTy, CGM.SizeTy, KmpRoutineEntryPtrTy, + CGM.Int32Ty, CGM.Int32Ty}; // Return void * and then cast to particular kmp_task_t type. llvm::FunctionType *FnTy = llvm::FunctionType::get(CGM.VoidPtrTy, TypeParams, /*isVarArg=*/false); @@ -3915,7 +3916,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc, // Build call kmp_task_t * __kmpc_omp_task_alloc(ident_t *, kmp_int32 gtid, // kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds, - // kmp_routine_entry_t *task_entry); + // kmp_routine_entry_t *task_entry, kmp_int32 deps, kmp_int32 deps_noalias); // Task flags. Format is taken from // http://llvm.org/svn/llvm-project/openmp/trunk/runtime/src/kmp.h, // description of kmp_tasking_flags struct. @@ -3923,7 +3924,8 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc, TiedFlag = 0x1, FinalFlag = 0x2, DestructorsFlag = 0x8, - PriorityFlag = 0x20 + PriorityFlag = 0x20, + DepsFlag = 0x80000000 }; unsigned Flags = Data.Tied ? TiedFlag : 0; bool NeedsCleanup = false; @@ -3934,6 +3936,9 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc, } if (Data.Priority.getInt()) Flags = Flags | PriorityFlag; + unsigned NumDependencies = Data.Dependences.size(); + if (NumDependencies) + Flags = Flags | DepsFlag; auto *TaskFlags = Data.Final.getPointer() ? CGF.Builder.CreateSelect(Data.Final.getPointer(), @@ -3946,7 +3951,9 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc, getThreadID(CGF, Loc), TaskFlags, KmpTaskTWithPrivatesTySize, SharedsSize, CGF.Builder.CreatePointerBitCastOrAddrSpaceCast( - TaskEntry, KmpRoutineEntryPtrTy)}; + TaskEntry, KmpRoutineEntryPtrTy), + CGF.Builder.getInt32(NumDependencies), + CGF.Builder.getInt32(0)}; auto *NewTask = CGF.EmitRuntimeCall( createRuntimeFunction(OMPRTL__kmpc_omp_task_alloc), AllocArgs); auto *NewTaskNewTaskTTy = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast( @@ -4036,7 +4043,7 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc, unsigned NumDependencies = Data.Dependences.size(); if (NumDependencies) { // Dependence kind for RTL. - enum RTLDependenceKindTy { DepIn = 0x01, DepInOut = 0x3 }; + enum RTLDependenceKindTy { DepIn = 0x01, DepOut = 0x02, DepInOut = 0x3, DepCW = 0x04, DepCommute = 0x08 }; enum RTLDependInfoFieldsTy { BaseAddr, Len, Flags }; RecordDecl *KmpDependInfoRD; QualType FlagsTy = @@ -4100,6 +4107,13 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc, case OMPC_DEPEND_inout: DepKind = DepInOut; break; + case OMPC_DEPEND_concurrent: + case OMPC_DEPEND_cw: + DepKind = RTLDependenceKindTy(int(DepCW)|int(DepInOut)); + break; + case OMPC_DEPEND_commute: + DepKind = RTLDependenceKindTy(int(DepCommute)|int(DepInOut)); + break; case OMPC_DEPEND_source: case OMPC_DEPEND_sink: case OMPC_DEPEND_unknown: