forked from OSchip/llvm-project
[MLIR] Add OpenMP dialect with barrier operation
Summary: Barrier is a simple operation that takes no arguments and returns nothing, but implies a side effect (synchronization of all threads) Reviewers: jdoerfert Subscribers: mgorny, guansong, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D72400
This commit is contained in:
parent
7830c2d44f
commit
63c8972562
|
@ -4,6 +4,7 @@ add_subdirectory(GPU)
|
|||
add_subdirectory(Linalg)
|
||||
add_subdirectory(LLVMIR)
|
||||
add_subdirectory(LoopOps)
|
||||
add_subdirectory(OpenMP)
|
||||
add_subdirectory(QuantOps)
|
||||
add_subdirectory(SPIRV)
|
||||
add_subdirectory(StandardOps)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
add_mlir_dialect(OpenMPOps OpenMPOps)
|
|
@ -0,0 +1,35 @@
|
|||
//===- OpenMPDialect.h - MLIR Dialect for OpenMP ----------------*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file declares the OpenMP dialect in MLIR.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef MLIR_DIALECT_OPENMP_OPENMPDIALECT_H_
|
||||
#define MLIR_DIALECT_OPENMP_OPENMPDIALECT_H_
|
||||
|
||||
#include "mlir/IR/Dialect.h"
|
||||
#include "mlir/IR/OpDefinition.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace omp {
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/OpenMP/OpenMPOps.h.inc"
|
||||
|
||||
class OpenMPDialect : public Dialect {
|
||||
public:
|
||||
explicit OpenMPDialect(MLIRContext *context);
|
||||
|
||||
static StringRef getDialectNamespace() { return "omp"; }
|
||||
};
|
||||
|
||||
} // namespace omp
|
||||
} // namespace mlir
|
||||
|
||||
#endif // MLIR_DIALECT_OPENMP_OPENMPDIALECT_H_
|
|
@ -0,0 +1,37 @@
|
|||
//===-- OpenMPOps.td - OpenMP dialect operation definitions *- tablegen -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the basic operations for the OpenMP dialect.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#ifndef OPENMP_OPS
|
||||
#define OPENMP_OPS
|
||||
|
||||
include "mlir/IR/OpBase.td"
|
||||
|
||||
def OpenMP_Dialect : Dialect {
|
||||
let name = "omp";
|
||||
}
|
||||
|
||||
class OpenMP_Op<string mnemonic, list<OpTrait> traits = []> :
|
||||
Op<OpenMP_Dialect, mnemonic, traits>;
|
||||
|
||||
def BarrierOp : OpenMP_Op<"barrier"> {
|
||||
let summary = "barrier construct";
|
||||
let description = [{
|
||||
The barrier construct specifies an explicit barrier at the point at which
|
||||
the construct appears.
|
||||
}];
|
||||
|
||||
let parser = [{ return success(); }];
|
||||
let printer = [{ p << getOperationName(); }];
|
||||
}
|
||||
|
||||
#endif // OPENMP_OPS
|
|
@ -4,6 +4,7 @@ add_subdirectory(GPU)
|
|||
add_subdirectory(Linalg)
|
||||
add_subdirectory(LLVMIR)
|
||||
add_subdirectory(LoopOps)
|
||||
add_subdirectory(OpenMP)
|
||||
add_subdirectory(QuantOps)
|
||||
add_subdirectory(SDBM)
|
||||
add_subdirectory(SPIRV)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
add_llvm_library(MLIROpenMP
|
||||
IR/OpenMPDialect.cpp
|
||||
|
||||
ADDITIONAL_HEADER_DIRS
|
||||
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/OpenMP
|
||||
)
|
||||
|
||||
add_dependencies(MLIROpenMP MLIROpenMPOpsIncGen)
|
|
@ -0,0 +1,34 @@
|
|||
//===- OpenMPDialect.cpp - MLIR Dialect for OpenMP implementation ---------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements the OpenMP dialect and its operations.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
|
||||
#include "mlir/IR/OpImplementation.h"
|
||||
|
||||
using namespace mlir;
|
||||
using namespace mlir::omp;
|
||||
|
||||
OpenMPDialect::OpenMPDialect(MLIRContext *context)
|
||||
: Dialect(getDialectNamespace(), context) {
|
||||
addOperations<
|
||||
#define GET_OP_LIST
|
||||
#include "mlir/Dialect/OpenMP/OpenMPOps.cpp.inc"
|
||||
>();
|
||||
}
|
||||
|
||||
namespace mlir {
|
||||
namespace omp {
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/OpenMP/OpenMPOps.cpp.inc"
|
||||
} // namespace omp
|
||||
} // namespace mlir
|
||||
|
||||
static DialectRegistration<OpenMPDialect> ompDialect;
|
|
@ -0,0 +1,7 @@
|
|||
// RUN: mlir-opt -verify-diagnostics %s | FileCheck %s
|
||||
|
||||
func @omp_barrier() -> () {
|
||||
// CHECK: omp.barrier
|
||||
omp.barrier
|
||||
return
|
||||
}
|
|
@ -33,6 +33,7 @@ set(LIBS
|
|||
MLIRLLVMIR
|
||||
MLIRLoopOps
|
||||
MLIRNVVMIR
|
||||
MLIROpenMP
|
||||
MLIROptMain
|
||||
MLIRParser
|
||||
MLIRPass
|
||||
|
|
Loading…
Reference in New Issue