octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: integer arithmetics


From: Jaroslav Hajek
Subject: Re: integer arithmetics
Date: Tue, 23 Sep 2008 08:39:54 +0200

On Mon, Sep 22, 2008 at 9:50 PM, John W. Eaton <address@hidden> wrote:
> On 22-Sep-2008, Jaroslav Hajek wrote:
>
> | this is the first part of my aim to extend & improve performance of
> | integer arithmetics in Octave. This patch does not yet implement int64
> | operations (though it prepares the ground). Indeed, the only files
> | modified by this patch are oct-inttypes.h and oct-inttypes.cc. Apart
> | from the octave_int<T> class, the design is mostly rewritten. Due to
> | the more specialized code employed, using C++ integer arithmetics
> | where possible, integer arithmetics from Octave ends up
> | significantly faster.
> |
> | Attached is what I got using "benchmark_intmath" from "benchmarks"
> | Octave-Forge package, averaged over 5 runs on a non-loaded node of our
> | cluster, a 2x dual core AMD Opteron machine on 2.5 GHz with 8 GB RAM,
> | Octave compiled with Intel C++ 10.1 at -O2.
> |
> | Btw. Speed-up is measured as (old-time/new-time - 1)*100%.
> |
> | benchmark results: (averages over 5 runs)
> |
> | [...]
> |
> |  This patch should not, IMHO, be applied before 3.2.x is forked, so
> | I'm sharing mainly for comments.
>
> I tried it but rebuilding fails with:
>
>  g++ -c -I/usr/include/freetype2  -fPIC -I. -I/home/jwe/src/octave/liboctave 
> -I.. -I../liboctave -I../src -I../libcruft/misc -I/home/jwe/src/octave 
> -I/home/jwe/src/octave/liboctave -I/home/jwe/src/octave/src 
> -I/home/jwe/src/octave/libcruft/misc  -DHAVE_CONFIG_H 
> -I/usr/include/freetype2 -Wall -W -Wshadow -Wold-style-cast -ggdb3 
> /home/jwe/src/octave/liboctave/MArray-i.cc -o pic/MArray-i.o
>  /home/jwe/src/octave/liboctave/oct-inttypes.h: In static member function 
> 'static T octave_int_arith_base<T, true>::div(T, T) [with T = signed char]':
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:754:   instantiated from 
> 'octave_int<T> octave_int<T>::operator/(const octave_int<T>&) const [with T = 
> signed char]'
>  /home/jwe/src/octave/liboctave/MArray.cc:126:   instantiated from 'MArray<T> 
> operator/(const MArray<T>&, const T&) [with T = octave_int<signed char>]'
>  /home/jwe/src/octave/liboctave/MArray-i.cc:45:   instantiated from here
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:640: error: call of overloaded 
> 'abs(int)' is ambiguous
>  /usr/include/c++/4.3/cmath:99: note: candidates are: double std::abs(double)
>  /usr/include/c++/4.3/cmath:103: note:                 float std::abs(float)
>  /usr/include/c++/4.3/cmath:107: note:                 long double 
> std::abs(long double)
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:648: error: call of overloaded 
> 'abs(int)' is ambiguous
>  /usr/include/c++/4.3/cmath:99: note: candidates are: double std::abs(double)
>  /usr/include/c++/4.3/cmath:103: note:                 float std::abs(float)
>  /usr/include/c++/4.3/cmath:107: note:                 long double 
> std::abs(long double)
>  /home/jwe/src/octave/liboctave/oct-inttypes.h: In static member function 
> 'static T octave_int_arith_base<T, true>::div(T, T) [with T = short int]':
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:754:   instantiated from 
> 'octave_int<T> octave_int<T>::operator/(const octave_int<T>&) const [with T = 
> short int]'
>  /home/jwe/src/octave/liboctave/MArray.cc:126:   instantiated from 'MArray<T> 
> operator/(const MArray<T>&, const T&) [with T = octave_int<short int>]'
>  /home/jwe/src/octave/liboctave/MArray-i.cc:46:   instantiated from here
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:640: error: call of overloaded 
> 'abs(int)' is ambiguous
>  /usr/include/c++/4.3/cmath:99: note: candidates are: double std::abs(double)
>  /usr/include/c++/4.3/cmath:103: note:                 float std::abs(float)
>  /usr/include/c++/4.3/cmath:107: note:                 long double 
> std::abs(long double)
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:648: error: call of overloaded 
> 'abs(int)' is ambiguous
>  /usr/include/c++/4.3/cmath:99: note: candidates are: double std::abs(double)
>  /usr/include/c++/4.3/cmath:103: note:                 float std::abs(float)
>  /usr/include/c++/4.3/cmath:107: note:                 long double 
> std::abs(long double)
>  /home/jwe/src/octave/liboctave/oct-inttypes.h: In static member function 
> 'static T octave_int_arith_base<T, true>::div(T, T) [with T = int]':
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:754:   instantiated from 
> 'octave_int<T> octave_int<T>::operator/(const octave_int<T>&) const [with T = 
> int]'
>  /home/jwe/src/octave/liboctave/MArray.cc:126:   instantiated from 'MArray<T> 
> operator/(const MArray<T>&, const T&) [with T = octave_int<int>]'
>  /home/jwe/src/octave/liboctave/MArray-i.cc:47:   instantiated from here
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:640: error: call of overloaded 
> 'abs(int)' is ambiguous
>  /usr/include/c++/4.3/cmath:99: note: candidates are: double std::abs(double)
>  /usr/include/c++/4.3/cmath:103: note:                 float std::abs(float)
>  /usr/include/c++/4.3/cmath:107: note:                 long double 
> std::abs(long double)
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:648: error: call of overloaded 
> 'abs(int)' is ambiguous
>  /usr/include/c++/4.3/cmath:99: note: candidates are: double std::abs(double)
>  /usr/include/c++/4.3/cmath:103: note:                 float std::abs(float)
>  /usr/include/c++/4.3/cmath:107: note:                 long double 
> std::abs(long double)
>  /home/jwe/src/octave/liboctave/oct-inttypes.h: In static member function 
> 'static T octave_int_arith_base<T, true>::div(T, T) [with T = long int]':
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:754:   instantiated from 
> 'octave_int<T> octave_int<T>::operator/(const octave_int<T>&) const [with T = 
> long int]'
>  /home/jwe/src/octave/liboctave/MArray.cc:126:   instantiated from 'MArray<T> 
> operator/(const MArray<T>&, const T&) [with T = octave_int<long int>]'
>  /home/jwe/src/octave/liboctave/MArray-i.cc:48:   instantiated from here
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:640: error: call of overloaded 
> 'abs(long int)' is ambiguous
>  /usr/include/c++/4.3/cmath:99: note: candidates are: double std::abs(double)
>  /usr/include/c++/4.3/cmath:103: note:                 float std::abs(float)
>  /usr/include/c++/4.3/cmath:107: note:                 long double 
> std::abs(long double)
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:648: error: call of overloaded 
> 'abs(long int)' is ambiguous
>  /usr/include/c++/4.3/cmath:99: note: candidates are: double std::abs(double)
>  /usr/include/c++/4.3/cmath:103: note:                 float std::abs(float)
>  /usr/include/c++/4.3/cmath:107: note:                 long double 
> std::abs(long double)
>  /home/jwe/src/octave/liboctave/oct-inttypes.h: At global scope:
>  /home/jwe/src/octave/liboctave/oct-inttypes.h: In instantiation of 'static 
> bool octave_int_cmp_op::cf::op(T, T) [with T = unsigned int]':
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:204:   instantiated from 
> 'static T octave_int_base<T>::truncate_int(const S&) [with S = unsigned int, 
> T = short unsigned int]'
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:373:   instantiated from 
> 'static T octave_int_arith_base<T, false>::mul(T, T) [with T = short unsigned 
> int]'
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:753:   instantiated from 
> 'octave_int<T> octave_int<T>::operator*(const octave_int<T>&) const [with T = 
> short unsigned int]'
>  /home/jwe/src/octave/liboctave/MArray.cc:125:   instantiated from 'MArray<T> 
> operator*(const MArray<T>&, const T&) [with T = octave_int<short unsigned 
> int>]'
>  /home/jwe/src/octave/liboctave/MArray-i.cc:56:   instantiated from here
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:156: warning: unused parameter 
> 'x'
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:156: warning: unused parameter 
> 'y'
>  /home/jwe/src/octave/liboctave/oct-inttypes.h: In instantiation of 'static 
> bool octave_int_cmp_op::cf::op(T, T) [with T = long unsigned int]':
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:204:   instantiated from 
> 'static T octave_int_base<T>::truncate_int(const S&) [with S = long unsigned 
> int, T = unsigned int]'
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:373:   instantiated from 
> 'static T octave_int_arith_base<T, false>::mul(T, T) [with T = unsigned int]'
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:753:   instantiated from 
> 'octave_int<T> octave_int<T>::operator*(const octave_int<T>&) const [with T = 
> unsigned int]'
>  /home/jwe/src/octave/liboctave/MArray.cc:125:   instantiated from 'MArray<T> 
> operator*(const MArray<T>&, const T&) [with T = octave_int<unsigned int>]'
>  /home/jwe/src/octave/liboctave/MArray-i.cc:57:   instantiated from here
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:156: warning: unused parameter 
> 'x'
>  /home/jwe/src/octave/liboctave/oct-inttypes.h:156: warning: unused parameter 
> 'y'
>  make[2]: *** [pic/MArray-i.o] Error 1
>  make[2]: Leaving directory `/scratch/jwe/build/octave/liboctave'
>  make[1]: *** [liboctave] Error 2
>  make[1]: Leaving directory `/scratch/jwe/build/octave'
>  make: *** [all] Error 2
>
> Any clues?
>

Sorry. I didn't realize that std::abs (int) is declared in cstdlib,
not cmath. Please try again, same location. This new one should also
get rid of the unused vars warnings you see.


-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]