From 3365a3fa8a7fff93c4ccf854b9f32ce5d5990a7e Mon Sep 17 00:00:00 2001 From: Thierry <thierry.gautier@inrialpes.fr> Date: Tue, 24 Jan 2017 14:10:11 +0100 Subject: [PATCH] [extend] __kmpc_omp_task_alloc with ndeps and ndeps_nolias informations - code generated by the compiler is binary compatible with old library: these two fields are not viewed by older library. - those informations are only take into account iff specific depsinalloc tasking_flags is set. This extension would be used to store dependent list to the task in order to test Kaapi scheduler based on affinity defined by dependencies or to reduce overhead of OMPT to track data access per task. --- lib/CodeGen/CGOpenMPRuntime.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/CodeGen/CGOpenMPRuntime.cpp b/lib/CodeGen/CGOpenMPRuntime.cpp index 42eb59d23ec..8a18e51bcec 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); @@ -3911,7 +3912,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. @@ -3919,7 +3920,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; @@ -3930,6 +3932,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(), @@ -3942,7 +3947,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( -- GitLab