Skip to content

Commit cb9cfa0

Browse files
author
sstefan1
committed
[OpenMPOpt][Fix] Only initialize ICV initial values once.
Reviewers: jdoerfert, ggeorgakoudis Differential Revision: https://reviews.llvm.org/D88441
1 parent 324df26 commit cb9cfa0

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

llvm/include/llvm/Frontend/OpenMP/OMPConstants.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ enum class InternalControlVar {
4141
#include "llvm/Frontend/OpenMP/OMPKinds.def"
4242

4343
enum class ICVInitValue {
44-
#define ICV_DATA_ENV(Enum, Name, EnvVar, Init) Init,
44+
#define ICV_INIT_VALUE(Enum, Name) Enum,
4545
#include "llvm/Frontend/OpenMP/OMPKinds.def"
4646
};
4747

48-
#define ICV_DATA_ENV(Enum, Name, EnvVar, Init) \
49-
constexpr auto Init = omp::ICVInitValue::Init;
48+
#define ICV_INIT_VALUE(Enum, Name) \
49+
constexpr auto Enum = omp::ICVInitValue::Enum;
5050
#include "llvm/Frontend/OpenMP/OMPKinds.def"
5151

5252
/// IDs for all omp runtime library (RTL) functions.

llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,20 @@ __OMP_FUNCTION_TYPE(TaskRoutineEntry, false, Int32, Int32,
230230
///
231231
///{
232232

233+
#ifndef ICV_INIT_VALUE
234+
#define ICV_INIT_VALUE(Enum, Name)
235+
#endif
236+
237+
#define __ICV_INIT_VALUE(Name) ICV_INIT_VALUE(ICV_##Name, #Name)
238+
239+
__ICV_INIT_VALUE(ZERO)
240+
__ICV_INIT_VALUE(FALSE)
241+
__ICV_INIT_VALUE(IMPLEMENTATION_DEFINED)
242+
__ICV_INIT_VALUE(LAST)
243+
244+
#undef __ICV_INIT_VALUE
245+
#undef ICV_INIT_VALUE
246+
233247
#ifndef ICV_DATA_ENV
234248
#define ICV_DATA_ENV(Enum, Name, EnvVarName, Init)
235249
#endif
@@ -240,6 +254,7 @@ __OMP_FUNCTION_TYPE(TaskRoutineEntry, false, Int32, Int32,
240254
__ICV_DATA_ENV(nthreads, OMP_NUM_THREADS, ICV_IMPLEMENTATION_DEFINED)
241255
__ICV_DATA_ENV(active_levels, NONE, ICV_ZERO)
242256
__ICV_DATA_ENV(cancel, OMP_CANCELLATION, ICV_FALSE)
257+
__ICV_DATA_ENV(proc_bind, OMP_PROC_BIND, ICV_IMPLEMENTATION_DEFINED)
243258
__ICV_DATA_ENV(__last, last, ICV_LAST)
244259

245260
#undef __ICV_DATA_ENV
@@ -265,6 +280,7 @@ __ICV_RT_SET(nthreads, omp_set_num_threads)
265280
__ICV_RT_GET(nthreads, omp_get_max_threads)
266281
__ICV_RT_GET(active_levels, omp_get_active_level)
267282
__ICV_RT_GET(cancel, omp_get_cancellation)
283+
__ICV_RT_GET(proc_bind, omp_get_proc_bind)
268284

269285
#undef __ICV_RT_GET
270286
#undef ICV_RT_GET

llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,8 @@ struct OpenMPOpt {
518518
/// Print initial ICV values for testing.
519519
/// FIXME: This should be done from the Attributor once it is added.
520520
void printICVs() const {
521-
InternalControlVar ICVs[] = {ICV_nthreads, ICV_active_levels, ICV_cancel};
521+
InternalControlVar ICVs[] = {ICV_nthreads, ICV_active_levels, ICV_cancel,
522+
ICV_proc_bind};
522523

523524
for (Function *F : OMPInfoCache.ModuleSlice) {
524525
for (auto ICV : ICVs) {

0 commit comments

Comments
 (0)