Commit 56252580 authored by Joel E. Denny's avatar Joel E. Denny
Browse files

WIP: [Clacc][OpenACC] Prototype `acc routine seq`

parent a59e21d4
Loading
Loading
Loading
Loading
+25 −5
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ Run-Time Environment Variables
    * Appearing within a `parallel` construct and any number of levels
      of nesting within other `loop` directives are supported.
    * Appearing outside a `parallel` construct (that is, an orphaned
      loop) is not yet supported.
      `loop` construct) is not yet supported.
* Use without clauses is supported.
* Supported partitionability clauses
    * Implicit `independent`
@@ -303,6 +303,25 @@ Run-Time Environment Variables
* A `reduction` clause implies a `copy` clause (overriding the
  implicit `firstprivate` clause).

`routine` Directive
-------------------

* Lexical context
    * Appearing at file scope is supported.
    * Appearing within a function definition is not supported.
* Supported clauses
    * `seq` (required)
* Associated declaration
    * A lone function definition or prototype is supported.
    * A declaration containing multiple declarators is not supported.
      For example, `void foo(), bar();`.
* Function definition body
    * Appearance of any OpenACC directive produces a compile-time
      error diagnostic.  Thus, orphaned `loop` constructs are not yet
      supported.
    * Declaration of a static local variable produces a compile-time
      error diagnostic.

Subarrays
---------

@@ -317,10 +336,11 @@ Subarrays
Device-Side Directives
----------------------

Nesting of an `update`, `data`, `parallel`, or `parallel loop`
directive inside a `parallel`, `loop`, or `parallel loop` construct is
not yet supported.  We're not aware of any OpenACC implementation that
supports this yet.
Nesting of an `update`, `enter data`, `exit data`, `data`, `parallel`,
or `parallel loop` directive inside a `parallel`, `loop`, or `parallel
loop` construct or inside a function attributed with a `routine`
directive is not yet supported.  We're not aware of any OpenACC
implementation that supports such cases yet.

OpenACC Runtime Library API and Preprocessor
--------------------------------------------
+11 −2
Original line number Diff line number Diff line
@@ -28,9 +28,18 @@ namespace clang {
// AST classes for directives.
//===----------------------------------------------------------------------===//

/// This is a basic class for representing single OpenACC executable
/// directive.
///
/// This is a basic class for representing OpenACC executable directives and
/// constructs.
///
/// FIXME: The name should be changed to reflect that it's not just OpenACC
/// executable directives (like acc update).  The base class ExecutableDirective
/// should become something more generic too then, but it has to also make sense
/// for OMPExecutableDirective.  ActOnOpenACCExecutableDirective should be
/// renamed in Sema accordingly.  Perhaps ACCExecutableDirectiveOrConstruct is
/// the right name to distinguish it from declarative directives.  Perhaps the
/// base class should be ExecutableDirectiveOrConstruct.  Or maybe
/// ACCDirectiveStmt and base class DirectiveStmt is a nice summary of a
/// directive that is more than declarative.
class ACCExecutableDirective : public ExecutableDirective {
  friend class ASTStmtReader;
  /// Kind of the directive.
+19 −1
Original line number Diff line number Diff line
@@ -534,6 +534,9 @@ class Attr {
  // Set to true if this attribute meaningful when applied to or inherited
  // in a class template definition.
  bit MeaningfulToClassTemplateDefinition = 0;
  // Set to true if provides a custom implementation of the printPretty
  // function.
  bit HasCustomPrintPretty = 0;
  // Set to true if this attribute can be used with '#pragma clang attribute'.
  // By default, an attribute is supported by the '#pragma clang attribute'
  // only when:
@@ -3604,7 +3607,8 @@ def OMPDeclareTargetDecl : InheritableAttr {
    EnumArgument<"DevType", "DevTypeTy",
                 [ "host", "nohost", "any" ],
                 [ "DT_Host", "DT_NoHost", "DT_Any" ]>,
    UnsignedArgument<"Level">
    UnsignedArgument<"Level">,
    BoolArgument<"IsOpenACCTranslation">
  ];
  let AdditionalMembers = [{
    void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const;
@@ -3614,6 +3618,7 @@ def OMPDeclareTargetDecl : InheritableAttr {
    static llvm::Optional<DevTypeTy> getDeviceType(const ValueDecl *VD);
    static llvm::Optional<SourceLocation> getLocation(const ValueDecl *VD);
  }];
  let HasCustomPrintPretty = 1;
}

def OMPAllocateDecl : InheritableAttr {
@@ -3659,6 +3664,19 @@ def OMPDeclareVariant : InheritableAttr {
  }];
}

def ACCRoutineDecl : InheritableAttr {
  let Spellings = [Pragma<"acc", "routine">];
  let SemaHandler = 0;
  let Subjects = SubjectList<[Function]>;
  let Args = [
    EnumArgument<"Partitioning", "PartitioningTy",
                 [ "seq" ],
                 [ "Seq" ]>
  ];
  let Documentation = [Undocumented];
  let HasCustomPrintPretty = 1;
}

def Assumption : InheritableAttr {
  let Spellings = [Clang<"assume">];
  let Subjects = SubjectList<[Function, ObjCMethod]>;
+9 −0
Original line number Diff line number Diff line
@@ -319,6 +319,15 @@ def err_rewrite_acc_end_in_macro : Error<
def err_rewrite_acc_end_in_pragma_op : Error<
  "cannot rewrite OpenACC directive that has no associated statement and that "
  "appears within a _Pragma operator">;
def err_rewrite_acc_routine_in_pragma_op : Error<
  "cannot rewrite OpenACC routine directive that appears within a _Pragma "
  "operator">;
def err_rewrite_acc_routine_function_start_in_macro : Error<
  "cannot rewrite OpenACC routine directive whose associated function "
  "declaration starts within a macro expansion">;
def err_rewrite_acc_routine_function_end_in_macro : Error<
  "cannot rewrite OpenACC routine directive whose associated function "
  "declaration ends within a macro expansion">;
} // end of RewriteOpenACC category

}
+16 −0
Original line number Diff line number Diff line
@@ -10842,6 +10842,22 @@ def note_acc_disable_diag : Note<
def err_acc_no_self_host_device_clause : Error<
  "expected at least one 'self', 'host', or 'device' clause for '#pragma acc "
  "update'">;
// TODO: Once the other clauses are supported, this should say:
//   "expected at least one 'gang', 'worker', 'vector', or 'seq' clause for "
//   "'#pragma acc routine'"
def err_acc_no_gang_worker_vector_seq_clause : Error<
  "expected 'seq' clause for '#pragma acc routine'">;
def err_acc_expected_function_after_directive : Error<
  "'#pragma acc %0' must be followed by a lone function prototype or "
  "definition">;
def err_acc_routine_unexpected_directive : Error<
  "'#pragma acc %0' is not permitted within function '%1' because the latter "
  "is attributed with '#pragma acc routine'">;
def err_acc_routine_static_local : Error<
  "static local variable '%0' is not permitted within function '%1' because "
  "the latter is attributed with '#pragma acc routine'">;
def note_acc_routine : Note<
  "function '%0' attributed with '#pragma acc routine' here">;
} // end of OpenACC category
let CategoryName = "Related Result Type Issue" in {
Loading