Skip to content

[SYCL][FPGA] Change address space for USM pointers as kernel args #2095

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 2 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,11 @@ class SyclKernelDeclCreator : public SyclKernelFieldHandler {
// space, because OpenCL requires it.
QualType PointeeTy = FieldTy->getPointeeType();
Qualifiers Quals = PointeeTy.getQualifiers();
Quals.setAddressSpace(LangAS::opencl_global);
auto AS = Quals.getAddressSpace();
// Leave global_device and global_host address spaces as is to help FPGA
// device in memory allocations
if (AS != LangAS::opencl_global_device && AS != LangAS::opencl_global_host)
Quals.setAddressSpace(LangAS::opencl_global);
PointeeTy = SemaRef.getASTContext().getQualifiedType(
PointeeTy.getUnqualifiedType(), Quals);
QualType ModTy = SemaRef.getASTContext().getPointerType(PointeeTy);
Expand Down
16 changes: 16 additions & 0 deletions clang/test/CodeGenSYCL/kernel-device-space-arg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: %clang_cc1 -fsycl -fsycl-is-device -I %S/Inputs -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -disable-llvm-passes -o - | FileCheck %s

// CHECK: define {{.*}}spir_kernel void @_ZTSZ4mainE15kernel_function(i32 addrspace(5)* {{.*}} i32 addrspace(6)* {{.*}}

#include "sycl.hpp"

int main() {
__attribute__((opencl_global_device)) int *GLOBDEV = nullptr;
__attribute__((opencl_global_host)) int *GLOBHOST = nullptr;
cl::sycl::kernel_single_task<class kernel_function>(
[=]() {
__attribute__((opencl_global_device)) int *DevPtr = GLOBDEV;
__attribute__((opencl_global_host)) int *HostPtr = GLOBHOST;
});
return 0;
}