Hi all, Based on the GSoC project description, while working on my project proposal, I thought I could start contributing to some individual parts first. This patch makes OMP_WAIT_POLICY accept the pvsched option. Tests and documentation have also been added.
Please take a look when you get a chance. Thanks, Yuao
From 0ff78eb853cd8c4a618c93ec74b0fbf389243f09 Mon Sep 17 00:00:00 2001 From: Yuao Ma <[email protected]> Date: Thu, 26 Feb 2026 21:59:55 +0800 Subject: [PATCH] libgomp: make OMP_WAIT_POLICY accept pvsched As per the project 'libgomp Optimizations for Scheduler Guided OpenMP Execution in Cloud VMs' specified. libgomp/ChangeLog: * env.c (parse_wait_policy): Add pvsched. (gomp_get_wait_policy): Add helper function to map wait_policy to str. (print_device_specific_icvs, omp_display_env): Utilize gomp_get_wait_policy. * libgomp.texi: Mention pvsched. * testsuite/libgomp.c-c++-common/omp-display-env-1.c: Test pvsched. --- libgomp/env.c | 24 +++++++++++++++---- libgomp/libgomp.texi | 4 ++++ .../libgomp.c-c++-common/omp-display-env-1.c | 2 ++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/libgomp/env.c b/libgomp/env.c index 15450d92497..51cb2d087f2 100644 --- a/libgomp/env.c +++ b/libgomp/env.c @@ -1117,6 +1117,11 @@ parse_wait_policy (const char *env, const char *val, void *const params[]) ret = 0; val += 7; } + else if (strncasecmp (val, "pvsched", 7) == 0) + { + ret = 2; + val += 7; + } else val = "X"; while (isspace ((unsigned char) *val)) @@ -1679,6 +1684,17 @@ gomp_set_icv_flag (uint32_t *value, enum gomp_icvs icv) *value |= 1 << (icv - 1); } +static const char * +gomp_get_wait_policy (int wait_policy) +{ + if (wait_policy == 1) + return "ACTIVE"; + else if (wait_policy == 2) + return "PVSCHED"; + else + return "PASSIVE"; +} + static void print_device_specific_icvs (int icv_code) { @@ -1748,7 +1764,7 @@ print_device_specific_icvs (int icv_code) if (gomp_get_icv_flag (list->flags, GOMP_ICV_WAIT_POLICY)) fprintf (stderr, " [%d] OMP_WAIT_POLICY = '%s'\n", list->device_num, - list->icvs.wait_policy > 0 ? "ACTIVE" : "PASSIVE"); + gomp_get_wait_policy (list->icvs.wait_policy)); break; case GOMP_ICV_STACKSIZE: if (gomp_get_icv_flag (list->flags, GOMP_ICV_STACKSIZE)) @@ -1861,13 +1877,13 @@ omp_display_env (int verbose) /* GOMP's default value is actually neither active nor passive. */ fprintf (stderr, " [host] OMP_WAIT_POLICY = '%s'\n", - none->icvs.wait_policy > 0 ? "ACTIVE" : "PASSIVE"); + gomp_get_wait_policy (none->icvs.wait_policy)); if (all != NULL && gomp_get_icv_flag (all->flags, GOMP_ICV_WAIT_POLICY)) fprintf (stderr, " [all] OMP_WAIT_POLICY = '%s'\n", - all->icvs.wait_policy > 0 ? "ACTIVE" : "PASSIVE"); + gomp_get_wait_policy (all->icvs.wait_policy)); if (dev != NULL && gomp_get_icv_flag (dev->flags, GOMP_ICV_WAIT_POLICY)) fprintf (stderr, " [device] OMP_WAIT_POLICY = '%s'\n", - dev->icvs.wait_policy > 0 ? "ACTIVE" : "PASSIVE"); + gomp_get_wait_policy (dev->icvs.wait_policy)); print_device_specific_icvs (GOMP_ICV_WAIT_POLICY); fprintf (stderr, " [host] OMP_THREAD_LIMIT = '%u'\n", diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi index 258ea8a7619..73c0e74c79e 100644 --- a/libgomp/libgomp.texi +++ b/libgomp/libgomp.texi @@ -4647,6 +4647,10 @@ power while waiting; while the value is @code{ACTIVE} specifies that they should. If undefined, threads wait actively for a short time before waiting passively. +As an extension, if the value is @code{PVSCHED}, the runtime library will +employ a para-virtualized scheduling guided barrier synchronization mechanism, +though this feature has not yet been implemented. + @item @emph{See also}: @ref{GOMP_SPINCOUNT} diff --git a/libgomp/testsuite/libgomp.c-c++-common/omp-display-env-1.c b/libgomp/testsuite/libgomp.c-c++-common/omp-display-env-1.c index 9ea7adecb58..6d5ea365b62 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/omp-display-env-1.c +++ b/libgomp/testsuite/libgomp.c-c++-common/omp-display-env-1.c @@ -39,6 +39,7 @@ /* { dg-set-target-env-var OMP_WAIT_POLICY_ALL "ACTIVE" } */ /* { dg-set-target-env-var OMP_WAIT_POLICY_DEV "passive" } */ /* { dg-set-target-env-var OMP_WAIT_POLICY_DEV_24 "PASSIVE" } */ +/* { dg-set-target-env-var OMP_WAIT_POLICY_DEV_25 "pvsched" } */ /* { dg-set-target-env-var OMP_TEAMS_THREAD_LIMIT "42" } */ /* { dg-set-target-env-var OMP_TEAMS_THREAD_LIMIT_ALL "43" } */ /* { dg-set-target-env-var OMP_TEAMS_THREAD_LIMIT_DEV "44" } */ @@ -90,6 +91,7 @@ main () /* { dg-output ".*\\\[all\] OMP_WAIT_POLICY = 'ACTIVE'.*" { target native } } */ /* { dg-output ".*\\\[device\] OMP_WAIT_POLICY = 'PASSIVE'.*" { target native } } */ /* { dg-output ".*\\\[24\] OMP_WAIT_POLICY = 'PASSIVE'.*" { target native } } */ +/* { dg-output ".*\\\[25\] OMP_WAIT_POLICY = 'PVSCHED'.*" { target native } } */ /* { dg-output ".*\\\[host] OMP_THREAD_LIMIT = '45'.*" { target native } } */ /* { dg-output ".*\\\[all\] OMP_THREAD_LIMIT = '43'.*" { target native } } */ -- 2.53.0
