Skip to content
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
2 changes: 1 addition & 1 deletion clang/lib/DPCT/AnalysisInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2947,7 +2947,7 @@ void MemVarInfo::migrateToDeviceGlobal(const VarDecl *MemVar) {
auto &Ctx = DpctGlobalInfo::getContext();
auto &MacroArgMap = DpctGlobalInfo::getMacroArgRecordMap();
auto TSI = MemVar->getTypeSourceInfo();
auto OriginTL = TSI->getTypeLoc();
auto OriginTL = TSI->getTypeLoc().getUnqualifiedLoc().getAs<TypeLoc>();
auto TL = OriginTL;
auto BegLoc = MemVar->getBeginLoc();
if (BegLoc.isMacroID()) {
Expand Down
8 changes: 5 additions & 3 deletions clang/lib/DPCT/RulesLang/RulesLangNoneAPIAndType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,6 @@ void MemVarAnalysisRule::runRule(const MatchFinder::MatchResult &Result) {
auto MemVarRef = getNodeAsType<DeclRefExpr>(Result, "used");
auto Func = getAssistNodeAsType<FunctionDecl>(Result, "func");
auto Decl = getAssistNodeAsType<VarDecl>(Result, "decl");
DpctGlobalInfo &Global = DpctGlobalInfo::getInstance();
if (MemVarRef && Func && Decl) {
if (isCubVar(Decl)) {
return;
Expand All @@ -820,8 +819,11 @@ void MemVarAnalysisRule::runRule(const MatchFinder::MatchResult &Result) {
return;
if (VD == nullptr)
return;

auto Var = Global.findMemVarInfo(VD);
std::string CanonicalType = VD->getType().getCanonicalType().getAsString();
if (CanonicalType.find("block_tile_memory") != std::string::npos) {
return;
}
auto Var = MemVarInfo::buildMemVarInfo(VD);
if (Func->hasAttr<CUDAGlobalAttr>() || Func->hasAttr<CUDADeviceAttr>()) {
if (!(DpctGlobalInfo::useGroupLocalMemory() &&
VD->hasAttr<CUDASharedAttr>() &&
Expand Down
20 changes: 20 additions & 0 deletions clang/test/dpct/device_global/device_global2.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: dpct --format-range=none --use-experimental-features=device_global -in-root %S -out-root %T/device_global2 %S/device_global2.cu --cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only
// RUN: FileCheck --input-file %T/device_global2/device_global2.dp.cpp --match-full-lines %s

#include <cuda_runtime.h>
#include <iostream>
#include <vector>

// CHECK: static sycl::ext::oneapi::experimental::device_global<int> var_a;
__device__ int var_a;

// CHECK: static constexpr sycl::ext::oneapi::experimental::device_global<int8_t[2]> var_b {-1, -1};
static constexpr __device__ int8_t var_b[2] = {-1, -1};

template<typename T>
__global__ void kernel(T b) {
var_a;
var_b[0];
}

template __global__ void kernel<int>(int b);