]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgomp/icv.c
openmp: Add OpenMP _BitInt support [PR113409]
[thirdparty/gcc.git] / libgomp / icv.c
index e58b961558e8681c5936cd37ed99549038026358..c4a4d68edd2dcf058e96680005623221c0cee1f5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005-2016 Free Software Foundation, Inc.
+/* Copyright (C) 2005-2024 Free Software Foundation, Inc.
    Contributed by Richard Henderson <rth@redhat.com>.
 
    This file is part of the GNU Offloading and Multi Processing Library
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* This file defines the OpenMP internal control variables and associated
-   OpenMP API entry points.  */
+/* This file defines the OpenMP API entry points that operate on internal
+   control variables.  */
 
 #include "libgomp.h"
 #include "gomp-constants.h"
 #include <limits.h>
 
-struct gomp_task_icv gomp_global_icv = {
-  .nthreads_var = 1,
-  .thread_limit_var = UINT_MAX,
-  .run_sched_var = GFS_DYNAMIC,
-  .run_sched_chunk_size = 1,
-  .default_device_var = 0,
-  .dyn_var = false,
-  .nest_var = false,
-  .bind_var = omp_proc_bind_false,
-  .target_data = NULL
-};
-
-unsigned long gomp_max_active_levels_var = INT_MAX;
-bool gomp_cancel_var = false;
-int gomp_max_task_priority_var = 0;
-#ifndef HAVE_SYNC_BUILTINS
-gomp_mutex_t gomp_managed_threads_lock;
-#endif
-unsigned long gomp_available_cpus = 1, gomp_managed_threads = 1;
-unsigned long long gomp_spin_count_var, gomp_throttled_spin_count_var;
-unsigned long *gomp_nthreads_var_list, gomp_nthreads_var_list_len;
-char *gomp_bind_var_list;
-unsigned long gomp_bind_var_list_len;
-void **gomp_places_list;
-unsigned long gomp_places_list_len;
-int gomp_debug_var;
-unsigned int gomp_num_teams_var;
-char *goacc_device_type;
-int goacc_device_num;
+ialias_redirect (omp_get_active_level)
 
 void
 omp_set_num_threads (int n)
@@ -81,25 +53,32 @@ omp_get_dynamic (void)
   return icv->dyn_var;
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 void
 omp_set_nested (int val)
 {
   struct gomp_task_icv *icv = gomp_icv (true);
-  icv->nest_var = val;
+  if (val)
+    icv->max_active_levels_var = gomp_supported_active_levels;
+  else if (icv->max_active_levels_var > 1)
+    icv->max_active_levels_var = 1;
 }
 
 int
 omp_get_nested (void)
 {
   struct gomp_task_icv *icv = gomp_icv (false);
-  return icv->nest_var;
+  return (icv->max_active_levels_var > 1
+         && icv->max_active_levels_var > omp_get_active_level ());
 }
+#pragma GCC diagnostic pop
 
 void
 omp_set_schedule (omp_sched_t kind, int chunk_size)
 {
   struct gomp_task_icv *icv = gomp_icv (true);
-  switch (kind)
+  switch (kind & ~omp_sched_monotonic)
     {
     case omp_sched_static:
       if (chunk_size < 1)
@@ -146,13 +125,27 @@ void
 omp_set_max_active_levels (int max_levels)
 {
   if (max_levels >= 0)
-    gomp_max_active_levels_var = max_levels;
+    {
+      struct gomp_task_icv *icv = gomp_icv (true);
+
+      if (max_levels <= gomp_supported_active_levels)
+       icv->max_active_levels_var = max_levels;
+      else
+       icv->max_active_levels_var = gomp_supported_active_levels;
+    }
 }
 
 int
 omp_get_max_active_levels (void)
 {
-  return gomp_max_active_levels_var;
+  struct gomp_task_icv *icv = gomp_icv (false);
+  return icv->max_active_levels_var;
+}
+
+int
+omp_get_supported_active_levels (void)
+{
+  return gomp_supported_active_levels;
 }
 
 int
@@ -174,12 +167,6 @@ omp_get_proc_bind (void)
   return icv->bind_var;
 }
 
-int
-omp_get_initial_device (void)
-{
-  return GOMP_DEVICE_HOST_FALLBACK;
-}
-
 int
 omp_get_num_places (void)
 {
@@ -227,22 +214,46 @@ omp_get_partition_place_nums (int *place_nums)
     *place_nums++ = thr->ts.place_partition_off + i;
 }
 
+void
+omp_set_default_allocator (omp_allocator_handle_t allocator)
+{
+  struct gomp_thread *thr = gomp_thread ();
+  if (allocator == omp_null_allocator)
+    allocator = omp_default_mem_alloc;
+  thr->ts.def_allocator = (uintptr_t) allocator;
+}
+
+omp_allocator_handle_t
+omp_get_default_allocator (void)
+{
+  struct gomp_thread *thr = gomp_thread ();
+  if (thr->ts.def_allocator == omp_null_allocator)
+    return (omp_allocator_handle_t) gomp_def_allocator;
+  else
+    return (omp_allocator_handle_t) thr->ts.def_allocator;
+}
+
 ialias (omp_set_dynamic)
-ialias (omp_set_nested)
-ialias (omp_set_num_threads)
 ialias (omp_get_dynamic)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ialias (omp_set_nested)
 ialias (omp_get_nested)
+#pragma GCC diagnostic pop
+ialias (omp_set_num_threads)
 ialias (omp_set_schedule)
 ialias (omp_get_schedule)
 ialias (omp_get_max_threads)
 ialias (omp_get_thread_limit)
 ialias (omp_set_max_active_levels)
 ialias (omp_get_max_active_levels)
+ialias (omp_get_supported_active_levels)
 ialias (omp_get_cancellation)
 ialias (omp_get_proc_bind)
-ialias (omp_get_initial_device)
 ialias (omp_get_max_task_priority)
 ialias (omp_get_num_places)
 ialias (omp_get_place_num)
 ialias (omp_get_partition_num_places)
 ialias (omp_get_partition_place_nums)
+ialias (omp_set_default_allocator)
+ialias (omp_get_default_allocator)