Re: [sage-devel] Re: Call qsort from cython code .... with an inlined comparison function ?!

2014-11-23 Thread Francesco Biscani
icc is a pretty garbage C++ compiler, unless you are doing exactly the type of linear algebra operations that they optimise to death (on Intel processors at least :) for benchmarketing. On 23 November 2014 at 21:53, Thierry Dumont wrote: > Le 23/11/2014 20:53, Jeroen Demeyer a écrit : > >> On 20

Re: [sage-devel] Re: Call qsort from cython code .... with an inlined comparison function ?!

2014-11-23 Thread Thierry Dumont
Le 23/11/2014 20:53, Jeroen Demeyer a écrit : On 2014-11-23 19:05, Thierry Dumont wrote: Vtune shows, for example, that a call to std::copy is not as fast as a for loop, which is turned by the compiler in a memcopy (probably std::copy is not!). If that's the case, get a better C++ compiler. h

Re: [sage-devel] Re: Call qsort from cython code .... with an inlined comparison function ?!

2014-11-23 Thread Francesco Biscani
On 23 November 2014 at 20:41, Thierry Dumont wrote: > But what about the quick sort? is it sure that the implementation cannot > degenerate? it is well known all the efficiency can be lost if the "key" > used for partition is not chosen as it should be... What about replacing > the quick sort by

Re: [sage-devel] Re: Call qsort from cython code .... with an inlined comparison function ?!

2014-11-23 Thread Jeroen Demeyer
On 2014-11-23 19:05, Thierry Dumont wrote: Vtune shows, for example, that a call to std::copy is not as fast as a for loop, which is turned by the compiler in a memcopy (probably std::copy is not!). If that's the case, get a better C++ compiler. -- You received this message because you are subs

Re: [sage-devel] Re: Call qsort from cython code .... with an inlined comparison function ?!

2014-11-23 Thread Thierry Dumont
Le 23/11/2014 19:09, Nathann Cohen a écrit : Hello ! What about likwid https://code.google.com/p/likwid ? It is free. Did somebody used it to measure cython code performances? Never tried vtune, nor likwid. What is the size of what you are sorting ? If it is small enough to fit in the cache

Re: [sage-devel] Re: Call qsort from cython code .... with an inlined comparison function ?!

2014-11-23 Thread Thierry Dumont
Le 23/11/2014 19:07, Francesco Biscani a écrit : On 23 November 2014 at 18:07, Volker Braun mailto:vbraun.n...@gmail.com>> wrote: C++ std::sort will be able to inline the comparator. Just look at the assembly code:-) +1 std::sort() will do exactly what you describe, only in a type-safe

Re: [sage-devel] Re: Call qsort from cython code .... with an inlined comparison function ?!

2014-11-23 Thread Christopher Swenson
There's a sort.h library you should be able to include that will have quick sort + many others, and will allow the compiler to properly inline functions. https://github.com/swenson/sort (disclaimer: I wrote it). I get about a 10x speed improvement over qsort just for the ability to inline functions

Re: [sage-devel] Re: Call qsort from cython code .... with an inlined comparison function ?!

2014-11-23 Thread Francesco Biscani
On 23 November 2014 at 19:05, Thierry Dumont wrote: > > Is gprof enough powerful with modern architectures on such programs? from > my point of view, no. > There are non free, commercial, tools like vtune which can do fantastic > measurement job. Vtune shows, for example, that a call to std::copy

Re: [sage-devel] Re: Call qsort from cython code .... with an inlined comparison function ?!

2014-11-23 Thread Nathann Cohen
Hello ! > What about likwid https://code.google.com/p/likwid ? It is free. Did > somebody used it to measure cython code performances? Never tried vtune, nor likwid. > What is the size of what you are sorting ? If it is small enough to fit in > the caches, and better in the L1 cache, you can pos

Re: [sage-devel] Re: Call qsort from cython code .... with an inlined comparison function ?!

2014-11-23 Thread Francesco Biscani
On 23 November 2014 at 18:07, Volker Braun wrote: > > C++ std::sort will be able to inline the comparator. > +1 std::sort() will do exactly what you describe, only in a type-safe and compiler-checked automatic way. -- You received this message because you are subscribed to the Google Groups "

Re: [sage-devel] Re: Call qsort from cython code .... with an inlined comparison function ?!

2014-11-23 Thread Thierry Dumont
Le 23/11/2014 18:07, Volker Braun a écrit : Did you profile your code on the C-level? e.g. using gprof? As a rule of thumb, guesses about where the bottleneck is are wrong :-) Its entirely conceivable that branch prediction and speculative execution solve this already for you. Is gprof enough

Re: [sage-devel] Re: Call qsort from cython code .... with an inlined comparison function ?!

2014-11-23 Thread Nathann Cohen
Yo ! > Did you profile your code on the C-level? e.g. using gprof? As a rule of > thumb, guesses about where the bottleneck is are wrong :-) Its entirely > conceivable that branch prediction and speculative execution solve this > already for you. Yeees daddy :-P I did that like a grown man w

[sage-devel] Re: Call qsort from cython code .... with an inlined comparison function ?!

2014-11-23 Thread Volker Braun
Did you profile your code on the C-level? e.g. using gprof? As a rule of thumb, guesses about where the bottleneck is are wrong :-) Its entirely conceivable that branch prediction and speculative execution solve this already for you. C++ std::sort will be able to inline the comparator. Link-t