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

Segment fault/Bus error from CreateHomalgMatrixFromSparseString in Singular #307

Open
HereAround opened this issue Jan 14, 2020 · 13 comments

Comments

@HereAround
Copy link
Member

I create a large (56.426 x 48.018) spare matrix over the rationals in Singular. For convenience, the entries are saved as a list in the following .txt file:

entries.txt

Now I issue the following code, to crease the corresponding matrix:

LoadPackage( "RingsForHomalg" );
rationals := HomalgFieldOfRationalsInSingular();
Read( "entries.txt" );
matrix := CreateHomalgMatrixFromSparseString( String( entries ), 56426, 48018, rationals );

On Plesken, this leads to the following error message:

Error, the external CAS Singular (running with PID 406990) returned the following error:
Singular : signal 11 (v: 4122):
current line:>>homalg_variable_5[38059,42739]=1;<<
Segment fault/Bus error occurred at 7f11f1c2ce68 because of 10a82 (r:1579015574)
please inform the authors
trying to restart...

at /opt/gap/gap_pkg/pkg/homalg_project/HomalgToCAS/gap/homalgSendBlocking.gi:812 called from
homalgSendBlocking( [ M, "[", c, r, "]=", s ], "need_command", HOMALG_IO.Pictograms.SetMatElm ); at /opt/gap/gap_pkg/pkg/homalg_project/RingsForHomalg/gap/Singular.gi:2113 called from
SetMatElm( M, Int( a[1] ), Int( a[2] ), a[3], R ); at /opt/gap/gap_pkg/pkg/homalg_project/MatricesForHomalg/gap/HomalgMatrix.gi:2139 called from
f( x ); at /opt/gap/gap-stable-4.11/lib/coll.gi:2189 called from
Perform( s, function ( a )
SetMatElm( M, Int( a[1] ), Int( a[2] ), a[3], R );
return;
end ); at /opt/gap/gap_pkg/pkg/homalg_project/MatricesForHomalg/gap/HomalgMatrix.gi:2139 called from
<function "CreateHomalgMatrixFromSparseString constructor for homalg matrices">( )
called from read-eval loop at Error.gi:14
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue

Any suggestion on how this can be fixed?

@HereAround HereAround changed the title Segment fault/Bus error on creating CreateHomalgMatrixFromSparseString in Singular Segment fault/Bus error from CreateHomalgMatrixFromSparseString in Singular Jan 14, 2020
@mohamed-barakat
Copy link
Member

This is a Singular problem. You can use

gap> homalgIOMode("f");

(before creating the ring) to instruct homalg to dump the communication in a Singular-readable ifle.

@HereAround
Copy link
Member Author

HereAround commented Jan 15, 2020

Thanks for the suggestion. I have just tried this on Plesken:

LoadPackage( "RingsForHomalg" );
homalgIOMode("f");
rationals := HomalgFieldOfRationalsInSingular();
Read( "entries.txt" );
matrix := CreateHomalgMatrixFromSparseString( String( entries ), 56426, 48018, rationals );

Unfortunately, this leads to the same error as above.

@mohamed-barakat
Copy link
Member

Yes, but you now have the Singular-dump :) So now you can take the dump with the needed file entries.txt and open an issue on Singular/Sources.

@mohamed-barakat
Copy link
Member

What is the state of this issue?

@HereAround
Copy link
Member Author

Andreas Steenpass suggested, that this is likely linked to insufficient RAM. Moreover, it seems possible to save RAM by changing the code supplied to Singular by the CASForHomalg-Interface.

Whilst I believe that this is likely to fix the issue, I have unfortunately not yet been able to investigate in more detail for time reasons.

@mohamed-barakat
Copy link
Member

Good, then we leave it open until you report on it.

@HereAround
Copy link
Member Author

HereAround commented Jun 20, 2020

Let me comment more on the above. I have just tried to run the above code again, and it is working now. Still, it typically requires about 40GB of RAM. Hence, as suggested above, this code will likely fail in case there is fewer RAM available.

Maybe we can discuss, if all of this can be resolved uniformly by a package "SparseMatricesForHomalg", which provides SparseMatrices interfaces to Singular, Magma, Spasms... Or (if not already happened?) we extend the existing MatricesForHomalgPackage by this functionality.

@mohamed-barakat
Copy link
Member

  • To reduce the memory consumption by Singular, @steenpass suggested the following: "Auf meinem Rechner läuft der Code, den Du in dem Issue auf Github gepostet hast, tatsächlich durch, schreibt aber fast den ganzen Swap voll und braucht insgesamt gut 40 GB. Das kannst Du schon auf die Hälfte reduzieren, wenn Du einfach
    matrix mat[48018][56426];
    anstelle von
    matrix mat[48018][56426] = 0;
    schreibst. Das wird trotzdem mit Nullen initialisiert ". Maybe we can remove the "=0" at the interface to Singular?

This is not as easy as it seems since homalgSendBlocking supports specifying the LHS and the RHS of = but does not support creating an assignment without an =.

@mohamed-barakat
Copy link
Member

Maybe we can discuss, if all of this can be resolved uniformly by a package "SparseMatricesForHomalg", which provides SparseMatrices interfaces to Singular, Magma, Spasms... Or (if not already happened?) we extend the existing MatricesForHomalgPackage by this functionality.

Yes, this would be great but should happen in coordination with the new matrixobj interface in GAP. On the long run, I would like to outsource the handling of matrices/sparse-matrices to GAP/Julia/Oscar.

@HereAround
Copy link
Member Author

  • To reduce the memory consumption by Singular, @steenpass suggested the following: "Auf meinem Rechner läuft der Code, den Du in dem Issue auf Github gepostet hast, tatsächlich durch, schreibt aber fast den ganzen Swap voll und braucht insgesamt gut 40 GB. Das kannst Du schon auf die Hälfte reduzieren, wenn Du einfach
    matrix mat[48018][56426];
    anstelle von
    matrix mat[48018][56426] = 0;
    schreibst. Das wird trotzdem mit Nullen initialisiert ". Maybe we can remove the "=0" at the interface to Singular?

This is not as easy as it seems since homalgSendBlocking supports specifying the LHS and the RHS of = but does not support creating an assignment without an =.

I suppose a specialized/additional `homalgSendBlocking'-method, which initializes objects with zeros, is too involved (e.g. for architectural reasons)?

@HereAround
Copy link
Member Author

Maybe we can discuss, if all of this can be resolved uniformly by a package "SparseMatricesForHomalg", which provides SparseMatrices interfaces to Singular, Magma, Spasms... Or (if not already happened?) we extend the existing MatricesForHomalgPackage by this functionality.

Yes, this would be great but should happen in coordination with the new matrixobj interface in GAP. On the long run, I would like to outsource the handling of matrices/sparse-matrices to GAP/Julia/Oscar.

I agree. Best to solve this once in one place.

@mohamed-barakat
Copy link
Member

I suppose a specialized/additional `homalgSendBlocking'-method, which initializes objects with zeros, is too involved (e.g. for architectural reasons)?

homallgSendBlocking is a global function that does the complex analysis internally, which would be far too complicated for GAP's simplistic method selection. If this a really a pressing serious issue for you I can invest some time and resolve it for you.

@HereAround
Copy link
Member Author

Thank you Mohamed. No, I think the current support for matrices is sufficient (and has been for years). Let us consider this a feature request.

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

No branches or pull requests

2 participants