Skip to content
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

Crash due to the usage of pointers in reverse mode #195

Closed
grimmmyshini opened this issue Feb 22, 2021 · 8 comments · Fixed by #686
Closed

Crash due to the usage of pointers in reverse mode #195

grimmmyshini opened this issue Feb 22, 2021 · 8 comments · Fixed by #686

Comments

@grimmmyshini
Copy link
Contributor

grimmmyshini commented Feb 22, 2021

Minimum reproducible example:

double f5(double a) {
  double *ptr;
  ptr = &a;
  return *ptr;
}

Another example is simply

double f5(double* p){
  return *p;
}

calling clad::gradient on the above results in the following error,

stack trace
DeclRefExpr for Decl not entered in LocalDeclMap?
UNREACHABLE executed at /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExpr.cpp:2619!
Stack dump:
0.	Program arguments: /home/grimmyshini/cern/obj/bin/clang-9 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name temp.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir /home/grimmyshini/cern/obj/lib/clang/9.0.1 -I ../src/tools/clad/include/ -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward -internal-isystem /usr/local/include -internal-isystem /home/grimmyshini/cern/obj/lib/clang/9.0.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/grimmyshini/cern/obj -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -add-plugin clad -load /home/grimmyshini/cern/inst/lib/clad.so -faddrsig -o /tmp/temp-409fa2.o -x c++ ../src/tools/clad/demos/temp.cpp 
1.	<eof> parser at end of file
2.	LLVM IR generation of declaration 'f5_grad'
3.	Generating code for declaration 'f5_grad'
 #0 0x000055b1912b655f llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/grimmyshini/cern/src/lib/Support/Unix/Signals.inc:533:22
 #1 0x000055b1912b65f2 PrintStackTraceSignalHandler(void*) /home/grimmyshini/cern/src/lib/Support/Unix/Signals.inc:594:1
 #2 0x000055b1912b44e0 llvm::sys::RunSignalHandlers() /home/grimmyshini/cern/src/lib/Support/Signals.cpp:68:20
 #3 0x000055b1912b5f19 SignalHandler(int) /home/grimmyshini/cern/src/lib/Support/Unix/Signals.inc:385:1
 #4 0x00007faaf6d828a0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
 #5 0x00007faaf59dcf47 raise /build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #6 0x00007faaf59de8b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
 #7 0x000055b19123cfc7 bindingsErrorHandler(void*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) /home/grimmyshini/cern/src/lib/Support/ErrorHandling.cpp:218:55
 #8 0x000055b1919da0f7 clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExpr.cpp:2624:21
 #9 0x000055b1919d2b25 clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) (.localalias) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExpr.cpp:1274:50
