[Openmp-commits] [flang] [llvm] [openmp] [flang][OpenMP] Compile proper `omp_lib.mod` from the `openmp/src/include` sources (PR #80874)
Michael Klemm via Openmp-commits
openmp-commits at lists.llvm.org
Tue Mar 12 10:49:34 PDT 2024
https://github.com/mjklemm updated https://github.com/llvm/llvm-project/pull/80874
>From 75b7a1cd869d9aec3f6e034d4c3e892babbe9ae3 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Tue, 6 Feb 2024 17:59:36 +0100
Subject: [PATCH 01/28] Guard '!$dir if' with '#ifdef __INTEL_COMPILER'
Flang does not yet support '!$dir if' directives. So, to make
this file compilable with Flang, they need to be guarded with
__INTEL_COMPILER (since the if is targeting the intel compiler
anyways)
---
openmp/runtime/src/include/omp_lib.f90.var | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/openmp/runtime/src/include/omp_lib.f90.var b/openmp/runtime/src/include/omp_lib.f90.var
index 1ca542db3767ef..cc031a653d80a5 100644
--- a/openmp/runtime/src/include/omp_lib.f90.var
+++ b/openmp/runtime/src/include/omp_lib.f90.var
@@ -37,7 +37,7 @@
integer, parameter :: omp_interop_kind = c_intptr_t
integer, parameter :: omp_interop_fr_kind = omp_integer_kind
- type omp_alloctrait
+ type omp_alloctrait!
integer(kind=omp_alloctrait_key_kind) key
integer(kind=omp_alloctrait_val_kind) value
end type omp_alloctrait
@@ -392,82 +392,102 @@
end subroutine omp_fulfill_event
subroutine omp_init_lock(svar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_init_lock
!DIR$ ENDIF
+#endif
use omp_lib_kinds
integer (kind=omp_lock_kind) svar
end subroutine omp_init_lock
subroutine omp_destroy_lock(svar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_destroy_lock
!DIR$ ENDIF
+#endif
use omp_lib_kinds
integer (kind=omp_lock_kind) svar
end subroutine omp_destroy_lock
subroutine omp_set_lock(svar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_set_lock
!DIR$ ENDIF
+#endif
use omp_lib_kinds
integer (kind=omp_lock_kind) svar
end subroutine omp_set_lock
subroutine omp_unset_lock(svar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_unset_lock
!DIR$ ENDIF
+#endif
use omp_lib_kinds
integer (kind=omp_lock_kind) svar
end subroutine omp_unset_lock
function omp_test_lock(svar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_test_lock
!DIR$ ENDIF
+#endif
use omp_lib_kinds
logical (kind=omp_logical_kind) omp_test_lock
integer (kind=omp_lock_kind) svar
end function omp_test_lock
subroutine omp_init_nest_lock(nvar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_init_nest_lock
!DIR$ ENDIF
+#endif
use omp_lib_kinds
integer (kind=omp_nest_lock_kind) nvar
end subroutine omp_init_nest_lock
subroutine omp_destroy_nest_lock(nvar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_destroy_nest_lock
!DIR$ ENDIF
+#endif
use omp_lib_kinds
integer (kind=omp_nest_lock_kind) nvar
end subroutine omp_destroy_nest_lock
subroutine omp_set_nest_lock(nvar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_set_nest_lock
!DIR$ ENDIF
+#endif
use omp_lib_kinds
integer (kind=omp_nest_lock_kind) nvar
end subroutine omp_set_nest_lock
subroutine omp_unset_nest_lock(nvar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_unset_nest_lock
!DIR$ ENDIF
+#endif
use omp_lib_kinds
integer (kind=omp_nest_lock_kind) nvar
end subroutine omp_unset_nest_lock
function omp_test_nest_lock(nvar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_test_nest_lock
!DIR$ ENDIF
+#endif
use omp_lib_kinds
integer (kind=omp_integer_kind) omp_test_nest_lock
integer (kind=omp_nest_lock_kind) nvar
>From 38f20849c912866d95002cb4829fb3f5f439948b Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Tue, 6 Feb 2024 22:33:03 +0100
Subject: [PATCH 02/28] Remove accidental typo
---
openmp/runtime/src/include/omp_lib.f90.var | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/openmp/runtime/src/include/omp_lib.f90.var b/openmp/runtime/src/include/omp_lib.f90.var
index cc031a653d80a5..68799fc52ff020 100644
--- a/openmp/runtime/src/include/omp_lib.f90.var
+++ b/openmp/runtime/src/include/omp_lib.f90.var
@@ -37,7 +37,7 @@
integer, parameter :: omp_interop_kind = c_intptr_t
integer, parameter :: omp_interop_fr_kind = omp_integer_kind
- type omp_alloctrait!
+ type omp_alloctrait
integer(kind=omp_alloctrait_key_kind) key
integer(kind=omp_alloctrait_val_kind) value
end type omp_alloctrait
>From d9482466ce3cbdfed295c65f61955cb15f7c72bd Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Wed, 7 Feb 2024 14:21:15 +0100
Subject: [PATCH 03/28] Rename omp_lib.f90.var to omp_lib.F90.var, incl it's
processed output
---
openmp/runtime/src/CMakeLists.txt | 6 +++---
.../src/include/{omp_lib.f90.var => omp_lib.F90.var} | 0
2 files changed, 3 insertions(+), 3 deletions(-)
rename openmp/runtime/src/include/{omp_lib.f90.var => omp_lib.F90.var} (100%)
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index b0ecf1213dabe5..7e2a05e003b8d9 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -18,7 +18,7 @@ if(${LIBOMP_OMPT_SUPPORT})
configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var omp-tools.h @ONLY)
endif()
-# Generate message catalog files: kmp_i18n_id.inc and kmp_i18n_default.inc
+# Generate message catalog fioles: kmp_i18n_id.inc and kmp_i18n_default.inc
add_custom_command(
OUTPUT kmp_i18n_id.inc
COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/message-converter.pl --os=${LIBOMP_PERL_SCRIPT_OS}
@@ -314,7 +314,7 @@ endif()
# One compilation step creates both omp_lib.mod and omp_lib_kinds.mod
if(${LIBOMP_FORTRAN_MODULES})
configure_file(${LIBOMP_INC_DIR}/omp_lib.h.var omp_lib.h @ONLY)
- configure_file(${LIBOMP_INC_DIR}/omp_lib.f90.var omp_lib.f90 @ONLY)
+ configure_file(${LIBOMP_INC_DIR}/omp_lib.F90.var omp_lib.F90 @ONLY)
# Workaround for gfortran to build modules with the
# omp_sched_monotonic integer parameter
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
@@ -323,7 +323,7 @@ if(${LIBOMP_FORTRAN_MODULES})
add_custom_target(libomp-mod ALL DEPENDS omp_lib.mod omp_lib_kinds.mod)
libomp_get_fflags(LIBOMP_CONFIGURED_FFLAGS)
if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
- set(LIBOMP_FORTRAN_SOURCE_FILE omp_lib.f90)
+ set(LIBOMP_FORTRAN_SOURCE_FILE omp_lib.F90)
else()
message(FATAL_ERROR "Fortran module build requires Fortran 90 compiler")
endif()
diff --git a/openmp/runtime/src/include/omp_lib.f90.var b/openmp/runtime/src/include/omp_lib.F90.var
similarity index 100%
rename from openmp/runtime/src/include/omp_lib.f90.var
rename to openmp/runtime/src/include/omp_lib.F90.var
>From 3f6d1eb04cbc9529deb85d8053a27782a0cc0436 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Thu, 8 Feb 2024 16:06:00 +0100
Subject: [PATCH 04/28] Remove old .h and .f90 file
---
flang/module/omp_lib.f90 | 13 --
flang/module/omp_lib.h | 454 ---------------------------------------
2 files changed, 467 deletions(-)
delete mode 100644 flang/module/omp_lib.f90
delete mode 100644 flang/module/omp_lib.h
diff --git a/flang/module/omp_lib.f90 b/flang/module/omp_lib.f90
deleted file mode 100644
index 2ca15da6891591..00000000000000
--- a/flang/module/omp_lib.f90
+++ /dev/null
@@ -1,13 +0,0 @@
-!===-- module/omp_lib.f90 --------------------------------------------------===!
-!
-! 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
-!
-!===------------------------------------------------------------------------===!
-
-module omp_lib
-
-include "omp_lib.h"
-
-end module omp_lib
diff --git a/flang/module/omp_lib.h b/flang/module/omp_lib.h
deleted file mode 100644
index efc9ceb16968bb..00000000000000
--- a/flang/module/omp_lib.h
+++ /dev/null
@@ -1,454 +0,0 @@
-!===-- module/omp_lib.h ------------------------------------------*- F90 -*-===!
-!
-! 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
-!
-!===------------------------------------------------------------------------===!
-
-!dir$ free
-
- integer, parameter :: omp_integer_kind = selected_int_kind(9) ! 32-bit int
- integer, parameter :: omp_logical_kind = 1 ! C_BOOL
-
- integer, parameter :: omp_sched_kind = omp_integer_kind
- integer, parameter :: omp_proc_bind_kind = omp_integer_kind
- integer, parameter :: omp_pause_resource_kind = omp_integer_kind
- integer, parameter :: omp_sync_hint_kind = omp_integer_kind
- integer, parameter :: omp_lock_hint_kind = omp_sync_hint_kind
- integer, parameter :: omp_event_handle_kind = omp_integer_kind
- integer, parameter :: omp_alloctrait_key_kind = omp_integer_kind
- integer, parameter :: omp_alloctrait_val_kind = omp_integer_kind
- integer, parameter :: omp_allocator_handle_kind = omp_integer_kind
- integer, parameter :: omp_memspace_handle_kind = omp_integer_kind
- integer, parameter :: omp_lock_kind = int_ptr_kind()
- integer, parameter :: omp_nest_lock_kind = int_ptr_kind()
- integer, parameter :: omp_depend_kind = omp_integer_kind
-
- integer(kind=omp_sched_kind), parameter :: &
- omp_sched_static = 1, &
- omp_sched_dynamic = 2, &
- omp_sched_guided = 3, &
- omp_sched_auto = 4
-
- integer(kind=omp_proc_bind_kind), parameter :: &
- omp_proc_bind_false = 0, &
- omp_proc_bind_true = 1, &
- omp_proc_bind_master = 2, &
- omp_proc_bind_close = 3, &
- omp_proc_bind_spread = 4
-
- integer(kind=omp_pause_resource_kind), parameter :: &
- omp_pause_soft = 1, &
- omp_pause_hard = 2
-
- integer(kind=omp_sync_hint_kind), parameter :: &
- omp_sync_hint_none = 0, &
- omp_sync_hint_uncontended = 1, &
- omp_sync_hint_contended = 2, &
- omp_sync_hint_nonspeculative = 4, &
- omp_sync_hint_speculative = 8
- integer(kind=omp_lock_hint_kind), parameter :: &
- omp_lock_hint_none = omp_sync_hint_none, &
- omp_lock_hint_uncontended = omp_sync_hint_uncontended, &
- omp_lock_hint_contended = omp_sync_hint_contended, &
- omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative, &
- omp_lock_hint_speculative = omp_sync_hint_speculative
-
- integer(kind=omp_event_handle_kind), parameter :: &
- omp_allow_completion_event = 0, &
- omp_task_fulfill_event = 1
-
- integer(kind=omp_alloctrait_key_kind), parameter :: &
- omp_atk_sync_hint = 1, &
- omp_atk_alignment = 2, &
- omp_atk_access = 3, &
- omp_atk_pool_size = 4, &
- omp_atk_fallback = 5, &
- omp_atk_fb_data = 6, &
- omp_atk_pinned = 7, &
- omp_atk_partition = 8
-
- integer(kind=omp_alloctrait_val_kind), parameter :: &
- omp_atv_false = 0, &
- omp_atv_true = 1, &
- omp_atv_default = 2, &
- omp_atv_contended = 3, &
- omp_atv_uncontended = 4, &
- omp_atv_sequential = 5, &
- omp_atv_private = 6, &
- omp_atv_all = 7, &
- omp_atv_thread = 8, &
- omp_atv_pteam = 9, &
- omp_atv_cgroup = 10, &
- omp_atv_default_mem_fb = 11, &
- omp_atv_null_fb = 12, &
- omp_atv_abort_fb = 13, &
- omp_atv_allocator_fb = 14, &
- omp_atv_environment = 15, &
- omp_atv_nearest = 16, &
- omp_atv_blocked = 17, &
- omp_atv_interleaved = 18
-
- type, bind(c) :: omp_alloctrait
- integer(kind=omp_alloctrait_key_kind) :: key, value
- end type omp_alloctrait
-
- integer(kind=omp_allocator_handle_kind), parameter :: omp_null_allocator = 0
-
- integer(kind=omp_memspace_handle_kind), parameter :: &
- omp_default_mem_space = 0, &
- omp_large_cap_mem_space = 0, &
- omp_const_mem_space = 0, &
- omp_high_bw_mem_space = 0, &
- omp_low_lat_mem_space = 0, &
- omp_default_mem_alloc = 1, &
- omp_large_cap_mem_alloc = omp_default_mem_alloc, &
- omp_const_mem_alloc = 1, &
- omp_high_bw_mem_alloc = 1, &
- omp_low_lat_mem_alloc = 1, &
- omp_thread_mem_alloc = omp_atv_thread, &
- omp_pteam_mem_alloc = omp_atv_pteam, &
- omp_cgroup_mem_alloc = omp_atv_cgroup
-
- integer(kind=omp_integer_kind), parameter :: openmp_version = 200805
-
- interface
-
- subroutine omp_set_num_threads(nthreads) bind(c)
- import
- integer(kind=omp_integer_kind), value :: nthreads
- end subroutine omp_set_num_threads
-
- function omp_get_num_threads() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_num_threads
- end function omp_get_num_threads
-
- function omp_get_max_threads() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_max_threads
- end function omp_get_max_threads
-
- function omp_get_thread_num() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_thread_num
- end function omp_get_thread_num
-
- function omp_get_num_procs() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_num_procs
- end function omp_get_num_procs
-
- function omp_in_parallel() bind(c)
- import
- logical(kind=omp_logical_kind) :: omp_in_parallel
- end function omp_in_parallel
-
- subroutine omp_set_dynamic(enable) bind(c)
- import
- logical(kind=omp_logical_kind), value :: enable
- end subroutine omp_set_dynamic
-
- function omp_get_dynamic() bind(c)
- import
- logical(kind=omp_logical_kind) :: omp_get_dynamic
- end function omp_get_dynamic
-
- function omp_get_cancelation() bind(c)
- import
- logical(kind=omp_logical_kind) :: omp_get_cancelation
- end function omp_get_cancelation
-
- subroutine omp_set_nested(enable) bind(c)
- import
- logical(kind=omp_logical_kind), value :: enable
- end subroutine omp_set_nested
-
- function omp_get_nested() bind(c)
- import
- logical(kind=omp_logical_kind) ::omp_get_nested
- end function omp_get_nested
-
- subroutine omp_set_schedule(kind, modifier) bind(c)
- import
- integer(kind=omp_integer_kind), value :: kind, modifier
- end subroutine omp_set_schedule
-
- subroutine omp_get_schedule(kind, modifier) bind(c)
- import
- integer(kind=omp_integer_kind), intent(out) :: kind, modifier
- end subroutine omp_get_schedule
-
- function omp_get_thread_limit() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_thread_limit
- end function omp_get_thread_limit
-
- function omp_get_supported_active_levels() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_supported_active_levels
- end function omp_get_supported_active_levels
-
- subroutine omp_set_max_active_levels(max_levels) bind(c)
- import
- integer(kind=omp_integer_kind), value :: max_levels
- end subroutine omp_set_max_active_levels
-
- function omp_get_max_active_levels() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_max_active_levels
- end function omp_get_max_active_levels
-
- function omp_get_level() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_level
- end function omp_get_level
-
- function omp_get_ancestor_thread_num(level) bind(c)
- import
- integer(kind=omp_integer_kind), value :: level
- integer(kind=omp_integer_kind) :: omp_get_ancestor_thread_num
- end function omp_get_ancestor_thread_num
-
- function omp_get_team_size(level) bind(c)
- import
- integer(kind=omp_integer_kind), value :: level
- integer(kind=omp_integer_kind) :: omp_get_team_size
- end function omp_get_team_size
-
- function omp_get_active_level() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_active_level
- end function omp_get_active_level
-
- function omp_in_final() bind(c)
- import
- logical(kind=omp_logical_kind) :: omp_in_final
- end function omp_in_final
-
- function omp_get_proc_bind() bind(c)
- import
- integer(kind=omp_proc_bind_kind) :: omp_get_proc_bind
- end function omp_get_proc_bind
-
- function omp_get_num_places() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_num_places
- end function omp_get_num_places
-
- function omp_get_place_num_procs(place_num) bind(c)
- import
- integer(kind=omp_integer_kind), value :: place_num
- integer(kind=omp_integer_kind) omp_get_place_num_procs
- end function omp_get_place_num_procs
-
- subroutine omp_get_place_proc_ids(place_num, ids) bind(c)
- import
- integer(kind=omp_integer_kind), value :: place_num
- integer(kind=omp_integer_kind), intent(out) :: ids(*)
- end subroutine omp_get_place_proc_ids
-
- function omp_get_place_num() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_place_num
- end function omp_get_place_num
-
- function omp_get_partition_num_places() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_partition_num_places
- end function omp_get_partition_num_places
-
- subroutine omp_get_partition_place_nums(place_nums) bind(c)
- import
- integer(kind=omp_integer_kind), intent(out) :: place_nums(*)
- end subroutine omp_get_partition_place_nums
-
- subroutine omp_set_affinity_format(format) bind(c)
- import
- character(len=*), intent(in) :: format
- end subroutine omp_set_affinity_format
-
- function omp_get_affinity_format(buffer) bind(c)
- import
- character(len=*), intent(out) :: buffer
- integer(kind=omp_integer_kind) :: omp_get_affinity_format
- end function omp_get_affinity_format
-
- subroutine omp_display_affinity(format) bind(c)
- import
- character(len=*), intent(in) :: format
- end subroutine omp_display_affinity
-
- function omp_capture_affinity(buffer, format) bind(c)
- import
- character(len=*), intent(out) :: buffer
- character(len=*), intent(in) :: format
- integer(kind=omp_integer_kind) omp_capture_affinity
- end function omp_capture_affinity
-
- subroutine omp_set_default_device(device_num) bind(c)
- import
- integer(kind=omp_integer_kind), value :: device_num
- end subroutine omp_set_default_device
-
- function omp_get_default_device() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_default_device
- end function omp_get_default_device
-
- function omp_get_num_devices() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_num_devices
- end function omp_get_num_devices
-
- function omp_get_device_num() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_device_num
- end function omp_get_device_num
-
- function omp_get_num_teams() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_num_teams
- end function omp_get_num_teams
-
- function omp_get_team_num() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_team_num
- end function omp_get_team_num
-
- function omp_is_initial_device() bind(c)
- import
- integer(kind=omp_logical_kind) :: omp_is_initial_device ! TODO: should this be LOGICAL?
- end function omp_is_initial_device
-
- function omp_get_initial_device() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_initial_device
- end function omp_get_initial_device
-
- function omp_get_max_task_priority() bind(c)
- import
- integer(kind=omp_integer_kind) :: omp_get_max_task_priority
- end function omp_get_max_task_priority
-
- function omp_pause_resource(kind, device_num) bind(c)
- import
- integer(kind=omp_pause_resource_kind), value :: kind
- integer(kind=omp_integer_kind), value :: device_num
- integer(kind=omp_integer_kind) :: omp_pause_resource
- end function omp_pause_resource
-
- function omp_pause_resource_all(kind) bind(c)
- import
- integer(kind=omp_pause_resource_kind), value :: kind
- integer(kind=omp_integer_kind) :: omp_pause_resource_all
- end function omp_pause_resource_all
-
-! Lock routines
- subroutine omp_init_lock(lockvar) bind(c, name="omp_init_lock_")
- import
- integer(kind=omp_lock_kind), intent(out) :: lockvar
- end subroutine omp_init_lock
-
- subroutine omp_init_lock_with_hint(lockvar, hint) bind(c, name="omp_init_lock_with_hint_")
- import
- integer(kind=omp_lock_kind), intent(out) :: lockvar
- integer(kind=omp_sync_hint_kind), value :: hint
- end subroutine omp_init_lock_with_hint
-
- subroutine omp_destroy_lock(lockvar) bind(c, name="omp_destroy_lock_")
- import
- integer(kind=omp_lock_kind), intent(inout) :: lockvar
- end subroutine omp_destroy_lock
-
- subroutine omp_set_lock(lockvar) bind(c, name="omp_set_lock_")
- import
- integer(kind=omp_lock_kind), intent(inout) :: lockvar
- end subroutine omp_set_lock
-
- subroutine omp_unset_lock(lockvar) bind(c, name="omp_unset_lock_")
- import
- integer(kind=omp_lock_kind), intent(inout) :: lockvar
- end subroutine omp_unset_lock
-
- function omp_test_lock(lockvar) bind(c, name="omp_test_lock_")
- import
- integer(kind=omp_lock_kind), intent(inout) :: lockvar
- logical(kind=omp_logical_kind) :: omp_test_lock
- end function omp_test_lock
-
- subroutine omp_init_nest_lock(lockvar) bind(c, name="omp_init_nest_lock_")
- import
- integer(kind=omp_nest_lock_kind), intent(out) :: lockvar
- end subroutine omp_init_nest_lock
-
- subroutine omp_init_nest_lock_with_hint(lockvar, hint) bind(c, name="omp_init_nest_lock_with_hint_")
- import
- integer(kind=omp_nest_lock_kind), intent(out) :: lockvar
- integer(kind=omp_sync_hint_kind), value :: hint
- end subroutine omp_init_nest_lock_with_hint
-
- subroutine omp_destroy_nest_lock(lockvar) bind(c, name="omp_destroy_nest_lock_")
- import
- integer(kind=omp_nest_lock_kind), intent(inout) :: lockvar
- end subroutine omp_destroy_nest_lock
-
- subroutine omp_set_nest_lock(lockvar) bind(c, name="omp_set_nest_lock_")
- import
- integer(kind=omp_nest_lock_kind), intent(inout) :: lockvar
- end subroutine omp_set_nest_lock
-
- subroutine omp_unset_nest_lock(lockvar) bind(c, name="omp_unset_nest_lock_")
- import
- integer(kind=omp_nest_lock_kind), intent(inout) :: lockvar
- end subroutine omp_unset_nest_lock
-
- function omp_test_nest_lock(lockvar) bind(c, name="omp_test_nest_lock_")
- import
- integer(kind=omp_integer_kind) :: omp_test_nest_lock
- integer(kind=omp_nest_lock_kind), intent(inout) :: lockvar
- end function omp_test_nest_lock
-
-! Timing routines
- function omp_get_wtime() bind(c)
- double precision omp_get_wtime
- end function omp_get_wtime
-
- function omp_get_wtick() bind(c)
- double precision omp_get_wtick
- end function omp_get_wtick
-
-! Event routine
- subroutine omp_fullfill_event(event) bind(c) ! TODO: is this the correct spelling?
- import
- integer(kind=omp_event_handle_kind) :: event
- end subroutine omp_fullfill_event
-
-! Device Memory Routines
-
-! Memory Management Routines
- function omp_init_allocator(memspace, ntraits, traits) bind(c)
- import
- integer(kind=omp_memspace_handle_kind), value :: memspace
- integer, value :: ntraits
- type(omp_alloctrait), intent(in) :: traits(*)
- integer(kind=omp_allocator_handle_kind) :: omp_init_allocator
- end function omp_init_allocator
-
- subroutine omp_destroy_allocator(allocator) bind(c)
- import
- integer(kind=omp_allocator_handle_kind), value :: allocator
- end subroutine omp_destroy_allocator
-
- subroutine omp_set_default_allocator(allocator) bind(c)
- import
- integer(kind=omp_allocator_handle_kind), value :: allocator
- end subroutine omp_set_default_allocator
-
- function omp_get_default_allocator() bind(c)
- import
- integer(kind=omp_allocator_handle_kind) :: omp_get_default_allocator
- end function omp_get_default_allocator
-
- end interface
>From f09d582b07009831010dc3ad473e5df0ffe8399d Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Thu, 8 Feb 2024 16:06:28 +0100
Subject: [PATCH 05/28] Implement CMakery to produce .mod files from OpenMP
runtime sources
---
flang/tools/f18/CMakeLists.txt | 22 ++++++++++++++++++++--
openmp/runtime/src/CMakeLists.txt | 5 +++--
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index ba6c6642c0b62e..8369eae39994d0 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -17,10 +17,10 @@ set(MODULES
"ieee_features"
"iso_c_binding"
"iso_fortran_env"
- "omp_lib"
"__fortran_builtins"
"__fortran_type_info"
)
+#"omp_lib"
# Create module files directly from the top-level module source directory.
# If CMAKE_CROSSCOMPILING, then the newly built flang-new executable was
@@ -71,6 +71,22 @@ if (NOT CMAKE_CROSSCOMPILING)
list(APPEND MODULE_FILES ${base}.mod ${base}.f18.mod)
install(FILES ${base}.mod ${base}.f18.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
endforeach()
+
+ # Special case for omp_lib.mod, because its source comes from openmp/runtime/src/include.
+ # It also produces to module files: omp_lib.mod and omp_lib_kinds.mod.
+ message("MK: ${CMAKE_BINARY_DIR}")
+ set(base ${FLANG_INTRINSIC_MODULES_DIR}/omp_lib)
+ add_custom_command(OUTPUT ${base}.mod
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
+ COMMAND flang-new -cpp -fsyntax-only ${opts} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
+ ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90
+ DEPENDS flang-new ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90 ${depends}
+ )
+ add_custom_command(OUTPUT ${base}.f18.mod
+ DEPENDS ${base}.mod
+ COMMAND ${CMAKE_COMMAND} -E copy ${base}.mod ${base}.f18.mod)
+ list(APPEND MODULE_FILES ${base}.mod ${base}.f18.mod)
+ install(FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
endif()
add_custom_target(module_files ALL DEPENDS ${MODULE_FILES})
@@ -86,6 +102,8 @@ if (NOT WIN32)
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/flang-to-external-fc DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
+# TODO: Is this the right file coming from the OpenMP runtime or is this a copy of it?
# TODO Move this to a more suitable location
+#file(COPY ${FLANG_SOURCE_DIR}/module/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
file(COPY ${FLANG_SOURCE_DIR}/module/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
-install(FILES ${CMAKE_BINARY_DIR}/include/flang/OpenMP/omp_lib.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang/OpenMP")
+install(FILES ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang/OpenMP")
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index 7e2a05e003b8d9..54203730ecc91f 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -312,9 +312,10 @@ endif()
# Building the Fortran module files
# One compilation step creates both omp_lib.mod and omp_lib_kinds.mod
+configure_file(${LIBOMP_INC_DIR}/omp_lib.h.var omp_lib.h @ONLY)
+configure_file(${LIBOMP_INC_DIR}/omp_lib.F90.var omp_lib.F90 @ONLY)
+message("LIBOMP: produce omp_lib.h omp_lib.F90")
if(${LIBOMP_FORTRAN_MODULES})
- configure_file(${LIBOMP_INC_DIR}/omp_lib.h.var omp_lib.h @ONLY)
- configure_file(${LIBOMP_INC_DIR}/omp_lib.F90.var omp_lib.F90 @ONLY)
# Workaround for gfortran to build modules with the
# omp_sched_monotonic integer parameter
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
>From ee7baef5bcd9205ffdbe7ce787eb1f0ff6542fa0 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Thu, 8 Feb 2024 16:34:31 +0100
Subject: [PATCH 06/28] Add dependecy for ISO_S_BINDING, as needed by
omp_lib.mod
---
flang/tools/f18/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 8369eae39994d0..514fc6387addbb 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -80,7 +80,7 @@ if (NOT CMAKE_CROSSCOMPILING)
COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
COMMAND flang-new -cpp -fsyntax-only ${opts} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90
- DEPENDS flang-new ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90 ${depends}
+ DEPENDS flang-new ${FLANG_INTRINSIC_MODULES_DIR}/iso_c_binding.mod ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90 ${depends}
)
add_custom_command(OUTPUT ${base}.f18.mod
DEPENDS ${base}.mod
>From 6aa43813c3f0d73dfd11f2edc6a27a90f251b0e9 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Thu, 8 Feb 2024 16:49:00 +0100
Subject: [PATCH 07/28] Correct a few things about copying and installing files
---
flang/tools/f18/CMakeLists.txt | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 514fc6387addbb..0e3cfbcfc00001 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -59,6 +59,7 @@ if (NOT CMAKE_CROSSCOMPILING)
endif()
endif()
+ # TODO: We may need to flag this with conditional, in case Flang is built w/o OpenMP support
add_custom_command(OUTPUT ${base}.mod
COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
COMMAND flang-new -cpp -fsyntax-only ${opts} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
@@ -85,7 +86,10 @@ if (NOT CMAKE_CROSSCOMPILING)
add_custom_command(OUTPUT ${base}.f18.mod
DEPENDS ${base}.mod
COMMAND ${CMAKE_COMMAND} -E copy ${base}.mod ${base}.f18.mod)
- list(APPEND MODULE_FILES ${base}.mod ${base}.f18.mod)
+ add_custom_command(OUTPUT ${base}_kinds.f18.mod
+ DEPENDS ${base}.mod
+ COMMAND ${CMAKE_COMMAND} -E copy ${base}_kinds.mod ${base}_kinds.f18.mod)
+ list(APPEND MODULE_FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod)
install(FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
endif()
@@ -105,5 +109,6 @@ endif()
# TODO: Is this the right file coming from the OpenMP runtime or is this a copy of it?
# TODO Move this to a more suitable location
#file(COPY ${FLANG_SOURCE_DIR}/module/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
-file(COPY ${FLANG_SOURCE_DIR}/module/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
-install(FILES ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang/OpenMP")
+file(COPY ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
+install(FILES ${CMAKE_BINARY_DIR}/include/flang/OpenMP/omp_lib.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang/OpenMP")
+
>From 29eb7a4f1e4de7927f8b30f56f60f4640dd3aa9d Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Tue, 20 Feb 2024 15:18:27 +0100
Subject: [PATCH 08/28] Add missing generated dependence
---
flang/tools/f18/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 0e3cfbcfc00001..a867edb8b4a493 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -77,7 +77,7 @@ if (NOT CMAKE_CROSSCOMPILING)
# It also produces to module files: omp_lib.mod and omp_lib_kinds.mod.
message("MK: ${CMAKE_BINARY_DIR}")
set(base ${FLANG_INTRINSIC_MODULES_DIR}/omp_lib)
- add_custom_command(OUTPUT ${base}.mod
+ add_custom_command(OUTPUT ${base}.mod ${base}_kinds.mod
COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
COMMAND flang-new -cpp -fsyntax-only ${opts} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90
>From 6b32f374cf818e6669b0404bea1efe31d5b23330 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Tue, 20 Feb 2024 15:18:42 +0100
Subject: [PATCH 09/28] Cleanup CMake debugging code
---
flang/tools/f18/CMakeLists.txt | 2 --
1 file changed, 2 deletions(-)
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index a867edb8b4a493..396c85df150229 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -20,7 +20,6 @@ set(MODULES
"__fortran_builtins"
"__fortran_type_info"
)
-#"omp_lib"
# Create module files directly from the top-level module source directory.
# If CMAKE_CROSSCOMPILING, then the newly built flang-new executable was
@@ -75,7 +74,6 @@ if (NOT CMAKE_CROSSCOMPILING)
# Special case for omp_lib.mod, because its source comes from openmp/runtime/src/include.
# It also produces to module files: omp_lib.mod and omp_lib_kinds.mod.
- message("MK: ${CMAKE_BINARY_DIR}")
set(base ${FLANG_INTRINSIC_MODULES_DIR}/omp_lib)
add_custom_command(OUTPUT ${base}.mod ${base}_kinds.mod
COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
>From cae882da0b82f8dc993c42572f1353068399dffe Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Wed, 21 Feb 2024 10:12:24 +0100
Subject: [PATCH 10/28] Correct USE statements for OpenMP API routines
---
openmp/runtime/src/include/omp_lib.F90.var | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/openmp/runtime/src/include/omp_lib.F90.var b/openmp/runtime/src/include/omp_lib.F90.var
index 68799fc52ff020..14670f9082cf1d 100644
--- a/openmp/runtime/src/include/omp_lib.F90.var
+++ b/openmp/runtime/src/include/omp_lib.F90.var
@@ -588,20 +588,20 @@
end subroutine omp_display_env
function omp_target_alloc(size, device_num) bind(c)
- use omp_lib_kinds
+ use, intrinsic :: iso_c_binding, only: c_ptr, c_size_t, c_int
type(c_ptr) omp_target_alloc
integer(c_size_t), value :: size
integer(c_int), value :: device_num
end function omp_target_alloc
subroutine omp_target_free(device_ptr, device_num) bind(c)
- use omp_lib_kinds
+ use, intrinsic :: iso_c_binding, only: c_ptr, c_int
type(c_ptr), value :: device_ptr
integer(c_int), value :: device_num
end subroutine omp_target_free
function omp_target_is_present(ptr, device_num) bind(c)
- use omp_lib_kinds
+ use, intrinsic :: iso_c_binding, only: c_ptr, c_int
integer(c_int) omp_target_is_present
type(c_ptr), value :: ptr
integer(c_int), value :: device_num
@@ -609,7 +609,7 @@
function omp_target_memcpy(dst, src, length, dst_offset, src_offset, &
dst_device_num, src_device_num) bind(c)
- use omp_lib_kinds
+ use, intrinsic :: iso_c_binding, only: c_ptr, c_size_t, c_int
integer(c_int) omp_target_memcpy
type(c_ptr), value :: dst, src
integer(c_size_t), value :: length, dst_offset, src_offset
@@ -619,7 +619,7 @@
function omp_target_memcpy_rect(dst, src, element_size, num_dims, &
volume, dst_offsets, src_offsets, dst_dimensions, &
src_dimensions, dst_device_num, src_device_num) bind(c)
- use omp_lib_kinds
+ use, intrinsic :: iso_c_binding, only: c_ptr, c_size_t, c_int
integer(c_int) omp_target_memcpy_rect
type(c_ptr), value :: dst, src
integer(c_size_t), value :: element_size
@@ -632,6 +632,7 @@
src_offset, dst_device_num, src_device_num, depobj_count, &
depobj_list) bind(c)
use omp_lib_kinds
+ use, intrinsic :: iso_c_binding, only: c_ptr, c_size_t, c_int
integer(c_int) omp_target_memcpy_async
type(c_ptr), value :: dst, src
integer(c_size_t), value :: length, dst_offset, src_offset
@@ -645,6 +646,7 @@
src_dimensions, dst_device_num, src_device_num, depobj_count, &
depobj_list) bind(c)
use omp_lib_kinds
+ use, intrinsic :: iso_c_binding, only: c_ptr, c_size_t, c_int
integer(c_int) omp_target_memcpy_rect_async
type(c_ptr), value :: dst, src
integer(c_size_t), value :: element_size
@@ -666,8 +668,8 @@
function omp_target_memset_async(ptr, val, count, device_num, &
depobj_count, depobj_list) bind(c)
- use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_size_t
use omp_lib_kinds
+ use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_size_t
type(c_ptr) :: omp_target_memset_async
type(c_ptr), value :: ptr
integer(c_int), value :: val
@@ -679,7 +681,7 @@
function omp_target_associate_ptr(host_ptr, device_ptr, size, &
device_offset, device_num) bind(c)
- use omp_lib_kinds
+ use, intrinsic :: iso_c_binding, only: c_ptr, c_size_t, c_int
integer(c_int) omp_target_associate_ptr
type(c_ptr), value :: host_ptr, device_ptr
integer(c_size_t), value :: size, device_offset
@@ -687,21 +689,20 @@
end function omp_target_associate_ptr
function omp_get_mapped_ptr(ptr, device_num) bind(c)
- use omp_lib_kinds
+ use, intrinsic :: iso_c_binding, only: c_ptr, c_int
type(c_ptr) omp_get_mapped_ptr
type(c_ptr), value :: ptr
integer(c_int), value :: device_num
end function omp_get_mapped_ptr
function omp_target_disassociate_ptr(ptr, device_num) bind(c)
- use omp_lib_kinds
+ use, intrinsic :: iso_c_binding, only: c_ptr, c_int
integer(c_int) omp_target_disassociate_ptr
type(c_ptr), value :: ptr
integer(c_int), value :: device_num
end function omp_target_disassociate_ptr
function omp_target_is_accessible(ptr, size, device_num) bind(c)
- use omp_lib_kinds
use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t, c_int
integer(c_int) omp_target_is_accessible
type(c_ptr), value :: ptr
>From fb36811f07cd95c688140baf9e294d254bc66c37 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Wed, 21 Feb 2024 10:41:41 +0100
Subject: [PATCH 11/28] Change default visibility to PRIVATE
---
openmp/runtime/src/include/omp_lib.F90.var | 279 +++++++++++----------
1 file changed, 144 insertions(+), 135 deletions(-)
diff --git a/openmp/runtime/src/include/omp_lib.F90.var b/openmp/runtime/src/include/omp_lib.F90.var
index 14670f9082cf1d..2fd61883879fa8 100644
--- a/openmp/runtime/src/include/omp_lib.F90.var
+++ b/openmp/runtime/src/include/omp_lib.F90.var
@@ -14,37 +14,42 @@
use, intrinsic :: iso_c_binding
- integer, parameter :: omp_integer_kind = c_int
- integer, parameter :: omp_logical_kind = 4
- integer, parameter :: omp_real_kind = c_float
- integer, parameter :: kmp_double_kind = c_double
- integer, parameter :: omp_lock_kind = c_intptr_t
- integer, parameter :: omp_nest_lock_kind = c_intptr_t
- integer, parameter :: omp_sched_kind = omp_integer_kind
- integer, parameter :: omp_proc_bind_kind = omp_integer_kind
- integer, parameter :: kmp_pointer_kind = c_intptr_t
- integer, parameter :: kmp_size_t_kind = c_size_t
- integer, parameter :: kmp_affinity_mask_kind = c_intptr_t
- integer, parameter :: kmp_cancel_kind = omp_integer_kind
- integer, parameter :: omp_sync_hint_kind = omp_integer_kind
- integer, parameter :: omp_lock_hint_kind = omp_sync_hint_kind
- integer, parameter :: omp_control_tool_kind = omp_integer_kind
- integer, parameter :: omp_control_tool_result_kind = omp_integer_kind
- integer, parameter :: omp_allocator_handle_kind = c_intptr_t
- integer, parameter :: omp_memspace_handle_kind = c_intptr_t
- integer, parameter :: omp_alloctrait_key_kind = omp_integer_kind
- integer, parameter :: omp_alloctrait_val_kind = c_intptr_t
- integer, parameter :: omp_interop_kind = c_intptr_t
- integer, parameter :: omp_interop_fr_kind = omp_integer_kind
+ ! Set PRIVATE by default to explicitly only export what is meant
+ ! to be exported by this MODULE.
+ private
+
+ integer, parameter, public :: omp_integer_kind = c_int
+ integer, parameter, public :: omp_logical_kind = 4
+ integer, parameter, public :: omp_real_kind = c_float
+ integer, parameter, public :: kmp_double_kind = c_double
+ integer, parameter, public :: omp_lock_kind = c_intptr_t
+ integer, parameter, public :: omp_nest_lock_kind = c_intptr_t
+ integer, parameter, public :: omp_sched_kind = omp_integer_kind
+ integer, parameter, public :: omp_proc_bind_kind = omp_integer_kind
+ integer, parameter, public :: kmp_pointer_kind = c_intptr_t
+ integer, parameter, public :: kmp_size_t_kind = c_size_t
+ integer, parameter, public :: kmp_affinity_mask_kind = c_intptr_t
+ integer, parameter, public :: kmp_cancel_kind = omp_integer_kind
+ integer, parameter, public :: omp_sync_hint_kind = omp_integer_kind
+ integer, parameter, public :: omp_lock_hint_kind = omp_sync_hint_kind
+ integer, parameter, public :: omp_control_tool_kind = omp_integer_kind
+ integer, parameter, public :: omp_control_tool_result_kind = omp_integer_kind
+ integer, parameter, public :: omp_allocator_handle_kind = c_intptr_t
+ integer, parameter, public :: omp_memspace_handle_kind = c_intptr_t
+ integer, parameter, public :: omp_alloctrait_key_kind = omp_integer_kind
+ integer, parameter, public :: omp_alloctrait_val_kind = c_intptr_t
+ integer, parameter, public :: omp_interop_kind = c_intptr_t
+ integer, parameter, public :: omp_interop_fr_kind = omp_integer_kind
type omp_alloctrait
integer(kind=omp_alloctrait_key_kind) key
integer(kind=omp_alloctrait_val_kind) value
end type omp_alloctrait
+ public :: omp_alloctrait
- integer, parameter :: omp_pause_resource_kind = omp_integer_kind
- integer, parameter :: omp_depend_kind = c_intptr_t
- integer, parameter :: omp_event_handle_kind = c_intptr_t
+ integer, parameter, public :: omp_pause_resource_kind = omp_integer_kind
+ integer, parameter, public :: omp_depend_kind = c_intptr_t
+ integer, parameter, public :: omp_event_handle_kind = c_intptr_t
end module omp_lib_kinds
@@ -52,119 +57,123 @@
use omp_lib_kinds
- integer (kind=omp_integer_kind), parameter :: openmp_version = @LIBOMP_OMP_YEAR_MONTH@
- integer (kind=omp_integer_kind), parameter :: kmp_version_major = @LIBOMP_VERSION_MAJOR@
- integer (kind=omp_integer_kind), parameter :: kmp_version_minor = @LIBOMP_VERSION_MINOR@
- integer (kind=omp_integer_kind), parameter :: kmp_version_build = @LIBOMP_VERSION_BUILD@
+ ! Set PRIVATE by default to explicitly only export what is meant
+ ! to be exported by this MODULE.
+ private
+
+ integer (kind=omp_integer_kind), parameter, public :: openmp_version = @LIBOMP_OMP_YEAR_MONTH@
+ integer (kind=omp_integer_kind), parameter, public :: kmp_version_major = @LIBOMP_VERSION_MAJOR@
+ integer (kind=omp_integer_kind), parameter, public :: kmp_version_minor = @LIBOMP_VERSION_MINOR@
+ integer (kind=omp_integer_kind), parameter, public :: kmp_version_build = @LIBOMP_VERSION_BUILD@
character(*) kmp_build_date
parameter( kmp_build_date = '@LIBOMP_BUILD_DATE@' )
- integer(kind=omp_sched_kind), parameter :: omp_sched_static = 1
- integer(kind=omp_sched_kind), parameter :: omp_sched_dynamic = 2
- integer(kind=omp_sched_kind), parameter :: omp_sched_guided = 3
- integer(kind=omp_sched_kind), parameter :: omp_sched_auto = 4
- integer(kind=omp_sched_kind), parameter :: omp_sched_monotonic = int(Z'80000000', kind=omp_sched_kind)
-
- integer (kind=omp_proc_bind_kind), parameter :: omp_proc_bind_false = 0
- integer (kind=omp_proc_bind_kind), parameter :: omp_proc_bind_true = 1
- integer (kind=omp_proc_bind_kind), parameter :: omp_proc_bind_master = 2
- integer (kind=omp_proc_bind_kind), parameter :: omp_proc_bind_close = 3
- integer (kind=omp_proc_bind_kind), parameter :: omp_proc_bind_spread = 4
-
- integer (kind=kmp_cancel_kind), parameter :: kmp_cancel_parallel = 1
- integer (kind=kmp_cancel_kind), parameter :: kmp_cancel_loop = 2
- integer (kind=kmp_cancel_kind), parameter :: kmp_cancel_sections = 3
- integer (kind=kmp_cancel_kind), parameter :: kmp_cancel_taskgroup = 4
-
- integer (kind=omp_sync_hint_kind), parameter :: omp_sync_hint_none = 0
- integer (kind=omp_sync_hint_kind), parameter :: omp_sync_hint_uncontended = 1
- integer (kind=omp_sync_hint_kind), parameter :: omp_sync_hint_contended = 2
- integer (kind=omp_sync_hint_kind), parameter :: omp_sync_hint_nonspeculative = 4
- integer (kind=omp_sync_hint_kind), parameter :: omp_sync_hint_speculative = 8
- integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_none = omp_sync_hint_none
- integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_uncontended = omp_sync_hint_uncontended
- integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_contended = omp_sync_hint_contended
- integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative
- integer (kind=omp_lock_hint_kind), parameter :: omp_lock_hint_speculative = omp_sync_hint_speculative
- integer (kind=omp_lock_hint_kind), parameter :: kmp_lock_hint_hle = 65536
- integer (kind=omp_lock_hint_kind), parameter :: kmp_lock_hint_rtm = 131072
- integer (kind=omp_lock_hint_kind), parameter :: kmp_lock_hint_adaptive = 262144
-
- integer (kind=omp_control_tool_kind), parameter :: omp_control_tool_start = 1
- integer (kind=omp_control_tool_kind), parameter :: omp_control_tool_pause = 2
- integer (kind=omp_control_tool_kind), parameter :: omp_control_tool_flush = 3
- integer (kind=omp_control_tool_kind), parameter :: omp_control_tool_end = 4
-
- integer (kind=omp_control_tool_result_kind), parameter :: omp_control_tool_notool = -2
- integer (kind=omp_control_tool_result_kind), parameter :: omp_control_tool_nocallback = -1
- integer (kind=omp_control_tool_result_kind), parameter :: omp_control_tool_success = 0
- integer (kind=omp_control_tool_result_kind), parameter :: omp_control_tool_ignored = 1
-
- integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_sync_hint = 1
- integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_alignment = 2
- integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_access = 3
- integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_pool_size = 4
- integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_fallback = 5
- integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_fb_data = 6
- integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_pinned = 7
- integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_partition = 8
-
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_default = -1
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_false = 0
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_true = 1
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_contended = 3
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_uncontended = 4
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_serialized = 5
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_sequential = omp_atv_serialized
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_private = 6
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_all = 7
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_thread = 8
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_pteam = 9
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_cgroup = 10
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_default_mem_fb = 11
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_null_fb = 12
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_abort_fb = 13
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_allocator_fb = 14
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_environment = 15
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_nearest = 16
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_blocked = 17
- integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_interleaved = 18
-
- integer (kind=omp_allocator_handle_kind), parameter :: omp_null_allocator = 0
- integer (kind=omp_allocator_handle_kind), parameter :: omp_default_mem_alloc = 1
- integer (kind=omp_allocator_handle_kind), parameter :: omp_large_cap_mem_alloc = 2
- integer (kind=omp_allocator_handle_kind), parameter :: omp_const_mem_alloc = 3
- integer (kind=omp_allocator_handle_kind), parameter :: omp_high_bw_mem_alloc = 4
- integer (kind=omp_allocator_handle_kind), parameter :: omp_low_lat_mem_alloc = 5
- integer (kind=omp_allocator_handle_kind), parameter :: omp_cgroup_mem_alloc = 6
- integer (kind=omp_allocator_handle_kind), parameter :: omp_pteam_mem_alloc = 7
- integer (kind=omp_allocator_handle_kind), parameter :: omp_thread_mem_alloc = 8
- integer (kind=omp_allocator_handle_kind), parameter :: llvm_omp_target_host_mem_alloc = 100
- integer (kind=omp_allocator_handle_kind), parameter :: llvm_omp_target_shared_mem_alloc = 101
- integer (kind=omp_allocator_handle_kind), parameter :: llvm_omp_target_device_mem_alloc = 102
-
- integer (kind=omp_memspace_handle_kind), parameter :: omp_default_mem_space = 0
- integer (kind=omp_memspace_handle_kind), parameter :: omp_large_cap_mem_space = 1
- integer (kind=omp_memspace_handle_kind), parameter :: omp_const_mem_space = 2
- integer (kind=omp_memspace_handle_kind), parameter :: omp_high_bw_mem_space = 3
- integer (kind=omp_memspace_handle_kind), parameter :: omp_low_lat_mem_space = 4
- integer (kind=omp_memspace_handle_kind), parameter :: llvm_omp_target_host_mem_space = 100
- integer (kind=omp_memspace_handle_kind), parameter :: llvm_omp_target_shared_mem_space = 101
- integer (kind=omp_memspace_handle_kind), parameter :: llvm_omp_target_device_mem_space = 102
-
- integer (kind=omp_pause_resource_kind), parameter :: omp_pause_resume = 0
- integer (kind=omp_pause_resource_kind), parameter :: omp_pause_soft = 1
- integer (kind=omp_pause_resource_kind), parameter :: omp_pause_hard = 2
-
- integer (kind=omp_interop_fr_kind), parameter :: omp_ifr_cuda = 1
- integer (kind=omp_interop_fr_kind), parameter :: omp_ifr_cuda_driver = 2
- integer (kind=omp_interop_fr_kind), parameter :: omp_ifr_opencl = 3
- integer (kind=omp_interop_fr_kind), parameter :: omp_ifr_sycl = 4
- integer (kind=omp_interop_fr_kind), parameter :: omp_ifr_hip = 5
- integer (kind=omp_interop_fr_kind), parameter :: omp_ifr_level_zero = 6
- integer (kind=omp_interop_fr_kind), parameter :: omp_ifr_last = 7
-
- integer (kind=omp_interop_kind), parameter :: omp_interop_none = 0
+ integer(kind=omp_sched_kind), parameter, public :: omp_sched_static = 1
+ integer(kind=omp_sched_kind), parameter, public :: omp_sched_dynamic = 2
+ integer(kind=omp_sched_kind), parameter, public :: omp_sched_guided = 3
+ integer(kind=omp_sched_kind), parameter, public :: omp_sched_auto = 4
+ integer(kind=omp_sched_kind), parameter, public :: omp_sched_monotonic = int(Z'80000000', kind=omp_sched_kind)
+
+ integer (kind=omp_proc_bind_kind), parameter, public :: omp_proc_bind_false = 0
+ integer (kind=omp_proc_bind_kind), parameter, public :: omp_proc_bind_true = 1
+ integer (kind=omp_proc_bind_kind), parameter, public :: omp_proc_bind_master = 2
+ integer (kind=omp_proc_bind_kind), parameter, public :: omp_proc_bind_close = 3
+ integer (kind=omp_proc_bind_kind), parameter, public :: omp_proc_bind_spread = 4
+
+ integer (kind=kmp_cancel_kind), parameter, public :: kmp_cancel_parallel = 1
+ integer (kind=kmp_cancel_kind), parameter, public :: kmp_cancel_loop = 2
+ integer (kind=kmp_cancel_kind), parameter, public :: kmp_cancel_sections = 3
+ integer (kind=kmp_cancel_kind), parameter, public :: kmp_cancel_taskgroup = 4
+
+ integer (kind=omp_sync_hint_kind), parameter, public :: omp_sync_hint_none = 0
+ integer (kind=omp_sync_hint_kind), parameter, public :: omp_sync_hint_uncontended = 1
+ integer (kind=omp_sync_hint_kind), parameter, public :: omp_sync_hint_contended = 2
+ integer (kind=omp_sync_hint_kind), parameter, public :: omp_sync_hint_nonspeculative = 4
+ integer (kind=omp_sync_hint_kind), parameter, public :: omp_sync_hint_speculative = 8
+ integer (kind=omp_lock_hint_kind), parameter, public :: omp_lock_hint_none = omp_sync_hint_none
+ integer (kind=omp_lock_hint_kind), parameter, public :: omp_lock_hint_uncontended = omp_sync_hint_uncontended
+ integer (kind=omp_lock_hint_kind), parameter, public :: omp_lock_hint_contended = omp_sync_hint_contended
+ integer (kind=omp_lock_hint_kind), parameter, public :: omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative
+ integer (kind=omp_lock_hint_kind), parameter, public :: omp_lock_hint_speculative = omp_sync_hint_speculative
+ integer (kind=omp_lock_hint_kind), parameter, public :: kmp_lock_hint_hle = 65536
+ integer (kind=omp_lock_hint_kind), parameter, public :: kmp_lock_hint_rtm = 131072
+ integer (kind=omp_lock_hint_kind), parameter, public :: kmp_lock_hint_adaptive = 262144
+
+ integer (kind=omp_control_tool_kind), parameter, public :: omp_control_tool_start = 1
+ integer (kind=omp_control_tool_kind), parameter, public :: omp_control_tool_pause = 2
+ integer (kind=omp_control_tool_kind), parameter, public :: omp_control_tool_flush = 3
+ integer (kind=omp_control_tool_kind), parameter, public :: omp_control_tool_end = 4
+
+ integer (kind=omp_control_tool_result_kind), parameter, public :: omp_control_tool_notool = -2
+ integer (kind=omp_control_tool_result_kind), parameter, public :: omp_control_tool_nocallback = -1
+ integer (kind=omp_control_tool_result_kind), parameter, public :: omp_control_tool_success = 0
+ integer (kind=omp_control_tool_result_kind), parameter, public :: omp_control_tool_ignored = 1
+
+ integer (kind=omp_alloctrait_key_kind), parameter, public :: omp_atk_sync_hint = 1
+ integer (kind=omp_alloctrait_key_kind), parameter, public :: omp_atk_alignment = 2
+ integer (kind=omp_alloctrait_key_kind), parameter, public :: omp_atk_access = 3
+ integer (kind=omp_alloctrait_key_kind), parameter, public :: omp_atk_pool_size = 4
+ integer (kind=omp_alloctrait_key_kind), parameter, public :: omp_atk_fallback = 5
+ integer (kind=omp_alloctrait_key_kind), parameter, public :: omp_atk_fb_data = 6
+ integer (kind=omp_alloctrait_key_kind), parameter, public :: omp_atk_pinned = 7
+ integer (kind=omp_alloctrait_key_kind), parameter, public :: omp_atk_partition = 8
+
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_default = -1
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_false = 0
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_true = 1
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_contended = 3
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_uncontended = 4
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_serialized = 5
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_sequential = omp_atv_serialized
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_private = 6
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_all = 7
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_thread = 8
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_pteam = 9
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_cgroup = 10
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_default_mem_fb = 11
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_null_fb = 12
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_abort_fb = 13
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_allocator_fb = 14
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_environment = 15
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_nearest = 16
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_blocked = 17
+ integer (kind=omp_alloctrait_val_kind), parameter, public :: omp_atv_interleaved = 18
+
+ integer (kind=omp_allocator_handle_kind), parameter, public :: omp_null_allocator = 0
+ integer (kind=omp_allocator_handle_kind), parameter, public :: omp_default_mem_alloc = 1
+ integer (kind=omp_allocator_handle_kind), parameter, public :: omp_large_cap_mem_alloc = 2
+ integer (kind=omp_allocator_handle_kind), parameter, public :: omp_const_mem_alloc = 3
+ integer (kind=omp_allocator_handle_kind), parameter, public :: omp_high_bw_mem_alloc = 4
+ integer (kind=omp_allocator_handle_kind), parameter, public :: omp_low_lat_mem_alloc = 5
+ integer (kind=omp_allocator_handle_kind), parameter, public :: omp_cgroup_mem_alloc = 6
+ integer (kind=omp_allocator_handle_kind), parameter, public :: omp_pteam_mem_alloc = 7
+ integer (kind=omp_allocator_handle_kind), parameter, public :: omp_thread_mem_alloc = 8
+ integer (kind=omp_allocator_handle_kind), parameter, public :: llvm_omp_target_host_mem_alloc = 100
+ integer (kind=omp_allocator_handle_kind), parameter, public :: llvm_omp_target_shared_mem_alloc = 101
+ integer (kind=omp_allocator_handle_kind), parameter, public :: llvm_omp_target_device_mem_alloc = 102
+
+ integer (kind=omp_memspace_handle_kind), parameter, public :: omp_default_mem_space = 0
+ integer (kind=omp_memspace_handle_kind), parameter, public :: omp_large_cap_mem_space = 1
+ integer (kind=omp_memspace_handle_kind), parameter, public :: omp_const_mem_space = 2
+ integer (kind=omp_memspace_handle_kind), parameter, public :: omp_high_bw_mem_space = 3
+ integer (kind=omp_memspace_handle_kind), parameter, public :: omp_low_lat_mem_space = 4
+ integer (kind=omp_memspace_handle_kind), parameter, public :: llvm_omp_target_host_mem_space = 100
+ integer (kind=omp_memspace_handle_kind), parameter, public :: llvm_omp_target_shared_mem_space = 101
+ integer (kind=omp_memspace_handle_kind), parameter, public :: llvm_omp_target_device_mem_space = 102
+
+ integer (kind=omp_pause_resource_kind), parameter, public :: omp_pause_resume = 0
+ integer (kind=omp_pause_resource_kind), parameter, public :: omp_pause_soft = 1
+ integer (kind=omp_pause_resource_kind), parameter, public :: omp_pause_hard = 2
+
+ integer (kind=omp_interop_fr_kind), parameter, public :: omp_ifr_cuda = 1
+ integer (kind=omp_interop_fr_kind), parameter, public :: omp_ifr_cuda_driver = 2
+ integer (kind=omp_interop_fr_kind), parameter, public :: omp_ifr_opencl = 3
+ integer (kind=omp_interop_fr_kind), parameter, public :: omp_ifr_sycl = 4
+ integer (kind=omp_interop_fr_kind), parameter, public :: omp_ifr_hip = 5
+ integer (kind=omp_interop_fr_kind), parameter, public :: omp_ifr_level_zero = 6
+ integer (kind=omp_interop_fr_kind), parameter, public :: omp_ifr_last = 7
+
+ integer (kind=omp_interop_kind), parameter, public :: omp_interop_none = 0
interface
>From ad4eb2bbad194742bc73086733abbb0f606596f0 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Wed, 21 Feb 2024 16:55:32 +0100
Subject: [PATCH 12/28] Cleanup debugging code
---
openmp/runtime/src/CMakeLists.txt | 1 -
1 file changed, 1 deletion(-)
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index 54203730ecc91f..8a24bd150d5e4c 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -314,7 +314,6 @@ endif()
# One compilation step creates both omp_lib.mod and omp_lib_kinds.mod
configure_file(${LIBOMP_INC_DIR}/omp_lib.h.var omp_lib.h @ONLY)
configure_file(${LIBOMP_INC_DIR}/omp_lib.F90.var omp_lib.F90 @ONLY)
-message("LIBOMP: produce omp_lib.h omp_lib.F90")
if(${LIBOMP_FORTRAN_MODULES})
# Workaround for gfortran to build modules with the
# omp_sched_monotonic integer parameter
>From 544b5f65fddf45d194e71134656c7f9135ca7d72 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Mon, 26 Feb 2024 20:51:18 +0100
Subject: [PATCH 13/28] Add proper PUBLIC statements of the OpenMP API
---
openmp/runtime/src/include/omp_lib.F90.var | 120 +++++++++++++++++++++
1 file changed, 120 insertions(+)
diff --git a/openmp/runtime/src/include/omp_lib.F90.var b/openmp/runtime/src/include/omp_lib.F90.var
index 2fd61883879fa8..e17db21b9368a4 100644
--- a/openmp/runtime/src/include/omp_lib.F90.var
+++ b/openmp/runtime/src/include/omp_lib.F90.var
@@ -930,4 +930,124 @@
end interface
+ ! make the above routine definitions public
+ public :: omp_set_num_threads
+ public :: omp_set_dynamic
+ public :: omp_set_nested
+ public :: omp_get_num_threads
+ public :: omp_get_max_threads
+ public :: omp_get_thread_num
+ public :: omp_get_num_procs
+ public :: omp_in_parallel
+ public :: omp_in_final
+ public :: omp_get_dynamic
+ public :: omp_get_nested
+ public :: omp_get_thread_limit
+ public :: omp_set_max_active_levels
+ public :: omp_get_max_active_levels
+ public :: omp_get_level
+ public :: omp_get_active_level
+ public :: omp_get_ancestor_thread_num
+ public :: omp_get_team_size
+ public :: omp_set_schedule
+ public :: omp_get_schedule
+ public :: omp_get_proc_bind
+ public :: omp_get_num_places
+ public :: omp_get_place_num_procs
+ public :: omp_get_place_proc_ids
+ public :: omp_get_place_num
+ public :: omp_get_partition_num_places
+ public :: omp_get_partition_place_nums
+ public :: omp_get_wtime
+ public :: omp_get_wtick
+ public :: omp_get_default_device
+ public :: omp_set_default_device
+ public :: omp_get_num_devices
+ public :: omp_get_num_teams
+ public :: omp_get_team_num
+ public :: omp_get_cancellation
+ public :: omp_is_initial_device
+ public :: omp_get_initial_device
+ public :: omp_get_device_num
+ public :: omp_pause_resource
+ public :: omp_pause_resource_all
+ public :: omp_get_supported_active_levels
+ public :: omp_fulfill_event
+ public :: omp_init_lock
+ public :: omp_destroy_lock
+ public :: omp_set_lock
+ public :: omp_unset_lock
+ public :: omp_test_lock
+ public :: omp_init_nest_lock
+ public :: omp_destroy_nest_lock
+ public :: omp_set_nest_lock
+ public :: omp_unset_nest_lock
+ public :: omp_test_nest_lock
+ public :: omp_get_max_task_priority
+ public :: omp_init_lock_with_hint
+ public :: omp_init_nest_lock_with_hint
+ public :: omp_control_tool
+ public :: omp_init_allocator
+ public :: omp_destroy_allocator
+ public :: omp_set_default_allocator
+ public :: omp_get_default_allocator
+ public :: omp_set_affinity_format
+ public :: omp_get_affinity_format
+ public :: omp_display_affinity
+ public :: omp_capture_affinity
+ public :: omp_set_num_teams
+ public :: omp_get_max_teams
+ public :: omp_set_teams_thread_limit
+ public :: omp_get_teams_thread_limit
+ public :: omp_display_env
+ public :: omp_target_alloc
+ public :: omp_target_free
+ public :: omp_target_is_present
+ public :: omp_target_memcpy
+ public :: omp_target_memcpy_rect
+ public :: omp_target_memcpy_async
+ public :: omp_target_memcpy_rect_async
+ public :: omp_target_memset
+ public :: omp_target_memset_async
+ public :: omp_target_associate_ptr
+ public :: omp_get_mapped_ptr
+ public :: omp_target_disassociate_ptr
+ public :: omp_target_is_accessible
+ public :: omp_alloc
+ public :: omp_aligned_alloc
+ public :: omp_calloc
+ public :: omp_aligned_calloc
+ public :: omp_realloc
+ public :: omp_free
+ public :: omp_in_explicit_task
+ public :: kmp_set_stacksize
+ public :: kmp_set_stacksize_s
+ public :: kmp_set_blocktime
+ public :: kmp_set_library_serial
+ public :: kmp_set_library_turnaround
+ public :: kmp_set_library_throughput
+ public :: kmp_set_library
+ public :: kmp_set_defaults
+ public :: kmp_get_stacksize
+ public :: kmp_get_stacksize_s
+ public :: kmp_get_blocktime
+ public :: kmp_get_library
+ public :: kmp_set_disp_num_buffers
+ public :: kmp_set_affinity
+ public :: kmp_get_affinity
+ public :: kmp_get_affinity_max_proc
+ public :: kmp_create_affinity_mask
+ public :: kmp_destroy_affinity_mask
+ public :: kmp_set_affinity_mask_proc
+ public :: kmp_unset_affinity_mask_proc
+ public :: kmp_get_affinity_mask_proc
+ public :: kmp_malloc
+ public :: kmp_aligned_malloc
+ public :: kmp_calloc
+ public :: kmp_realloc
+ public :: kmp_free
+ public :: kmp_set_warnings_on
+ public :: kmp_set_warnings_off
+ public :: kmp_get_cancellation_status
+
end module omp_lib
>From ceb78f8765cfc43b34d380c6cab1cd97cb71dfc1 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Mon, 26 Feb 2024 20:53:48 +0100
Subject: [PATCH 14/28] Fix typo
---
openmp/runtime/src/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index 8a24bd150d5e4c..595545220c1e53 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -18,7 +18,7 @@ if(${LIBOMP_OMPT_SUPPORT})
configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var omp-tools.h @ONLY)
endif()
-# Generate message catalog fioles: kmp_i18n_id.inc and kmp_i18n_default.inc
+# Generate message catalog files: kmp_i18n_id.inc and kmp_i18n_default.inc
add_custom_command(
OUTPUT kmp_i18n_id.inc
COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/message-converter.pl --os=${LIBOMP_PERL_SCRIPT_OS}
>From acb6299f4d9657cf35fa4114c497926161edbc41 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Wed, 28 Feb 2024 17:29:01 +0100
Subject: [PATCH 15/28] Re-export definitions of omp_lib_kinds
---
openmp/runtime/src/include/omp_lib.F90.var | 28 ++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/openmp/runtime/src/include/omp_lib.F90.var b/openmp/runtime/src/include/omp_lib.F90.var
index e17db21b9368a4..63a3c93b8d9296 100644
--- a/openmp/runtime/src/include/omp_lib.F90.var
+++ b/openmp/runtime/src/include/omp_lib.F90.var
@@ -61,6 +61,34 @@
! to be exported by this MODULE.
private
+ ! Re-export definitions in omp_lib_kinds
+ public :: omp_integer_kind
+ public :: omp_logical_kind
+ public :: omp_real_kind
+ public :: kmp_double_kind
+ public :: omp_lock_kind
+ public :: omp_nest_lock_kind
+ public :: omp_sched_kind
+ public :: omp_proc_bind_kind
+ public :: kmp_pointer_kind
+ public :: kmp_size_t_kind
+ public :: kmp_affinity_mask_kind
+ public :: kmp_cancel_kind
+ public :: omp_sync_hint_kind
+ public :: omp_lock_hint_kind
+ public :: omp_control_tool_kind
+ public :: omp_control_tool_result_kind
+ public :: omp_allocator_handle_kind
+ public :: omp_memspace_handle_kind
+ public :: omp_alloctrait_key_kind
+ public :: omp_alloctrait_val_kind
+ public :: omp_interop_kind
+ public :: omp_interop_fr_kind
+ public :: omp_alloctrait
+ public :: omp_pause_resource_kind
+ public :: omp_depend_kind
+ public :: omp_event_handle_kind
+
integer (kind=omp_integer_kind), parameter, public :: openmp_version = @LIBOMP_OMP_YEAR_MONTH@
integer (kind=omp_integer_kind), parameter, public :: kmp_version_major = @LIBOMP_VERSION_MAJOR@
integer (kind=omp_integer_kind), parameter, public :: kmp_version_minor = @LIBOMP_VERSION_MINOR@
>From 14593438f6f60053b08763ccfe1db3043269db7d Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Wed, 28 Feb 2024 16:53:22 +0100
Subject: [PATCH 16/28] Guard !$DIR for Intel compiler in omp_lib.h
---
openmp/runtime/src/include/omp_lib.h.var | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/openmp/runtime/src/include/omp_lib.h.var b/openmp/runtime/src/include/omp_lib.h.var
index 617f2321676dee..a709a2f298f8c8 100644
--- a/openmp/runtime/src/include/omp_lib.h.var
+++ b/openmp/runtime/src/include/omp_lib.h.var
@@ -486,82 +486,102 @@
end subroutine omp_fulfill_event
subroutine omp_init_lock(svar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_init_lock
!DIR$ ENDIF
+#endif
import
integer (kind=omp_lock_kind) svar
end subroutine omp_init_lock
subroutine omp_destroy_lock(svar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_destroy_lock
!DIR$ ENDIF
+#endif
import
integer (kind=omp_lock_kind) svar
end subroutine omp_destroy_lock
subroutine omp_set_lock(svar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_set_lock
!DIR$ ENDIF
+#endif
import
integer (kind=omp_lock_kind) svar
end subroutine omp_set_lock
subroutine omp_unset_lock(svar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_unset_lock
!DIR$ ENDIF
+#endif
import
integer (kind=omp_lock_kind) svar
end subroutine omp_unset_lock
function omp_test_lock(svar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_test_lock
!DIR$ ENDIF
+#endif
import
logical (kind=omp_logical_kind) omp_test_lock
integer (kind=omp_lock_kind) svar
end function omp_test_lock
subroutine omp_init_nest_lock(nvar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_init_nest_lock
!DIR$ ENDIF
+#endif
import
integer (kind=omp_nest_lock_kind) nvar
end subroutine omp_init_nest_lock
subroutine omp_destroy_nest_lock(nvar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_destroy_nest_lock
!DIR$ ENDIF
+#endif
import
integer (kind=omp_nest_lock_kind) nvar
end subroutine omp_destroy_nest_lock
subroutine omp_set_nest_lock(nvar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_set_nest_lock
!DIR$ ENDIF
+#endif
import
integer (kind=omp_nest_lock_kind) nvar
end subroutine omp_set_nest_lock
subroutine omp_unset_nest_lock(nvar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_unset_nest_lock
!DIR$ ENDIF
+#endif
import
integer (kind=omp_nest_lock_kind) nvar
end subroutine omp_unset_nest_lock
function omp_test_nest_lock(nvar) bind(c)
+#ifdef __INTEL_COMPILER
!DIR$ IF(__INTEL_COMPILER.GE.1400)
!DIR$ attributes known_intrinsic :: omp_test_nest_lock
!DIR$ ENDIF
+#endif
import
integer (kind=omp_integer_kind) omp_test_nest_lock
integer (kind=omp_nest_lock_kind) nvar
@@ -990,6 +1010,7 @@
end subroutine kmp_set_warnings_off
end interface
+#ifdef __INTEL_COMPILER
!DIR$ IF DEFINED (__INTEL_OFFLOAD)
!DIR$ IF(__INTEL_COMPILER.LT.1900)
@@ -1158,3 +1179,4 @@
!$omp declare target(omp_init_nest_lock_with_hint )
!DIR$ ENDIF
!DIR$ ENDIF
+#endif
>From 8dee6022c2c16f83b4443ff27eec22b4f6918d52 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Wed, 28 Feb 2024 16:52:48 +0100
Subject: [PATCH 17/28] Add -cpp to include-omp-header.f90 test
---
flang/test/Driver/include-omp-header.f90 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/flang/test/Driver/include-omp-header.f90 b/flang/test/Driver/include-omp-header.f90
index 4bf43bbc882bb4..b716f8ace60ce9 100644
--- a/flang/test/Driver/include-omp-header.f90
+++ b/flang/test/Driver/include-omp-header.f90
@@ -7,11 +7,11 @@
! This should just work
! RUN: not rm omp_lib.h
-! RUN: %flang -fsyntax-only -fopenmp %s 2>&1
+! RUN: %flang -cpp -fsyntax-only -fopenmp %s 2>&1
! Create an empty omp_lib.h header that _does not_ define omp_default_mem_alloc - this should lead to semantic errors
! RUN: touch omp_lib.h
-! RUN: not %flang -fsyntax-only -fopenmp %s 2>&1 | FileCheck %s
+! RUN: not %flang -cpp -fsyntax-only -fopenmp %s 2>&1 | FileCheck %s
! RUN: rm omp_lib.h
! CHECK: error: Must have INTEGER type, but is REAL(4)
>From 1cd971b8160ed00c29993eb1d7f60169526b512b Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Wed, 28 Feb 2024 15:11:50 +0100
Subject: [PATCH 18/28] Correct atomic-write.f90 test case correctly refer to
register
---
flang/test/Lower/OpenMP/atomic-write.f90 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/flang/test/Lower/OpenMP/atomic-write.f90 b/flang/test/Lower/OpenMP/atomic-write.f90
index 119f60c1a92f56..e87a2300f55f54 100644
--- a/flang/test/Lower/OpenMP/atomic-write.f90
+++ b/flang/test/Lower/OpenMP/atomic-write.f90
@@ -21,8 +21,8 @@
!CHECK: %[[Z_VAL:.*]] = fir.load %[[Z_DECL]]#0 : !fir.ref<i32>
!CHECK: %[[C2:.*]] = arith.constant 2 : i32
!CHECK: %[[Z_DIV_2:.*]] = arith.divsi %[[Z_VAL]], %[[C2]] : i32
-!CHECK: %172 = arith.addi %[[TEN_X]], %[[Z_DIV_2]] : i32
-!CHECK: omp.atomic.write %163#1 = %172 hint(speculative) memory_order(release) : !fir.ref<i32>, i32
+!CHECK: %[[ADD_RES:.*]] = arith.addi %[[TEN_X]], %[[Z_DIV_2]] : i32
+!CHECK: omp.atomic.write %[[Y_DECL]]#1 = %[[ADD_RES]] hint(speculative) memory_order(release) : !fir.ref<i32>, i32
program OmpAtomicWrite
use omp_lib
>From 76ecc360a24ba783e4aa869d8ade83fb80b2839b Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Wed, 28 Feb 2024 15:59:22 +0100
Subject: [PATCH 19/28] Fix inconsistency in test cases (kind=8, wrong
constants)
---
.../test/Lower/OpenMP/FIR/parallel-sections.f90 | 16 ++++++++--------
flang/test/Lower/OpenMP/FIR/parallel.f90 | 8 ++++----
flang/test/Lower/OpenMP/FIR/sections.f90 | 4 ++--
flang/test/Lower/OpenMP/FIR/single.f90 | 2 +-
flang/test/Lower/OpenMP/FIR/task.f90 | 4 ++--
flang/test/Lower/OpenMP/FIR/taskgroup.f90 | 4 ++--
flang/test/Lower/OpenMP/FIR/teams.f90 | 3 ++-
flang/test/Lower/OpenMP/parallel-sections.f90 | 8 ++++----
flang/test/Lower/OpenMP/parallel.f90 | 4 ++--
flang/test/Lower/OpenMP/sections.f90 | 4 ++--
flang/test/Lower/OpenMP/single.f90 | 2 +-
flang/test/Lower/OpenMP/task.f90 | 4 ++--
flang/test/Lower/OpenMP/taskgroup.f90 | 4 ++--
flang/test/Lower/OpenMP/teams.f90 | 2 +-
flang/test/Parser/OpenMP/allocate-tree.f90 | 6 +++---
15 files changed, 38 insertions(+), 37 deletions(-)
diff --git a/flang/test/Lower/OpenMP/FIR/parallel-sections.f90 b/flang/test/Lower/OpenMP/FIR/parallel-sections.f90
index 33fda178323f2b..be9505f1b047c1 100644
--- a/flang/test/Lower/OpenMP/FIR/parallel-sections.f90
+++ b/flang/test/Lower/OpenMP/FIR/parallel-sections.f90
@@ -38,16 +38,16 @@ end subroutine omp_parallel_sections
subroutine omp_parallel_sections_allocate(x, y)
use omp_lib
integer, intent(inout) :: x, y
- !FIRDialect: %[[allocator_1:.*]] = arith.constant 1 : i32
- !FIRDialect: %[[allocator_2:.*]] = arith.constant 1 : i32
- !LLVMDialect: %[[allocator_1:.*]] = llvm.mlir.constant(1 : i32) : i32
- !LLVMDialect: %[[allocator_2:.*]] = llvm.mlir.constant(1 : i32) : i32
+ !FIRDialect: %[[allocator_1:.*]] = arith.constant 4 : i64
+ !FIRDialect: %[[allocator_2:.*]] = arith.constant 4 : i64
+ !LLVMDialect: %[[allocator_1:.*]] = llvm.mlir.constant(4 : i64) : i64
+ !LLVMDialect: %[[allocator_2:.*]] = llvm.mlir.constant(4 : i64) : i64
!OMPDialect: omp.parallel allocate(
- !FIRDialect: %[[allocator_2]] : i32 -> %{{.*}} : !fir.ref<i32>) {
- !LLVMDialect: %[[allocator_2]] : i32 -> %{{.*}} : !llvm.ptr) {
+ !FIRDialect: %[[allocator_2]] : i64 -> %{{.*}} : !fir.ref<i32>) {
+ !LLVMDialect: %[[allocator_2]] : i64 -> %{{.*}} : !llvm.ptr) {
!OMPDialect: omp.sections allocate(
- !FIRDialect: %[[allocator_1]] : i32 -> %{{.*}} : !fir.ref<i32>) {
- !LLVMDialect: %[[allocator_1]] : i32 -> %{{.*}} : !llvm.ptr) {
+ !FIRDialect: %[[allocator_1]] : i64 -> %{{.*}} : !fir.ref<i32>) {
+ !LLVMDialect: %[[allocator_1]] : i64 -> %{{.*}} : !llvm.ptr) {
!$omp parallel sections allocate(omp_high_bw_mem_alloc: x)
!OMPDialect: omp.section {
!$omp section
diff --git a/flang/test/Lower/OpenMP/FIR/parallel.f90 b/flang/test/Lower/OpenMP/FIR/parallel.f90
index b68551df234161..b56b58d188bb7f 100644
--- a/flang/test/Lower/OpenMP/FIR/parallel.f90
+++ b/flang/test/Lower/OpenMP/FIR/parallel.f90
@@ -153,8 +153,8 @@ subroutine parallel_allocate()
use omp_lib
integer :: x
!OMPDialect: omp.parallel allocate(
- !FIRDialect: %{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>
- !LLVMDialect: %{{.+}} : i32 -> %{{.+}} : !llvm.ptr
+ !FIRDialect: %{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>
+ !LLVMDialect: %{{.+}} : i64 -> %{{.+}} : !llvm.ptr
!OMPDialect: ) {
!$omp parallel allocate(omp_high_bw_mem_alloc: x) private(x)
!FIRDialect: arith.addi
@@ -195,8 +195,8 @@ subroutine parallel_multiple_clauses(alpha, num_threads)
!$omp end parallel
!OMPDialect: omp.parallel if({{.*}} : i1) num_threads({{.*}} : i32) allocate(
- !FIRDialect: %{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>
- !LLVMDialect: %{{.+}} : i32 -> %{{.+}} : !llvm.ptr
+ !FIRDialect: %{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>
+ !LLVMDialect: %{{.+}} : i64 -> %{{.+}} : !llvm.ptr
!OMPDialect: ) {
!$omp parallel num_threads(num_threads) if(alpha .le. 0) allocate(omp_high_bw_mem_alloc: alpha) private(alpha)
!FIRDialect: fir.call
diff --git a/flang/test/Lower/OpenMP/FIR/sections.f90 b/flang/test/Lower/OpenMP/FIR/sections.f90
index 640ec34a05bc21..e5632e23c2fc4d 100644
--- a/flang/test/Lower/OpenMP/FIR/sections.f90
+++ b/flang/test/Lower/OpenMP/FIR/sections.f90
@@ -5,8 +5,8 @@
!CHECK: func @_QQmain() attributes {fir.bindc_name = "sample"} {
!CHECK: %[[COUNT:.*]] = fir.address_of(@_QFEcount) : !fir.ref<i32>
!CHECK: %[[ETA:.*]] = fir.alloca f32 {bindc_name = "eta", uniq_name = "_QFEeta"}
-!CHECK: %[[CONST_1:.*]] = arith.constant 1 : i32
-!CHECK: omp.sections allocate(%[[CONST_1]] : i32 -> %0 : !fir.ref<i32>) {
+!CHECK: %[[CONST_1:.*]] = arith.constant 4 : i64
+!CHECK: omp.sections allocate(%[[CONST_1]] : i64 -> %0 : !fir.ref<i32>) {
!CHECK: omp.section {
!CHECK: %[[PRIVATE_ETA:.*]] = fir.alloca f32 {bindc_name = "eta", pinned, uniq_name = "_QFEeta"}
!CHECK: %[[PRIVATE_DOUBLE_COUNT:.*]] = fir.alloca i32 {bindc_name = "double_count", pinned, uniq_name = "_QFEdouble_count"}
diff --git a/flang/test/Lower/OpenMP/FIR/single.f90 b/flang/test/Lower/OpenMP/FIR/single.f90
index 266f6d94c60db4..168540b343b73b 100644
--- a/flang/test/Lower/OpenMP/FIR/single.f90
+++ b/flang/test/Lower/OpenMP/FIR/single.f90
@@ -55,7 +55,7 @@ subroutine single_allocate()
integer :: x
!CHECK: omp.parallel {
!$omp parallel
- !CHECK: omp.single allocate(%{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>) {
+ !CHECK: omp.single allocate(%{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>) {
!$omp single allocate(omp_high_bw_mem_alloc: x) private(x)
!CHECK: arith.addi
x = x + 12
diff --git a/flang/test/Lower/OpenMP/FIR/task.f90 b/flang/test/Lower/OpenMP/FIR/task.f90
index 4e7e54588c796f..0d2880f2de1091 100644
--- a/flang/test/Lower/OpenMP/FIR/task.f90
+++ b/flang/test/Lower/OpenMP/FIR/task.f90
@@ -63,7 +63,7 @@ end subroutine omp_task_priority
subroutine task_allocate()
use omp_lib
integer :: x
- !CHECK: omp.task allocate(%{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>) {
+ !CHECK: omp.task allocate(%{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>) {
!$omp task allocate(omp_high_bw_mem_alloc: x) private(x)
!CHECK: arith.addi
x = x + 12
@@ -217,7 +217,7 @@ subroutine task_multiple_clauses()
integer :: x, y, z
logical :: buzz
- !CHECK: omp.task if(%{{.+}}) final(%{{.+}}) priority(%{{.+}}) allocate(%{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>) {
+ !CHECK: omp.task if(%{{.+}}) final(%{{.+}}) priority(%{{.+}}) allocate(%{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>) {
!$omp task if(buzz) final(buzz) priority(z) allocate(omp_high_bw_mem_alloc: x) private(x) firstprivate(y)
!CHECK: %[[x_priv:.+]] = fir.alloca i32
diff --git a/flang/test/Lower/OpenMP/FIR/taskgroup.f90 b/flang/test/Lower/OpenMP/FIR/taskgroup.f90
index 55aba3ddb6c20c..035278ffc9dfb2 100644
--- a/flang/test/Lower/OpenMP/FIR/taskgroup.f90
+++ b/flang/test/Lower/OpenMP/FIR/taskgroup.f90
@@ -5,9 +5,9 @@ subroutine omp_taskgroup
use omp_lib
integer :: allocated_x
!CHECK-DAG: %{{.*}} = fir.alloca i32 {bindc_name = "allocated_x", uniq_name = "_QFomp_taskgroupEallocated_x"}
-!CHECK-DAG: %{{.*}} = arith.constant 1 : i32
+!CHECK-DAG: %{{.*}} = arith.constant 4 : i64
-!CHECK: omp.taskgroup allocate(%{{.*}} : i32 -> %0 : !fir.ref<i32>)
+!CHECK: omp.taskgroup allocate(%{{.*}} : i64 -> %0 : !fir.ref<i32>)
!$omp taskgroup allocate(omp_high_bw_mem_alloc: allocated_x)
!$omp task
!CHECK: fir.call @_QPwork() {{.*}}: () -> ()
diff --git a/flang/test/Lower/OpenMP/FIR/teams.f90 b/flang/test/Lower/OpenMP/FIR/teams.f90
index 51f9087acb0b59..27e4e95eed5e38 100644
--- a/flang/test/Lower/OpenMP/FIR/teams.f90
+++ b/flang/test/Lower/OpenMP/FIR/teams.f90
@@ -104,8 +104,9 @@ end subroutine teams_threadlimit
subroutine teams_allocate()
use omp_lib
integer :: x
+ integer :: y
! CHECK: omp.teams
- ! CHECK-SAME: allocate(%{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>)
+ ! CHECK-SAME: allocate(%{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>)
!$omp teams allocate(omp_high_bw_mem_alloc: x) private(x)
! CHECK: arith.addi
x = x + 12
diff --git a/flang/test/Lower/OpenMP/parallel-sections.f90 b/flang/test/Lower/OpenMP/parallel-sections.f90
index 77139e40ed8c0e..457e5b3abd54a4 100644
--- a/flang/test/Lower/OpenMP/parallel-sections.f90
+++ b/flang/test/Lower/OpenMP/parallel-sections.f90
@@ -37,12 +37,12 @@ end subroutine omp_parallel_sections
subroutine omp_parallel_sections_allocate(x, y)
use omp_lib
integer, intent(inout) :: x, y
- !CHECK: %[[allocator_1:.*]] = arith.constant 1 : i32
- !CHECK: %[[allocator_2:.*]] = arith.constant 1 : i32
+ !CHECK: %[[allocator_1:.*]] = arith.constant 4 : i64
+ !CHECK: %[[allocator_2:.*]] = arith.constant 4 : i64
!CHECK: omp.parallel allocate(
- !CHECK: %[[allocator_2]] : i32 -> %{{.*}} : !fir.ref<i32>) {
+ !CHECK: %[[allocator_2]] : i64 -> %{{.*}} : !fir.ref<i32>) {
!CHECK: omp.sections allocate(
- !CHECK: %[[allocator_1]] : i32 -> %{{.*}} : !fir.ref<i32>) {
+ !CHECK: %[[allocator_1]] : i64 -> %{{.*}} : !fir.ref<i32>) {
!$omp parallel sections allocate(omp_high_bw_mem_alloc: x)
!CHECK: omp.section {
!$omp section
diff --git a/flang/test/Lower/OpenMP/parallel.f90 b/flang/test/Lower/OpenMP/parallel.f90
index 0e43244994cfdb..c896eb1fffb04b 100644
--- a/flang/test/Lower/OpenMP/parallel.f90
+++ b/flang/test/Lower/OpenMP/parallel.f90
@@ -152,7 +152,7 @@ subroutine parallel_allocate()
use omp_lib
integer :: x
!CHECK: omp.parallel allocate(
- !CHECK: %{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>
+ !CHECK: %{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>
!CHECK: ) {
!$omp parallel allocate(omp_high_bw_mem_alloc: x) private(x)
!CHECK: arith.addi
@@ -193,7 +193,7 @@ subroutine parallel_multiple_clauses(alpha, num_threads)
!$omp end parallel
!CHECK: omp.parallel if({{.*}} : i1) num_threads({{.*}} : i32) allocate(
- !CHECK: %{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>
+ !CHECK: %{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>
!CHECK: ) {
!$omp parallel num_threads(num_threads) if(alpha .le. 0) allocate(omp_high_bw_mem_alloc: alpha) private(alpha)
!CHECK: fir.call
diff --git a/flang/test/Lower/OpenMP/sections.f90 b/flang/test/Lower/OpenMP/sections.f90
index 6bad688058d282..110c287e1c7f70 100644
--- a/flang/test/Lower/OpenMP/sections.f90
+++ b/flang/test/Lower/OpenMP/sections.f90
@@ -7,8 +7,8 @@
!CHECK: %[[COUNT:.*]] = fir.address_of(@_QFEcount) : !fir.ref<i32>
!CHECK: %[[COUNT_DECL:.*]]:2 = hlfir.declare %[[COUNT]] {uniq_name = "_QFEcount"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
!CHECK: %[[ETA:.*]] = fir.alloca f32 {bindc_name = "eta", uniq_name = "_QFEeta"}
-!CHECK: %[[CONST_1:.*]] = arith.constant 1 : i32
-!CHECK: omp.sections allocate(%[[CONST_1]] : i32 -> %[[COUNT_DECL]]#1 : !fir.ref<i32>) {
+!CHECK: %[[CONST_1:.*]] = arith.constant 4 : i64
+!CHECK: omp.sections allocate(%[[CONST_1]] : i64 -> %[[COUNT_DECL]]#1 : !fir.ref<i32>) {
!CHECK: omp.section {
!CHECK: %[[PRIVATE_ETA:.*]] = fir.alloca f32 {bindc_name = "eta", pinned, uniq_name = "_QFEeta"}
!CHECK: %[[PRIVATE_ETA_DECL:.*]]:2 = hlfir.declare %[[PRIVATE_ETA]] {uniq_name = "_QFEeta"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
diff --git a/flang/test/Lower/OpenMP/single.f90 b/flang/test/Lower/OpenMP/single.f90
index ffc41af84e3c21..2c31f3897fe62a 100644
--- a/flang/test/Lower/OpenMP/single.f90
+++ b/flang/test/Lower/OpenMP/single.f90
@@ -57,7 +57,7 @@ subroutine single_allocate()
integer :: x
!CHECK: omp.parallel {
!$omp parallel
- !CHECK: omp.single allocate(%{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>) {
+ !CHECK: omp.single allocate(%{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>) {
!$omp single allocate(omp_high_bw_mem_alloc: x) private(x)
!CHECK: arith.addi
x = x + 12
diff --git a/flang/test/Lower/OpenMP/task.f90 b/flang/test/Lower/OpenMP/task.f90
index 7d7a79af3185f5..20c01ad630dbdf 100644
--- a/flang/test/Lower/OpenMP/task.f90
+++ b/flang/test/Lower/OpenMP/task.f90
@@ -63,7 +63,7 @@ end subroutine omp_task_priority
subroutine task_allocate()
use omp_lib
integer :: x
- !CHECK: omp.task allocate(%{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>) {
+ !CHECK: omp.task allocate(%{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>) {
!$omp task allocate(omp_high_bw_mem_alloc: x) private(x)
!CHECK: arith.addi
x = x + 12
@@ -225,7 +225,7 @@ subroutine task_multiple_clauses()
integer :: x, y, z
logical :: buzz
- !CHECK: omp.task if(%{{.+}}) final(%{{.+}}) priority(%{{.+}}) allocate(%{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>) {
+ !CHECK: omp.task if(%{{.+}}) final(%{{.+}}) priority(%{{.+}}) allocate(%{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>) {
!$omp task if(buzz) final(buzz) priority(z) allocate(omp_high_bw_mem_alloc: x) private(x) firstprivate(y)
!CHECK: %[[X_PRIV_ALLOCA:.+]] = fir.alloca i32 {bindc_name = "x", pinned, uniq_name = "_QFtask_multiple_clausesEx"}
diff --git a/flang/test/Lower/OpenMP/taskgroup.f90 b/flang/test/Lower/OpenMP/taskgroup.f90
index 85dc253b59d659..74bc508c626a59 100644
--- a/flang/test/Lower/OpenMP/taskgroup.f90
+++ b/flang/test/Lower/OpenMP/taskgroup.f90
@@ -6,9 +6,9 @@ subroutine omp_taskgroup
integer :: allocated_x
!CHECK: %[[ALLOC_X_REF:.*]] = fir.alloca i32 {bindc_name = "allocated_x", uniq_name = "_QFomp_taskgroupEallocated_x"}
!CHECK-NEXT: %[[ALLOC_X_DECL:.*]]:2 = hlfir.declare %[[ALLOC_X_REF]] {uniq_name = "_QFomp_taskgroupEallocated_x"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
-!CHECK: %[[C1:.*]] = arith.constant 1 : i32
+!CHECK: %[[C4:.*]] = arith.constant 4 : i64
-!CHECK: omp.taskgroup allocate(%[[C1]] : i32 -> %[[ALLOC_X_DECL]]#1 : !fir.ref<i32>)
+!CHECK: omp.taskgroup allocate(%[[C4]] : i64 -> %[[ALLOC_X_DECL]]#1 : !fir.ref<i32>)
!$omp taskgroup allocate(omp_high_bw_mem_alloc: allocated_x)
!$omp task
!CHECK: fir.call @_QPwork() {{.*}}: () -> ()
diff --git a/flang/test/Lower/OpenMP/teams.f90 b/flang/test/Lower/OpenMP/teams.f90
index 2620d7752a4ed3..cd398e847cdbda 100644
--- a/flang/test/Lower/OpenMP/teams.f90
+++ b/flang/test/Lower/OpenMP/teams.f90
@@ -105,7 +105,7 @@ subroutine teams_allocate()
use omp_lib
integer :: x
! CHECK: omp.teams
- ! CHECK-SAME: allocate(%{{.+}} : i32 -> %{{.+}} : !fir.ref<i32>)
+ ! CHECK-SAME: allocate(%{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>)
!$omp teams allocate(omp_high_bw_mem_alloc: x) private(x)
! CHECK: arith.addi
x = x + 12
diff --git a/flang/test/Parser/OpenMP/allocate-tree.f90 b/flang/test/Parser/OpenMP/allocate-tree.f90
index f04e431e74ae5d..ac99efbcad936c 100644
--- a/flang/test/Parser/OpenMP/allocate-tree.f90
+++ b/flang/test/Parser/OpenMP/allocate-tree.f90
@@ -36,8 +36,8 @@ end program allocate_tree
!CHECK-NEXT: | | | | | Designator -> DataRef -> Name =
!CHECK-NEXT: | | | AllocateStmt
-!UNPARSE: !$OMP ALLOCATE (w) ALLOCATOR(1_4)
-!UNPARSE-NEXT: !$OMP ALLOCATE (xarray) ALLOCATOR(1_4)
-!UNPARSE-NEXT: !$OMP ALLOCATE (zarray) ALLOCATOR(1_4)
+!UNPARSE: !$OMP ALLOCATE (w) ALLOCATOR(3_8)
+!UNPARSE-NEXT: !$OMP ALLOCATE (xarray) ALLOCATOR(2_8)
+!UNPARSE-NEXT: !$OMP ALLOCATE (zarray) ALLOCATOR(1_8)
!UNPARSE-NEXT: !$OMP ALLOCATE
!UNPARSE-NEXT: ALLOCATE(w, xarray(4_4), zarray(t,z))
>From df430c9aa3b2d918cb6658b8c141475221b9e867 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Thu, 29 Feb 2024 11:30:41 +0100
Subject: [PATCH 20/28] Don't build omp_lib.mod and omp_lib.h if not OpenMP
runtime support configured
---
flang/tools/f18/CMakeLists.txt | 50 ++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 20 deletions(-)
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 396c85df150229..beda5a6f383135 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -21,6 +21,7 @@ set(MODULES
"__fortran_type_info"
)
+message("MK: LLVM_TOOL_OPENMP_BUILD=${LLVM_TOOL_OPENMP_BUILD}")
# Create module files directly from the top-level module source directory.
# If CMAKE_CROSSCOMPILING, then the newly built flang-new executable was
# cross compiled, and thus can't be executed on the build system and thus
@@ -73,22 +74,28 @@ if (NOT CMAKE_CROSSCOMPILING)
endforeach()
# Special case for omp_lib.mod, because its source comes from openmp/runtime/src/include.
- # It also produces to module files: omp_lib.mod and omp_lib_kinds.mod.
- set(base ${FLANG_INTRINSIC_MODULES_DIR}/omp_lib)
- add_custom_command(OUTPUT ${base}.mod ${base}_kinds.mod
- COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
- COMMAND flang-new -cpp -fsyntax-only ${opts} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
- ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90
- DEPENDS flang-new ${FLANG_INTRINSIC_MODULES_DIR}/iso_c_binding.mod ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90 ${depends}
- )
- add_custom_command(OUTPUT ${base}.f18.mod
- DEPENDS ${base}.mod
- COMMAND ${CMAKE_COMMAND} -E copy ${base}.mod ${base}.f18.mod)
- add_custom_command(OUTPUT ${base}_kinds.f18.mod
+ # It also produces to module files: omp_lib.mod and omp_lib_kinds.mod. Compile these
+ # files only if OpenMP support has been configured.
+ if (LLVM_TOOL_OPENMP_BUILD)
+ message(STATUS "OpenMP runtime support enabled, building omp_lib.mod")
+ set(base ${FLANG_INTRINSIC_MODULES_DIR}/omp_lib)
+ add_custom_command(OUTPUT ${base}.mod ${base}_kinds.mod
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
+ COMMAND flang-new -cpp -fsyntax-only ${opts} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
+ ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90
+ DEPENDS flang-new ${FLANG_INTRINSIC_MODULES_DIR}/iso_c_binding.mod ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.F90 ${depends}
+ )
+ add_custom_command(OUTPUT ${base}.f18.mod
DEPENDS ${base}.mod
- COMMAND ${CMAKE_COMMAND} -E copy ${base}_kinds.mod ${base}_kinds.f18.mod)
- list(APPEND MODULE_FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod)
- install(FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
+ COMMAND ${CMAKE_COMMAND} -E copy ${base}.mod ${base}.f18.mod)
+ add_custom_command(OUTPUT ${base}_kinds.f18.mod
+ DEPENDS ${base}.mod
+ COMMAND ${CMAKE_COMMAND} -E copy ${base}_kinds.mod ${base}_kinds.f18.mod)
+ list(APPEND MODULE_FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod)
+ install(FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
+ else()
+ message(STATUS "Not building omp_lib.mod, OpenMP runtime support disabled")
+ endif()
endif()
add_custom_target(module_files ALL DEPENDS ${MODULE_FILES})
@@ -104,9 +111,12 @@ if (NOT WIN32)
install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/flang-to-external-fc DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
-# TODO: Is this the right file coming from the OpenMP runtime or is this a copy of it?
# TODO Move this to a more suitable location
-#file(COPY ${FLANG_SOURCE_DIR}/module/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
-file(COPY ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
-install(FILES ${CMAKE_BINARY_DIR}/include/flang/OpenMP/omp_lib.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang/OpenMP")
-
+# Copy the generated omp_lib.h header file, if OpenMP support has been configured.
+if (LLVM_TOOL_OPENMP_BUILD)
+ message(STATUS "OpenMP runtime support enabled, building omp_lib.h")
+ file(COPY ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
+ install(FILES ${CMAKE_BINARY_DIR}/include/flang/OpenMP/omp_lib.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang/OpenMP")
+else()
+ message(STATUS "Not copying omp_lib.h, OpenMP runtime support disabled")
+endif()
>From 12d13dbc986c149021926b2141fa8aa35522c39f Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Thu, 29 Feb 2024 11:31:26 +0100
Subject: [PATCH 21/28] Require OpenMP runtime for OpenMP tests
---
flang/test/Lower/OpenMP/FIR/atomic-capture.f90 | 2 ++
flang/test/Lower/OpenMP/FIR/atomic-read.f90 | 2 ++
flang/test/Lower/OpenMP/FIR/atomic-update.f90 | 2 ++
flang/test/Lower/OpenMP/FIR/atomic-write.f90 | 2 ++
flang/test/Lower/OpenMP/FIR/critical.f90 | 2 ++
flang/test/Lower/OpenMP/FIR/parallel-sections.f90 | 2 ++
flang/test/Lower/OpenMP/FIR/parallel.f90 | 2 ++
flang/test/Lower/OpenMP/FIR/sections.f90 | 2 ++
flang/test/Lower/OpenMP/FIR/single.f90 | 2 ++
flang/test/Lower/OpenMP/FIR/task.f90 | 2 ++
flang/test/Lower/OpenMP/FIR/taskgroup.f90 | 2 ++
flang/test/Lower/OpenMP/FIR/teams.f90 | 2 ++
flang/test/Lower/OpenMP/atomic-capture.f90 | 2 ++
flang/test/Lower/OpenMP/atomic-read.f90 | 2 ++
flang/test/Lower/OpenMP/atomic-update.f90 | 2 ++
flang/test/Lower/OpenMP/atomic-write.f90 | 2 ++
flang/test/Lower/OpenMP/critical.f90 | 2 ++
flang/test/Lower/OpenMP/omp-lib-num-threads.f90 | 2 ++
flang/test/Lower/OpenMP/parallel-sections.f90 | 2 ++
flang/test/Lower/OpenMP/parallel.f90 | 2 ++
flang/test/Lower/OpenMP/sections.f90 | 2 ++
flang/test/Lower/OpenMP/single.f90 | 2 ++
flang/test/Lower/OpenMP/task.f90 | 2 ++
flang/test/Lower/OpenMP/taskgroup.f90 | 2 ++
flang/test/Lower/OpenMP/teams.f90 | 2 ++
flang/test/Lower/OpenMP/threadprivate-default-clause.f90 | 2 ++
flang/test/Parser/OpenMP/allocate-tree-spec-part.f90 | 2 ++
flang/test/Parser/OpenMP/allocate-tree.f90 | 2 ++
flang/test/Parser/OpenMP/target_device_parse.f90 | 2 ++
flang/test/Semantics/OpenMP/allocate-clause01.f90 | 2 ++
flang/test/Semantics/OpenMP/allocate-directive.f90 | 2 ++
flang/test/Semantics/OpenMP/allocate01.f90 | 2 ++
flang/test/Semantics/OpenMP/allocate02.f90 | 2 ++
flang/test/Semantics/OpenMP/allocate03.f90 | 2 ++
flang/test/Semantics/OpenMP/allocate04.f90 | 2 ++
flang/test/Semantics/OpenMP/allocate05.f90 | 2 ++
flang/test/Semantics/OpenMP/allocate06.f90 | 2 ++
flang/test/Semantics/OpenMP/allocate07.f90 | 2 ++
flang/test/Semantics/OpenMP/allocate08.f90 | 2 ++
flang/test/Semantics/OpenMP/allocate09.f90 | 2 ++
flang/test/Semantics/OpenMP/allocators01.f90 | 2 ++
flang/test/Semantics/OpenMP/allocators02.f90 | 2 ++
flang/test/Semantics/OpenMP/allocators03.f90 | 2 ++
flang/test/Semantics/OpenMP/allocators04.f90 | 2 ++
flang/test/Semantics/OpenMP/allocators05.f90 | 2 ++
flang/test/Semantics/OpenMP/allocators06.f90 | 2 ++
flang/test/Semantics/OpenMP/atomic-hint-clause.f90 | 2 ++
flang/test/Semantics/OpenMP/atomic01.f90 | 2 ++
flang/test/Semantics/OpenMP/atomic02.f90 | 2 ++
flang/test/Semantics/OpenMP/atomic03.f90 | 2 ++
flang/test/Semantics/OpenMP/atomic04.f90 | 2 ++
flang/test/Semantics/OpenMP/atomic05.f90 | 2 ++
flang/test/Semantics/OpenMP/clause-validity01.f90 | 2 ++
flang/test/Semantics/OpenMP/critical-hint-clause.f90 | 2 ++
flang/test/Semantics/OpenMP/declare-target01.f90 | 2 ++
flang/test/Semantics/OpenMP/flush02.f90 | 2 ++
flang/test/Semantics/OpenMP/omp-atomic-assignment-stmt.f90 | 2 ++
flang/test/Semantics/OpenMP/parallel-sections01.f90 | 2 ++
flang/test/Semantics/OpenMP/resolve06.f90 | 2 ++
flang/test/Semantics/OpenMP/sections02.f90 | 2 ++
flang/test/Semantics/OpenMP/sync-critical02.f90 | 2 ++
flang/test/Semantics/OpenMP/taskgroup01.f90 | 2 ++
flang/test/Semantics/OpenMP/threadprivate01.f90 | 2 ++
flang/test/lit.cfg.py | 6 ++++++
flang/test/lit.site.cfg.py.in | 1 +
65 files changed, 133 insertions(+)
diff --git a/flang/test/Lower/OpenMP/FIR/atomic-capture.f90 b/flang/test/Lower/OpenMP/FIR/atomic-capture.f90
index 024400a9e84718..9b94214b9da8bb 100644
--- a/flang/test/Lower/OpenMP/FIR/atomic-capture.f90
+++ b/flang/test/Lower/OpenMP/FIR/atomic-capture.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -fopenmp %s -o - | FileCheck %s
! This test checks the lowering of atomic capture
diff --git a/flang/test/Lower/OpenMP/FIR/atomic-read.f90 b/flang/test/Lower/OpenMP/FIR/atomic-read.f90
index 66be9e7139044c..7698c3d7490fe9 100644
--- a/flang/test/Lower/OpenMP/FIR/atomic-read.f90
+++ b/flang/test/Lower/OpenMP/FIR/atomic-read.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: bbc --use-desc-for-alloc=false -fopenmp -emit-fir -hlfir=false %s -o - | FileCheck %s
! This test checks the lowering of atomic read
diff --git a/flang/test/Lower/OpenMP/FIR/atomic-update.f90 b/flang/test/Lower/OpenMP/FIR/atomic-update.f90
index bd3d4ace440ee8..ae201807c337f0 100644
--- a/flang/test/Lower/OpenMP/FIR/atomic-update.f90
+++ b/flang/test/Lower/OpenMP/FIR/atomic-update.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! This test checks lowering of atomic and atomic update constructs
! RUN: bbc --use-desc-for-alloc=false -fopenmp -emit-fir -hlfir=false %s -o - | FileCheck %s
! RUN: %flang_fc1 -mllvm --use-desc-for-alloc=false -emit-fir -flang-deprecated-no-hlfir -fopenmp %s -o - | FileCheck %s
diff --git a/flang/test/Lower/OpenMP/FIR/atomic-write.f90 b/flang/test/Lower/OpenMP/FIR/atomic-write.f90
index 5d98176cc201ff..142481b7a1d210 100644
--- a/flang/test/Lower/OpenMP/FIR/atomic-write.f90
+++ b/flang/test/Lower/OpenMP/FIR/atomic-write.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: bbc --use-desc-for-alloc=false -fopenmp -emit-fir -hlfir=false %s -o - | FileCheck %s
! This test checks the lowering of atomic write
diff --git a/flang/test/Lower/OpenMP/FIR/critical.f90 b/flang/test/Lower/OpenMP/FIR/critical.f90
index e88178422a8347..fa33fb0fe58bb0 100644
--- a/flang/test/Lower/OpenMP/FIR/critical.f90
+++ b/flang/test/Lower/OpenMP/FIR/critical.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
!RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -fopenmp %s -o - | FileCheck %s --check-prefixes="OMPDialect"
!RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -fopenmp %s -o - | fir-opt --fir-to-llvm-ir | FileCheck %s --check-prefix="OMPDialect"
!RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -fopenmp %s -o - | fir-opt --fir-to-llvm-ir | tco | FileCheck %s --check-prefix="LLVMIR"
diff --git a/flang/test/Lower/OpenMP/FIR/parallel-sections.f90 b/flang/test/Lower/OpenMP/FIR/parallel-sections.f90
index be9505f1b047c1..7730ab87a719af 100644
--- a/flang/test/Lower/OpenMP/FIR/parallel-sections.f90
+++ b/flang/test/Lower/OpenMP/FIR/parallel-sections.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
!RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -fopenmp %s -o - | FileCheck %s --check-prefixes="FIRDialect,OMPDialect"
!RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -fopenmp %s -o - | fir-opt --cfg-conversion | fir-opt --fir-to-llvm-ir | FileCheck %s --check-prefixes="OMPDialect,LLVMDialect"
diff --git a/flang/test/Lower/OpenMP/FIR/parallel.f90 b/flang/test/Lower/OpenMP/FIR/parallel.f90
index b56b58d188bb7f..a2ceb2d939f258 100644
--- a/flang/test/Lower/OpenMP/FIR/parallel.f90
+++ b/flang/test/Lower/OpenMP/FIR/parallel.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
!RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -fopenmp %s -o - | FileCheck %s --check-prefixes="FIRDialect,OMPDialect"
!RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -fopenmp %s -o - | fir-opt --fir-to-llvm-ir | FileCheck %s --check-prefixes="LLVMDialect,OMPDialect"
diff --git a/flang/test/Lower/OpenMP/FIR/sections.f90 b/flang/test/Lower/OpenMP/FIR/sections.f90
index e5632e23c2fc4d..7b313f3dc0b41f 100644
--- a/flang/test/Lower/OpenMP/FIR/sections.f90
+++ b/flang/test/Lower/OpenMP/FIR/sections.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! This test checks the lowering of OpenMP sections construct with several clauses present
! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -fopenmp %s -o - | FileCheck %s
diff --git a/flang/test/Lower/OpenMP/FIR/single.f90 b/flang/test/Lower/OpenMP/FIR/single.f90
index 168540b343b73b..65ae07c2c28431 100644
--- a/flang/test/Lower/OpenMP/FIR/single.f90
+++ b/flang/test/Lower/OpenMP/FIR/single.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
!RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -fopenmp %s -o - | FileCheck %s
!RUN: bbc -emit-fir -hlfir=false -fopenmp %s -o - | FileCheck %s
diff --git a/flang/test/Lower/OpenMP/FIR/task.f90 b/flang/test/Lower/OpenMP/FIR/task.f90
index 0d2880f2de1091..012ac757d304a8 100644
--- a/flang/test/Lower/OpenMP/FIR/task.f90
+++ b/flang/test/Lower/OpenMP/FIR/task.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
!RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -fopenmp %s -o - | FileCheck %s
!CHECK-LABEL: func @_QPomp_task_simple() {
diff --git a/flang/test/Lower/OpenMP/FIR/taskgroup.f90 b/flang/test/Lower/OpenMP/FIR/taskgroup.f90
index 035278ffc9dfb2..78b9da8e9b0988 100644
--- a/flang/test/Lower/OpenMP/FIR/taskgroup.f90
+++ b/flang/test/Lower/OpenMP/FIR/taskgroup.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
!RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -fopenmp %s -o - | FileCheck %s
!CHECK-LABEL: @_QPomp_taskgroup
diff --git a/flang/test/Lower/OpenMP/FIR/teams.f90 b/flang/test/Lower/OpenMP/FIR/teams.f90
index 27e4e95eed5e38..9c0593a24f2df1 100644
--- a/flang/test/Lower/OpenMP/FIR/teams.f90
+++ b/flang/test/Lower/OpenMP/FIR/teams.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
! CHECK-LABEL: func @_QPteams_simple
diff --git a/flang/test/Lower/OpenMP/atomic-capture.f90 b/flang/test/Lower/OpenMP/atomic-capture.f90
index cde0281dbdc849..2587c24cedf3b5 100644
--- a/flang/test/Lower/OpenMP/atomic-capture.f90
+++ b/flang/test/Lower/OpenMP/atomic-capture.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! This test checks the lowering of atomic capture
! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
diff --git a/flang/test/Lower/OpenMP/atomic-read.f90 b/flang/test/Lower/OpenMP/atomic-read.f90
index 97a3777bd3dcad..366da21f53f8cf 100644
--- a/flang/test/Lower/OpenMP/atomic-read.f90
+++ b/flang/test/Lower/OpenMP/atomic-read.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
! This test checks the lowering of atomic read
diff --git a/flang/test/Lower/OpenMP/atomic-update.f90 b/flang/test/Lower/OpenMP/atomic-update.f90
index 10da97c68c24a1..051779e40816fa 100644
--- a/flang/test/Lower/OpenMP/atomic-update.f90
+++ b/flang/test/Lower/OpenMP/atomic-update.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! This test checks lowering of atomic and atomic update constructs
! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
diff --git a/flang/test/Lower/OpenMP/atomic-write.f90 b/flang/test/Lower/OpenMP/atomic-write.f90
index e87a2300f55f54..85955af64bbe28 100644
--- a/flang/test/Lower/OpenMP/atomic-write.f90
+++ b/flang/test/Lower/OpenMP/atomic-write.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
! This test checks the lowering of atomic write
diff --git a/flang/test/Lower/OpenMP/critical.f90 b/flang/test/Lower/OpenMP/critical.f90
index 5a4d2e4815df49..38e6d0eac1cbdc 100644
--- a/flang/test/Lower/OpenMP/critical.f90
+++ b/flang/test/Lower/OpenMP/critical.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
!CHECK: omp.critical.declare @help2
diff --git a/flang/test/Lower/OpenMP/omp-lib-num-threads.f90 b/flang/test/Lower/OpenMP/omp-lib-num-threads.f90
index e1af7d375dfa5a..d2b558a886ebed 100644
--- a/flang/test/Lower/OpenMP/omp-lib-num-threads.f90
+++ b/flang/test/Lower/OpenMP/omp-lib-num-threads.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - 2>&1 | FileCheck %s
! RUN: bbc -fopenmp -emit-hlfir -o - %s 2>&1 | FileCheck %s
! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - 2>&1 | FileCheck %s
diff --git a/flang/test/Lower/OpenMP/parallel-sections.f90 b/flang/test/Lower/OpenMP/parallel-sections.f90
index 457e5b3abd54a4..2f78dd4562b0ae 100644
--- a/flang/test/Lower/OpenMP/parallel-sections.f90
+++ b/flang/test/Lower/OpenMP/parallel-sections.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
!===============================================================================
diff --git a/flang/test/Lower/OpenMP/parallel.f90 b/flang/test/Lower/OpenMP/parallel.f90
index c896eb1fffb04b..6c062b706ed431 100644
--- a/flang/test/Lower/OpenMP/parallel.f90
+++ b/flang/test/Lower/OpenMP/parallel.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
!CHECK-LABEL: func @_QPparallel_simple
diff --git a/flang/test/Lower/OpenMP/sections.f90 b/flang/test/Lower/OpenMP/sections.f90
index 110c287e1c7f70..018848e635733b 100644
--- a/flang/test/Lower/OpenMP/sections.f90
+++ b/flang/test/Lower/OpenMP/sections.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! This test checks the lowering of OpenMP sections construct with several clauses present
! RUN: %flang_fc1 -flang-experimental-hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s
diff --git a/flang/test/Lower/OpenMP/single.f90 b/flang/test/Lower/OpenMP/single.f90
index 2c31f3897fe62a..10d537a0e18b23 100644
--- a/flang/test/Lower/OpenMP/single.f90
+++ b/flang/test/Lower/OpenMP/single.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
!RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s
diff --git a/flang/test/Lower/OpenMP/task.f90 b/flang/test/Lower/OpenMP/task.f90
index 20c01ad630dbdf..f3718b8829ccaf 100644
--- a/flang/test/Lower/OpenMP/task.f90
+++ b/flang/test/Lower/OpenMP/task.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
!CHECK-LABEL: func @_QPomp_task_simple() {
diff --git a/flang/test/Lower/OpenMP/taskgroup.f90 b/flang/test/Lower/OpenMP/taskgroup.f90
index 74bc508c626a59..76458f1f1127f3 100644
--- a/flang/test/Lower/OpenMP/taskgroup.f90
+++ b/flang/test/Lower/OpenMP/taskgroup.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
!CHECK-LABEL: @_QPomp_taskgroup
diff --git a/flang/test/Lower/OpenMP/teams.f90 b/flang/test/Lower/OpenMP/teams.f90
index cd398e847cdbda..f122a578a6e160 100644
--- a/flang/test/Lower/OpenMP/teams.f90
+++ b/flang/test/Lower/OpenMP/teams.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
! CHECK-LABEL: func @_QPteams_simple
diff --git a/flang/test/Lower/OpenMP/threadprivate-default-clause.f90 b/flang/test/Lower/OpenMP/threadprivate-default-clause.f90
index be07aeca2d5c32..10beaf6fefde7f 100644
--- a/flang/test/Lower/OpenMP/threadprivate-default-clause.f90
+++ b/flang/test/Lower/OpenMP/threadprivate-default-clause.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! Simple test for lowering of OpenMP Threadprivate Directive with HLFIR.
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
diff --git a/flang/test/Parser/OpenMP/allocate-tree-spec-part.f90 b/flang/test/Parser/OpenMP/allocate-tree-spec-part.f90
index 45a693d2cb0490..ab56b98b5783b3 100644
--- a/flang/test/Parser/OpenMP/allocate-tree-spec-part.f90
+++ b/flang/test/Parser/OpenMP/allocate-tree-spec-part.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %flang_fc1 -fopenmp -fdebug-dump-parse-tree %s | FileCheck %s
! Ensures associated declarative OMP allocations in the specification
! part are kept there
diff --git a/flang/test/Parser/OpenMP/allocate-tree.f90 b/flang/test/Parser/OpenMP/allocate-tree.f90
index ac99efbcad936c..02393a536cf477 100644
--- a/flang/test/Parser/OpenMP/allocate-tree.f90
+++ b/flang/test/Parser/OpenMP/allocate-tree.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %flang_fc1 -fopenmp -fdebug-dump-parse-tree %s | FileCheck %s
! RUN: %flang_fc1 -fopenmp -fdebug-unparse %s | FileCheck %s --check-prefix="UNPARSE"
! Ensures associated declarative OMP allocations are nested in their
diff --git a/flang/test/Parser/OpenMP/target_device_parse.f90 b/flang/test/Parser/OpenMP/target_device_parse.f90
index 1867c2f2a86c6f..dace34b6ec32f6 100644
--- a/flang/test/Parser/OpenMP/target_device_parse.f90
+++ b/flang/test/Parser/OpenMP/target_device_parse.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %flang_fc1 -fdebug-unparse-no-sema -fopenmp %s | FileCheck --ignore-case %s
! RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp %s | FileCheck --check-prefix="PARSE-TREE" %s
! Checks the parsing of Openmp 5.0 Target Device constructs
diff --git a/flang/test/Semantics/OpenMP/allocate-clause01.f90 b/flang/test/Semantics/OpenMP/allocate-clause01.f90
index 7e2f64397f738d..e059a4a61a90f3 100644
--- a/flang/test/Semantics/OpenMP/allocate-clause01.f90
+++ b/flang/test/Semantics/OpenMP/allocate-clause01.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.2
! The allocate clause's allocator modifier must be of type allocator_handle
diff --git a/flang/test/Semantics/OpenMP/allocate-directive.f90 b/flang/test/Semantics/OpenMP/allocate-directive.f90
index 254e5b617a7a90..1db13df4193822 100644
--- a/flang/test/Semantics/OpenMP/allocate-directive.f90
+++ b/flang/test/Semantics/OpenMP/allocate-directive.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! Check OpenMP Allocate directive
use omp_lib
diff --git a/flang/test/Semantics/OpenMP/allocate01.f90 b/flang/test/Semantics/OpenMP/allocate01.f90
index 4b290a5c2c749b..a91076c80b1f93 100644
--- a/flang/test/Semantics/OpenMP/allocate01.f90
+++ b/flang/test/Semantics/OpenMP/allocate01.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.0
! 2.11.3 allocate Directive
diff --git a/flang/test/Semantics/OpenMP/allocate02.f90 b/flang/test/Semantics/OpenMP/allocate02.f90
index d7da9ef575271e..dc4194aca7f127 100644
--- a/flang/test/Semantics/OpenMP/allocate02.f90
+++ b/flang/test/Semantics/OpenMP/allocate02.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.0
! 2.11.3 allocate Directive
diff --git a/flang/test/Semantics/OpenMP/allocate03.f90 b/flang/test/Semantics/OpenMP/allocate03.f90
index 320a9c9ea4122d..30a015f26c3120 100644
--- a/flang/test/Semantics/OpenMP/allocate03.f90
+++ b/flang/test/Semantics/OpenMP/allocate03.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.0
! 2.11.3 allocate Directive
diff --git a/flang/test/Semantics/OpenMP/allocate04.f90 b/flang/test/Semantics/OpenMP/allocate04.f90
index 405781be4c2d27..b8a87094116150 100644
--- a/flang/test/Semantics/OpenMP/allocate04.f90
+++ b/flang/test/Semantics/OpenMP/allocate04.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.0
! 2.11.3 allocate Directive
diff --git a/flang/test/Semantics/OpenMP/allocate05.f90 b/flang/test/Semantics/OpenMP/allocate05.f90
index 04bcf9119e0f88..92eeaf4222ac97 100644
--- a/flang/test/Semantics/OpenMP/allocate05.f90
+++ b/flang/test/Semantics/OpenMP/allocate05.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.0
! 2.11.3 allocate Directive
diff --git a/flang/test/Semantics/OpenMP/allocate06.f90 b/flang/test/Semantics/OpenMP/allocate06.f90
index 68a7e8857eb897..c4474560bea399 100644
--- a/flang/test/Semantics/OpenMP/allocate06.f90
+++ b/flang/test/Semantics/OpenMP/allocate06.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.0
! 2.11.3 allocate Directive
diff --git a/flang/test/Semantics/OpenMP/allocate07.f90 b/flang/test/Semantics/OpenMP/allocate07.f90
index c01b35ab274004..3211c0bf28b9df 100644
--- a/flang/test/Semantics/OpenMP/allocate07.f90
+++ b/flang/test/Semantics/OpenMP/allocate07.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.0
! 2.11.3 allocate Directive
diff --git a/flang/test/Semantics/OpenMP/allocate08.f90 b/flang/test/Semantics/OpenMP/allocate08.f90
index 65029d1ce0e5f6..152ad07544ea46 100644
--- a/flang/test/Semantics/OpenMP/allocate08.f90
+++ b/flang/test/Semantics/OpenMP/allocate08.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.0
! 2.11.3 allocate Directive
diff --git a/flang/test/Semantics/OpenMP/allocate09.f90 b/flang/test/Semantics/OpenMP/allocate09.f90
index 26d6ff98c4a3f1..639d23cd6d30ff 100644
--- a/flang/test/Semantics/OpenMP/allocate09.f90
+++ b/flang/test/Semantics/OpenMP/allocate09.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.0
! 2.11.3 allocate Directive
diff --git a/flang/test/Semantics/OpenMP/allocators01.f90 b/flang/test/Semantics/OpenMP/allocators01.f90
index d674438b2ab207..02d686b49716e0 100644
--- a/flang/test/Semantics/OpenMP/allocators01.f90
+++ b/flang/test/Semantics/OpenMP/allocators01.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.2
! 6.7 allocators construct
diff --git a/flang/test/Semantics/OpenMP/allocators02.f90 b/flang/test/Semantics/OpenMP/allocators02.f90
index 32e7bc18ad99b0..9d8644bc30c614 100644
--- a/flang/test/Semantics/OpenMP/allocators02.f90
+++ b/flang/test/Semantics/OpenMP/allocators02.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.2
! 6.7 allocators construct
diff --git a/flang/test/Semantics/OpenMP/allocators03.f90 b/flang/test/Semantics/OpenMP/allocators03.f90
index 533434c2ace0f1..85ab91fde5e01b 100644
--- a/flang/test/Semantics/OpenMP/allocators03.f90
+++ b/flang/test/Semantics/OpenMP/allocators03.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.2
! 6.7 allocators construct
diff --git a/flang/test/Semantics/OpenMP/allocators04.f90 b/flang/test/Semantics/OpenMP/allocators04.f90
index d4467a2052a7dc..0c6e994e137ad4 100644
--- a/flang/test/Semantics/OpenMP/allocators04.f90
+++ b/flang/test/Semantics/OpenMP/allocators04.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.2
! Inherited from 2.11.3 allocate Directive
diff --git a/flang/test/Semantics/OpenMP/allocators05.f90 b/flang/test/Semantics/OpenMP/allocators05.f90
index 684eef69504951..07f1357b75b55b 100644
--- a/flang/test/Semantics/OpenMP/allocators05.f90
+++ b/flang/test/Semantics/OpenMP/allocators05.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.2
! Inherited from 2.11.3 allocate directive
diff --git a/flang/test/Semantics/OpenMP/allocators06.f90 b/flang/test/Semantics/OpenMP/allocators06.f90
index 17e168d4cfe0cb..d3773c05a485d0 100644
--- a/flang/test/Semantics/OpenMP/allocators06.f90
+++ b/flang/test/Semantics/OpenMP/allocators06.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.2
! Inherited from 2.11.3 allocate directive
diff --git a/flang/test/Semantics/OpenMP/atomic-hint-clause.f90 b/flang/test/Semantics/OpenMP/atomic-hint-clause.f90
index 5341fb2e7d2885..3cbde3ab586caa 100644
--- a/flang/test/Semantics/OpenMP/atomic-hint-clause.f90
+++ b/flang/test/Semantics/OpenMP/atomic-hint-clause.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! Semantic checks on hint clauses, as they appear on atomic constructs
diff --git a/flang/test/Semantics/OpenMP/atomic01.f90 b/flang/test/Semantics/OpenMP/atomic01.f90
index 5469f82a0083ca..868c7623928aee 100644
--- a/flang/test/Semantics/OpenMP/atomic01.f90
+++ b/flang/test/Semantics/OpenMP/atomic01.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! Semantic checks for OpenMP 5.0 standard 2.17.7 atomic Construct.
diff --git a/flang/test/Semantics/OpenMP/atomic02.f90 b/flang/test/Semantics/OpenMP/atomic02.f90
index c11622c87cbd35..db67fa63dcdf56 100644
--- a/flang/test/Semantics/OpenMP/atomic02.f90
+++ b/flang/test/Semantics/OpenMP/atomic02.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Atomic construct
diff --git a/flang/test/Semantics/OpenMP/atomic03.f90 b/flang/test/Semantics/OpenMP/atomic03.f90
index 5fc642088ca56f..9bcbace10fb602 100644
--- a/flang/test/Semantics/OpenMP/atomic03.f90
+++ b/flang/test/Semantics/OpenMP/atomic03.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Atomic construct
diff --git a/flang/test/Semantics/OpenMP/atomic04.f90 b/flang/test/Semantics/OpenMP/atomic04.f90
index ddf6b8bc2f5f6f..c0419a69d2dd76 100644
--- a/flang/test/Semantics/OpenMP/atomic04.f90
+++ b/flang/test/Semantics/OpenMP/atomic04.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Atomic construct
diff --git a/flang/test/Semantics/OpenMP/atomic05.f90 b/flang/test/Semantics/OpenMP/atomic05.f90
index b3ff6e9b910f4f..7b970dba8e49f1 100644
--- a/flang/test/Semantics/OpenMP/atomic05.f90
+++ b/flang/test/Semantics/OpenMP/atomic05.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
! This tests the various semantics related to the clauses of various OpenMP atomic constructs
diff --git a/flang/test/Semantics/OpenMP/clause-validity01.f90 b/flang/test/Semantics/OpenMP/clause-validity01.f90
index 3fa86ed105a292..ad5a405080598f 100644
--- a/flang/test/Semantics/OpenMP/clause-validity01.f90
+++ b/flang/test/Semantics/OpenMP/clause-validity01.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
use omp_lib
! Check OpenMP clause validity for the following directives:
diff --git a/flang/test/Semantics/OpenMP/critical-hint-clause.f90 b/flang/test/Semantics/OpenMP/critical-hint-clause.f90
index 33088c6caf3598..f35eea149135ac 100644
--- a/flang/test/Semantics/OpenMP/critical-hint-clause.f90
+++ b/flang/test/Semantics/OpenMP/critical-hint-clause.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! Semantic checks on hint clauses, as they appear on critical construct
diff --git a/flang/test/Semantics/OpenMP/declare-target01.f90 b/flang/test/Semantics/OpenMP/declare-target01.f90
index 3168781ba38391..549f708b08f913 100644
--- a/flang/test/Semantics/OpenMP/declare-target01.f90
+++ b/flang/test/Semantics/OpenMP/declare-target01.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.1
! Check OpenMP construct validity for the following directives:
diff --git a/flang/test/Semantics/OpenMP/flush02.f90 b/flang/test/Semantics/OpenMP/flush02.f90
index 7700954b190617..dbb57ac81450e5 100644
--- a/flang/test/Semantics/OpenMP/flush02.f90
+++ b/flang/test/Semantics/OpenMP/flush02.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! Check OpenMP 5.0 - 2.17.8 flush Construct
diff --git a/flang/test/Semantics/OpenMP/omp-atomic-assignment-stmt.f90 b/flang/test/Semantics/OpenMP/omp-atomic-assignment-stmt.f90
index 7e2d508839ff60..d9ced2cd795018 100644
--- a/flang/test/Semantics/OpenMP/omp-atomic-assignment-stmt.f90
+++ b/flang/test/Semantics/OpenMP/omp-atomic-assignment-stmt.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! Semantic checks for various assignments related to atomic constructs
diff --git a/flang/test/Semantics/OpenMP/parallel-sections01.f90 b/flang/test/Semantics/OpenMP/parallel-sections01.f90
index c5bfbdfcb7b268..2bf58ea2cb295c 100644
--- a/flang/test/Semantics/OpenMP/parallel-sections01.f90
+++ b/flang/test/Semantics/OpenMP/parallel-sections01.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
! OpenMP version 5.0.0
! 2.13.3 parallel sections Construct
diff --git a/flang/test/Semantics/OpenMP/resolve06.f90 b/flang/test/Semantics/OpenMP/resolve06.f90
index 1afc7408c0bc21..f9729050055958 100644
--- a/flang/test/Semantics/OpenMP/resolve06.f90
+++ b/flang/test/Semantics/OpenMP/resolve06.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
use omp_lib
!2.11.4 Allocate Clause
diff --git a/flang/test/Semantics/OpenMP/sections02.f90 b/flang/test/Semantics/OpenMP/sections02.f90
index bcdeb05e5a171c..b96455a960ef8e 100644
--- a/flang/test/Semantics/OpenMP/sections02.f90
+++ b/flang/test/Semantics/OpenMP/sections02.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
! OpenMP version 5.0.0
! 2.8.1 sections construct
diff --git a/flang/test/Semantics/OpenMP/sync-critical02.f90 b/flang/test/Semantics/OpenMP/sync-critical02.f90
index dac031f4f8fc36..fdd95fa76ad7c6 100644
--- a/flang/test/Semantics/OpenMP/sync-critical02.f90
+++ b/flang/test/Semantics/OpenMP/sync-critical02.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
! OpenMP Version 5.0
diff --git a/flang/test/Semantics/OpenMP/taskgroup01.f90 b/flang/test/Semantics/OpenMP/taskgroup01.f90
index a2494129b580ac..e3185552a44bb4 100644
--- a/flang/test/Semantics/OpenMP/taskgroup01.f90
+++ b/flang/test/Semantics/OpenMP/taskgroup01.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
use omp_lib
diff --git a/flang/test/Semantics/OpenMP/threadprivate01.f90 b/flang/test/Semantics/OpenMP/threadprivate01.f90
index 309d209a456727..5ba5f400eb203c 100644
--- a/flang/test/Semantics/OpenMP/threadprivate01.f90
+++ b/flang/test/Semantics/OpenMP/threadprivate01.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.1
! Check OpenMP construct validity for the following directives:
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index 9b8bb83ca23c74..93efd9a12801c7 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -13,6 +13,8 @@
from lit.llvm.subst import ToolSubst
from lit.llvm.subst import FindTool
+print(f'LIK MK: config.have_openmp_rtl={config.have_openmp_rtl}')
+
# Configuration file for the 'lit' test runner.
# name: The name of this test suite.
@@ -199,3 +201,7 @@
result = lit_config.params.get("LIBPGMATH")
if result:
config.environment["LIBPGMATH"] = True
+
+# Determine if OpenMP runtime was built (enable OpenMP tests via REQUIRES in test file)
+if config.have_openmp_rtl:
+ config.available_features.add("openmp_runtime")
diff --git a/flang/test/lit.site.cfg.py.in b/flang/test/lit.site.cfg.py.in
index 16411d82908cae..7f04bde97ecc0b 100644
--- a/flang/test/lit.site.cfg.py.in
+++ b/flang/test/lit.site.cfg.py.in
@@ -25,6 +25,7 @@ config.cc = "@CMAKE_C_COMPILER@"
config.osx_sysroot = path(r"@CMAKE_OSX_SYSROOT@")
config.targets_to_build = "@TARGETS_TO_BUILD@"
config.default_sysroot = "@DEFAULT_SYSROOT@"
+config.have_openmp_rtl = ("@LLVM_TOOL_OPENMP_BUILD@" == "TRUE")
import lit.llvm
lit.llvm.initialize(lit_config, config)
>From 76b6cd63600e98b1d1e87f6c1e62c359809e6695 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Thu, 29 Feb 2024 11:57:32 +0100
Subject: [PATCH 22/28] Cleanup
---
flang/test/lit.cfg.py | 2 --
flang/tools/f18/CMakeLists.txt | 1 -
2 files changed, 3 deletions(-)
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index 93efd9a12801c7..677eeeb720f19d 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -13,8 +13,6 @@
from lit.llvm.subst import ToolSubst
from lit.llvm.subst import FindTool
-print(f'LIK MK: config.have_openmp_rtl={config.have_openmp_rtl}')
-
# Configuration file for the 'lit' test runner.
# name: The name of this test suite.
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index beda5a6f383135..7b463853913544 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -21,7 +21,6 @@ set(MODULES
"__fortran_type_info"
)
-message("MK: LLVM_TOOL_OPENMP_BUILD=${LLVM_TOOL_OPENMP_BUILD}")
# Create module files directly from the top-level module source directory.
# If CMAKE_CROSSCOMPILING, then the newly built flang-new executable was
# cross compiled, and thus can't be executed on the build system and thus
>From ad92b4c92552de9ef60b186f26ec61a62ac50bc9 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Thu, 29 Feb 2024 12:20:48 +0100
Subject: [PATCH 23/28] Add REQUIRES to missed test
---
flang/test/Driver/include-omp-header.f90 | 2 ++
1 file changed, 2 insertions(+)
diff --git a/flang/test/Driver/include-omp-header.f90 b/flang/test/Driver/include-omp-header.f90
index b716f8ace60ce9..6ddc6f3da2a455 100644
--- a/flang/test/Driver/include-omp-header.f90
+++ b/flang/test/Driver/include-omp-header.f90
@@ -1,3 +1,5 @@
+! REQUIRES: openmp_runtime
+
! Verify that the omp_lib.h header is found and included correctly. This header file should be available at a path:
! * relative to the driver, that's
! * known the driver.
>From ad085b41b920ee18147dc2ce30585a99eb45b9cb Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Thu, 29 Feb 2024 17:46:23 +0100
Subject: [PATCH 24/28] Fix typo
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Valentin Clement (バレンタイン クレメン) <clementval at gmail.com>
---
flang/tools/f18/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 7b463853913544..07d09fa04ab51f 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -73,7 +73,7 @@ if (NOT CMAKE_CROSSCOMPILING)
endforeach()
# Special case for omp_lib.mod, because its source comes from openmp/runtime/src/include.
- # It also produces to module files: omp_lib.mod and omp_lib_kinds.mod. Compile these
+ # It also produces two module files: omp_lib.mod and omp_lib_kinds.mod. Compile these
# files only if OpenMP support has been configured.
if (LLVM_TOOL_OPENMP_BUILD)
message(STATUS "OpenMP runtime support enabled, building omp_lib.mod")
>From c7e1dbc47e9d91a1b5e644074731a4bc9f27bf67 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Wed, 6 Mar 2024 17:15:03 +0100
Subject: [PATCH 25/28] Update CMake messages to be more precise
---
flang/tools/f18/CMakeLists.txt | 8 ++++----
llvm/runtimes/CMakeLists.txt | 4 ++++
openmp/runtime/src/CMakeLists.txt | 16 +++++++++++++++-
3 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 07d09fa04ab51f..97347bf4456f85 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -76,7 +76,7 @@ if (NOT CMAKE_CROSSCOMPILING)
# It also produces two module files: omp_lib.mod and omp_lib_kinds.mod. Compile these
# files only if OpenMP support has been configured.
if (LLVM_TOOL_OPENMP_BUILD)
- message(STATUS "OpenMP runtime support enabled, building omp_lib.mod")
+ message(STATUS "OpenMP runtime support enabled via LLVM_ENABLED_PROJECTS, building omp_lib.mod")
set(base ${FLANG_INTRINSIC_MODULES_DIR}/omp_lib)
add_custom_command(OUTPUT ${base}.mod ${base}_kinds.mod
COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
@@ -93,7 +93,7 @@ if (NOT CMAKE_CROSSCOMPILING)
list(APPEND MODULE_FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod)
install(FILES ${base}.mod ${base}.f18.mod ${base}_kinds.mod ${base}_kinds.f18.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
else()
- message(STATUS "Not building omp_lib.mod, OpenMP runtime support disabled")
+ message(STATUS "Not building omp_lib.mod, no OpenMP runtime in LLVM_ENABLED_PROJECTS")
endif()
endif()
@@ -113,9 +113,9 @@ endif()
# TODO Move this to a more suitable location
# Copy the generated omp_lib.h header file, if OpenMP support has been configured.
if (LLVM_TOOL_OPENMP_BUILD)
- message(STATUS "OpenMP runtime support enabled, building omp_lib.h")
+ message(STATUS "OpenMP runtime support enabled via LLVM_ENABLED_PROJECTS, building omp_lib.h")
file(COPY ${CMAKE_BINARY_DIR}/projects/openmp/runtime/src/omp_lib.h DESTINATION "${CMAKE_BINARY_DIR}/include/flang/OpenMP/" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
install(FILES ${CMAKE_BINARY_DIR}/include/flang/OpenMP/omp_lib.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang/OpenMP")
else()
- message(STATUS "Not copying omp_lib.h, OpenMP runtime support disabled")
+ message(STATUS "Not copying omp_lib.h, no OpenMP runtime in LLVM_ENABLED_PROJECTS")
endif()
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 8c48d85a4346f4..295da93f60db8c 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -417,6 +417,10 @@ if(runtimes)
# together in a single CMake invocation.
set(extra_deps "")
if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
+ if (${LLVM_TOOL_FLANG_BUILD})
+ message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
+ set(LIBOMP_FORTRAN_MODULES_COMPILER "flang-new")
+ endif()
foreach(dep opt llvm-link llvm-extract clang clang-offload-packager)
if(TARGET ${dep} AND OPENMP_ENABLE_LIBOMPTARGET)
list(APPEND extra_deps ${dep})
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index 595545220c1e53..0ceafd8a787fae 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -314,7 +314,21 @@ endif()
# One compilation step creates both omp_lib.mod and omp_lib_kinds.mod
configure_file(${LIBOMP_INC_DIR}/omp_lib.h.var omp_lib.h @ONLY)
configure_file(${LIBOMP_INC_DIR}/omp_lib.F90.var omp_lib.F90 @ONLY)
-if(${LIBOMP_FORTRAN_MODULES})
+
+if (NOT ${LIBOMP_FORTRAN_MODULES_COMPILER} STREQUAL "")
+ # If libomp is built as an LLVM runtime and the flang compiler is available,
+ # compile the Fortran module files.
+ message(STATUS "configuring openmp to build Fortran module files using ${LIBOMP_FORTRAN_MODULES_COMPILER}")
+ set(LIBOMP_FORTRAN_SOURCE_FILE omp_lib.F90)
+ add_custom_target(libomp-mod ALL DEPENDS omp_lib.mod omp_lib_kinds.mod)
+ add_custom_command(
+ OUTPUT omp_lib.mod omp_lib_kinds.mod
+ COMMAND ${LIBOMP_FORTRAN_MODULES_COMPILER} -cpp -fsyntax-only ${LIBOMP_FORTRAN_SOURCE_FILE}
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${LIBOMP_FORTRAN_SOURCE_FILE}
+ ${CMAKE_CURRENT_BINARY_DIR}/omp_lib.h
+ )
+elseif(${LIBOMP_FORTRAN_MODULES})
+ # The following requests explicit building of the Fortran module files
# Workaround for gfortran to build modules with the
# omp_sched_monotonic integer parameter
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
>From 59ead5319808b716a989fe38e4745e848492970f Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Thu, 7 Mar 2024 14:47:03 +0100
Subject: [PATCH 26/28] Inject proper dependence to have flang available before
building "openmp"
---
llvm/runtimes/CMakeLists.txt | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 295da93f60db8c..23e3d986eff86d 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -419,7 +419,11 @@ if(runtimes)
if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES)
if (${LLVM_TOOL_FLANG_BUILD})
message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
- set(LIBOMP_FORTRAN_MODULES_COMPILER "flang-new")
+ set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new")
+ # TODO: This is a workaround until flang becomes a first-class project
+ # in llvm/CMakeList.txt. Until then, this line ensures that flang-new is
+ # built before "openmp" is built as a runtime project.
+ list(APPEND extra_deps "flang-new")
endif()
foreach(dep opt llvm-link llvm-extract clang clang-offload-packager)
if(TARGET ${dep} AND OPENMP_ENABLE_LIBOMPTARGET)
>From c28aeb54cf6185260a1a3a70907dbb90a1684cfb Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Tue, 12 Mar 2024 18:23:48 +0100
Subject: [PATCH 27/28] Fix up installation issue with omp_lib.mod
---
openmp/runtime/src/CMakeLists.txt | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index 0ceafd8a787fae..3550a84a4d5961 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -315,6 +315,7 @@ endif()
configure_file(${LIBOMP_INC_DIR}/omp_lib.h.var omp_lib.h @ONLY)
configure_file(${LIBOMP_INC_DIR}/omp_lib.F90.var omp_lib.F90 @ONLY)
+set(BUILD_FORTRAN_MODULES False)
if (NOT ${LIBOMP_FORTRAN_MODULES_COMPILER} STREQUAL "")
# If libomp is built as an LLVM runtime and the flang compiler is available,
# compile the Fortran module files.
@@ -327,6 +328,7 @@ if (NOT ${LIBOMP_FORTRAN_MODULES_COMPILER} STREQUAL "")
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${LIBOMP_FORTRAN_SOURCE_FILE}
${CMAKE_CURRENT_BINARY_DIR}/omp_lib.h
)
+ set(BUILD_FORTRAN_MODULES True)
elseif(${LIBOMP_FORTRAN_MODULES})
# The following requests explicit building of the Fortran module files
# Workaround for gfortran to build modules with the
@@ -349,6 +351,7 @@ elseif(${LIBOMP_FORTRAN_MODULES})
${CMAKE_CURRENT_BINARY_DIR}/omp_lib.h
)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES omp_lib${CMAKE_C_OUTPUT_EXTENSION})
+ set(BUILD_FORTRAN_MODULES True)
endif()
# Move files to exports/ directory if requested
@@ -422,7 +425,7 @@ if(${LIBOMP_OMPT_SUPPORT})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
endif()
-if(${LIBOMP_FORTRAN_MODULES})
+if(${BUILD_FORTRAN_MODULES})
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/omp_lib.h
${CMAKE_CURRENT_BINARY_DIR}/omp_lib.mod
>From 3639cbc09d0f8ec52cd1689baebf4635046b85c5 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Tue, 12 Mar 2024 12:49:04 -0500
Subject: [PATCH 28/28] Move omp_lib.mod and omp_lib_kinds.mod to include/flang
where they belong
---
llvm/runtimes/CMakeLists.txt | 1 +
openmp/runtime/src/CMakeLists.txt | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 23e3d986eff86d..12a55e238516ff 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -420,6 +420,7 @@ if(runtimes)
if (${LLVM_TOOL_FLANG_BUILD})
message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang-new")
set(LIBOMP_FORTRAN_MODULES_COMPILER "${CMAKE_BINARY_DIR}/bin/flang-new")
+ set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
# TODO: This is a workaround until flang becomes a first-class project
# in llvm/CMakeList.txt. Until then, this line ensures that flang-new is
# built before "openmp" is built as a runtime project.
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index 3550a84a4d5961..07449f20a06730 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -426,10 +426,14 @@ if(${LIBOMP_OMPT_SUPPORT})
set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
endif()
if(${BUILD_FORTRAN_MODULES})
+ set (destination ${LIBOMP_HEADERS_INSTALL_PATH})
+ if (NOT ${LIBOMP_MODULES_INSTALL_PATH} STREQUAL "")
+ set (destination ${LIBOMP_MODULES_INSTALL_PATH})
+ endif()
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/omp_lib.h
${CMAKE_CURRENT_BINARY_DIR}/omp_lib.mod
${CMAKE_CURRENT_BINARY_DIR}/omp_lib_kinds.mod
- DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH}
+ DESTINATION ${destination}
)
endif()
More information about the Openmp-commits
mailing list