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
Improve asteroidal triples code #19337
Comments
Branch: u/dcoudert/asteroid |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Commit: |
This comment has been minimized.
This comment has been minimized.
comment:3
Using int should be enough for the size of graphs we can process. |
Changed dependencies from #19334 to none |
comment:5
Err... int are usually larget than 32bits ?... |
comment:6
Replying to @nathanncohen:
In fact, no. On all systems I know, |
comment:7
Funny. I had somewhere in my head that int and long were the same size. Anyway, why should we downgrade those uint32 to int exactly? Nathann |
comment:8
It seems from the comments on the other ticket that you would only need to replace "-1" with "-1L"?.. |
comment:9
Replying to @nathanncohen:
on 32-bit systems that's true :-) Note that the C standard doesn't say much about this. On Windows for example, |
Dependencies: #19334 |
comment:11
The only guarantee by the C spec is that I'd recommend the C99 |
comment:13
So let's try with |
comment:14
Replying to @vbraun:
-1. Why should this graph code use a type of at least 32 bits? Where does the arbitrary number 32 come from? Why not If you don't want
Really, why that? I would say that you should always use types like |
comment:15
I did not check this specific code but uint32_t probably comes from the data structure "static_sparse_graph", which uses them. Then, as David said, this algorithm does not need uint32_t -- it would not run. The 31 bits of int32_t would do, and 16 bits would probably be sufficient.
Here we want to specify the bit length, because the smallest the type is the better it will be cached. We will read memory very very often in that code. Nathann |
comment:16
About the "fastest on the target system": that very much depends on the application. On 64-bit systems, it could easily be a 64-bit type. If you're making arrays of those (it seems that you do), you can end up slower than PS: I realize that we're bikeshedding here. I'm not really against |
comment:18
Yes yes, I agree.
Sooo... Would you say that there is actually anything that needs be changed in this file? We use fixed-size types, they are unsigned because that's what the data structure expects, and the change in Cython has been fixed by Volker with a cast. Nathann |
comment:19
Hello, the algorithm has time complexity I was using Let me know. David. |
comment:20
If you need only 16 bits then there is of course Replying to @jdemeyer:
But not guaranteed to be particularly fast.
I.e. the "legacy libraries" case.
But by using
With the C99 data types you just need to answer
|
comment:21
Replying to @vbraun:
I can play that game too: Usually, you see
I don't think that one should always answer this question. There are valid use cases for types which have different sizes on 32-bit and 64-bit systems. |
comment:22
Go play it somewhere else. This thing is a trac ticket. Review it or exchange private emails. Nathann |
comment:23
Replying to @jdemeyer:
I agree that there are valid use cases, but
|
comment:24
This, right after you decided to not include a stopgap in a code that returns wrong answers? That made me laugh. |
comment:25
Today, with sage 6.9.rc3 and without this patch, I have a segfault! With this patch it's working. I don't know which is the best type to use and above discussion confuses me. What I do know is that this patch solves a segfault and so is needed. Best, |
comment:26
Do you know if the segfault is deterministic? Does it happen consistently or may it be related to something else? I do not see how changing the type may fix anything that is not already fixed by #19334. Nathann |
comment:28
We can certainly close this ticket. |
Fix some types problems raised in #19334 for
asteroidal_triples.pyx
.In particular, we get rid of
uint32_t
whenever possible.Depends on #19334
CC: @nathanncohen
Component: graph theory
Author: David Coudert
Branch/Commit: u/dcoudert/asteroid @
e32015d
Issue created by migration from https://trac.sagemath.org/ticket/19337
The text was updated successfully, but these errors were encountered: