Skip to content

Conversation

@motabbara
Copy link
Contributor

@motabbara motabbara commented Jul 14, 2023

fixes #1327

Copy link
Member

@wsmoses wsmoses left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test otherwise LGTM

@tgymnich tgymnich merged commit 6a5d994 into EnzymeAD:main Jul 16, 2023
@ZuseZ4
Copy link
Collaborator

ZuseZ4 commented Jul 16, 2023

This one fails locally for me now:

opt: /u/drehwald/prog/llvm-project/llvm/lib/IR/Instructions.cpp:1460: llvm::LoadInst::LoadInst(llvm::Type*, llvm::Value*, const llvm::Twine&, bool, llvm::Align, llvm::AtomicOrdering, llvm::SyncScope::ID, llvm::Instruction*): Assertion `cast<PointerType>(Ptr->getType())->isOpaqueOrPointeeTypeMatches(Ty)' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /u/drehwald/prog/llvm-project/buildDbg/./bin/opt --enable-new-pm=0 -load=/u/drehwald/prog/enzyme_blas/enzyme/buildDbgBoth/Enzyme/LLVMEnzyme-14.so --enzyme-attributor=0 -enzyme -enzyme-preopt=false -mem2reg -early-cse -sroa -instsimplify -simplifycfg -adce -S
1.	Running pass 'Enzyme Pass' on module '<stdin>'.
 #0 0x00005654b2aee8ee llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /u/drehwald/prog/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:22
 #1 0x00005654b2aee9a9 PrintStackTraceSignalHandler(void*) /u/drehwald/prog/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
 #2 0x00005654b2aec610 llvm::sys::RunSignalHandlers() /u/drehwald/prog/llvm-project/llvm/lib/Support/Signals.cpp:97:20
 #3 0x00005654b2aee23a SignalHandler(int) /u/drehwald/prog/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x00007f2aec138420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #5 0x00007f2aebc7600b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #6 0x00007f2aebc55859 abort /build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:81:7
 #7 0x00007f2aebc55729 get_sysdep_segment_value /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:509:8
 #8 0x00007f2aebc55729 _nl_load_domain /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:970:34
 #9 0x00007f2aebc66fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#10 0x00005654b1d9aa5c llvm::LoadInst::LoadInst(llvm::Type*, llvm::Value*, llvm::Twine const&, bool, llvm::Align, llvm::AtomicOrdering, unsigned char, llvm::Instruction*) /u/drehwald/prog/llvm-project/llvm/lib/IR/Instructions.cpp:1461:14
#11 0x00005654b1d9a95c llvm::LoadInst::LoadInst(llvm::Type*, llvm::Value*, llvm::Twine const&, bool, llvm::Align, llvm::Instruction*) /u/drehwald/prog/llvm-project/llvm/lib/IR/Instructions.cpp:1449:44
#12 0x00007f2aeb3bcc61 llvm::IRBuilderBase::CreateAlignedLoad(llvm::Type*, llvm::Value*, llvm::MaybeAlign, bool, llvm::Twine const&) /u/drehwald/prog/llvm-project/llvm/include/llvm/IR/IRBuilder.h:1692:68
#13 0x00007f2aeb3bcb6d llvm::IRBuilderBase::CreateAlignedLoad(llvm::Type*, llvm::Value*, llvm::MaybeAlign, llvm::Twine const&) /u/drehwald/prog/llvm-project/llvm/include/llvm/IR/IRBuilder.h:1684:3
#14 0x00007f2aeb3bca96 llvm::IRBuilderBase::CreateLoad(llvm::Type*, llvm::Value*, llvm::Twine const&) /u/drehwald/prog/llvm-project/llvm/include/llvm/IR/IRBuilder.h:1665:3
#15 0x00007f2aeb41396d DiffeGradientUtils::addToDiffe(llvm::Value*, llvm::Value*, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&, llvm::Type*, llvm::ArrayRef<llvm::Value*>, llvm::Value*) /u/drehwald/prog/enzyme_blas/enzyme/Enzyme/DiffeGradientUtils.cpp:330:35
#16 0x00007f2aeb6ab444 AdjointGenerator<AugmentedReturn const*>::addToDiffe(llvm::Value*, llvm::Value*, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&, llvm::Type*, llvm::Value*) /u/drehwald/prog/enzyme_blas/enzyme/Enzyme/AdjointGenerator.h:2005:61
#17 0x00007f2aeb61bc64 AdjointGenerator<AugmentedReturn const*>::visitCallInst(llvm::CallInst&) /u/drehwald/prog/enzyme_blas/enzyme/buildDbgBoth/Enzyme/CallDerivatives.inc:8018:22
#18 0x00007f2aeb5d0a32 llvm::InstVisitor<AdjointGenerator<AugmentedReturn const*>, void>::delegateCallInst(llvm::CallInst&) /u/drehwald/prog/llvm-project/llvm/include/llvm/IR/InstVisitor.h:303:3
#19 0x00007f2aeb5235e9 llvm::InstVisitor<AdjointGenerator<AugmentedReturn const*>, void>::visitCall(llvm::CallInst&) /u/drehwald/prog/llvm-project/llvm/include/llvm/IR/Instruction.def:209:1
#20 0x00007f2aeb51410d llvm::InstVisitor<AdjointGenerator<AugmentedReturn const*>, void>::visit(llvm::Instruction&) /u/drehwald/prog/llvm-project/llvm/include/llvm/IR/Instruction.def:209:1
#21 0x00007f2aeb505a3d llvm::InstVisitor<AdjointGenerator<AugmentedReturn const*>, void>::visit(llvm::Instruction*) /u/drehwald/prog/llvm-project/llvm/include/llvm/IR/InstVisitor.h:112:52
#22 0x00007f2aeb4e149a EnzymeLogic::CreatePrimalAndGradient(ReverseCacheKey const&&, TypeAnalysis&, AugmentedReturn const*, bool) /u/drehwald/prog/enzyme_blas/enzyme/Enzyme/EnzymeLogic.cpp:4186:7
#23 0x00007f2aeb464092 (anonymous namespace)::EnzymeBase::HandleAutoDiff(llvm::Instruction*, unsigned int, llvm::Value*, llvm::Type*, llvm::SmallVectorImpl<llvm::Value*>&, std::map<int, llvm::Type*, std::less<int>, std::allocator<std::pair<int const, llvm::Type*> > > const&, std::vector<DIFFE_TYPE, std::allocator<DIFFE_TYPE> > const&, llvm::Function*, DerivativeMode, (anonymous namespace)::EnzymeBase::Options&, bool) /u/drehwald/prog/enzyme_blas/enzyme/Enzyme/Enzyme.cpp:1440:46
#24 0x00007f2aeb466187 (anonymous namespace)::EnzymeBase::HandleAutoDiffArguments(llvm::CallInst*, DerivativeMode, bool) /u/drehwald/prog/enzyme_blas/enzyme/Enzyme/Enzyme.cpp:1764:26
#25 0x00007f2aeb46a4c9 (anonymous namespace)::EnzymeBase::lowerEnzymeCalls(llvm::Function&, std::set<llvm::Function*, std::less<llvm::Function*>, std::allocator<llvm::Function*> >&) /u/drehwald/prog/enzyme_blas/enzyme/Enzyme/Enzyme.cpp:2431:48
#26 0x00007f2aeb46b62d (anonymous namespace)::EnzymeBase::run(llvm::Module&) /u/drehwald/prog/enzyme_blas/enzyme/Enzyme/Enzyme.cpp:2597:15
#27 0x00007f2aeb46d119 (anonymous namespace)::EnzymeOldPM::runOnModule(llvm::Module&) /u/drehwald/prog/enzyme_blas/enzyme/Enzyme/Enzyme.cpp:2846:57
#28 0x00005654b1de4fbb (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /u/drehwald/prog/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1549:20
#29 0x00005654b1ddfef0 llvm::legacy::PassManagerImpl::run(llvm::Module&) /u/drehwald/prog/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:539:13
#30 0x00005654b1de5891 llvm::legacy::PassManager::run(llvm::Module&) /u/drehwald/prog/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1677:1
#31 0x00005654b08d686f main /u/drehwald/prog/llvm-project/llvm/tools/opt/opt.cpp:1042:15
#32 0x00007f2aebc57083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
#33 0x00005654b08966ce _start (/u/drehwald/prog/llvm-project/buildDbg/./bin/opt+0x187d6ce)
FileCheck error: '<stdin>' is empty.
FileCheck command line:  FileCheck /h/344/drehwald/prog/enzyme_blas/enzyme/test/Enzyme/ReverseMode/Faddeeva_erf_aarch64.ll

--

********************
********************
Failed Tests (1):
  Enzyme :: Enzyme/ReverseMode/Faddeeva_erf_aarch64.ll

@motabbara motabbara deleted the aarch64cfp branch July 16, 2023 22:41
@motabbara
Copy link
Contributor Author

@ZuseZ4 what is dif->getType() and ptr->getType() on your local build with that test?

@wsmoses
Copy link
Member

wsmoses commented Jul 20, 2023

This is consistent and errors:

(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737347913600) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140737347913600) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=140737347913600, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007ffff7a57476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007ffff7a3d7f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007ffff7a3d71b in __assert_fail_base (fmt=0x7ffff7bf2150 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x6c62902 "Ty == cast<PointerType>(Ptr->getType())->getElementType()", 
    file=0x6c610b7 "/home/wmoses/llvms/llvm12/llvm/lib/IR/Instructions.cpp", line=1409, function=<optimized out>) at ./assert/assert.c:92
#6  0x00007ffff7a4ee96 in __GI___assert_fail (assertion=0x6c62902 "Ty == cast<PointerType>(Ptr->getType())->getElementType()", file=0x6c610b7 "/home/wmoses/llvms/llvm12/llvm/lib/IR/Instructions.cpp", line=1409, 
    function=0x6c6293c "llvm::LoadInst::LoadInst(llvm::Type *, llvm::Value *, const llvm::Twine &, bool, llvm::Align, llvm::AtomicOrdering, SyncScope::ID, llvm::Instruction *)") at ./assert/assert.c:101
#7  0x00000000035b4e26 in llvm::LoadInst::LoadInst (this=0x8ac4c50, Ty=0x8a80440, Ptr=0x8ac4710, Name=..., isVolatile=false, Align=..., Order=llvm::AtomicOrdering::NotAtomic, SSID=1 '\001', InsertBef=0x0)
    at /home/wmoses/llvms/llvm12/llvm/lib/IR/Instructions.cpp:1409
#8  0x00000000035b4c02 in llvm::LoadInst::LoadInst (this=0x8ac4c50, Ty=0x8a80440, Ptr=0x8ac4710, Name=..., isVolatile=false, Align=..., InsertBef=0x0) at /home/wmoses/llvms/llvm12/llvm/lib/IR/Instructions.cpp:1397
#9  0x00007ffff71bdedd in llvm::IRBuilderBase::CreateAlignedLoad (this=0x7fffffff8200, Ty=0x8a80440, Ptr=0x8ac4710, Align=..., isVolatile=false, Name=...) at /home/wmoses/llvms/llvm12/llvm/include/llvm/IR/IRBuilder.h:1776
#10 0x00007ffff71bdde9 in llvm::IRBuilderBase::CreateAlignedLoad (this=0x7fffffff8200, Ty=0x8a80440, Ptr=0x8ac4710, Align=..., Name=...) at /home/wmoses/llvms/llvm12/llvm/include/llvm/IR/IRBuilder.h:1760
#11 0x00007ffff71bdd14 in llvm::IRBuilderBase::CreateLoad (this=0x7fffffff8200, Ty=0x8a80440, Ptr=0x8ac4710, Name=...) at /home/wmoses/llvms/llvm12/llvm/include/llvm/IR/IRBuilder.h:1713
#12 0x00007ffff7215f80 in DiffeGradientUtils::addToDiffe (this=0x8a9b210, val=0x8a8e9c0, dif=0x8ac4680, BuilderM=..., addingType=0x8a80080, idxs=..., mask=0x0) at /home/wmoses/git/Enzyme/enzyme/Enzyme/DiffeGradientUtils.cpp:330
#13 0x00007ffff74ae3dc in AdjointGenerator<AugmentedReturn const*>::addToDiffe (this=0x7fffffff8de0, val=0x8a8e9c0, dif=0x8ac4680, Builder=..., T=0x8a80080, mask=0x0) at /home/wmoses/git/Enzyme/enzyme/Enzyme/AdjointGenerator.h:2020
#14 0x00007ffff741c0f9 in AdjointGenerator<AugmentedReturn const*>::visitCallInst (this=0x7fffffff8de0, call=...) at /home/wmoses/git/Enzyme/enzyme/build12/Enzyme/CallDerivatives.inc:8018
#15 0x00007ffff73cfef4 in llvm::InstVisitor<AdjointGenerator<AugmentedReturn const*>, void>::delegateCallInst (this=0x7fffffff8de0, I=...) at /home/wmoses/llvms/llvm12/llvm/include/llvm/IR/InstVisitor.h:299
#16 0x00007ffff73207af in llvm::InstVisitor<AdjointGenerator<AugmentedReturn const*>, void>::visitCall (this=0x7fffffff8de0, I=...) at /home/wmoses/llvms/llvm12/llvm/include/llvm/IR/Instruction.def:209
#17 0x00007ffff73110a9 in llvm::InstVisitor<AdjointGenerator<AugmentedReturn const*>, void>::visit (this=0x7fffffff8de0, I=...) at /home/wmoses/llvms/llvm12/llvm/include/llvm/IR/Instruction.def:209
#18 0x00007ffff730211f in llvm::InstVisitor<AdjointGenerator<AugmentedReturn const*>, void>::visit (this=0x7fffffff8de0, I=0x8a95880) at /home/wmoses/llvms/llvm12/llvm/include/llvm/IR/InstVisitor.h:112
#19 0x00007ffff72dc91b in EnzymeLogic::CreatePrimalAndGradient (this=0x8a86498, key=..., TA=..., augmenteddata=0x0, omp=false) at /home/wmoses/git/Enzyme/enzyme/Enzyme/EnzymeLogic.cpp:4185
#20 0x00007ffff7267ad1 in (anonymous namespace)::EnzymeBase::HandleAutoDiff (this=0x8a86498, CI=0x8a7ed10, CallingConv=0, ret=0x8a7ed10, retElemType=0x0, args=..., byVal=std::map with 0 elements, constants=std::vector of length 1, capacity 1 = {...}, 
    fn=0x8a13218, mode=DerivativeMode::ReverseModeCombined, options=..., sizeOnly=false) at /home/wmoses/git/Enzyme/enzyme/Enzyme/Enzyme.cpp:1440
#21 0x00007ffff7269c30 in (anonymous namespace)::EnzymeBase::HandleAutoDiffArguments (this=0x8a86498, CI=0x8a7ed10, mode=DerivativeMode::ReverseModeCombined, sizeOnly=false) at /home/wmoses/git/Enzyme/enzyme/Enzyme/Enzyme.cpp:1764
#22 0x00007ffff726e118 in (anonymous namespace)::EnzymeBase::lowerEnzymeCalls (this=0x8a86498, F=..., done=std::set with 2 elements = {...}) at /home/wmoses/git/Enzyme/enzyme/Enzyme/Enzyme.cpp:2431
#23 0x00007ffff726ed73 in (anonymous namespace)::EnzymeBase::run (this=0x8a86498, M=...) at /home/wmoses/git/Enzyme/enzyme/Enzyme/Enzyme.cpp:2597
#24 0x00007ffff727574c in EnzymeNewPM::run (this=0x8a86498, M=..., MAM=...) at /home/wmoses/git/Enzyme/enzyme/Enzyme/Enzyme.cpp:2880
#25 0x00007ffff72b8e71 in llvm::detail::PassModel<llvm::Module, EnzymeNewPM, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (this=0x8a86490, IR=..., AM=...)
    at /home/wmoses/llvms/llvm12/llvm/include/llvm/IR/PassManagerInternal.h:85
#26 0x000000000365b9ec in llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (this=0x7fffffffb498, IR=..., AM=...)
    at /home/wmoses/llvms/llvm12/llvm/include/llvm/IR/PassManager.h:517
#27 0x0000000000d9a82c in llvm::runPassPipeline (Arg0=..., M=..., TM=0x0, TLII=0x7fffffffd648, Out=0x8a7f250, ThinLTOLinkOut=0x0, OptRemarkFile=0x0, PassPipeline=..., Passes=..., OK=llvm::opt_tool::OK_OutputAssembly, 
    VK=llvm::opt_tool::VK_VerifyInAndOut, ShouldPreserveAssemblyUseListOrder=false, ShouldPreserveBitcodeUseListOrder=true, EmitSummaryIndex=false, EmitModuleHash=false, EnableDebugify=false, Coroutines=false)
    at /home/wmoses/llvms/llvm12/llvm/tools/opt/NewPMDriver.cpp:449
#28 0x0000000000dcf32a in main (argc=8, argv=0x7fffffffdf48) at /home/wmoses/llvms/llvm12/llvm/tools/opt/opt.cpp:787
(gdb) f 12
#12 0x00007ffff7215f80 in DiffeGradientUtils::addToDiffe (this=0x8a9b210, val=0x8a8e9c0, dif=0x8ac4680, BuilderM=..., addingType=0x8a80080, idxs=..., mask=0x0) at /home/wmoses/git/Enzyme/enzyme/Enzyme/DiffeGradientUtils.cpp:330
330	  Value *old = BuilderM.CreateLoad(dif->getType(), ptr);
(gdb) l ptr->dump()
Function "ptr->dump()" not defined.
(gdb) p ptr->dump()
  %"in'de" = alloca [2 x double], align 8
$1 = void
(gdb) p dif->dump()
  %37 = insertvalue { double, double } %36, double %33, 1
$2 = void
(gdb) f 16
#16 0x00007ffff73207af in llvm::InstVisitor<AdjointGenerator<AugmentedReturn const*>, void>::visitCall (this=0x7fffffff8de0, I=...) at /home/wmoses/llvms/llvm12/llvm/include/llvm/IR/Instruction.def:209
209	HANDLE_OTHER_INST(56, Call   , CallInst   )  // Call a function
(gdb) f 14
#14 0x00007ffff741c0f9 in AdjointGenerator<AugmentedReturn const*>::visitCallInst (this=0x7fffffff8de0, call=...) at /home/wmoses/git/Enzyme/enzyme/build12/Enzyme/CallDerivatives.inc:8018
8018	          if (toadd) addToDiffe(call.getOperand(0), toadd, Builder2, call.getOperand(0)->getType());
(gdb) p call.dump()
  %call = call [2 x double] @Faddeeva_erf([2 x double] %in, double 0.000000e+00) #1
$3 = void
(gdb) p toadd->dump()
  %37 = insertvalue { double, double } %36, double %33, 1
$4 = void

I'm going to revert this as broken, @motabbara do you want to take another stab at this.

wsmoses added a commit that referenced this pull request Jul 20, 2023
@motabbara
Copy link
Contributor Author

motabbara commented Jul 20, 2023

yup. sorry for the mess up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

faddeeva_erfc and friends not handled for macOS aarch64

4 participants