File tree Expand file tree Collapse file tree 2 files changed +40
-3
lines changed
sycl/test-e2e/DeviceGlobal Expand file tree Collapse file tree 2 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -5759,9 +5759,15 @@ LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) {
57595759 if (Scope && Scope->isWorkGroup ())
57605760 return LangAS::sycl_local;
57615761
5762- const RecordDecl *RD = D->getType ()->getAsRecordDecl ();
5763- if (getTriple ().isNVPTX () && RD && RD->hasAttr <SYCLDeviceGlobalAttr>() && D->getType ().isConstQualified ())
5764- return LangAS::cuda_constant;
5762+ if (getTriple ().isNVPTX () || getTriple ().isAMDGPU ()) {
5763+ const RecordDecl *RD = D->getType ()->getAsRecordDecl ();
5764+ if (RD && RD->hasAttr <SYCLDeviceGlobalAttr>()) {
5765+ clang::CXXRecordDecl *record = D->getType ()->getAsCXXRecordDecl ();
5766+ const auto *Spec = cast<ClassTemplateSpecializationDecl>(record);
5767+ if (Spec->getTemplateArgs ().get (0 ).getAsType ().isConstQualified ())
5768+ return LangAS::opencl_constant;
5769+ }
5770+ }
57655771 }
57665772
57675773 if (LangOpts.SYCLIsDevice &&
Original file line number Diff line number Diff line change 1+ // RUN: %{build} -o %t.out
2+ // RUN: %{run} %t.out
3+ //
4+ // The OpenCL GPU backends do not currently support device_global backend
5+ // calls.
6+ //
7+ // UNSUPPORTED: opencl && gpu
8+
9+ #include " common.hpp"
10+
11+ device_global<const int , TestProperties> DeviceGlobalVar;
12+
13+ int main () {
14+ queue Q;
15+
16+ int HostVal = 42 ;
17+ Q.memcpy (DeviceGlobalVar, &HostVal);
18+ Q.wait ();
19+ int OutVal = 0 ;
20+
21+ {
22+ buffer<int , 1 > OutBuf (&OutVal, 1 );
23+ Q.submit ([&](handler &CGH) {
24+ auto OutAcc = OutBuf.get_access <access::mode::write>(CGH);
25+ CGH.single_task ([=]() { OutAcc[0 ] = DeviceGlobalVar.get (); });
26+ });
27+ }
28+
29+ assert (OutVal == 42 && " Read value does not match." );
30+ return 0 ;
31+ }
You can’t perform that action at this time.
0 commit comments