canonical for-loop test-expr

Discuss the OpenMP 3.0 API Specifications with the OpenMP Arch. Review Board. (Read Only)

canonical for-loop test-expr

Postby nathanweeks » Sun Jul 12, 2009 7:17 pm

I have a comment regarding the use of test expressions of the form "b relational-op var" with C/C++ loop constructs. The OpenMP 3.0 API states the following:

Page 39, line 6 (canonical form of a for-loop)
Code: Select all
for (init-expr; test-expr; incr-expr) structured-block


Page 39, lines 12-14
Code: Select all
test-expr     One of the following:
                     var relational-op b
                     b relational-op var


Page 39, lines 34-38
Code: Select all
relational-op   One of the following:
                      <
                      <=
                      >
                      >=


Page 45, lines 8-10
Code: Select all
If relational-op is < or <= then incr-expr must cause var to increase on each
iteration of the loop. Conversely, if relational-op is > or >= then incr-expr
must cause var to decrease on each iteration of the loop.


However, if test-expr is of the form "b < var", and the value of var must be
increased on each iteration of the loop, then test-expr will always evaluate to true
(barring any wrap-around) if it wasn't false to begin with. Similarly, if test-expr is
of the form "b > var", and the value of var must be decreased on each iteration of the loop,
then test-expr will always evaluate to true if (again, disregarding wrap-around) if it wasn't
false to begin with.

--
Nathan Weeks
--
Nathan Weeks
Iowa State University HPC Group
http://weeks.public.iastate.edu/
nathanweeks
 
Posts: 41
Joined: Sun May 17, 2009 6:19 am
Location: Iowa State University

Re: canonical for-loop test-expr

Postby lfm » Thu Jul 16, 2009 8:13 am

Thanks, Nathan. I believe that you're correct, and that the wording was always assuming the 'var rel=op b' form. I'll bring this to the attention of the language committee.

Regards,

-- Larry
lfm
 
Posts: 135
Joined: Sun Oct 21, 2007 4:58 pm
Location: OpenMP ARB

Re: canonical for-loop test-expr

Postby bronis » Thu Jul 16, 2009 1:58 pm

Nathan:

I agree that you are correct. I have created a ticket to correct this mistake for OpenMP 3.1, which the Language Committee is actively working on at this time. If you are interested, the error arose in the 3.0 specification when test-expr was expanded to allow the use of b relational-op var.

Thanks for noticing this,

Bronis
bronis
 
Posts: 5
Joined: Thu Oct 09, 2008 4:38 am


Return to OpenMP 3.0 API Specifications

Who is online

Users browsing this forum: No registered users and 2 guests

cron