Giter Club home page Giter Club logo

Comments (6)

wsmoses avatar wsmoses commented on May 27, 2024

I've reproduced this and deduced that we weren't enabling scoped alias analysis (and thus Enzyme, without that improved alias info, had to assume extra things cached). Happily turning that on eliminates the caches completely (which is undergoing a PR now).

from enzyme.

unrealwill avatar unrealwill commented on May 27, 2024

Thanks for the quick fix ! 👍

from enzyme.

unrealwill avatar unrealwill commented on May 27, 2024

FYI, I cloned a fresh enzyme revision 6117bbd which should contain the current fix, then rebuild, and reinstall Enzyme.
But I still observe the bug with clang version 11.1.0
I'll try a more recent clang (hopefully it will have a compatible Cuda version).

from enzyme.

unrealwill avatar unrealwill commented on May 27, 2024

The bug is also present with
clang version 12.0.1 freshly installed from https://github.com/llvm/llvm-project/tree/release/12.x

I'll try clang's mainline

from enzyme.

wsmoses avatar wsmoses commented on May 27, 2024

Just to confirm, can you past the output of the analysis?

Specifically, the thing to look for is that there's no more lines like bugDense.cpp:21:31: remark: Caching instruction

There will still exist some lines like bugDense.cpp:21:21: remark: Load may need caching which effectively say that you're overwriting out and if you need the old value of out, it needs to be cached because of this store. A different analysis (differential use analysis) will determine that Enzyme won't need the old value of out in the reverse, and thus there's no need to cache it (and thus no Caching instruction...)

from enzyme.

unrealwill avatar unrealwill commented on May 27, 2024

OK, it still spits plenty of lines but looking more carefully there is no longer "remark: Caching instruction".
👍 so I guess it should be OK now.

There is still a "remark: Load must be recomputed" though (but I care less about this provided it's not quadratic)

Here is the new output :

clang bugDense.cpp  -lstdc++ -lm  -fno-exceptions -Rpass=enzyme -Xclang -load -Xclang /usr/local/lib/ClangEnzyme-12.so  -O2  -o bin/bugDense
remark: Load may need caching   %arrayidx9.promoted.i = load double, double* %arrayidx9.i, align 8, !tbaa !47, !alias.scope !32, !noalias !44 due to   store double %add10.i, double* %arrayidx9.i, align 8, !dbg !49, !tbaa !47, !alias.scope !32, !noalias !44 [-Rpass=enzyme]
bugDense.cpp:21:21: remark: Load may need caching   %10 = load double, double* %arrayidx.i, align 8, !dbg !56, !tbaa !47, !alias.scope !26, !noalias !57 due to   tail call void @llvm.memset.p0i8.i64(i8* align 8 %v6.i.i34, i8 0, i64 %15, i1 false) #12, !dbg !79, !alias.scope !80, !noalias !83 [-Rpass=enzyme]
          out[i] += A[i*m+j] *x[j];
                    ^
bugDense.cpp:21:31: remark: Load may need caching   %11 = load double, double* %arrayidx6.i, align 8, !dbg !58, !tbaa !47, !alias.scope !30, !noalias !59 due to   tail call void @llvm.memset.p0i8.i64(i8* align 8 %v6.i.i34, i8 0, i64 %15, i1 false) #12, !dbg !79, !alias.scope !80, !noalias !83 [-Rpass=enzyme]
          out[i] += A[i*m+j] *x[j];
                              ^
remark: Load may need caching   %arrayidx9.promoted.i43 = load double, double* %arrayidx9.i42, align 8, !tbaa !47, !alias.scope !74, !noalias !83 due to   store double %add10.i54, double* %arrayidx9.i42, align 8, !dbg !86, !tbaa !47, !alias.scope !74, !noalias !83 [-Rpass=enzyme]
bugDense.cpp:21:31: remark: Load must be recomputed   %11 = load double, double* %arrayidx6.i, align 8, !dbg !58, !tbaa !47, !alias.scope !30, !noalias !59 in reverse_invertfor.body4.i due to   tail call void @llvm.memset.p0i8.i64(i8* align 8 %v6.i.i34, i8 0, i64 %15, i1 false) #12, !dbg !79, !alias.scope !80, !noalias !83 [-Rpass=enzyme]

from enzyme.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.