Skip to content
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

rewrite Matrix_modn_sparse and vector_modn_sparse code so that the modulus is 64-bit on 64-bit platforms #12679

Closed
williamstein opened this issue Mar 16, 2012 · 15 comments

Comments

@williamstein
Copy link
Contributor

Right now the matrix modn sparse class uses ints to store entries. The basic reason is the code

cdef struct c_vector_modint:
    int *entries

in sage/modules/vector_modn_sparse_h.pxi. This should probably instead use the unsigned C99 type uint_fast64_t.

CC: @sagetrac-Bouillaguet @ClementPernet @embray @videlec

Component: linear algebra

Author: Frédéric Chapoton

Branch/Commit: bc31936

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/12679

@vbraun
Copy link
Member

vbraun commented May 22, 2013

comment:1

As discussed in #14627, this should really be signed int_fast64_t. Then it fits into a PyInt on all sensible (i.e. excluding Win64) platforms.

@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@fchapoton
Copy link
Contributor

comment:7

tentative


New commits:

bc31936using int_fast64 for vector_modn_sparse

@fchapoton
Copy link
Contributor

Branch: u/chapoton/12679

@fchapoton
Copy link
Contributor

Commit: bc31936

@fchapoton
Copy link
Contributor

comment:9

Is this a good idea or not ?

@fchapoton
Copy link
Contributor

Author: Frédéric Chapoton

@ClementPernet
Copy link
Contributor

comment:10

I strongly support using ints with a specified size when they will be used for arithmetic. I am not familar with the Win64 support problem so I can not tell for this aspect, but otherwise, this seems like a very good move.

@fchapoton
Copy link
Contributor

comment:11

Thanks. And the patchbot is green.

So we should ask Erik what happens on Windows. Erik ?

@fchapoton
Copy link
Contributor

comment:12

Erik or anybody else ? review, opinion, please ?

@fchapoton
Copy link
Contributor

comment:13

Do someone have any comments ? Could somebody please test on Windows ?

@tscrim
Copy link
Collaborator

tscrim commented Dec 9, 2019

Reviewer: Travis Scrimshaw

@tscrim
Copy link
Collaborator

tscrim commented Dec 9, 2019

comment:14

LGTM.

@embray
Copy link
Contributor

embray commented Dec 9, 2019

comment:15

I do need to get the Cygwin patchbot working again. I was running one for a time but it went down, and I never got it running again. Samuel also had one running for a time but he's out of town and I don't know what happened to it. Maybe I'll work on that today.

Nevertheless I don't see any special reason to test this on Windows. int_fast_64_t is part of the C99 standard and will resolve to the appropriate type on the target platform.

@embray
Copy link
Contributor

embray commented Dec 9, 2019

comment:16

Replying to @vbraun:

As discussed in #14627, this should really be signed int_fast64_t. Then it fits into a PyInt on all sensible (i.e. excluding Win64) platforms.

I see, you were worrying about this comment. But it's not an issue. I think the concern here was that on native Windows compilers sizeof(long) == 4 (and the Python 2 PyIntObject uses a long to store its value). But on Cygwin sizeof(long) == 8 so this is not a problem, as we don't support Sage on native Windows anyways.

Plus it's only an issue for Python 2. In the Python 3 PyLongObject which is used for all ints, it uses (by default, on any modern 64-bit system) exact bit size types.

@vbraun
Copy link
Member

vbraun commented Dec 11, 2019

Changed branch from u/chapoton/12679 to bc31936

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants