-
Notifications
You must be signed in to change notification settings - Fork 769
[sycl-post-link] Don't remove llvm.compiler.used for NVPTX #15224
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
Changes from all commits
72a6032
74fa7ba
3f9ae01
1b8c225
4b06c76
d3c9529
e852cbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
;; This test verifies llc on AMDGCN will delete the llvm.compiler.used symbol | ||
;; while keeping the symbol in the outputted ASM. | ||
|
||
; RUN: llc < %s -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 | FileCheck %s | ||
; RUN: llc < %s -mtriple=amdgcn-amd-amdhsa -mcpu=gfx906 | FileCheck %s | ||
; RUN: llc < %s -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a | FileCheck %s | ||
|
||
@keep_this = internal global i32 2, align 4 | ||
@llvm.compiler.used = appending global [1 x ptr] [ptr @keep_this], section "llvm.metadata" | ||
|
||
; CHECK-NOT: llvm.metadata | ||
; CHECK-NOT: llvm{{.*}}used | ||
; CHECK-NOT: llvm{{.*}}compiler{{.*}}used | ||
|
||
; CHECK: .type keep_this,@object ; | ||
|
||
; CHECK-NOT: llvm.metadata | ||
; CHECK-NOT: llvm{{.*}}used | ||
; CHECK-NOT: llvm{{.*}}compiler{{.*}}used |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
;; This test verifies llc on NVPTX will delete the llvm.compiler.used symbol | ||
;; while keeping the symbol in the outputted ASM. | ||
|
||
; RUN: llc < %s -march=nvptx64 | FileCheck %s | ||
|
||
@keep_this = internal global i32 2, align 4 | ||
@llvm.compiler.used = appending global [1 x ptr] [ptr @keep_this], section "llvm.metadata" | ||
|
||
; CHECK-NOT: llvm.metadata | ||
; CHECK-NOT: llvm{{.*}}used | ||
; CHECK-NOT: llvm{{.*}}compiler{{.*}}used | ||
|
||
; CHECK: .global .align 4 .u32 keep_this | ||
|
||
; CHECK-NOT: llvm.metadata | ||
; CHECK-NOT: llvm{{.*}}used | ||
; CHECK-NOT: llvm{{.*}}compiler{{.*}}used |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
// | ||
// The OpenCL GPU backends do not currently support device_global backend | ||
// calls. | ||
// UNSUPPORTED: opencl && gpu | ||
// | ||
// Tests static device_global access through device kernels. | ||
|
||
#include "common.hpp" | ||
|
||
static device_global<int[4], TestProperties> DeviceGlobalVar; | ||
|
||
int main() { | ||
queue Q; | ||
|
||
Q.single_task([=]() { DeviceGlobalVar.get()[0] = 42; }); | ||
// Make sure that the write happens before subsequent read | ||
Q.wait(); | ||
|
||
int OutVal = 0; | ||
{ | ||
buffer<int, 1> OutBuf(&OutVal, 1); | ||
Q.submit([&](handler &CGH) { | ||
auto OutAcc = OutBuf.get_access<access::mode::write>(CGH); | ||
CGH.single_task([=]() { OutAcc[0] = DeviceGlobalVar.get()[0]; }); | ||
}); | ||
} | ||
assert(OutVal == 42 && "Read value does not match."); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Tests that the llvm.compiler.used symbol, which is used to implement static | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit of a mess but the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the latest stage it is being removed? Why can't we have test for that component? Is the "mess" final, or do we expect pipelines to be unified? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need a test when programmer uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If image compression is "opt-in" and we will not opt in in this test, then why is this an issue @aelovikov-intel ? It seems unlikely that binary formatting is going to change drastically in the next while, and if it does then I think this test will be the least of our problems. I am using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for response @uditagarwal97 :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated the test to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because that's an implementation detail of something unrelated to your test and it must not make any assumptions of it. |
||
// device globals, is removed at some point in compilation. For SPIR-V this | ||
// symbol is removed at sycl-post-link and for NVPTX/AMDGCN it is removed at | ||
// lowering. | ||
// | ||
// It also checks that the symbol can be found in an object file for a given | ||
// triple, thus validating that `llvm-strings` can successfully be used to | ||
// check for the presence of the symbol. | ||
|
||
// UNSUPPORTED: windows | ||
|
||
// RUN: %clangxx -fsycl -fsycl-device-only %s -o %t | ||
// RUN: llvm-strings %t | grep "llvm.compiler.used" | ||
// RUN: %clangxx -fsycl %s -o %t | ||
// RUN: llvm-strings %t | not grep "llvm.compiler.used" | ||
|
||
// RUN: %if cuda %{ %clangxx -fsycl -fsycl-device-only -fsycl-targets=nvptx64-nvidia-cuda %s -o %t %} | ||
// RUN: %if cuda %{ llvm-strings %t | grep "llvm.compiler.used" %} | ||
// RUN: %if cuda %{ %clangxx -fsycl -fsycl-targets=nvptx64-nvidia-cuda %s -o %t %} | ||
// RUN: %if cuda %{ llvm-strings %t | not grep "llvm.compiler.used" %} | ||
|
||
// RUN: %if hip_amd %{ %clangxx -fsycl -fsycl-device-only -fsycl-targets=amd_gpu_gfx906 %s -o %t %} | ||
// RUN: %if hip_amd %{ llvm-strings %t | grep "llvm.compiler.used" %} | ||
// RUN: %if hip_amd %{ %clangxx -fsycl -fsycl-targets=amd_gpu_gfx906 %s -o %t %} | ||
// RUN: %if hip_amd %{ llvm-strings %t | not grep "llvm.compiler.used" %} | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
using namespace sycl; | ||
using namespace sycl::ext::oneapi::experimental; | ||
|
||
static device_global<int> DeviceGlobalVar; | ||
|
||
int main() { | ||
sycl::queue{}.single_task([=] { volatile int ReadVal = DeviceGlobalVar; }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We intend to replace the translator with SPIR-V backend eventually. Can we remove the check at that point of time?
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the SPIRV backend is being used instead of
llvm-spirv
I think it'd be better to remove thellvm.compiler.used
symbol in the backend, instead of insycl-post-link
, although some might disagree. I think it's OK to keep the current behaviour for the moment unless it becomes a problem later.