Skip to content

[AMDGPU] Add code model (#70760) test for amdgpu target. #71019

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

Closed
wants to merge 7 commits into from

Conversation

pravinjagtap
Copy link
Contributor

Missed adding code model test during #70760.

@llvmbot
Copy link
Member

llvmbot commented Nov 2, 2023

@llvm/pr-subscribers-clang-driver
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-amdgpu

Author: Pravin Jagtap (pravinjagtap)

Changes

Missed adding code model test during #70760.


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

1 Files Affected:

  • (added) llvm/test/CodeGen/AMDGPU/codemodel.ll (+9)
diff --git a/llvm/test/CodeGen/AMDGPU/codemodel.ll b/llvm/test/CodeGen/AMDGPU/codemodel.ll
new file mode 100644
index 000000000000000..8b60257b2076aed
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/codemodel.ll
@@ -0,0 +1,9 @@
+; RUN: not llc -verify-machineinstrs -o - -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx900 -code-model=tiny < %s 2>&1 | FileCheck %s --check-prefix=TINY
+; RUN: not llc -verify-machineinstrs -o - -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx900 -code-model=kernel < %s 2>&1 | FileCheck %s --check-prefix=KERNEL
+
+; TINY:    Target does not support the tiny CodeModel
+; KERNEL:    Target does not support the kernel CodeModel
+
+define void @foo() {
+  ret void
+}

Copy link
Contributor

@arsenm arsenm left a comment

Choose a reason for hiding this comment

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

This doesn't test the driver behavior, which is what the patch changed. This should be a clang driver test, not codegen

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Nov 2, 2023
@@ -13,6 +13,11 @@
// RUN: not %clang -### -c --target=aarch64 -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=ERR-MEDIUM %s
// RUN: not %clang -### -c --target=aarch64 -mcmodel=kernel %s 2>&1 | FileCheck --check-prefix=ERR-KERNEL %s
// RUN: not %clang --target=aarch64_32-linux -### -S -mcmodel=small %s 2>&1 | FileCheck --check-prefix=ERR-AARCH64_32 %s
// RUN: %clang --target=amdgcn-amd-amdhsa -nogpulib -### -c -mcmodel=tiny %s 2>&1 | FileCheck --check-prefix=AMDGPU-MCMODEL-TINY %s
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure exactly what's being tested here, this looks like it's targeting C as a target? The more relevant case would be with amdgcn as the offload target. For direct compilation it would make more sense to emit the error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change is intended to handle all possible code models for AMDGPU target. Basically, we want to avoid erroring out for device side code models. Does it make sense to have negative case for amdgpu ?

Copy link
Contributor

Choose a reason for hiding this comment

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

There's 2 cases. The case where we're directly codegening to the target, in which case it behaves like a regular CPU target. That's what you're testing here, but it's somewhat unusual. We could error here as before.

The more realistic case is treating it as an offload target from OpenMP or HIP, so I think it's more important to test that case. We definitely don't want an error here.

Copy link
Contributor Author

@pravinjagtap pravinjagtap Nov 3, 2023

Choose a reason for hiding this comment

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

I think, recent updates to PR (3rd commit: 9dc7689983b74dd381df556bc9e61165e08d85b4) address both the cases you are referring to.

@@ -0,0 +1,9 @@
; RUN: not llc -verify-machineinstrs -o - -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx900 -code-model=tiny < %s 2>&1 | FileCheck %s --check-prefix=TINY
; RUN: not llc -verify-machineinstrs -o - -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx900 -code-model=kernel < %s 2>&1 | FileCheck %s --check-prefix=KERNEL
Copy link
Collaborator

Choose a reason for hiding this comment

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

need test for all -code-model values

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As matt suggested, this test is not exercising the code changes that I intended in #70760. So I will remove this test.

@yxsamliu
Copy link
Collaborator

yxsamliu commented Nov 6, 2023

I think we need to fix clang and not passing -mcmodel=tiny/kernel to clang -cc1.

https://github.com/llvm/llvm-project/pull/70760/files#r1383372722

probably we can do that in this PR

Copy link

github-actions bot commented Nov 7, 2023

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

@pravinjagtap pravinjagtap force-pushed the test-mcmode-amdgpu branch 2 times, most recently from 7b3d4dc to 30f98ec Compare November 16, 2023 06:55
Comment on lines +5775 to +5783
} else if (Triple.isAMDGPU()) {
// AMDGPU does not care about the code model.
Ok = true;
// AMDGPU target ignores CM tiny and kernel.
if (CM == "tiny" || CM == "kernel") {
Skip = true;
D.Diag(diag::warn_ignored_clang_option)
<< A->getSpelling() << CM << TripleStr;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is doing more than adding the test?

Copy link
Collaborator

@yxsamliu yxsamliu left a comment

Choose a reason for hiding this comment

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

LGTM. Please update PR title before merging

@arsenm
Copy link
Contributor

arsenm commented Feb 1, 2024

LGTM. Please update PR title before merging

So this was only supposed to add the test, or implement this too?

@arsenm
Copy link
Contributor

arsenm commented Feb 29, 2024

reverse ping

@pravinjagtap pravinjagtap deleted the test-mcmode-amdgpu branch March 1, 2024 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AMDGPU clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants