[Openmp-commits] [openmp] 693358d - [OpenMP][DeviceRTL][NFC] Use `OMPTgtExecModeFlags` from `llvm/include/llvm/Frontend/OpenMP/OMPDeviceConstants.h`
Shilei Tian via Openmp-commits
openmp-commits at lists.llvm.org
Sun Jan 22 16:10:59 PST 2023
Author: Shilei Tian
Date: 2023-01-22T19:10:54-05:00
New Revision: 693358d78721f4fa516cc703bffa4ae35080dca8
URL: https://github.com/llvm/llvm-project/commit/693358d78721f4fa516cc703bffa4ae35080dca8
DIFF: https://github.com/llvm/llvm-project/commit/693358d78721f4fa516cc703bffa4ae35080dca8.diff
LOG: [OpenMP][DeviceRTL][NFC] Use `OMPTgtExecModeFlags` from `llvm/include/llvm/Frontend/OpenMP/OMPDeviceConstants.h`
This patch makes preparation for a series that will enable per-kernel information
used in both host and device runtime. Some variables/enums, such as `OMPTgtExecModeFlags`,
have to be shared by both of them. A new header `OMPDeviceConstants.h` is added,
containing code that will be shared by them. We will introduce more variables soon.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D142320
Added:
llvm/include/llvm/Frontend/OpenMP/OMPDeviceConstants.h
Modified:
llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
openmp/libomptarget/DeviceRTL/include/Types.h
openmp/libomptarget/DeviceRTL/src/Kernel.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h b/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
index 94dadbe75c2c8..afdbc4d9788d6 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
@@ -185,14 +185,6 @@ enum class OMPScheduleType {
LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue */ ModifierMask)
};
-enum OMPTgtExecModeFlags : int8_t {
- OMP_TGT_EXEC_MODE_GENERIC = 1 << 0,
- OMP_TGT_EXEC_MODE_SPMD = 1 << 1,
- OMP_TGT_EXEC_MODE_GENERIC_SPMD =
- OMP_TGT_EXEC_MODE_GENERIC | OMP_TGT_EXEC_MODE_SPMD,
- LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue */ OMP_TGT_EXEC_MODE_GENERIC_SPMD)
-};
-
/// Values for bit flags used to specify the mapping type for
/// offloading.
enum class OpenMPOffloadMappingFlags : uint64_t {
@@ -280,4 +272,6 @@ enum class RTLDependenceKindTy {
} // end namespace llvm
+#include "OMPDeviceConstants.h"
+
#endif // LLVM_FRONTEND_OPENMP_OMPCONSTANTS_H
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPDeviceConstants.h b/llvm/include/llvm/Frontend/OpenMP/OMPDeviceConstants.h
new file mode 100644
index 0000000000000..0a223b0e73a1d
--- /dev/null
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPDeviceConstants.h
@@ -0,0 +1,31 @@
+//===- OMPDeviceConstants.h - OpenMP device related constants ----- 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
+//
+//===----------------------------------------------------------------------===//
+/// \file
+///
+/// This file defines constans that will be used by both host and device
+/// compilation.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_FRONTEND_OPENMP_OMPDEVICECONSTANTS_H
+#define LLVM_FRONTEND_OPENMP_OMPDEVICECONSTANTS_H
+
+namespace llvm {
+namespace omp {
+enum OMPTgtExecModeFlags {
+ OMP_TGT_EXEC_MODE_GENERIC = 1 << 0,
+ OMP_TGT_EXEC_MODE_SPMD = 1 << 1,
+ OMP_TGT_EXEC_MODE_GENERIC_SPMD =
+ OMP_TGT_EXEC_MODE_GENERIC | OMP_TGT_EXEC_MODE_SPMD
+};
+
+} // end namespace omp
+
+} // end namespace llvm
+
+#endif // LLVM_FRONTEND_OPENMP_OMPDEVICECONSTANTS_H
diff --git a/openmp/libomptarget/DeviceRTL/include/Types.h b/openmp/libomptarget/DeviceRTL/include/Types.h
index 700ebbd394dd1..628755bc55ed5 100644
--- a/openmp/libomptarget/DeviceRTL/include/Types.h
+++ b/openmp/libomptarget/DeviceRTL/include/Types.h
@@ -191,11 +191,6 @@ typedef enum omp_allocator_handle_t {
KMP_ALLOCATOR_MAX_HANDLE = ~(0U)
} omp_allocator_handle_t;
-enum OMPTgtExecModeFlags : int8_t {
- OMP_TGT_EXEC_MODE_GENERIC = 1 << 0,
- OMP_TGT_EXEC_MODE_SPMD = 1 << 1,
-};
-
#define __PRAGMA(STR) _Pragma(#STR)
#define OMP_PRAGMA(STR) __PRAGMA(omp STR)
diff --git a/openmp/libomptarget/DeviceRTL/src/Kernel.cpp b/openmp/libomptarget/DeviceRTL/src/Kernel.cpp
index 03c6aa4967d34..c88aacbf6e432 100644
--- a/openmp/libomptarget/DeviceRTL/src/Kernel.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Kernel.cpp
@@ -17,6 +17,8 @@
#include "Synchronization.h"
#include "Types.h"
+#include "llvm/Frontend/OpenMP/OMPDeviceConstants.h"
+
using namespace ompx;
#pragma omp begin declare target device_type(nohost)
@@ -68,7 +70,8 @@ extern "C" {
int32_t __kmpc_target_init(IdentTy *Ident, int8_t Mode,
bool UseGenericStateMachine) {
FunctionTracingRAII();
- const bool IsSPMD = Mode & OMP_TGT_EXEC_MODE_SPMD;
+ const bool IsSPMD =
+ Mode & llvm::omp::OMPTgtExecModeFlags::OMP_TGT_EXEC_MODE_SPMD;
if (IsSPMD) {
inititializeRuntime(/* IsSPMD */ true);
synchronize::threadsAligned();
@@ -127,7 +130,8 @@ int32_t __kmpc_target_init(IdentTy *Ident, int8_t Mode,
///
void __kmpc_target_deinit(IdentTy *Ident, int8_t Mode) {
FunctionTracingRAII();
- const bool IsSPMD = Mode & OMP_TGT_EXEC_MODE_SPMD;
+ const bool IsSPMD =
+ Mode & llvm::omp::OMPTgtExecModeFlags::OMP_TGT_EXEC_MODE_SPMD;
state::assumeInitialState(IsSPMD);
if (IsSPMD)
return;
More information about the Openmp-commits
mailing list