-
Notifications
You must be signed in to change notification settings - Fork 768
[SYCL] Generalize GlobalOffset and enable it for AMDGPU #5855
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
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1f4034e
[SYCL] Correctly set global offset for HIP
jchlanda 8d33c4a
[SYCL] Use MDNode to annotate SYCL kernels on AMD
jchlanda 47f1721
[SYCL] Introduce SYCL lower IR target helpers
jchlanda 8212755
[SYCL] Generalize SYCL global offset pass
jchlanda 4fb0d97
[SYCL] Run global offset on AMDGPU
jchlanda a916ce6
[LIBCLC] Add proper support for get_global_offset for AMD
jchlanda ffddff3
[SYCL] Global offset docs
jchlanda fa945e6
[SYCL] Use SYCLKernelAttr for AMDGCN metadata generation
jchlanda 7997a2d
[SYCL] Add test for kernel annotations
jchlanda 2c433e9
PR comments addressed.
jchlanda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// RUN: %clang_cc1 -triple spir64-unknown-unknown -fsycl-is-device \ | ||
// RUN: -S -emit-llvm %s -o %temp.ll | ||
// RUN: FileCheck -check-prefix=CHECK-SPIR --input-file %temp.ll %s | ||
|
||
// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fsycl-is-device \ | ||
// RUN: -S -emit-llvm %s -o %temp.ll | ||
// RUN: FileCheck -check-prefix=CHECK-NVPTX --input-file %temp.ll %s | ||
|
||
// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -fsycl-is-device \ | ||
// RUN: -S -emit-llvm %s -o %temp.ll | ||
// RUN: FileCheck -check-prefix=CHECK-AMDGCN --input-file %temp.ll %s | ||
|
||
// The test makes sure that `[nnvm|amdgcn].annotations are correctly generated | ||
// only for their respective targets. | ||
|
||
#include "Inputs/sycl.hpp" | ||
|
||
sycl::handler H; | ||
|
||
class Functor { | ||
public: | ||
void operator()() const {} | ||
}; | ||
|
||
// CHECK-SPIR-NOT: annotations = | ||
|
||
// CHECK-NVPTX: nvvm.annotations = !{[[FIRST:![0-9]]], [[SECOND:![0-9]]]} | ||
// CHECK-NVPTX: [[FIRST]] = !{void ()* @_ZTS7Functor, !"kernel", i32 1} | ||
// CHECK-NVPTX: [[SECOND]] = !{void ()* @_ZTSZZ4mainENKUlRN2cl4sycl7handlerEE0_clES2_E5foo_2, !"kernel", i32 1} | ||
|
||
// CHECK-AMDGCN: amdgcn.annotations = !{[[FIRST:![0-9]]], [[SECOND:![0-9]]]} | ||
// CHECK-AMDGCN: [[FIRST]] = !{void ()* @_ZTS7Functor, !"kernel", i32 1} | ||
// CHECK-AMDGCN: [[SECOND]] = !{void ()* @_ZTSZZ4mainENKUlRN2cl4sycl7handlerEE0_clES2_E5foo_2, !"kernel", i32 1} | ||
|
||
int main() { | ||
sycl::queue q; | ||
q.submit([&](sycl::handler &cgh) { | ||
Functor foo{}; | ||
cgh.single_task(foo); | ||
}); | ||
|
||
q.submit([&](cl::sycl::handler &cgh) { | ||
cgh.parallel_for<class foo_2>(cl::sycl::range<1>(1), | ||
[=](cl::sycl::item<1> item) { | ||
}); | ||
}); | ||
return 0; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
|
||
workitem/get_global_offset.ll | ||
group/collectives.cl | ||
group/collectives_helpers.ll | ||
atomic/loadstore_helpers.ll | ||
|
42 changes: 42 additions & 0 deletions
42
libclc/amdgcn-amdhsa/libspirv/workitem/get_global_offset.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
;;===----------------------------------------------------------------------===// | ||
;; | ||
;; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
;; See https://llvm.org/LICENSE.txt for license information. | ||
;; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
;; | ||
;;===----------------------------------------------------------------------===// | ||
|
||
#if __clang_major__ >= 7 | ||
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7" | ||
#else | ||
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7" | ||
#endif | ||
|
||
; Function Attrs: nounwind readnone speculatable | ||
declare i32 addrspace(5)* @llvm.amdgcn.implicit.offset() | ||
|
||
define hidden i64 @_Z22__spirv_GlobalOffset_xv() nounwind alwaysinline { | ||
entry: | ||
%0 = tail call i32 addrspace(5)* @llvm.amdgcn.implicit.offset() | ||
%1 = load i32, i32 addrspace(5)* %0, align 4 | ||
%zext = zext i32 %1 to i64 | ||
ret i64 %zext | ||
} | ||
|
||
define hidden i64 @_Z22__spirv_GlobalOffset_yv() nounwind alwaysinline { | ||
entry: | ||
%0 = tail call i32 addrspace(5)* @llvm.amdgcn.implicit.offset() | ||
%arrayidx = getelementptr inbounds i32, i32 addrspace(5)* %0, i64 1 | ||
%1 = load i32, i32 addrspace(5)* %arrayidx, align 4 | ||
%zext = zext i32 %1 to i64 | ||
ret i64 %zext | ||
} | ||
|
||
define hidden i64 @_Z22__spirv_GlobalOffset_zv() nounwind alwaysinline { | ||
entry: | ||
%0 = tail call i32 addrspace(5)* @llvm.amdgcn.implicit.offset() | ||
%arrayidx = getelementptr inbounds i32, i32 addrspace(5)* %0, i64 2 | ||
%1 = load i32, i32 addrspace(5)* %arrayidx, align 4 | ||
%zext = zext i32 %1 to i64 | ||
ret i64 %zext | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
workitem/get_global_offset.cl | ||
workitem/get_group_id.cl | ||
workitem/get_global_size.cl | ||
workitem/get_local_id.cl | ||
|
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//===------------ TargetHelpers.h - Helpers for SYCL kernels ------------- ===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Helper functions for processing SYCL kernels. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_SYCL_SYCL_LOWER_IR_TARGET_HELPERS_H | ||
#define LLVM_SYCL_SYCL_LOWER_IR_TARGET_HELPERS_H | ||
|
||
#include "llvm/ADT/SmallVector.h" | ||
#include "llvm/IR/Function.h" | ||
#include "llvm/IR/Module.h" | ||
|
||
using namespace llvm; | ||
|
||
namespace llvm { | ||
namespace TargetHelpers { | ||
|
||
enum class ArchType { Cuda, AMDHSA, Unsupported }; | ||
|
||
struct KernelPayload { | ||
KernelPayload(Function *Kernel, MDNode *MD = nullptr); | ||
Function *Kernel; | ||
MDNode *MD; | ||
}; | ||
|
||
ArchType getArchType(const Module &M); | ||
|
||
std::string getAnnotationString(ArchType AT); | ||
|
||
void populateKernels(Module &M, SmallVectorImpl<KernelPayload> &Kernels, | ||
TargetHelpers::ArchType AT); | ||
|
||
} // end namespace TargetHelpers | ||
} // end namespace llvm | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.