#10 0x000055b1919d265a clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExpr.cpp:1213:22
#11 0x000055b191a1b3aa (anonymous namespace)::ScalarExprEmitter::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:256:3
#12 0x000055b191a1b6bf (anonymous namespace)::ScalarExprEmitter::EmitLoadOfLValue(clang::Expr const*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:305:32
#13 0x000055b191a1c29a (anonymous namespace)::ScalarExprEmitter::VisitDeclRefExpr(clang::DeclRefExpr*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:508:30
#14 0x000055b191a336b0 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) /home/grimmyshini/cern/obj/tools/clang/include/clang/AST/StmtNodes.inc:919:1
#15 0x000055b191a1ba4d (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:424:57
#16 0x000055b191a24729 (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:2150:17
#17 0x000055b191a34dd9 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::VisitImplicitCastExpr(clang::ImplicitCastExpr*) /home/grimmyshini/cern/obj/tools/clang/include/clang/AST/StmtNodes.inc:865:1
#18 0x000055b191a33608 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) /home/grimmyshini/cern/obj/tools/clang/include/clang/AST/StmtNodes.inc:865:1
#19 0x000055b191a1ba4d (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:424:57
#20 0x000055b191a30ead clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:4437:1
#21 0x000055b1919d20eb clang::CodeGen::CodeGenFunction::EmitPointerWithAlignment(clang::Expr const*, clang::CodeGen::LValueBaseInfo*, clang::CodeGen::TBAAAccessInfo*) (.localalias) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExpr.cpp:1142:10
#22 0x000055b1919da722 clang::CodeGen::CodeGenFunction::EmitUnaryOpLValue(clang::UnaryOperator const*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExpr.cpp:2687:54
#23 0x000055b1919d316a clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) (.localalias) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExpr.cpp:1339:52
#24 0x000055b1919d265a clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExpr.cpp:1213:22
#25 0x000055b191a1b3aa (anonymous namespace)::ScalarExprEmitter::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:256:3
#26 0x000055b191a1b6bf (anonymous namespace)::ScalarExprEmitter::EmitLoadOfLValue(clang::Expr const*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:305:32
#27 0x000055b191a1cc34 (anonymous namespace)::ScalarExprEmitter::VisitUnaryDeref(clang::UnaryOperator const*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:624:30
#28 0x000055b191a328e3 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) /home/grimmyshini/cern/src/tools/clang/include/clang/AST/StmtVisitor.h:91:26
#29 0x000055b191a1ba4d (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:424:57
#30 0x000055b191a24729 (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:2150:17
#31 0x000055b191a34dd9 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::VisitImplicitCastExpr(clang::ImplicitCastExpr*) /home/grimmyshini/cern/obj/tools/clang/include/clang/AST/StmtNodes.inc:865:1
#32 0x000055b191a33608 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) /home/grimmyshini/cern/obj/tools/clang/include/clang/AST/StmtNodes.inc:865:1
#33 0x000055b191a1ba4d (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:424:57
#34 0x000055b191a30ead clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:4437:1
#35 0x000055b1919a5076 clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGDecl.cpp:750:40
#36 0x000055b1919aaa1c clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGDecl.cpp:1886:19
#37 0x000055b1919aa6b2 clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGDecl.cpp:1845:26
#38 0x000055b1919a7967 clang::CodeGen::CodeGenFunction::EmitAutoVarDecl(clang::VarDecl const&) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGDecl.cpp:1286:22
#39 0x000055b1919a27dc clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGDecl.cpp:192:27
#40 0x000055b1919a24e4 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (.localalias) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGDecl.cpp:137:47
#41 0x000055b19168b164 clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGStmt.cpp:1132:3
#42 0x000055b19168745f clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGStmt.cpp:350:75
#43 0x000055b1916867e5 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGStmt.cpp:49:3
#44 0x000055b19168797c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CGStmt.cpp:390:3
#45 0x000055b19170a753 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CodeGenFunction.cpp:1033:36
#46 0x000055b19170b3c1 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CodeGenFunction.cpp:1198:21
#47 0x000055b191732ab1 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:4320:3
#48 0x000055b19172bdeb clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:2759:47
#49 0x000055b19172adb8 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:2512:5
#50 0x000055b191736a7b clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.localalias) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:5128:37
#51 0x000055b1925774df (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/ModuleBuilder.cpp:161:7
#52 0x000055b19257093c clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CodeGenAction.cpp:172:7
#53 0x000055b191d41c9c clang::MultiplexConsumer::HandleTopLevelDecl(clang::DeclGroupRef) /home/grimmyshini/cern/src/tools/clang/lib/Frontend/MultiplexConsumer.cpp:271:25
#54 0x00007faaf5561081 clad::plugin::CladPlugin::ProcessDiffRequest(clad::DiffRequest&) (.localalias) /home/grimmyshini/cern/src/tools/clad/tools/ClangPlugin.cpp:200:9
#55 0x00007faaf5560b9a clad::plugin::CladPlugin::HandleTopLevelDecl(clang::DeclGroupRef) /home/grimmyshini/cern/src/tools/clad/tools/ClangPlugin.cpp:128:7
#56 0x000055b191d41c9c clang::MultiplexConsumer::HandleTopLevelDecl(clang::DeclGroupRef) /home/grimmyshini/cern/src/tools/clang/lib/Frontend/MultiplexConsumer.cpp:271:25
#57 0x000055b193bd546a clang::ParseAST(clang::Sema&, bool, bool) /home/grimmyshini/cern/src/tools/clang/lib/Parse/ParseAST.cpp:162:20
#58 0x000055b191d02587 clang::ASTFrontendAction::ExecuteAction() /home/grimmyshini/cern/src/tools/clang/lib/Frontend/FrontendAction.cpp:1041:11
#59 0x000055b19256f379 clang::CodeGenAction::ExecuteAction() /home/grimmyshini/cern/src/tools/clang/lib/CodeGen/CodeGenAction.cpp:1060:1
#60 0x000055b191d01eea clang::FrontendAction::Execute() /home/grimmyshini/cern/src/tools/clang/lib/Frontend/FrontendAction.cpp:938:38
#61 0x000055b191c9dc7e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/grimmyshini/cern/src/tools/clang/lib/Frontend/CompilerInstance.cpp:944:42
#62 0x000055b191e61c19 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/grimmyshini/cern/src/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:291:38
#63 0x000055b18fcf62bb cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/grimmyshini/cern/src/tools/clang/tools/driver/cc1_main.cpp:249:40
#64 0x000055b18fceb973 ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) /home/grimmyshini/cern/src/tools/clang/tools/driver/driver.cpp:309:64
#65 0x000055b18fcec051 main /home/grimmyshini/cern/src/tools/clang/tools/driver/driver.cpp:381:26
#66 0x00007faaf59bfb97 __libc_start_main /build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#67 0x000055b18fcea15a _start (/home/grimmyshini/cern/obj/bin/clang-9+0x224415a)
clang-9: error: unable to execute command: Aborted (core dumped)
clang-9: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 9.0.1 (https://github.com/llvm-mirror/clang.git bed37d4b18ce6993fc2567e8de61f6b30fd0cb75) (https://github.com/llvm-mirror/llvm.git c2f5309b216cb02a0aae17353549d985b5b05635)
@StarWonder67
Copy link

Hi, I am a beginner in open source and would like to contribute to this issue. From what I can gather, an error is being generated because of the use of pointers. Please correct me if I am wrong.

@grimmmyshini
Copy link
Contributor Author

Yes, as it says in the title, the error is indeed being generated by the use of pointers, a concept that is not fully supported by Clad. You could start by going through the source code and dumping the generated AST of the derivative function.

You can also use any debugger you like to check out the control flow of the code to get a better understanding of how things are done in Clad. This may also be helpful in narrowing down where the error is.

@Nirhar
Copy link
Contributor

Nirhar commented Mar 15, 2022

The address operator is supposed be a non-differentiable operator right? How exactly is it handled in the existing codebase? How much of support already exists for pointers in the codebase? Are there any existing examples that use pointers and work correctly?

@Nirhar
Copy link
Contributor

Nirhar commented May 25, 2022

cc @vgvassilev @grimmmyshini

@parth-07
Copy link
Collaborator

The address operator is supposed be a non-differentiable operator right?

Yes! Mathematically, the address-of operator is a non-differentiable operator. However, it does impact the primal function, and thus the derived function as well. The important thing to keep in mind to correctly produce the derived function is: the control flow of derivative computation should follow the control flow of primal computation in reverse, and use the same values as were used by the corresponding primal computation.

Correctly setting pointer variables and derivative of pointer variables is a way to keep the control flow consistent. Please keep in mind that derivative of pointer variable is a very misleading term, because pointer variables do not represent a mathematical object, and thus cannot have derivatives. But nonetheless, it is still a common term in AD literature. You can understand derivative of a pointer variable as a variable that helps to keep the control flow consistent and facilitate using the same values in the reverse pass computation as were used by the corresponding forward pass computation.

How exactly is it handled in the existing codebase?

Currently, Reverse Mode AD does not support pointers. We have plans to add pointer support in the near future.

How much of support already exists for pointers in the codebase?

Forward Mode AD (clad::differentiate) have complete support for differentiating code that uses pointers.

Are there any existing examples that use pointers and work correctly?

We currently do not have a definite Reverse Mode AD differentiation model that supports pointers. For seeing the differentiation of code that uses pointers using the Reverse Mode AD, you can checkout other C/C++ based AD tools.

@Nirhar
Copy link
Contributor

Nirhar commented Jun 7, 2022

Minimum reproducible example:

double f5(double a) {
  double *ptr;
  ptr = &a;
  return *ptr;
}

Another example is simply

double f5(double* p){
  return *p;
}

calling clad::gradient on the above results in the following error,
stack trace

The code snippets shown here don't compile when I use clad(with clang) in debug mode. It throws the following error:

void clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList&, clang::CodeGen::CodeGenFunction::PrototypeWrapper, llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, const clang::Expr* const, const clang::Stmt* const> >, clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int, clang::CodeGen::CodeGenFunction::EvaluationOrder): Assertion `(isGenericMethod || Ty->isVariablyModifiedType() || Ty.getNonReferenceType()->isObjCRetainableType() || getContext() .getCanonicalType(Ty.getNonReferenceType()) .getTypePtr() == getContext().getCanonicalType((*Arg)->getType()).getTypePtr()) && "type mismatch in call argument!"' failed.

However when non debug mode of clad is used then the error doesn't come and it compiles, however this leads to segmentation fault during runtime as mentioned in the issue.

@parth-07
Copy link
Collaborator

The code snippets shown here don't compile when I use clad(with clang) in debug mode. It throws the following error:

Clang debug build contains various assertions for ensuring consistency of the AST. These assertions are not present in release builds.

@Rishabh9955
Copy link

Rishabh9955 commented Apr 1, 2023

double f5(double a) {
double *ptr;
ptr = &a;
return *ptr;
}
do this
double f5(double a) {
return a;
}
message me - rs6322398@gmail.com

vaithak added a commit to vaithak/clad that referenced this issue Dec 20, 2023
This commit adds support for pointer operation in reverse mode.
The technique is maintain a corresponding derivative pointer
variable, which gets updated (and stored/restored) in the exact same way
as the primal pointer variable in both forward and reverse passes.

Added a workaround (with a FIXME comment) in the UsefulToStoreGlobal
method to essentially bypass TBR analysis results for pointer expr.

Fixes vgvassilev#195, vgvassilev#197
vaithak added a commit to vaithak/clad that referenced this issue Dec 20, 2023
This commit adds support for pointer operation in reverse mode. The technique is to maintain a corresponding derivative pointer variable, which gets updated (and stored/restored) in the exact same way as the primal pointer variable in both forward and reverse passes.
Added a workaround (with a FIXME comment) in the UsefulToStoreGlobal method to essentially bypass TBR analysis results for pointer expr.

Fixes vgvassilev#195, Fixes vgvassilev#197
vaithak added a commit to vaithak/clad that referenced this issue Dec 22, 2023
This commit adds support for pointer operation in reverse mode. The technique is to maintain a corresponding derivative pointer variable, which gets updated (and stored/restored) in the exact same way as the primal pointer variable in both forward and reverse passes.
Added a workaround (with a FIXME comment) in the UsefulToStoreGlobal method to essentially bypass TBR analysis results for pointer expr.

Fixes vgvassilev#195, Fixes vgvassilev#197
vaithak added a commit to vaithak/clad that referenced this issue Dec 29, 2023
This commit adds support for pointer operation in reverse mode. The technique is to maintain a corresponding derivative pointer variable, which gets updated (and stored/restored) in the exact same way as the primal pointer variable in both forward and reverse passes.
Added a workaround (with a FIXME comment) in the UsefulToStoreGlobal method to essentially bypass TBR analysis results for pointer expr.

Fixes vgvassilev#195, Fixes vgvassilev#197
vaithak added a commit to vaithak/clad that referenced this issue Dec 29, 2023
This commit adds support for pointer operation in reverse mode. The technique is to maintain a corresponding derivative pointer variable, which gets updated (and stored/restored) in the exact same way as the primal pointer variable in both forward and reverse passes.
Added a workaround (with a FIXME comment) in the UsefulToStoreGlobal method to essentially bypass TBR analysis results for pointer expr.

Fixes vgvassilev#195, Fixes vgvassilev#197
vaithak added a commit to vaithak/clad that referenced this issue Dec 30, 2023
This commit adds support for pointer operation in reverse mode. The technique is to maintain a corresponding derivative pointer variable, which gets updated (and stored/restored) in the exact same way as the primal pointer variable in both forward and reverse passes.
Added a workaround (with a FIXME comment) in the UsefulToStoreGlobal method to essentially bypass TBR analysis results for pointer expr.

Fixes vgvassilev#195, Fixes vgvassilev#197
vgvassilev pushed a commit that referenced this issue Dec 30, 2023
This commit adds support for pointer operation in reverse mode. The technique is to maintain a corresponding derivative pointer variable, which gets updated (and stored/restored) in the exact same way as the primal pointer variable in both forward and reverse passes.
Added a workaround (with a FIXME comment) in the UsefulToStoreGlobal method to essentially bypass TBR analysis results for pointer expr.

Fixes #195, Fixes #197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants