aboutsummaryrefslogtreecommitdiff
path: root/libgomp/fortran.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgomp/fortran.c')
-rw-r--r--libgomp/fortran.c104
1 files changed, 102 insertions, 2 deletions
diff --git a/libgomp/fortran.c b/libgomp/fortran.c
index 24172a0..0157bae 100644
--- a/libgomp/fortran.c
+++ b/libgomp/fortran.c
@@ -28,6 +28,8 @@
#include "libgomp.h"
#include "libgomp_f.h"
#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
#include <limits.h>
#ifdef HAVE_ATTRIBUTE_ALIAS
@@ -82,6 +84,8 @@ ialias_redirect (omp_get_team_num)
ialias_redirect (omp_is_initial_device)
ialias_redirect (omp_get_initial_device)
ialias_redirect (omp_get_max_task_priority)
+ialias_redirect (omp_pause_resource)
+ialias_redirect (omp_pause_resource_all)
#endif
#ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
@@ -368,7 +372,9 @@ omp_get_schedule_ (int32_t *kind, int32_t *chunk_size)
omp_sched_t k;
int cs;
omp_get_schedule (&k, &cs);
- *kind = k;
+ /* For now mask off GFS_MONOTONIC, because OpenMP 4.5 code will not
+ expect to see it. */
+ *kind = k & ~GFS_MONOTONIC;
*chunk_size = cs;
}
@@ -378,7 +384,8 @@ omp_get_schedule_8_ (int32_t *kind, int64_t *chunk_size)
omp_sched_t k;
int cs;
omp_get_schedule (&k, &cs);
- *kind = k;
+ /* See above. */
+ *kind = k & ~GFS_MONOTONIC;
*chunk_size = cs;
}
@@ -576,3 +583,96 @@ omp_get_max_task_priority_ (void)
{
return omp_get_max_task_priority ();
}
+
+void
+omp_set_affinity_format_ (const char *format, size_t format_len)
+{
+ gomp_set_affinity_format (format, format_len);
+}
+
+int32_t
+omp_get_affinity_format_ (char *buffer, size_t buffer_len)
+{
+ size_t len = strlen (gomp_affinity_format_var);
+ if (buffer_len)
+ {
+ if (len < buffer_len)
+ {
+ memcpy (buffer, gomp_affinity_format_var, len);
+ memset (buffer + len, ' ', buffer_len - len);
+ }
+ else
+ memcpy (buffer, gomp_affinity_format_var, buffer_len);
+ }
+ return len;
+}
+
+void
+omp_display_affinity_ (const char *format, size_t format_len)
+{
+ char *fmt = NULL, fmt_buf[256];
+ char buf[512];
+ if (format_len)
+ {
+ fmt = format_len < 256 ? fmt_buf : gomp_malloc (format_len + 1);
+ memcpy (fmt, format, format_len);
+ fmt[format_len] = '\0';
+ }
+ struct gomp_thread *thr = gomp_thread ();
+ size_t ret
+ = gomp_display_affinity (buf, sizeof buf,
+ format_len ? fmt : gomp_affinity_format_var,
+ gomp_thread_self (), &thr->ts, thr->place);
+ if (ret < sizeof buf)
+ {
+ buf[ret] = '\n';
+ fwrite (buf, 1, ret + 1, stderr);
+ }
+ else
+ {
+ char *b = gomp_malloc (ret + 1);
+ gomp_display_affinity (buf, sizeof buf,
+ format_len ? fmt : gomp_affinity_format_var,
+ gomp_thread_self (), &thr->ts, thr->place);
+ b[ret] = '\n';
+ fwrite (b, 1, ret + 1, stderr);
+ free (b);
+ }
+ if (fmt && fmt != fmt_buf)
+ free (fmt);
+}
+
+int32_t
+omp_capture_affinity_ (char *buffer, const char *format,
+ size_t buffer_len, size_t format_len)
+{
+ char *fmt = NULL, fmt_buf[256];
+ if (format_len)
+ {
+ fmt = format_len < 256 ? fmt_buf : gomp_malloc (format_len + 1);
+ memcpy (fmt, format, format_len);
+ fmt[format_len] = '\0';
+ }
+ struct gomp_thread *thr = gomp_thread ();
+ size_t ret
+ = gomp_display_affinity (buffer, buffer_len,
+ format_len ? fmt : gomp_affinity_format_var,
+ gomp_thread_self (), &thr->ts, thr->place);
+ if (fmt && fmt != fmt_buf)
+ free (fmt);
+ if (ret < buffer_len)
+ memset (buffer + ret, ' ', buffer_len - ret);
+ return ret;
+}
+
+int32_t
+omp_pause_resource_ (const int32_t *kind, const int32_t *device_num)
+{
+ return omp_pause_resource (*kind, *device_num);
+}
+
+int32_t
+omp_pause_resource_all_ (const int32_t *kind)
+{
+ return omp_pause_resource_all (*kind);
+}