Skip to content

Conversation

@DanielCChen
Copy link
Contributor

The openmp runtime failed to build on LoP with LLVM18 on LoP due to the addition of -Wvla-cxx-extension as

llvm-project/openmp/runtime/src/ompt-general.cpp:711:15: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
  711 |   int tmp_ids[ids_size];
      |               ^~~~~~~~
llvm-project/openmp/runtime/src/ompt-general.cpp:711:15: note: function parameter 'ids_size' with unknown value cannot be used in a constant expression
llvm-project/openmp/runtime/src/ompt-general.cpp:704:65: note: declared here
  704 | OMPT_API_ROUTINE int ompt_get_place_proc_ids(int place_num, int ids_size,
      |                                                                 ^
1 error generated.

This patch is to ignore the checking against this usage.

@DanielCChen DanielCChen self-assigned this Nov 1, 2024
@llvmbot llvmbot added the openmp:libomp OpenMP host runtime label Nov 1, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 1, 2024

@llvm/pr-subscribers-openmp

Author: Daniel Chen (DanielCChen)

Changes

The openmp runtime failed to build on LoP with LLVM18 on LoP due to the addition of -Wvla-cxx-extension as

llvm-project/openmp/runtime/src/ompt-general.cpp:711:15: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
  711 |   int tmp_ids[ids_size];
      |               ^~~~~~~~
llvm-project/openmp/runtime/src/ompt-general.cpp:711:15: note: function parameter 'ids_size' with unknown value cannot be used in a constant expression
llvm-project/openmp/runtime/src/ompt-general.cpp:704:65: note: declared here
  704 | OMPT_API_ROUTINE int ompt_get_place_proc_ids(int place_num, int ids_size,
      |                                                                 ^
1 error generated.

This patch is to ignore the checking against this usage.


Full diff: https://github.com/llvm/llvm-project/pull/114583.diff

1 Files Affected:

  • (modified) openmp/runtime/src/ompt-general.cpp (+3)
diff --git a/openmp/runtime/src/ompt-general.cpp b/openmp/runtime/src/ompt-general.cpp
index 923eea2a563a91..c96bb3153b8a89 100644
--- a/openmp/runtime/src/ompt-general.cpp
+++ b/openmp/runtime/src/ompt-general.cpp
@@ -708,6 +708,9 @@ OMPT_API_ROUTINE int ompt_get_place_proc_ids(int place_num, int ids_size,
   return 0;
 #else
   int i, count;
+#ifdef __clang_major__ >= 18
+#pragma clang diagnostic ignored "-Wvla-cxx-extension"
+#endif
   int tmp_ids[ids_size];
   for (int j = 0; j < ids_size; j++)
     tmp_ids[j] = 0;

@jhuber6
Copy link
Contributor

jhuber6 commented Nov 1, 2024

I would prefer we remove the VLA access, but I don't know how difficult it is for this case.

Copy link
Contributor

@shiltian shiltian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is wrong. I previous added a VLA-equal template thing in libomp and replaced all uses there. Can you move it somewhere common such that ompt can also use it?

@DanielCChen
Copy link
Contributor Author

No, this is wrong. I previous added a VLA-equal template thing in libomp and replaced all uses there. Can you move it somewhere common such that ompt can also use it?

Thanks for the pointer! @shiltian
I am pretty sure this is the change you are referring to (eaab947).

I replaced the offending code in ompt-general.cpp as

//  int tmp_ids[ids_size];
  SimpleVLA<int> tmp_ids(ids_size);

and it fixed the issue.

Since kmp_utils.h only has SimpleVLA, I can either just include it in ompt-general.cpp, or rename it to something like omp_utility.h to be more general. Thoughts?

Copy link
Contributor

@shiltian shiltian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought ompt source file was in a separate directory. :-)

#if KMP_OS_UNIX
#include <dlfcn.h>
#endif
#include "kmp_utils.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put it in the right order?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put it in the right order?

Could you please be more specific? @shiltian

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanielCChen, I think https://llvm.org/docs/CodingStandards.html#include-style says that this header should be moved up. Indeed, it wouldn't fit under the "system include files" comment.

I don't know what to say about the include of ompt-specific.cpp (yes, .cpp!) below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That is what I meant.

I don't know what to say about the include of ompt-specific.cpp (yes, .cpp!) below.

Me neither. ;-) That is before libomp was contributed to LLVM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I will move it before the system #include then.

@DanielCChen DanielCChen changed the title [OpenMP] Ignore the error introduced by -Wvla-cxx-extension on ompt-general.cpp. [OpenMP] Using SimpleVLA to handle vla usage in ompt-general.cpp. Nov 4, 2024
@DanielCChen DanielCChen merged commit d3d8103 into llvm:main Nov 4, 2024
6 checks passed
@DanielCChen DanielCChen deleted the daniel_omp branch November 4, 2024 17:42
PhilippRados pushed a commit to PhilippRados/llvm-project that referenced this pull request Nov 6, 2024
…lvm#114583)

The `openmp` runtime failed to build on LoP with LLVM18 on LoP due to
the addition of `-Wvla-cxx-extension` as
```
llvm-project/openmp/runtime/src/ompt-general.cpp:711:15: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
  711 |   int tmp_ids[ids_size];
      |               ^~~~~~~~
llvm-project/openmp/runtime/src/ompt-general.cpp:711:15: note: function parameter 'ids_size' with unknown value cannot be used in a constant expression
llvm-project/openmp/runtime/src/ompt-general.cpp:704:65: note: declared here
  704 | OMPT_API_ROUTINE int ompt_get_place_proc_ids(int place_num, int ids_size,
      |                                                                 ^
1 error generated.
```

This patch is to ignore the checking against this usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

openmp:libomp OpenMP host runtime openmp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants