Skip to content

Conversation

@arsenm
Copy link
Contributor

@arsenm arsenm commented Dec 8, 2025

No description provided.

Copy link
Contributor Author

arsenm commented Dec 8, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arsenm arsenm marked this pull request as ready for review December 8, 2025 18:24
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Dec 8, 2025
@llvmbot
Copy link
Member

llvmbot commented Dec 8, 2025

@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-clang

Author: Matt Arsenault (arsenm)

Changes

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

1 Files Affected:

  • (modified) clang/test/Headers/cuda_with_openmp.cu (+1-1)
diff --git a/clang/test/Headers/cuda_with_openmp.cu b/clang/test/Headers/cuda_with_openmp.cu
index 8ea0de5972ff2..efde4ecdc6626 100644
--- a/clang/test/Headers/cuda_with_openmp.cu
+++ b/clang/test/Headers/cuda_with_openmp.cu
@@ -2,7 +2,7 @@
 // Reported in https://bugs.llvm.org/show_bug.cgi?id=48014
 ///==========================================================================///
 
-// REQUIRES: nvptx-registered-target, host-supports-cuda
+// REQUIRES: nvptx-registered-target
 
 // RUN: %clang -x cuda -fopenmp -c %s -o - --cuda-path=%S/../Driver/Inputs/CUDA/usr/local/cuda -nocudalib -isystem %S/Inputs/include -isystem %S/../../lib/Headers -fsyntax-only
 

@Artem-B
Copy link
Member

Artem-B commented Dec 8, 2025

The change looks OK to me, but I don't have enough context to tell if there's something special about OpenMP parts.
@jhuber6 may be the best person to stamp this PR.

@arsenm
Copy link
Contributor Author

arsenm commented Dec 8, 2025

This came from 6106b94 but is the wrong condition, I can't guess what zos actually cares about

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

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

Should work since we pass -nocudalib, probably just leftover so it's best to get rid of it. In the past I've tested stuff like this by just temporarily renaming my local CUDA installation so it wasn't found by default

@perry-ca
Copy link
Contributor

perry-ca commented Dec 8, 2025

This test will fail on z/OS without a resource requirement for cuda. I get these errors when running this test:

clang: warning: argument unused during compilation: '-c' [-Wunused-command-line-argument]
In file included from <built-in>:1:
In file included from ./../../lib/Headers/__clang_cuda_runtime_wrapper.h:158:
./../../lib/Headers/__clang_cuda_math.h:284:13: error: use of undeclared identifier 'INT_MAX'
  284 |   if (__b > INT_MAX)
      |             ^~~~~~~
./../../lib/Headers/__clang_cuda_math.h:286:13: error: use of undeclared identifier 'INT_MIN'
  286 |   if (__b < INT_MIN)
      |             ^~~~~~~
./../../lib/Headers/__clang_cuda_math.h:291:13: error: use of undeclared identifier 'INT_MAX'
  291 |   if (__b > INT_MAX)
      |             ^~~~~~~
./../../lib/Headers/__clang_cuda_math.h:293:13: error: use of undeclared identifier 'INT_MIN'
  293 |   if (__b < INT_MIN)
      |             ^~~~~~~
4 errors generated when compiling for sm_52.

Is there a better resource to require? This does require the the target support cuda.

@perry-ca
Copy link
Contributor

perry-ca commented Dec 8, 2025

I noticed the test case includes real system headers (see the option -isystem %S/../../lib/Headers) and not platform independent stubs. That makes the lit test highly unportable.

@arsenm
Copy link
Contributor Author

arsenm commented Dec 8, 2025

This test will fail on z/OS without a resource requirement for cuda. I get these errors when running this test:

clang: warning: argument unused during compilation: '-c' [-Wunused-command-line-argument]
In file included from <built-in>:1:
In file included from ./../../lib/Headers/__clang_cuda_runtime_wrapper.h:158:
./../../lib/Headers/__clang_cuda_math.h:284:13: error: use of undeclared identifier 'INT_MAX'
  284 |   if (__b > INT_MAX)
      |             ^~~~~~~
