Unverified Commit cca38425 authored by Pat McCormick's avatar Pat McCormick Committed by GitHub
Browse files

Merge pull request #31 from pmccormick/release/10.x

Code cleanup and some better diagnostics for Kokkos processing.
parents 3baca4e6 c296c8db
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -260,10 +260,16 @@ def warn_alias_with_section : Warning<
  InGroup<IgnoredAttributes>;

def warn_kokkos_no_functor : Warning<
    "kokkos - functors unsupported (reverting to C++ mode for construct).">,
    "kokkos - parallel_for functors unsupported.\n"
    "Falling back to standard C++ mode but executable could be unstable.">,
    InGroup<BackendOptimizationFailure>;
def warn_kokkos_unknown_stmt_class : Warning<
    "kokkos - unrecognized/unsupported construct in parallel_for statement.\n"
    "Failling back to standard C++ mode but executable could be unstable.">,
    InGroup<BackendOptimizationFailure>;
def warn_kokkos_unknown_bounds_expr : Warning<
    "kokkos - unrecognized bounds/limit expression (reverting to C++ mode for construct).">,
    "kokkos - unrecognized bounds/limit expression.\n"
    "Falling back to standard C++ mode but executable could be unstable.">,
    InGroup<BackendOptimizationFailure>;
def warn_kokkos_reduce_unsupported : Warning<
    "kokkos - reduction constructs are currently unsupported.">,
+24 −28
Original line number Diff line number Diff line
@@ -2580,7 +2580,6 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {

    // Check for captured variables.
    if (E->refersToEnclosingVariableOrCapture()) {

      // kitsune: if we are generating a kokkos-based lambda construct
      // we are likely going to eventually tarnsform it into a parallel
      // loop construct. Thus we have to carefully consider how we handle
@@ -4622,7 +4621,7 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E,
  // a traditional loop construct -- thus our result is not a call expr
  // but essentially the removal of the call.
  //
  // FIXME: is this sound in all lambda use cases?  --PM 
  // TODO: is this path sound in all lambda use cases?  --PM
  //
  if (getLangOpts().Kokkos) {
    const FunctionDecl *fdecl = E->getDirectCallee();
@@ -4632,12 +4631,9 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E,
          qname == "Kokkos::parallel_reduce") {
	    if (EmitKokkosConstruct(E))
	      return RValue::get(nullptr);
	// else fall through to standard C++ support. 
    } else if (getLangOpts().KokkosNoInit &&
		    (qname == "Kokkos::initialize" ||
  		   qname == "Kokkos::finalize"))
	// In "no-init" mode we skip code generation for the
	// Kokkos initialization entry (and finalize) points. 
      return RValue::get(nullptr);
    }
  }
+87 −92
Original line number Diff line number Diff line
@@ -96,7 +96,8 @@ namespace {
  static void
  ExtractParallelForComponents(const CallExpr* CE,
					   std::string &CN, const Expr *& BE,
					   const LambdaExpr *& LE)
					   const LambdaExpr *& LE,
             DiagnosticsEngine &Diags)
  {
    // Recongized constructs:
    //
@@ -146,7 +147,8 @@ namespace {
      OE = CE->getArg(curArgIndex);
      SE = SimplifyExpr(OE);
    } else {
      SE->dump();
      Diags.Report(SE->getExprLoc(), diag::warn_kokkos_unknown_stmt_class);
      //SE->dump();
      BE = nullptr;
      LE = nullptr;
      return;
@@ -155,6 +157,7 @@ namespace {
    if (SE->getStmtClass() == Expr::LambdaExprClass) {
      LE = dyn_cast<LambdaExpr>(SE);
    } else {
      Diags.Report(CE->getExprLoc(), diag::warn_kokkos_no_functor);
      LE = nullptr;
      return;
    }
@@ -240,19 +243,12 @@ bool CodeGenFunction::EmitKokkosParallelFor(const CallExpr *CE,
  std::string      PFName; // construct name (for kokkos profiling)
  const Expr       *BE = nullptr; // "bounds" expression
  const LambdaExpr *Lambda = nullptr; // the lambda
  ExtractParallelForComponents(CE, PFName, BE, Lambda);
  DiagnosticsEngine &Diags = CGM.getDiags();
  ExtractParallelForComponents(CE, PFName, BE, Lambda, Diags);

  if (Lambda == nullptr) { 
  if (Lambda == nullptr)
    // The parallel_for doesn't have a (recognizable) lambda expression.
    // 
    // Functor support is problematic as it can live in a different 
    // compilaton unit.  We always punt and go the pure C++ route in
    // these cases. 
    DiagnosticsEngine &Diags = CGM.getDiags();
    // TODO: should reword this warning terminology. 
    Diags.Report(CE->getExprLoc(), diag::warn_kokkos_no_functor);
    return false;
  }

  if (BE == nullptr) {
    // We didn't get a known bounds expression back -- this is most likely
@@ -402,4 +398,3 @@ bool CodeGenFunction::EmitKokkosParallelReduce(const CallExpr *CE,
  Diags.Report(CE->getExprLoc(), diag::warn_kokkos_reduce_unsupported);
  return false;
}