Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation errors using -fopenmp #6552

Closed
Pansysk75 opened this issue Oct 9, 2024 · 2 comments · Fixed by #6553
Closed

Compilation errors using -fopenmp #6552

Pansysk75 opened this issue Oct 9, 2024 · 2 comments · Fixed by #6553

Comments

@Pansysk75
Copy link
Member

HPX does not compile when using -fopenmp (or -fopenmp-simd) on Clang or GCC.

Clang: Can't use pragma in constexpr function

/work/pansysk75/hpx-test/hpx/libs/core/algorithms/include/hpx/parallel/unseq/reduce_helpers.hpp:134:13: error: statement not allowed in constexpr function
            HPX_VECTOR_REDUCTION(& : init)
            ^
/work/pansysk75/hpx-test/hpx/libs/core/config/include/hpx/config/auto_vectorization.hpp:61:38: note: expanded from macro 'HPX_VECTOR_REDUCTION'
#define HPX_VECTOR_REDUCTION(CLAUSE) HPX_PRAGMA(omp simd reduction(CLAUSE))
                                     ^
/work/pansysk75/hpx-test/hpx/libs/core/config/include/hpx/config/auto_vectorization.hpp:27:23: note: expanded from macro 'HPX_PRAGMA'
#define HPX_PRAGMA(x) _Pragma(#x)
                      ^

Clang/GCC: Loops in non-canonical form

/work/pansysk75/hpx-test/hpx/libs/core/algorithms/include/hpx/parallel/unseq/loop.hpp:269:21: error: initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')
                    for (/**/; count < num; (void) ++count, ++it, ++dest)
                    ^

/work/pansysk75/hpx-test/hpx/libs/core/algorithms/include/hpx/parallel/unseq/loop.hpp:229:78: error: expected ‘;’ before ‘)’ token
  229 |                     for (HPX_UNUSED(count); count < num; (void) ++count, ++it)
      |                                                                              ^

GCC: invalid increment expression

/work/pansysk75/hpx-test/hpx/libs/core/algorithms/include/hpx/parallel/util/loop.hpp:953:49: error: invalid increment expression
  953 |                     for (std::size_t i = 0; i < count;

@hkaiser Should we add feature tests for these, or just disable them for Clang/GCC? I suppose these were added with the Intel compiler in mind?

@hkaiser
Copy link
Member

hkaiser commented Oct 9, 2024

Should we add feature tests for these, or just disable them for Clang/GCC? I suppose these were added with the Intel compiler in mind?

They were created for gcc and clang :/ @Johan511 is this code part of your contributions?

I'd rather make the functions non-constexpr in this case and try to fix the other problems.

@Pansysk75 Pansysk75 linked a pull request Oct 9, 2024 that will close this issue
@Johan511
Copy link
Contributor

Johan511 commented Oct 9, 2024

The PR

The first error seems pretty self explanatory
second is because the variable is not initialized is loop body
third is because of 2 increments being done in the loop body

Unfortunately, openmp simd reduction is rather strict about how it wants the loop body to be
Working Example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants