some help about building enzyme

63 views
Skip to first unread message

Min Xu

unread,
Oct 10, 2023, 3:21:57 PM10/10/23
to Enzyme AD
Hi,

I am a software developer in ANSYS. I am new to enzyme and would like to learn it. When I pulled the enzyme from github and tried to build it following https://enzyme.mit.edu/Installation/. I got the following error during ninja

'class llvm::AttributeList' has no member named 'hasRetAttribute'; did you mean 'addRetAttribute'?
     if (f->getAttributes().hasRetAttribute(attr)) {
                            ^~~~~~~~~~~~~~~
                            addRetAttribute

The system is 
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.4.1708 (Core)
Release:        7.4.1708
Codename:       Core

Is there anyone can provide some help? Thanks in advance for your help!


Best,

Min


William Moses

unread,
Oct 10, 2023, 5:54:05 PM10/10/23
to Min Xu, Enzyme AD
Hi Min,

So we broke LLVM 14-16 support over the last few days, but actually just fixed it with https://github.com/EnzymeAD/Enzyme/pull/1475

Perhaps try again on the latest main (or if you prefer, the latest release)?

--
You received this message because you are subscribed to the Google Groups "Enzyme AD" group.
To unsubscribe from this group and stop receiving emails from it, send an email to enzyme-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/enzyme-dev/41dbb99e-5426-441d-a0fa-d80fb24c0829n%40googlegroups.com.

nmsu ust

unread,
Oct 13, 2023, 3:13:57 PM10/13/23
to William Moses, Enzyme AD
Hi William and Enzyme members

Thanks a lot for your help. After updating the repo, it works now with both clang16 and can run with a single code. However, when I try to compile code for multiple files in simple test codes following https://www.youtube.com/watch?v=rux1-oje9u8&t=2s. It didn't work. It failed at the last steps. 

clang++ -target x86_64-pc-linux-gnu -c -fuse-ld=lld -flto -O2  test-enzyme.cpp -o test-enzyme.o

clang++ -target x86_64-pc-linux-gnu -c -fuse-ld=lld -flto -O2  afun.cpp -o afun.o

clang++ -target x86_64-pc-linux-gnu -fuse-ld=lld -flto -O2 test-enzyme.o afun.o -fplugin=/net/nfs.lebisilon/home/mixu/Software/Enzyme/enzyme/build/Enzyme/ClangEnzyme-16.so -o my_program


image.png
I also tried the following and got the same error. I appreciate any suggestions. Is there any places for the documents of Enzyme? The online website seems not sufficient for complicated applications.

clang++ -target x86_64-pc-linux-gnu -fuse-ld=lld -flto -O2 test-enzyme.o afun.o -o my_program -Wl,-mllvm=-load=/net/nfs.lebisilon/home/mixu/Software/Enzyme/enzyme/build/Enzyme/LLVMEnzyme-16.so


Here are the simple codes. 

afun.hpp

double myfunction(double x);


afun.cpp


#include "afun.hpp"
double myfunction(double x)
{
    return 2 *x;
}



test-enzyme.cpp
#include <stdio.h>
#include "afun.hpp"

extern double __enzyme_autodiff(void*, double);

double square(double x) {
    return x * x + myfunction(x);
}

double dsquare(double x) {
    // This returns the derivative of square or 2 * x
    return __enzyme_autodiff((void*)square, x);
}

int main() {
    for(double i=1; i<5; i++)
        printf("square(%f)=%f, dsquare(%f)=%f", i, square(i), i, dsquare(i));
}


Thanks!

Best,

Min

Manuel Drehwald

unread,
Oct 18, 2023, 2:30:56 PM10/18/23
to Enzyme AD
Hi Min,

you are using LLVMEnzyme, but that one is intended to be used to differentiate LLVM-IR (.ll or .bc) files, using opt.
You are not using opt, but Clang, so you should either use ClangEnzyme or LLDEnzyme, our compiler and linker plugins.
Since you have multiple cpp files and ClangEnzyme can't differentiate across cpp files, you should use LLDEnzyme in this case.

Best,
Manuel

nmsu ust

unread,
Oct 18, 2023, 7:23:19 PM10/18/23
to Manuel Drehwald, Enzyme AD
Hi Manuel,

Thanks a lot for getting back to me. Thanks for pointing that out. I did not notice, there are LLDEnzyme and LLVMEnzyme. After use LLDEnzyme-16.so, I still get the following error.

clang++ -target x86_64-pc-linux-gnu -fuse-ld=lld -flto -O2 -Wl,-mllvm=-load=/net/nfs.lebisilon/home/mixu/Software/Enzyme/enzyme/build/Enzyme/LLDEnzyme-16.so /net/nfs.lebisilon/home/mixu/test/test_code/test-enzyme/obj/test-enzyme.o /net/nfs.lebisilon/home/mixu/test/test_code/test-enzyme/obj/afun.o -o /net/nfs.lebisilon/home/mixu/test/test_code/test-enzyme/my_program
ld.lld: error: undefined symbol: __enzyme_autodiff(void*, double)
>>> referenced by ld-temp.o
>>>               lto.tmp:(main)
>>> referenced by ld-temp.o
>>>               lto.tmp:(main)
>>> referenced by ld-temp.o
>>>               lto.tmp:(main)
>>> referenced 1 more times
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

Thanks in advance for your help!

Best,

Min

Manuel Drehwald

unread,
Oct 25, 2023, 2:28:25 AM10/25/23
to Enzyme AD
You will need to adjust the syntax to use LLDEnzyme, here is someone also asking about how to use LLDEnzyme.
If you have some time, we would appreciate any updates to the website (EnzymeAD/www repo) to make this information easier to find!
https://github.com/EnzymeAD/Enzyme/issues/1462
Reply all
Reply to author
Forward
0 new messages