./../../lib/Headers/__clang_cuda_math.h:286:13: error: use of undeclared identifier 'INT_MIN'
  286 |   if (__b < INT_MIN)
      |             ^~~~~~~
./../../lib/Headers/__clang_cuda_math.h:291:13: error: use of undeclared identifier 'INT_MAX'
  291 |   if (__b > INT_MAX)
      |             ^~~~~~~
./../../lib/Headers/__clang_cuda_math.h:293:13: error: use of undeclared identifier 'INT_MIN'
  293 |   if (__b < INT_MIN)
      |             ^~~~~~~
4 errors generated when compiling for sm_52.

Looks like a missing limits.h include in __clang_cuda_runtime_wrapper.h?

Is there a better resource to require?

This shouldn't require any host resource

This does require the the target support cuda.

No it doesn't, the extent that Cuda is required is the fake path to the headers

@perry-ca
Copy link
Contributor

perry-ca commented Dec 8, 2025

Another thing with this test is the -fopenmp option. z/OS doesn't support openmp. It at least needs a line saying unsupported when targeting z/OS. The problem with not using fake headers also needs to be addressed so testing other targets from z/OS works.

@arsenm
Copy link
Contributor Author

arsenm commented Dec 8, 2025

I noticed the test case includes real system headers (see the option -isystem %S/../../lib/Headers) and not platform independent stubs. That makes the lit test highly unportable.

Those aren't real system headers, that's pointing to clang/test/Headers/Inputs/

@arsenm arsenm force-pushed the users/arsenm/clang/remove-unnecessary-host-supports-cuda-test branch from 48a06fb to b966209 Compare December 8, 2025 19:40
@llvmbot llvmbot added backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics labels Dec 8, 2025
@perry-ca
Copy link
Contributor

perry-ca commented Dec 8, 2025

I noticed the test case includes real system headers (see the option -isystem %S/../../lib/Headers) and not platform independent stubs. That makes the lit test highly unportable.

Those aren't real system headers, that's pointing to clang/test/Headers/Inputs/

It's actually clang/test/Headers/../../lib/Headers which becomes clang/lib/Headers. Those are the real clang wrappers headers and they include system headers that don't resolve to the fake ones. For some reason the -H option doesn't work with the cuda processing otherwise I'd produce a list of the includes so we had something to work with.

@arsenm
Copy link
Contributor Author

arsenm commented Dec 8, 2025

Using explicit zOS run line demonstrates the host issue, so I added one of those, but the limits include is enough to fix it. This is still syntax only so the lack of codegen support shouldn't matter

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@perry-ca
Copy link
Contributor

perry-ca commented Dec 8, 2025

Thanks for the changes. I applied the change to the wrapper to include <climits>. That solved the compile error when running the clang command. I appear to have a single target build as running the test with llvm-lit is giving unsupported as the result. I'll rebuild and try llvm-lit again.

I don't think we need the other change to the .cu file. Won't that run the clang command twice if the user builds clang multi target. I think adding the climits solved the problem.

@arsenm
Copy link
Contributor Author

arsenm commented Dec 8, 2025

Thanks for the changes. I applied the change to the wrapper to include <climits>. That solved the compile error when running the clang command. I appear to have a single target build as running the test with llvm-lit is giving unsupported as the result. I'll rebuild and try llvm-lit again.

It should still be running the one supported run line and skipping the other (plus it still depends on nvptx, so you need at least those 2)

I don't think we need the other change to the .cu file. Won't that run the clang command twice if the user builds clang multi target. I think adding the climits solved the problem.

Yes, it will run twice. It catches the missed limits include from the zos run line, which is better than waiting for a failure on a zos host

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

Labels

backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants