-
Notifications
You must be signed in to change notification settings - Fork 8
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
Arithmetic operations are not performed #66
Comments
I'd have to debug it a bit and don't really have the time now, but this is likely an upstream bug in https://gitlab.com/cerlane/SoftPosit, since the operation you're doing is SoftPosit.jl/src/arithmetic.jl Line 3 in aa307d5
|
Thanks Mosè for looking into this. Indeed, while I've been trying to replace piece by piece of C-SoftPosit with pure Julia implementations, all arithmetic operations are still using a ccall. Alexandros, could you run the unit tests on your M1 with #main by doing julia>] test SoftPosit and post the test summaries here? |
Thank you very much, indeed, @giordano.
|
@alexandrosstamatiou could you please quote all your code blocks with triple backquotes? That'd make reading these long blocks much easier. Thanks. |
Sorry - is this what you meant? |
Yup, it looks much better 🙂 Thanks! |
As we thought, the problem is not the Julia code but the C code. In the Posit16(x) == Posit16_old(x) the first function calls a conversion that I’ve written in Julia to replace the C version and Posit16_old calls C SoftPosit. However that also means you could, for the time being, redefine all arithmetic operations via back&forth conversion. Like so
```
Base.:(+)(x::Posit16,y::Posit16) = Posit16(Float32(x)+Float32(y))
```
… On 11 May 2022, at 19:33, Mosè Giordano ***@***.***> wrote:
Yup, it looks much better 🙂 Thanks!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
|
At the moment, defining the arithmetic operations as conversions with Float32 is even faster julia> using SoftPosit, BenchmarkTools
julia> A,B = Posit16.(rand(1000,1000)),Posit16.(rand(1000,1000));
julia> @btime +($A,$B);
25.558 ms (2 allocations: 1.91 MiB)
julia> Base.:(+)(x::Posit16,y::Posit16) = Posit16(Float32(x)+Float32(y))
julia> @btime +($A,$B);
18.911 ms (2 allocations: 1.91 MiB) Probably because I tried to squeeze some performance out of the Posit16-Float32 conversion in Julia in #55 but |
Also meaning that I'd be happy to accept a PR that replaces ccall-arithmetic operations by pure Julia ones (whether via conversion or if anyone wants to write a posit addition from scratch, feel free 😄 ) |
upcoming v0.5 will be independent of C-SoftPosit. I overhauled the conversions and all arithmetics now use those to instead of calling specific posit-arithmetic functions. At the moment this is, despite the detour via float arithmetic, even faster than C-SoftPosit and the conversions are much faster (see #69). Feel free to report here whether #68 (branch |
julia> using SoftPosit
julia> a = Posit16(1.0);
julia> a + a
Posit16(2.0)
julia> versioninfo()
Julia Version 1.9.0-DEV.732
Commit ada860fe7d* (2022-06-10 15:07 UTC)
Platform Info:
OS: macOS (arm64-apple-darwin21.5.0)
CPU: 8 × Apple M1
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
Threads: 4 on 4 virtual cores
julia> pkgversion(SoftPosit)
v"0.5.0" |
Given that SoftPosit.jl v0.5 seems to work on M1, I'm closing this. |
Hi again,
I'm sorry, but there is another issue which I thought to mention in a different post. After resolving the method errors following your suggestions in the previous Issue post, the computation ran but wouldn't terminate! Many potential reasons of course, but I discovered that simple arithmetic operations of
Posit16
values don't work on my Mac (M1 processor):julia> a = Posit16(1.0);
julia> a + a
Posit16(1.0)
The same lines on the Windows machine give
julia> a = Posit16(1.0);
julia> a + a
Posit16(2.0)
Any ideas why this would happen? Recall that I installed the via Main to get SoftPosit.jl working on the Mac...
The text was updated successfully, but these errors were encountered: