public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] improve future::poll calibration loop
@ 2021-03-24  6:29 Alexandre Oliva
  0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2021-03-24  6:29 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:852e78555d17ac86e1c67df93d57335c5ad26594

commit 852e78555d17ac86e1c67df93d57335c5ad26594
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Mar 23 09:27:56 2021 -0300

    improve future::poll calibration loop
    
    The calibration loop I've recently added to the libstdc++
    future/members/poll.cc tests could still select iteration counts that
    might yield zero-time measurements for the wait_for when ready loop.
    
    Waiting for a future that has already had a value set is presumably
    uniformly faster than a zero-timed wait for a result, so I've changed
    the calibration loop to use the former.
    
    We might still be unlucky and get nonzero from the initial loop, so
    that the calibration is skipped altogether, but then get zero from the
    later when-ready loop.  I'm not dealing with this case in this patch.
    
    
    for  libstdc++-v3/ChangeLog
    
            * testsuite/30_threads/future/members/poll.cc: Use faster
            after-ready call in the calibration loop.

Diff:
---
 libstdc++-v3/testsuite/30_threads/future/members/poll.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/30_threads/future/members/poll.cc b/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
index 133dae15ac4..4c846d0b7ba 100644
--- a/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
+++ b/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
@@ -55,6 +55,12 @@ int main()
      Attempt to calibrate it.  */
   if (start == stop)
     {
+      /* After set_value, wait_for is faster, so use that for the
+	 calibration to avoid zero at low clock resultions.  */
+      promise<int> pc;
+      future<int> fc = pc.get_future();
+      pc.set_value(1);
+
       /* Loop until the clock advances, so that start is right after a
 	 time increment.  */
       do
@@ -65,7 +71,7 @@ int main()
 	 after another time increment.  */
       do
 	{
-	  f.wait_for(chrono::seconds(0));
+	  fc.wait_for(chrono::seconds(0));
 	  stop = chrono::high_resolution_clock::now();
 	  i++;
 	}


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] improve future::poll calibration loop
@ 2021-03-24  9:15 Alexandre Oliva
  0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2021-03-24  9:15 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:302e9dc278d05495655a4e342fea8349236508ae

commit 302e9dc278d05495655a4e342fea8349236508ae
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Wed Mar 24 05:44:41 2021 -0300

    improve future::poll calibration loop
    
    The calibration loop I've recently added to the libstdc++
    future/members/poll.cc tests could still select iteration counts that
    might yield zero-time measurements for the wait_for when ready loop.
    
    Waiting for a future that has already had a value set is presumably
    uniformly faster than a zero-timed wait for a result, so I've changed
    the calibration loop to use the former.
    
    We might still be unlucky and get nonzero from the initial loop, so
    that the calibration is skipped altogether, but then get zero from the
    later when-ready loop.  I'm not dealing with this case in this patch.
    
    
    for  libstdc++-v3/ChangeLog
    
            * testsuite/30_threads/future/members/poll.cc: Use faster
            after-ready call in the calibration loop.

Diff:
---
 libstdc++-v3/testsuite/30_threads/future/members/poll.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/30_threads/future/members/poll.cc b/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
index 133dae15ac4..4c846d0b7ba 100644
--- a/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
+++ b/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
@@ -55,6 +55,12 @@ int main()
      Attempt to calibrate it.  */
   if (start == stop)
     {
+      /* After set_value, wait_for is faster, so use that for the
+	 calibration to avoid zero at low clock resultions.  */
+      promise<int> pc;
+      future<int> fc = pc.get_future();
+      pc.set_value(1);
+
       /* Loop until the clock advances, so that start is right after a
 	 time increment.  */
       do
@@ -65,7 +71,7 @@ int main()
 	 after another time increment.  */
       do
 	{
-	  f.wait_for(chrono::seconds(0));
+	  fc.wait_for(chrono::seconds(0));
 	  stop = chrono::high_resolution_clock::now();
 	  i++;
 	}


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] improve future::poll calibration loop
@ 2021-03-24  9:07 Alexandre Oliva
  0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2021-03-24  9:07 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:f5a294cf2cac49b2c39eaa070d6899c0f3124e9c

