[PATCH] D17148: [OPENMP] Basic teams directive implementation

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 11 21:17:32 PST 2016


ABataev added inline comments.

================
Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4378-4398
@@ +4377,23 @@
+
+  const OMPNumTeamsClause *NT = TD.getSingleClause<OMPNumTeamsClause>();
+  const OMPThreadLimitClause *TL = TD.getSingleClause<OMPThreadLimitClause>();
+  if (NT || TL) {
+    NumTeamsVal = (NT) ? CGF.EmitScalarExpr(NT->getNumTeams(), true) :
+        NumTeamsVal = CGF.Builder.getInt32(0);
+
+    NumTeamsVal = (NT) ? CGF.Builder.CreateIntCast(
+          CGF.EmitScalarExpr(NT->getNumTeams()), CGM.Int32Ty,
+                             /* isSigned = */ true) :
+        CGF.Builder.getInt32(0);
+
+    ThreadLimitVal = (TL) ? CGF.Builder.CreateIntCast(
+          CGF.EmitScalarExpr(TL->getThreadLimit()), CGM.Int32Ty,
+                             /* isSigned = */ true) :
+        CGF.Builder.getInt32(0);
+
+    llvm::Value *PushNumTeamsArgs[] = {
+        RTLoc, getThreadID(CGF, Loc), NumTeamsVal, ThreadLimitVal};
+    CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_push_num_teams),
+                        PushNumTeamsArgs);
+  }
+
----------------
I don't like the idea of processing num_teams and thread_limit clauses in runtime lib. This must be done in emitCommonOMPTeamsDirective(), not in runtime

================
Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4413-4424
@@ +4412,13 @@
+
+llvm::Value *CGOpenMPRuntime::emitTeamsOutlinedFunction(
+    const OMPExecutableDirective &D, const VarDecl *ThreadIDVar,
+    OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen) {
+  assert(ThreadIDVar->getType()->isPointerType() &&
+         "thread id variable must be of type kmp_int32 *");
+  const CapturedStmt *CS = cast<CapturedStmt>(D.getAssociatedStmt());
+  CodeGenFunction CGF(CGM, true);
+  CGOpenMPOutlinedRegionInfo CGInfo(*CS, ThreadIDVar, CodeGen, InnermostKind,
+                                    /*HasCancel =*/ false);
+  CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
+  return CGF.GenerateOpenMPCapturedStmtFunction(*CS);
+}
----------------
This is very similar to emitParallelOutlinedFunction(). Maybe it is a good idea to join them into a single one?


http://reviews.llvm.org/D17148





More information about the cfe-commits mailing list