EnzymeAD / EnzymeAD/Enzyme

Compilation Fails for Posit numbers

Open
#253 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
LLVM
Stars
1.7k
Forks
188
Avg merge
2d 4h
Merged PRs (30d)
22

Description

Hello,

I tried to use Posit representation for floating point numbers .
I grab a header only library that does it as a drop-in replacement for double

`git clone https://github.com/stillwater-sc/universal`

`testPosit.cpp`

```
#include
using namespace std;

// https://github.com/stillwater-sc/universal
#pragma clang diagnostic ignored "-Wc++17-extensions"
#include

extern int enzyme_dup;
extern int enzyme_dupnoneed;
extern int enzyme_out;
extern int enzyme_const;

void __enzyme_autodiff(...);

template
T sq( T x)
{
return x*x;
}

template
void fun1( T* x, T* out )
{
*out = sq(x[0] - 1.0);
}

template
Real MyKernel(const Real& a, const Real& b) {
return a * b; // replace this with your kernel computation
}

constexpr double pi = 3.14159265358979323846;

using Real = sw::universal::posit<32,2>;

int main(int argc, char** argv )
{
cout << "testMemoryAllocator "<< endl;

Real a = sqrt(2);
Real b = pi;
std::cout << "Result: " << MyKernel(a, b) << std::endl;

Real x = 3.0;
Real out = 0.0;
{
out = 0.0;
fun1( &x, &out );
cout << "out " << endl;
cout << out << endl;
}

{
Real dx = 0.0;
Real gout = 1.0;
Real out = 0.0;
__enzyme_autodiff( fun1, enzyme_dup, &x, &dx,
enzyme_dup,&out,&gout );

cout << "out " << endl;
cout << out << endl;
cout << "dx " << endl;
cout << dx << endl;
}

}
```

`clang testPosit.cpp -I/home/username/universal/include -lstdc++ -lm -Xclang -load -Xclang /usr/local/lib/ClangEnzyme-11.so -O2 -o testPosit`

Here is the compilation log :
[errorPosit.log](https://github.com/wsmoses/Enzyme/files/6880098/errorPosit.log)

Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.