Skip to content

[offload][cmake] always define pythonize_bool macro #96028

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

Merged

Conversation

yingcong-wu
Copy link
Contributor

I use the following cmake config to build offload and openmp

cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS="clang;openmp"  -DLLVM_ENABLE_RUNTIMES="offload"  -DLLVM_LIT_ARGS="-vv -a" -DLLVM_ENABLE_ASSERTIONS=ON  ../llvm

and got the following error:

CMake Error at /tmp/build-llvm/llvm/offload/CMakeLists.txt:321 (pythonize_bool):
  Unknown CMake command "pythonize_bool". 

After some search I find out that the "correct" way to build this is putting openmp and offload to the ENABLE_RUNTIMES like

cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS="clang"  -DLLVM_ENABLE_RUNTIMES="openmp;offload"  -DLLVM_LIT_ARGS="-vv -a" -DLLVM_ENABLE_ASSERTIONS=ON  ../llvm

.

But since we don't forbid to config them using openmp as PROJECT and offload as RUNTIME, then we probably support it. The fix is to always define the pythonize_bool macro. For cmake, it is okay to redefine a macro, it does not cause a warning or else.

@llvmbot
Copy link
Member

llvmbot commented Jun 19, 2024

@llvm/pr-subscribers-offload

Author: Wu Yingcong (yingcong-wu)

Changes

I use the following cmake config to build offload and openmp

cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS="clang;openmp"  -DLLVM_ENABLE_RUNTIMES="offload"  -DLLVM_LIT_ARGS="-vv -a" -DLLVM_ENABLE_ASSERTIONS=ON  ../llvm

and got the following error:

CMake Error at /tmp/build-llvm/llvm/offload/CMakeLists.txt:321 (pythonize_bool):
  Unknown CMake command "pythonize_bool". 

After some search I find out that the "correct" way to build this is putting openmp and offload to the ENABLE_RUNTIMES like

cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS="clang"  -DLLVM_ENABLE_RUNTIMES="openmp;offload"  -DLLVM_LIT_ARGS="-vv -a" -DLLVM_ENABLE_ASSERTIONS=ON  ../llvm

.

But since we don't forbid to config them using openmp as PROJECT and offload as RUNTIME, then we probably support it. The fix is to always define the pythonize_bool macro. For cmake, it is okay to redefine a macro, it does not cause a warning or else.


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

1 Files Affected:

  • (modified) offload/CMakeLists.txt (+7-7)
diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index ead2aed414ffe..4cd97a6a5ff63 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -282,15 +282,15 @@ if(OPENMP_STANDALONE_BUILD)
       ${LLVM_LIBRARY_DIRS}
     REQUIRED
   )
+endif()
 
-  macro(pythonize_bool var)
-  if (${var})
-    set(${var} True)
-  else()
-    set(${var} False)
-  endif()
-  endmacro()
+macro(pythonize_bool var)
+if (${var})
+  set(${var} True)
+else()
+  set(${var} False)
 endif()
+endmacro()
 
 if(OPENMP_STANDALONE_BUILD OR TARGET omp)
   # Check LIBOMP_HAVE_VERSION_SCRIPT_FLAG

@shiltian
Copy link
Contributor

Will it cause issue if you have compiler-rt and openmp both in LLVM_ENABLE_PROJECTS?

@yingcong-wu
Copy link
Contributor Author

Yes, that would still have the same problem. The problem of only putting offload to LLVM_ENABLE_RUNTIMES is that it does not define its pythonize_bool in this case(if I put openmp to LLVM_ENABLE_RUNTIMES, then offload will use the pythonize_bool defined in openmp and will not have this problem), so I am trying to make it always define the pythonize_bool.

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.

LG

@yingcong-wu
Copy link
Contributor Author

Hi @shiltian , I don't have commit access, could you please help land this PR for me? Thanks.

@jhuber6 jhuber6 merged commit 8984113 into llvm:main Jun 20, 2024
7 checks passed
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
I use the following cmake config to build offload and openmp
```
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS="clang;openmp"  -DLLVM_ENABLE_RUNTIMES="offload"  -DLLVM_LIT_ARGS="-vv -a" -DLLVM_ENABLE_ASSERTIONS=ON  ../llvm
```
and got the following error:
```
CMake Error at /tmp/build-llvm/llvm/offload/CMakeLists.txt:321 (pythonize_bool):
  Unknown CMake command "pythonize_bool". 
```

After some search I find out that the "correct" way to build this is
putting openmp and offload to the ENABLE_RUNTIMES like
```
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS="clang"  -DLLVM_ENABLE_RUNTIMES="openmp;offload"  -DLLVM_LIT_ARGS="-vv -a" -DLLVM_ENABLE_ASSERTIONS=ON  ../llvm
```
.


But since we don't forbid to config them using openmp as PROJECT and
offload as RUNTIME, then we probably support it. The fix is to always
define the pythonize_bool macro. For cmake, it is okay to redefine a
macro, it does not cause a warning or else.
@yingcong-wu yingcong-wu deleted the yc/240619-always-define-pythonize_bool branch November 13, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants