Skip to content

Commit

Permalink
fix cuda
Browse files Browse the repository at this point in the history
  • Loading branch information
PetroZarytskyi committed Nov 25, 2024
1 parent 3acb66a commit 7372dd0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,8 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
// Check DeclRefExpr is a reference to an independent variable.
auto it = m_Variables.find(VD);
if (it == std::end(m_Variables)) {
if (VD->isFileVarDecl()) {
if (VD->isFileVarDecl() &&
!m_DiffReq->hasAttr<clang::CUDAGlobalAttr>()) {
Expr* DREDiff = DifferentiateGlobalVarDecl(VD);
it = m_Variables.emplace(VD, DREDiff).first;
} else
Expand Down Expand Up @@ -1462,10 +1463,10 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
return foundExpr;
}
// Not found, construct the adjoint and register it.
VarDecl* VDDiff =
BuildVarDecl(VD->getType(), CreateUniqueIdentifier(nameDiff_str),
m_DerivativeFnScope->getParent()->getParent(), DC,
getZeroInit(VD->getType()));
QualType TyDiff = getNonConstType(VD->getType(), m_Context, m_Sema);
VarDecl* VDDiff = BuildVarDecl(
TyDiff, CreateUniqueIdentifier(nameDiff_str),
m_DerivativeFnScope->getParent()->getParent(), DC, getZeroInit(TyDiff));

DC->addDecl(VDDiff);
DC->makeDeclVisibleInContext(VDDiff);
Expand Down

0 comments on commit 7372dd0

Please sign in to comment.