countable loops and OpenMP
up vote
0
down vote
favorite
Some OpenMP related documents state that in order for a loop to be treated by OpenMP it must be “countable” providing different definitions for a loop being “countable”:
• the number of iterations in the loop must be countable
with an integer and loop use a fixed increment.
• the loop count can be “determined” ( what does it mean “determined”? )
Is it indeed the requirement of OpenMP? Or is it requirement of a specific compiler implementation of OpenMP?
Also, can the following loop - doesn't seems to be countable - be parallelized by OpenMP ( note that the question is if the code can be pararallelized and not if there is a way to create a parallel equivalent of this code )
for ( i = 0; i < cnt; )
{
x1 = 2.0 * x - 1.;
if ( x1 < 1.0 )
{
i = i + 3;
x = x*2.;
}
else // if ( x1 >= 1. )
{
i = i + 2;
x = x/2.;
}
}
parallel-processing openmp
add a comment |
up vote
0
down vote
favorite
Some OpenMP related documents state that in order for a loop to be treated by OpenMP it must be “countable” providing different definitions for a loop being “countable”:
• the number of iterations in the loop must be countable
with an integer and loop use a fixed increment.
• the loop count can be “determined” ( what does it mean “determined”? )
Is it indeed the requirement of OpenMP? Or is it requirement of a specific compiler implementation of OpenMP?
Also, can the following loop - doesn't seems to be countable - be parallelized by OpenMP ( note that the question is if the code can be pararallelized and not if there is a way to create a parallel equivalent of this code )
for ( i = 0; i < cnt; )
{
x1 = 2.0 * x - 1.;
if ( x1 < 1.0 )
{
i = i + 3;
x = x*2.;
}
else // if ( x1 >= 1. )
{
i = i + 2;
x = x/2.;
}
}
parallel-processing openmp
You can't parallelize that loop as-is because the index depends on the result of the previous iteration, i.e. you have a dependency. That countable only refers tocnt
being known at the instant we enter the loop andi
being incremented in some trivial way.
– Qubit
yesterday
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Some OpenMP related documents state that in order for a loop to be treated by OpenMP it must be “countable” providing different definitions for a loop being “countable”:
• the number of iterations in the loop must be countable
with an integer and loop use a fixed increment.
• the loop count can be “determined” ( what does it mean “determined”? )
Is it indeed the requirement of OpenMP? Or is it requirement of a specific compiler implementation of OpenMP?
Also, can the following loop - doesn't seems to be countable - be parallelized by OpenMP ( note that the question is if the code can be pararallelized and not if there is a way to create a parallel equivalent of this code )
for ( i = 0; i < cnt; )
{
x1 = 2.0 * x - 1.;
if ( x1 < 1.0 )
{
i = i + 3;
x = x*2.;
}
else // if ( x1 >= 1. )
{
i = i + 2;
x = x/2.;
}
}
parallel-processing openmp
Some OpenMP related documents state that in order for a loop to be treated by OpenMP it must be “countable” providing different definitions for a loop being “countable”:
• the number of iterations in the loop must be countable
with an integer and loop use a fixed increment.
• the loop count can be “determined” ( what does it mean “determined”? )
Is it indeed the requirement of OpenMP? Or is it requirement of a specific compiler implementation of OpenMP?
Also, can the following loop - doesn't seems to be countable - be parallelized by OpenMP ( note that the question is if the code can be pararallelized and not if there is a way to create a parallel equivalent of this code )
for ( i = 0; i < cnt; )
{
x1 = 2.0 * x - 1.;
if ( x1 < 1.0 )
{
i = i + 3;
x = x*2.;
}
else // if ( x1 >= 1. )
{
i = i + 2;
x = x/2.;
}
}
parallel-processing openmp
parallel-processing openmp
edited yesterday
Zulan
14.9k62868
14.9k62868
asked yesterday
David Livshin
14
14
You can't parallelize that loop as-is because the index depends on the result of the previous iteration, i.e. you have a dependency. That countable only refers tocnt
being known at the instant we enter the loop andi
being incremented in some trivial way.
– Qubit
yesterday
add a comment |
You can't parallelize that loop as-is because the index depends on the result of the previous iteration, i.e. you have a dependency. That countable only refers tocnt
being known at the instant we enter the loop andi
being incremented in some trivial way.
– Qubit
yesterday
You can't parallelize that loop as-is because the index depends on the result of the previous iteration, i.e. you have a dependency. That countable only refers to
cnt
being known at the instant we enter the loop and i
being incremented in some trivial way.– Qubit
yesterday
You can't parallelize that loop as-is because the index depends on the result of the previous iteration, i.e. you have a dependency. That countable only refers to
cnt
being known at the instant we enter the loop and i
being incremented in some trivial way.– Qubit
yesterday
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
The OpenMP standard requires the Canonical Loop Form
The canonical form allows the iteration count of all associated loops to be computed before executing the outermost loop. The computation is performed for each loop in an integer type.
This isn't exactly restricted to integers, you may use pointer types in C and random access iterator types in C++ which are logically translated to integers.
The loop variable must not be modified within the for loop (except for the increment expression). Therefore your example is not valid OpenMP code.
Further restrictions are that the loop test must be a relation comparison <
, <=
, >
, or >=
- not !=
or something more complex. The increment must be constant throughout the loop. The missing increment expression in your example also invalidates it.
You can read about this in the OpenMP standard section 2.6.
That is what I don't understand: what does it mean: "computed"? ( or sometimes referred as: "determined" ).
– David Livshin
yesterday
Say the loop count is something like(upper_limit - lower_limit) / increment
. Computing it means that you know the value to be a specific number e.g.42
before executing the loop.
– Zulan
yesterday
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The OpenMP standard requires the Canonical Loop Form
The canonical form allows the iteration count of all associated loops to be computed before executing the outermost loop. The computation is performed for each loop in an integer type.
This isn't exactly restricted to integers, you may use pointer types in C and random access iterator types in C++ which are logically translated to integers.
The loop variable must not be modified within the for loop (except for the increment expression). Therefore your example is not valid OpenMP code.
Further restrictions are that the loop test must be a relation comparison <
, <=
, >
, or >=
- not !=
or something more complex. The increment must be constant throughout the loop. The missing increment expression in your example also invalidates it.
You can read about this in the OpenMP standard section 2.6.
That is what I don't understand: what does it mean: "computed"? ( or sometimes referred as: "determined" ).
– David Livshin
yesterday
Say the loop count is something like(upper_limit - lower_limit) / increment
. Computing it means that you know the value to be a specific number e.g.42
before executing the loop.
– Zulan
yesterday
add a comment |
up vote
0
down vote
The OpenMP standard requires the Canonical Loop Form
The canonical form allows the iteration count of all associated loops to be computed before executing the outermost loop. The computation is performed for each loop in an integer type.
This isn't exactly restricted to integers, you may use pointer types in C and random access iterator types in C++ which are logically translated to integers.
The loop variable must not be modified within the for loop (except for the increment expression). Therefore your example is not valid OpenMP code.
Further restrictions are that the loop test must be a relation comparison <
, <=
, >
, or >=
- not !=
or something more complex. The increment must be constant throughout the loop. The missing increment expression in your example also invalidates it.
You can read about this in the OpenMP standard section 2.6.
That is what I don't understand: what does it mean: "computed"? ( or sometimes referred as: "determined" ).
– David Livshin
yesterday
Say the loop count is something like(upper_limit - lower_limit) / increment
. Computing it means that you know the value to be a specific number e.g.42
before executing the loop.
– Zulan
yesterday
add a comment |
up vote
0
down vote
up vote
0
down vote
The OpenMP standard requires the Canonical Loop Form
The canonical form allows the iteration count of all associated loops to be computed before executing the outermost loop. The computation is performed for each loop in an integer type.
This isn't exactly restricted to integers, you may use pointer types in C and random access iterator types in C++ which are logically translated to integers.
The loop variable must not be modified within the for loop (except for the increment expression). Therefore your example is not valid OpenMP code.
Further restrictions are that the loop test must be a relation comparison <
, <=
, >
, or >=
- not !=
or something more complex. The increment must be constant throughout the loop. The missing increment expression in your example also invalidates it.
You can read about this in the OpenMP standard section 2.6.
The OpenMP standard requires the Canonical Loop Form
The canonical form allows the iteration count of all associated loops to be computed before executing the outermost loop. The computation is performed for each loop in an integer type.
This isn't exactly restricted to integers, you may use pointer types in C and random access iterator types in C++ which are logically translated to integers.
The loop variable must not be modified within the for loop (except for the increment expression). Therefore your example is not valid OpenMP code.
Further restrictions are that the loop test must be a relation comparison <
, <=
, >
, or >=
- not !=
or something more complex. The increment must be constant throughout the loop. The missing increment expression in your example also invalidates it.
You can read about this in the OpenMP standard section 2.6.
answered yesterday
Zulan
14.9k62868
14.9k62868
That is what I don't understand: what does it mean: "computed"? ( or sometimes referred as: "determined" ).
– David Livshin
yesterday
Say the loop count is something like(upper_limit - lower_limit) / increment
. Computing it means that you know the value to be a specific number e.g.42
before executing the loop.
– Zulan
yesterday
add a comment |
That is what I don't understand: what does it mean: "computed"? ( or sometimes referred as: "determined" ).
– David Livshin
yesterday
Say the loop count is something like(upper_limit - lower_limit) / increment
. Computing it means that you know the value to be a specific number e.g.42
before executing the loop.
– Zulan
yesterday
That is what I don't understand: what does it mean: "computed"? ( or sometimes referred as: "determined" ).
– David Livshin
yesterday
That is what I don't understand: what does it mean: "computed"? ( or sometimes referred as: "determined" ).
– David Livshin
yesterday
Say the loop count is something like
(upper_limit - lower_limit) / increment
. Computing it means that you know the value to be a specific number e.g. 42
before executing the loop.– Zulan
yesterday
Say the loop count is something like
(upper_limit - lower_limit) / increment
. Computing it means that you know the value to be a specific number e.g. 42
before executing the loop.– Zulan
yesterday
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369295%2fcountable-loops-and-openmp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You can't parallelize that loop as-is because the index depends on the result of the previous iteration, i.e. you have a dependency. That countable only refers to
cnt
being known at the instant we enter the loop andi
being incremented in some trivial way.– Qubit
yesterday