[sage-devel] Re: How to compile sparse graph backend with c++

2021-01-12 Thread 'jonatha...@googlemail.com' via sage-devel
I tried to compile more things with C++ and things just got worse. But 
maybe I did it wrong, that is also possible.

Anyway, using sets as an alternative wasn't really sucessfull. It is a bit 
slower. Turns out the data structure is pretty good.

David Coudert schrieb am Dienstag, 12. Januar 2021 um 09:56:19 UTC+1:

> I have not tried yet, but isn't it due to the fact that some parts are 
> compiled with C and others with C++ ?
>
> Le lundi 11 janvier 2021 à 11:28:47 UTC+1, jonatha...@googlemail.com a 
> écrit :
>
>> Super weird. I think it is a cython bug, but I'm not sure.
>>
>> The problem seems to be that the parent class has the same method. I need 
>> to enforce the correct method
>> by
>>
>> self.foo(u) -> SparseGraph.foo(self, u)
>>
>> This seems to work (compiles and the doctests pass).
>>
>> jonatha...@googlemail.com schrieb am Freitag, 8. Januar 2021 um 16:31:48 
>> UTC+1:
>>
>>> Prepending 
>>> # distutils: language = c++
>>> to src/sage/graphs/base/sparse_graph.pyx makes my compilation crash.
>>>
>>> Does anyone know, how to fix it. I'm on develop and I'm getting the 
>>> following compilation error. Does anyone know how to resolve this? Thank 
>>> you.
>>>
>>> Jonathan
>>>
>>> (I want to see whether cpp set would be a reasonable alternative to our 
>>> private tree implementation.)
>>>
>>> [sagelib-9.3.beta5] [3/3] gcc -Wno-unused-result -Wsign-compare -DNDEBUG 
>>> -g -fwrapv -O3 -Wall -Wno-unused -march=native -O2 -g -march=native -O3 -g 
>>> -fPIC -I./sage/data_structures 
>>> -I/srv/public/kliem/sage/local/lib/python3.8/site-packages/cysignals 
>>> -I./sage/cpython -Isage/data_structures 
>>> -I/srv/public/kliem/sage/build/pkgs/sagelib/src 
>>> -I/srv/public/kliem/sage/local/include/python3.8 
>>> -I/srv/public/kliem/sage/local/lib/python3.8/site-packages/numpy/core/include
>>>  
>>> -Ibuild/cythonized -I/srv/public/kliem/sage/local/include/python3.8 -c 
>>> build/cythonized/sage/graphs/base/sparse_graph.cpp -o 
>>> build/temp.linux-x86_64-3.8/build/cythonized/sage/graphs/base/sparse_graph.o
>>>  
>>> -fno-strict-aliasing -DCYTHON_CLINE_IN_TRACEBACK=1 -std=c++11
>>> [sagelib-9.3.beta5] build/cythonized/sage/graphs/base/sparse_graph.cpp: 
>>> In function ‘PyObject* 
>>> __pyx_f_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label(__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraph*,
>>>  
>>> int, int, int, 
>>> __pyx_opt_args_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label*)’:
>>> [sagelib-9.3.beta5] 
>>> build/cythonized/sage/graphs/base/sparse_graph.cpp:6543:94: error: cannot 
>>> convert ‘__pyx_obj_4sage_6graphs_4base_7c_graph_CGraph*’ to 
>>> ‘__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraph*’
>>> [sagelib-9.3.beta5]__pyx_t_6 = 
>>> __pyx_f_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label_unsafe(((struct
>>>  
>>> __pyx_obj_4sage_6graphs_4base_7c_graph_CGraph *)__pyx_v_self), __pyx_v_u, 
>>> __pyx_v_v, __pyx_v_l); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 
>>> 917, __pyx_L1_error)
>>> [sagelib-9.3.beta5] 
>>>  
>>> ~^
>>> [sagelib-9.3.beta5] 
>>> build/cythonized/sage/graphs/base/sparse_graph.cpp:6280:155: note:   
>>> initializing argument 1 of ‘int 
>>> __pyx_f_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label_unsafe(__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraph*,
>>>  
>>> int, int, int)’
>>> [sagelib-9.3.beta5]  static int 
>>> __pyx_f_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label_unsafe(struct
>>>  
>>> __pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraph *__pyx_v_self, int 
>>> __pyx_v_u, int __pyx_v_v, int __pyx_v_l) {
>>> [sagelib-9.3.beta5] 
>>>   
>>> ~^~~~
>>> [sagelib-9.3.beta5] build/cythonized/sage/graphs/base/sparse_graph.cpp: 
>>> In function ‘PyObject* 
>>> __pyx_pf_4sage_6graphs_4base_12sparse_graph_18SparseGraphBackend_4has_edge(__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraphBackend*,
>>>  
>>> PyObject*, PyObject*, PyObject*)’:
>>> [sagelib-9.3.beta5] 
>>> build/cythonized/sage/graphs/base/sparse_graph.cpp:10771:105: error: cannot 
>>> convert ‘__pyx_obj_4sage_6graphs_4base_7c_graph_CGraphBackend*’ to 
>>> ‘__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraphBackend*’
>>> [sagelib-9.3.beta5]__pyx_t_2 = 
>>> __pyx_f_4sage_6graphs_4base_12sparse_graph_18SparseGraphBackend__has_labeled_edge_unsafe(((struct
>>>  
>>> __pyx_obj_4sage_6graphs_4base_7c_graph_CGraphBackend *)__pyx_v_self), 
>>> __pyx_v_u_int, __pyx_v_v_int, __pyx_v_l); if (unlikely(__pyx_t_2 == 
>>> ((int)-1))) __PYX_ERR(0, 1348, __pyx_L1_error)
>>> [sagelib-9.3.beta5] 
>>>   

[sage-devel] Re: How to compile sparse graph backend with c++

2021-01-12 Thread David Coudert
I have not tried yet, but isn't it due to the fact that some parts are 
compiled with C and others with C++ ?

Le lundi 11 janvier 2021 à 11:28:47 UTC+1, jonatha...@googlemail.com a 
écrit :

> Super weird. I think it is a cython bug, but I'm not sure.
>
> The problem seems to be that the parent class has the same method. I need 
> to enforce the correct method
> by
>
> self.foo(u) -> SparseGraph.foo(self, u)
>
> This seems to work (compiles and the doctests pass).
>
> jonatha...@googlemail.com schrieb am Freitag, 8. Januar 2021 um 16:31:48 
> UTC+1:
>
>> Prepending 
>> # distutils: language = c++
>> to src/sage/graphs/base/sparse_graph.pyx makes my compilation crash.
>>
>> Does anyone know, how to fix it. I'm on develop and I'm getting the 
>> following compilation error. Does anyone know how to resolve this? Thank 
>> you.
>>
>> Jonathan
>>
>> (I want to see whether cpp set would be a reasonable alternative to our 
>> private tree implementation.)
>>
>> [sagelib-9.3.beta5] [3/3] gcc -Wno-unused-result -Wsign-compare -DNDEBUG 
>> -g -fwrapv -O3 -Wall -Wno-unused -march=native -O2 -g -march=native -O3 -g 
>> -fPIC -I./sage/data_structures 
>> -I/srv/public/kliem/sage/local/lib/python3.8/site-packages/cysignals 
>> -I./sage/cpython -Isage/data_structures 
>> -I/srv/public/kliem/sage/build/pkgs/sagelib/src 
>> -I/srv/public/kliem/sage/local/include/python3.8 
>> -I/srv/public/kliem/sage/local/lib/python3.8/site-packages/numpy/core/include
>>  
>> -Ibuild/cythonized -I/srv/public/kliem/sage/local/include/python3.8 -c 
>> build/cythonized/sage/graphs/base/sparse_graph.cpp -o 
>> build/temp.linux-x86_64-3.8/build/cythonized/sage/graphs/base/sparse_graph.o 
>> -fno-strict-aliasing -DCYTHON_CLINE_IN_TRACEBACK=1 -std=c++11
>> [sagelib-9.3.beta5] build/cythonized/sage/graphs/base/sparse_graph.cpp: 
>> In function ‘PyObject* 
>> __pyx_f_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label(__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraph*,
>>  
>> int, int, int, 
>> __pyx_opt_args_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label*)’:
>> [sagelib-9.3.beta5] 
>> build/cythonized/sage/graphs/base/sparse_graph.cpp:6543:94: error: cannot 
>> convert ‘__pyx_obj_4sage_6graphs_4base_7c_graph_CGraph*’ to 
>> ‘__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraph*’
>> [sagelib-9.3.beta5]__pyx_t_6 = 
>> __pyx_f_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label_unsafe(((struct
>>  
>> __pyx_obj_4sage_6graphs_4base_7c_graph_CGraph *)__pyx_v_self), __pyx_v_u, 
>> __pyx_v_v, __pyx_v_l); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 
>> 917, __pyx_L1_error)
>> [sagelib-9.3.beta5]  
>> 
>> ~^
>> [sagelib-9.3.beta5] 
>> build/cythonized/sage/graphs/base/sparse_graph.cpp:6280:155: note:   
>> initializing argument 1 of ‘int 
>> __pyx_f_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label_unsafe(__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraph*,
>>  
>> int, int, int)’
>> [sagelib-9.3.beta5]  static int 
>> __pyx_f_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label_unsafe(struct
>>  
>> __pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraph *__pyx_v_self, int 
>> __pyx_v_u, int __pyx_v_v, int __pyx_v_l) {
>> [sagelib-9.3.beta5]  
>>  
>> ~^~~~
>> [sagelib-9.3.beta5] build/cythonized/sage/graphs/base/sparse_graph.cpp: 
>> In function ‘PyObject* 
>> __pyx_pf_4sage_6graphs_4base_12sparse_graph_18SparseGraphBackend_4has_edge(__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraphBackend*,
>>  
>> PyObject*, PyObject*, PyObject*)’:
>> [sagelib-9.3.beta5] 
>> build/cythonized/sage/graphs/base/sparse_graph.cpp:10771:105: error: cannot 
>> convert ‘__pyx_obj_4sage_6graphs_4base_7c_graph_CGraphBackend*’ to 
>> ‘__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraphBackend*’
>> [sagelib-9.3.beta5]__pyx_t_2 = 
>> __pyx_f_4sage_6graphs_4base_12sparse_graph_18SparseGraphBackend__has_labeled_edge_unsafe(((struct
>>  
>> __pyx_obj_4sage_6graphs_4base_7c_graph_CGraphBackend *)__pyx_v_self), 
>> __pyx_v_u_int, __pyx_v_v_int, __pyx_v_l); if (unlikely(__pyx_t_2 == 
>> ((int)-1))) __PYX_ERR(0, 1348, __pyx_L1_error)
>> [sagelib-9.3.beta5]  
>>
>> ~^~~~
>> [sagelib-9.3.beta5] 
>> build/cythonized/sage/graphs/base/sparse_graph.cpp:2013:173: note:   
>> initializing argument 1 of ‘int 
>> __pyx_f_4sage_6graphs_4base_12sparse_graph_18SparseGraphBackend__has_labeled_edge_unsafe(__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraphBackend*,
>>  
>> int, int, PyObject*)’
>> 

[sage-devel] Re: How to compile sparse graph backend with c++

2021-01-11 Thread 'jonatha...@googlemail.com' via sage-devel
Super weird. I think it is a cython bug, but I'm not sure.

The problem seems to be that the parent class has the same method. I need 
to enforce the correct method
by

self.foo(u) -> SparseGraph.foo(self, u)

This seems to work (compiles and the doctests pass).

jonatha...@googlemail.com schrieb am Freitag, 8. Januar 2021 um 16:31:48 
UTC+1:

> Prepending 
> # distutils: language = c++
> to src/sage/graphs/base/sparse_graph.pyx makes my compilation crash.
>
> Does anyone know, how to fix it. I'm on develop and I'm getting the 
> following compilation error. Does anyone know how to resolve this? Thank 
> you.
>
> Jonathan
>
> (I want to see whether cpp set would be a reasonable alternative to our 
> private tree implementation.)
>
> [sagelib-9.3.beta5] [3/3] gcc -Wno-unused-result -Wsign-compare -DNDEBUG 
> -g -fwrapv -O3 -Wall -Wno-unused -march=native -O2 -g -march=native -O3 -g 
> -fPIC -I./sage/data_structures 
> -I/srv/public/kliem/sage/local/lib/python3.8/site-packages/cysignals 
> -I./sage/cpython -Isage/data_structures 
> -I/srv/public/kliem/sage/build/pkgs/sagelib/src 
> -I/srv/public/kliem/sage/local/include/python3.8 
> -I/srv/public/kliem/sage/local/lib/python3.8/site-packages/numpy/core/include 
> -Ibuild/cythonized -I/srv/public/kliem/sage/local/include/python3.8 -c 
> build/cythonized/sage/graphs/base/sparse_graph.cpp -o 
> build/temp.linux-x86_64-3.8/build/cythonized/sage/graphs/base/sparse_graph.o 
> -fno-strict-aliasing -DCYTHON_CLINE_IN_TRACEBACK=1 -std=c++11
> [sagelib-9.3.beta5] build/cythonized/sage/graphs/base/sparse_graph.cpp: In 
> function ‘PyObject* 
> __pyx_f_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label(__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraph*,
>  
> int, int, int, 
> __pyx_opt_args_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label*)’:
> [sagelib-9.3.beta5] 
> build/cythonized/sage/graphs/base/sparse_graph.cpp:6543:94: error: cannot 
> convert ‘__pyx_obj_4sage_6graphs_4base_7c_graph_CGraph*’ to 
> ‘__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraph*’
> [sagelib-9.3.beta5]__pyx_t_6 = 
> __pyx_f_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label_unsafe(((struct
>  
> __pyx_obj_4sage_6graphs_4base_7c_graph_CGraph *)__pyx_v_self), __pyx_v_u, 
> __pyx_v_v, __pyx_v_l); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 
> 917, __pyx_L1_error)
> [sagelib-9.3.beta5]   
>
> ~^
> [sagelib-9.3.beta5] 
> build/cythonized/sage/graphs/base/sparse_graph.cpp:6280:155: note:   
> initializing argument 1 of ‘int 
> __pyx_f_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label_unsafe(__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraph*,
>  
> int, int, int)’
> [sagelib-9.3.beta5]  static int 
> __pyx_f_4sage_6graphs_4base_12sparse_graph_11SparseGraph_add_arc_label_unsafe(struct
>  
> __pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraph *__pyx_v_self, int 
> __pyx_v_u, int __pyx_v_v, int __pyx_v_l) {
> [sagelib-9.3.beta5]   
> 
> ~^~~~
> [sagelib-9.3.beta5] build/cythonized/sage/graphs/base/sparse_graph.cpp: In 
> function ‘PyObject* 
> __pyx_pf_4sage_6graphs_4base_12sparse_graph_18SparseGraphBackend_4has_edge(__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraphBackend*,
>  
> PyObject*, PyObject*, PyObject*)’:
> [sagelib-9.3.beta5] 
> build/cythonized/sage/graphs/base/sparse_graph.cpp:10771:105: error: cannot 
> convert ‘__pyx_obj_4sage_6graphs_4base_7c_graph_CGraphBackend*’ to 
> ‘__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraphBackend*’
> [sagelib-9.3.beta5]__pyx_t_2 = 
> __pyx_f_4sage_6graphs_4base_12sparse_graph_18SparseGraphBackend__has_labeled_edge_unsafe(((struct
>  
> __pyx_obj_4sage_6graphs_4base_7c_graph_CGraphBackend *)__pyx_v_self), 
> __pyx_v_u_int, __pyx_v_v_int, __pyx_v_l); if (unlikely(__pyx_t_2 == 
> ((int)-1))) __PYX_ERR(0, 1348, __pyx_L1_error)
> [sagelib-9.3.beta5]   
>   
> ~^~~~
> [sagelib-9.3.beta5] 
> build/cythonized/sage/graphs/base/sparse_graph.cpp:2013:173: note:   
> initializing argument 1 of ‘int 
> __pyx_f_4sage_6graphs_4base_12sparse_graph_18SparseGraphBackend__has_labeled_edge_unsafe(__pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraphBackend*,
>  
> int, int, PyObject*)’
> [sagelib-9.3.beta5]  static int 
> __pyx_f_4sage_6graphs_4base_12sparse_graph_18SparseGraphBackend__has_labeled_edge_unsafe(struct
>  
> __pyx_obj_4sage_6graphs_4base_12sparse_graph_SparseGraphBackend 
> *__pyx_v_self, int __pyx_v_u_int, int __pyx_v_v_int, PyObject *__pyx_v_l); 
> /* proto*/
>