commit f5a294cf2cac49b2c39eaa070d6899c0f3124e9c
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Wed Mar 24 05:44:41 2021 -0300

    improve future::poll calibration loop
    
    The calibration loop I've recently added to the libstdc++
    future/members/poll.cc tests could still select iteration counts that
    might yield zero-time measurements for the wait_for when ready loop.
    
    Waiting for a future that has already had a value set is presumably
    uniformly faster than a zero-timed wait for a result, so I've changed
    the calibration loop to use the former.
    
    We might still be unlucky and get nonzero from the initial loop, so
    that the calibration is skipped altogether, but then get zero from the
    later when-ready loop.  I'm not dealing with this case in this patch.
    
    
    for  libstdc++-v3/ChangeLog
    
            * testsuite/30_threads/future/members/poll.cc: Use faster
            after-ready call in the calibration loop.

Diff:
---
 libstdc++-v3/testsuite/30_threads/future/members/poll.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/30_threads/future/members/poll.cc b/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
index 133dae15ac4..4c846d0b7ba 100644
--- a/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
+++ b/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
@@ -55,6 +55,12 @@ int main()
      Attempt to calibrate it.  */
   if (start == stop)
     {
+      /* After set_value, wait_for is faster, so use that for the
+	 calibration to avoid zero at low clock resultions.  */
+      promise<int> pc;
+      future<int> fc = pc.get_future();
+      pc.set_value(1);
+
       /* Loop until the clock advances, so that start is right after a
 	 time increment.  */
       do
@@ -65,7 +71,7 @@ int main()
 	 after another time increment.  */
       do
 	{
-	  f.wait_for(chrono::seconds(0));
+	  fc.wait_for(chrono::seconds(0));
 	  stop = chrono::high_resolution_clock::now();
 	  i++;
 	}


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] improve future::poll calibration loop
@ 2021-03-23 12:34 Alexandre Oliva
  0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2021-03-23 12:34 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:9bc8a66862f6660b3d423f2c930b1e1691a412c7

commit 9bc8a66862f6660b3d423f2c930b1e1691a412c7
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Mar 23 09:27:56 2021 -0300

    improve future::poll calibration loop
    
    The calibration loop I've recently added to the libstdc++
    future/members/poll.cc tests could still select iteration counts that
    might yield zero-time measurements for the wait_for when ready loop.
    
    Waiting for a future that has already had a value set is presumably
    uniformly faster than a zero-timed wait for a result, so I've changed
    the calibration loop to use the former.
    
    We might still be unlucky and get nonzero from the initial loop, so
    that the calibration is skipped altogether, but then get zero from the
    later when-ready loop.  I'm not dealing with this case in this patch.
    
    
    for  libstdc++-v3/ChangeLog
    
            * testsuite/30_threads/future/members/poll.cc: Use faster
            after-ready call in the calibration loop.

Diff:
---
 libstdc++-v3/testsuite/30_threads/future/members/poll.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/30_threads/future/members/poll.cc b/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
index 133dae15ac4..4c846d0b7ba 100644
--- a/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
+++ b/libstdc++-v3/testsuite/30_threads/future/members/poll.cc
@@ -55,6 +55,12 @@ int main()
      Attempt to calibrate it.  */
   if (start == stop)
     {
+      /* After set_value, wait_for is faster, so use that for the
+	 calibration to avoid zero at low clock resultions.  */
+      promise<int> pc;
+      future<int> fc = pc.get_future();
+      pc.set_value(1);
+
       /* Loop until the clock advances, so that start is right after a
 	 time increment.  */
       do
@@ -65,7 +71,7 @@ int main()
 	 after another time increment.  */
       do
 	{
-	  f.wait_for(chrono::seconds(0));
+	  fc.wait_for(chrono::seconds(0));
 	  stop = chrono::high_resolution_clock::now();
 	  i++;
 	}


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-24  9:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24  6:29 [gcc(refs/users/aoliva/heads/testme)] improve future::poll calibration loop Alexandre Oliva
  -- strict thread matches above, loose matches on Subject: below --
2021-03-24  9:15 Alexandre Oliva
2021-03-24  9:07 Alexandre Oliva
2021-03-23 12:34 Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).