-
Notifications
You must be signed in to change notification settings - Fork 196
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
add MP_SMALL_STACK_SIZE
option
#538
Conversation
d577ff8
to
75d8a23
Compare
75d8a23
to
aab1c1f
Compare
@jlaitine could you maybe have a look and tell me whether that's an acceptable solution for you? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found nothing except some typos.
But the effect on the ECC computations is interesting!
What happened to this PR? Did you change your mind? I find it quite interesting to have a choice between stack and heap for this. On the other side: it breaks our general thread-safety and needs locks. |
838b736
to
f18c997
Compare
No, I just didn't have the passion to follow up :)
That's indeed a thing. I'm not sure whether it'd make sense to replace the locks by taking care of that ourselves and using lock-free/atomic operations under the hood!? |
3e1a7ce
to
887b799
Compare
Sorry, took a bit longer to check.
Yes, looks reasonable. Caveat: I cannot test the Windows stuff now: my last PC here with Windows (what is the plural of Windows?) let the magic smoke out, need a visit to Ebay before going on. PS: I am aware of my TODO list, it's not forgotten! |
My SO just explained to me that the plural only works with the complete name! Microsoft Windows -> Microsofts Windows
No need to hurry, we have time.
I'll see what I can do by extending CI. |
Ah, ok, my thanks to your SO!
That would be really nice!
You have, but I'm an overweight old fart already! ;-) My main problem is the error I got with the base2->base10 conversion with a single round of NR to compute the next divisor at a very large (close to We need to be able to do at most 22 rounds with Was the aformentioned single error just a random bitflip? An error elsewhere? *hng*! |
2723f09
to
d6dca63
Compare
You're very welcome ;-)
wow, what a ride ... In between I was not sure whether I'd simply disable the feature for MSVC ... but now it seems to work^TM ... |
d6dca63
to
21207c4
Compare
This adds an option to use a heap-buffer for the usually stack-based `MP_WARRAY`-sized temporary buffers. Per default it will reserve a single buffer, which can be modified * at compile-time via the `MP_WARRAY_NUM` define * at run-time by calling `mp_warray_init()` The internal structure can only be created once. If one wants to modify the maximum number of elements, the entire structure has to be free'd by calling `mp_warray_free()`. In case one wants to use this option with multiple threads, one shall use the `mp_warray_init()` function and pass appropriate locking functions. Signed-off-by: Steffen Jaeckel <[email protected]>
21207c4
to
c9b07aa
Compare
`s_warray_init()` and `s_warray_free()` are not safe and MUST NOT be called from multiple threads. This also removes `MP_WARRAY_NUM`, since automatic initialization will not be safe for more than one thread. Signed-off-by: Steffen Jaeckel <[email protected]>
To be able to support this for MSVC as well, we have to move this into a separate private API function. Signed-off-by: Steffen Jaeckel <[email protected]>
Output gets garbeled a bit, but we only care for the result which is `Tests OK/NOP/FAIL: 50/0/0`. Add `-Wno-incomplete-setjmp-declaration` since `clang-10` shipping with Ubuntu 20.04 seems broken... and `-Wno-unknown-warning-option` since `clang-8` doesn't know about this warning... Signed-off-by: Steffen Jaeckel <[email protected]>
... and fix some MSVC related (and other) things. Signed-off-by: Steffen Jaeckel <[email protected]>
Signed-off-by: Steffen Jaeckel <[email protected]>
c9b07aa
to
334465d
Compare
@jlaitine can you please check if this works for you? |
Signed-off-by: Steffen Jaeckel <[email protected]>
Signed-off-by: Steffen Jaeckel <[email protected]>
Signed-off-by: Steffen Jaeckel <[email protected]>
Signed-off-by: Steffen Jaeckel <[email protected]>
Signed-off-by: Steffen Jaeckel <[email protected]>
1ea2413
to
3570e12
Compare
aaaand in the end I disabled it for MSVC since IMO the most elegant solution is via TLS and MSVC seems to have a problem with TLS in DLLs. I'm not 100% sure what's going wrong, but since it was going fine with the static library [0] I suspect that we'd have to implement what's described in [1] and I'm simply not willing to do that, nor would I accept a PR that implements it. If I'm mistaken there and someone with more MSVC experience wants to chime in and provide an easy fix, I'll happily accept that :) [0] https://ci.appveyor.com/project/libtom/libtommath/builds/49507598 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bearhug?
So that's the superlativ of "unnecessary complicated", isn't it? |
Hi sorry for the very long response time, I have been busy with some other things. I see that this already got merged, so I tested the development branch directly and this change works perfectly! I still have a small compilation error, in PX4, which is compiled with "-Wall". Not related to this PR. I created anoter PR out of that: #578 Thanks again, |
Thanks a lot for the feedback! Glad to hear that it works for you :) |
This adds an option to use a heap-buffer for the usually stack-based
MP_WARRAY
-sized temporary buffers.Per default it will reserve a single buffer, which can be modified
MP_WARRAY_NUM
definemp_warray_init()
The internal structure can only be created once. If one wants to modify
the maximum number of elements, the entire structure has to be free'd
by calling
mp_warray_free()
.In case one wants to use this option with multiple threads, one shall
use the
mp_warray_init()
function and pass appropriate locking functions.Timings
Related to: #441 #447 #511