@@ -0,0 +1,219 @@
+/* Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This file is part of the GNU Offloading and Multi Processing Library
+ (libgomp).
+
+ Libgomp is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ Under Section 7 of GPL version 3, you are granted additional
+ permissions described in the GCC Runtime Library Exception, version
+ 3.1, as published by the Free Software Foundation.
+
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This file defines the OpenMP internal control variables. There is
+ no environment on the accelerator, so the variables can be changed
+ only via OpenMP API in target regions. */
+
+#include "libgomp.h"
+#include "libgomp_f.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_modifier = 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;
+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;
+
+void
+omp_set_num_threads (int n)
+{
+ struct gomp_task_icv *icv = gomp_icv (true);
+ icv->nthreads_var = (n > 0 ? n : 1);
+}
+
+void
+omp_set_dynamic (int val)
+{
+ struct gomp_task_icv *icv = gomp_icv (true);
+ icv->dyn_var = val;
+}
+
+int
+omp_get_dynamic (void)
+{
+ struct gomp_task_icv *icv = gomp_icv (false);
+ return icv->dyn_var;
+}
+
+void
+omp_set_nested (int val)
+{
+ struct gomp_task_icv *icv = gomp_icv (true);
+ icv->nest_var = val;
+}
+
+int
+omp_get_nested (void)
+{
+ struct gomp_task_icv *icv = gomp_icv (false);
+ return icv->nest_var;
+}
+
+void
+omp_set_schedule (omp_sched_t kind, int modifier)
+{
+ struct gomp_task_icv *icv = gomp_icv (true);
+ switch (kind)
+ {
+ case omp_sched_static:
+ if (modifier < 1)
+ modifier = 0;
+ icv->run_sched_modifier = modifier;
+ break;
+ case omp_sched_dynamic:
+ case omp_sched_guided:
+ if (modifier < 1)
+ modifier = 1;
+ icv->run_sched_modifier = modifier;
+ break;
+ case omp_sched_auto:
+ break;
+ default:
+ return;
+ }
+ icv->run_sched_var = kind;
+}
+
+void
+omp_get_schedule (omp_sched_t *kind, int *modifier)
+{
+ struct gomp_task_icv *icv = gomp_icv (false);
+ *kind = icv->run_sched_var;
+ *modifier = icv->run_sched_modifier;
+}
+
+int
+omp_get_max_threads (void)
+{
+ struct gomp_task_icv *icv = gomp_icv (false);
+ return icv->nthreads_var;
+}
+
+int
+omp_get_thread_limit (void)
+{
+ struct gomp_task_icv *icv = gomp_icv (false);
+ return icv->thread_limit_var > INT_MAX ? INT_MAX : icv->thread_limit_var;
+}
+
+void
+omp_set_max_active_levels (int max_levels)
+{
+ if (max_levels >= 0)
+ gomp_max_active_levels_var = max_levels;
+}
+
+int
+omp_get_max_active_levels (void)
+{
+ return gomp_max_active_levels_var;
+}
+
+int
+omp_get_cancellation (void)
+{
+ return 0;
+}
+
+omp_proc_bind_t
+omp_get_proc_bind (void)
+{
+ return omp_proc_bind_false;
+}
+
+void
+omp_set_default_device (int device_num __attribute__((unused)))
+{
+}
+
+int
+omp_get_default_device (void)
+{
+ return 0;
+}
+
+int
+omp_get_num_devices (void)
+{
+ return 0;
+}
+
+int
+omp_get_num_teams (void)
+{
+ /* FORNOW. */
+ return 1;
+}
+
+int
+omp_get_team_num (void)
+{
+ /* FORNOW. */
+ return 0;
+}
+
+int
+omp_is_initial_device (void)
+{
+ /* PTX is an accelerator-only target. */
+ return 0;
+}
+
+ialias (omp_set_dynamic)
+ialias (omp_set_nested)
+ialias (omp_set_num_threads)
+ialias (omp_get_dynamic)
+ialias (omp_get_nested)
+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_cancellation)
+ialias (omp_get_proc_bind)
+ialias (omp_set_default_device)
+ialias (omp_get_default_device)
+ialias (omp_get_num_devices)
+ialias (omp_get_num_teams)
+ialias (omp_get_team_num)
+ialias (omp_is_initial_device)