[pythran] Re: NPB

  • From: Brunet Pierrick <pierrick.brunet@xxxxxxxxxxxxxxxxxxx>
  • To: pythran@xxxxxxxxxxxxx
  • Date: Sun, 02 Dec 2012 15:47:21 +0100

We can use this example:

#pythran export test()
def test():
    for i in xrange(10,0,-1):
        print i

it is translated to:

for (typename assignable<decltype(proxy::xrange()(10L, 0L, -1L))>::type::iterator __target1 = __iter1.begin(); __target1 < __iter1.end(); ++__target1)
      {
        i = *__target1;
        print(i);
      }

__iter1.begin() is first equals to 10 whereas __iter.end() is equal to 0. At the first step, the condition is : 10 < 0, and it is false. BTW, my solution to change operator< for xrange_iterator is not a good solution IMO because it will cause some problem if we use these interators with another context. (when we will have iter() function for example)

About float, you have an idea for representation only? Or you have idea for precision?

Concerning perf, once again, I forget flags ... With -03, it takes only 156ms. 3x slower than C but 46x faster than python :-)

Le 02/12/2012 15:23, Serge GUELTON a écrit :
Thanks a lot for the hard work !

Concerning xrange:
Bad news. Can you provide us with a limited failing example ?

Concerning float representation:
I guess I know how to handle this

Concerning the perf:
what are the optimization flag ? Does callgrind points on a particular 
performance bottleneck ?

----- Mail original -----
De: "Brunet Pierrick" <pierrick.brunet@xxxxxxxxxxxxxxxxxxx>
À: pythran@xxxxxxxxxxxxx
Envoyé: Samedi 1 Décembre 2012 20:05:07
Objet: [pythran] NPB

Hi all,

After hours using debug, I finally found issue. Pythran doesn't handle
correctly xrange with negative step. Iterators are correctly generated
BUT the condition is : __iter1 < xrange.end().
It should be > if we have negative step. It is hard to handle this case
as for loop in python doesn't need comparaison. We only use iterators. A
solution may be to handle negative step in operator< in xrange_iterator.




Doing it, I have nearly the same output with python and pythran. The
only difference is :

pythran with constant folding :

Error is ' 6.13198380961e-11 '
(in this case other result are a little different too...)

pythran without constant folding :

Error is ' 4.80859796426e-12 '

python and C :

Error is 8.881784197e-15

About execution time, we have:

pythran with constant folding : 2.92s
pythran without constant folding : 2.95s
python : 7.08s
C : 0.052s

I didn't test omp for now.

Other comments :
We should add a std::cout.precision(12) to have the same output with
pythran and python if we print float.
print list[100:200] doesn't work with pythran because operator<< is not
overload for list_view
I think we doesn't correctly print boolean (0 or 1 instead of False or True)

Good night :-)





Other related posts: