- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would expect the two attached programs to give identical results, but they do not. Both are compiled with ifx, using the -qopenmp option for the do concurrent case. I realize that the do concurrent version does not initialize c to 0, but the standard says:
> Before execution of the iterations begins, the construct entity is assigned an initial value corresponding to its reduce-operation as specified in Table 11.1.
I'll also note that an equivalent openmp version does get the correct answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The array C has never been initialized and should be initialized independent of the DO CONCURRENT.
Inside the DO CONCURRENT, there are construct entities c that have the same type, rank, shape as c outside.
The construct entities are initialized to zero at the beginning of each iteration. At the end of the construct, the value of each construct entity is combined with the outside variable c. So, c1, c2, … cn are the construct entities for the n iterations of the loop.
After the loop c1, c2, … cn are combined with c the outside variable as if
c = c + c1 + c2 + … + cn
I set c=0.0 before the DO CONCURRENT construct and get the same answer as the serial and OpenMP versions.
GIGO... garbage in, garbage out.
See 11.1.7.5 Additional semantics of DO CONCURRENT constructs paragraph 5:
If a variable has REDUCE locality, on termination of the DO CONCURRENT construct the outside variable
is updated by combining it with the values the construct entity had at completion of each iteration, using the
reduce-operator. The processor may combine the values in any order.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'll take a look at this.
Which version of ifx are you using?
Please tell me the compiler options you are using other than -qopenmp.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FYI... You should use wall clock time to time parallel codes. system_clock gathers the CPU time for all threads.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As of 2035 the wall clock will no longer include leap seconds as the cost to industry is high. We are now divorced from the Sun God as the earth slows and a year is not a real year, whatever that means.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Barbara, I'm using ifx 2024.0.2 20231213, with only the -qopenmp option.
Thanks for the heads up about timing. Is the suggestion to use CPU_TIME? or DATE_AND_TIME?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
These are the routines I use for timing threaded applications.
- Intel Fortran has a function called etime, elapsed time. Here is more information.
- There's an OpenMP function, too, OMP_GET_WTIME().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The array C has never been initialized and should be initialized independent of the DO CONCURRENT.
Inside the DO CONCURRENT, there are construct entities c that have the same type, rank, shape as c outside.
The construct entities are initialized to zero at the beginning of each iteration. At the end of the construct, the value of each construct entity is combined with the outside variable c. So, c1, c2, … cn are the construct entities for the n iterations of the loop.
After the loop c1, c2, … cn are combined with c the outside variable as if
c = c + c1 + c2 + … + cn
I set c=0.0 before the DO CONCURRENT construct and get the same answer as the serial and OpenMP versions.
GIGO... garbage in, garbage out.
See 11.1.7.5 Additional semantics of DO CONCURRENT constructs paragraph 5:
If a variable has REDUCE locality, on termination of the DO CONCURRENT construct the outside variable
is updated by combining it with the values the construct entity had at completion of each iteration, using the
reduce-operator. The processor may combine the values in any order.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
:facepalm: "update" not "assign"
> If a variable has REDUCE locality, on termination of the DO CONCURRENT construct the outside variable is updated by combining it with the values the construct entity had at completion of each iteration, using the reduce-operation.
Sorry for misunderstanding.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page