Changeset 709 for trunk/ADOL-C/include


Ignore:
Timestamp:
Aug 9, 2016 8:51:09 AM (3 years ago)
Author:
kulshres
Message:

merge branch 'master' of 'gitclone' into 'svn'

The following commits have been merged:

commit 4c3cee7867eedfda0dfdd9354657208b355952f7
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Aug 8 12:47:29 2016 +0200

add more inline wrappers for pdouble

the proper function isn't resolved if getparam() or mkparam() is called
within a unary function. The compiler tries to resolve it to the
std::* function trying to convert pdouble to double,
instead of the ADOL-C function by converting pdouble to adub.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 6761846ac1130845ee0096b6a96a1736daf0fd00
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Aug 8 12:44:28 2016 +0200

make badouble copy constructor protected again

newer g++ or even clang++ does not require it. and we really don't want
badouble objects to be copied from user's code.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit 53dfb77db382259c7354efba347f0195f4241fb5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Aug 5 13:50:42 2016 +0200

Add actual vector mode code for CUDA adoubles

This seemingly did not exist. I don't know why. Perhaps scalar mode
code autmatically gets vectorized over threads. I'm not even sure
of the side effects of using NUMBER_DIRECTIONS > 1.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

Location:
trunk/ADOL-C/include/adolc
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ADOL-C/include/adolc/adouble.h

    r676 r709  
    8484    locint location;
    8585    badouble( void ) {};
    86     // must be public when using gcc >= 3.4 ( problems with value() )
     86    // Copy constructor:
     87    // must be public when using gcc >= 3.4 and gcc <= 4.3.0
    8788    // (see GCC 3.4 Release Series - Changes, New Features, and Fixes)
    88     //
    89     // badouble( const badouble& a ) {location = a.location;};
     89    // so we make it protected for newer compilers again.
     90    badouble( const badouble& a ) {};           /* ctor */
    9091    explicit badouble( locint lo ) {
    9192        location = lo;
     
    9697
    9798public:
    98     /*--------------------------------------------------------------------------*/
    99     badouble( const badouble& a ) {};           /* ctor */
    100 
     99    /*--------------------------------------------------------------------------*/   
    101100    inline locint loc( void ) const;                         /* Helpful stuff */
    102101
  • trunk/ADOL-C/include/adolc/adoublecuda.h

    r408 r709  
    1717#define ADOLC_ADOUBLECUDA_H 1
    1818
    19 #include <cstdio>
    2019#include <cstdlib>
    2120#include <iostream>
    2221#include <cmath>
    23 #include <limits>
    2422using std::cout;
    25 using std::cin;
    26 using std::cerr;
    2723using std::ostream;
    2824using std::istream;
     
    3430
    3531
     32#if defined(NUMBER_DIRECTIONS)
     33__managed__ size_t ADOLC_numDir = NUMBER_DIRECTIONS;
     34# if defined(DYNAMIC_DIRECTIONS)
     35#  define ADVAL_DECL           *adval
     36#  define ADVAL_TYPE_ADV       const double* adv
     37# else
     38#  define ADVAL_DECL           adval[NUMBER_DIRECTIONS]
     39#  define ADVAL_TYPE_ADV       const double adv[NUMBER_DIRECTIONS]
     40# endif
     41#  define ADVAL_TYPE           double*
     42#  define FOR_I_EQ_0_LT_NUMDIR for (size_t i = 0; i < ADOLC_numDir; i++)
     43#  define ADVAL_I              adval[i]
     44#  define ADV_I                adv[i]
     45#  define V_I                  v[i]
     46#else
     47#  define ADVAL_DECL           adval
    3648#  define ADVAL                adval
     49#  define ADVAL_TYPE_ADV       double adv
    3750#  define ADVAL_TYPE           double
    3851#  define FOR_I_EQ_0_LT_NUMDIR
     
    4053#  define ADV_I                adv
    4154#  define V_I                  v
     55#endif
    4256
    4357
     
    5266}
    5367
     68
     69#define CUDADEV __device__ inline
     70#define CUDAHOST __host__ inline
     71#define CUDAHOSTDEV __host__ __device__ inline
    5472
    5573class adouble {
    5674public:
    5775    // ctors
    58     __device__  inline adouble();
    59     __device__  inline adouble(const double v);
    60     __device__  inline adouble(const double v, ADVAL_TYPE adv);
    61     __device__  inline adouble(const adouble& a);
     76    CUDADEV adouble();
     77    CUDADEV adouble(const double v);
     78    CUDADEV adouble(const double v, ADVAL_TYPE_ADV);
     79    CUDADEV adouble(const adouble& a);
    6280#if defined(DYNAMIC_DIRECTIONS)
    63     inline ~adouble();
     81    CUDADEV ~adouble();
    6482#endif
    6583    /*******************  temporary results  ******************************/
    6684    // sign
    67     __device__  inline adouble operator - () const;
    68     __device__  inline adouble operator + () const;
     85    CUDADEV adouble operator - () const;
     86    CUDADEV adouble operator + () const;
    6987
    7088    // addition
    71     __device__  inline adouble operator + (const double v) const;
    72     __device__  inline adouble operator + (const adouble& a) const;
    73     __device__  inline friend
     89    CUDADEV adouble operator + (const double v) const;
     90    CUDADEV adouble operator + (const adouble& a) const;
     91    CUDADEV friend
    7492    adouble operator + (const double v, const adouble& a);
    7593
    7694    // substraction
    77     __device__  inline adouble operator - (const double v) const;
    78     __device__  inline adouble operator - (const adouble& a) const;
    79     __device__  inline friend
     95    CUDADEV adouble operator - (const double v) const;
     96    CUDADEV adouble operator - (const adouble& a) const;
     97    CUDADEV friend
    8098    adouble operator - (const double v, const adouble& a);
    8199
    82100    // multiplication
    83     __device__  inline adouble operator * (const double v) const;
    84     __device__  inline adouble operator * (const adouble& a) const;
    85     __device__  inline friend
     101    CUDADEV adouble operator * (const double v) const;
     102    CUDADEV adouble operator * (const adouble& a) const;
     103    CUDADEV friend
    86104    adouble operator * (const double v, const adouble& a);
    87105
    88106    // division
    89     __device__  inline adouble operator / (const double v) const;
    90     __device__  inline adouble operator / (const adouble& a) const;
    91     __device__  inline friend
     107    CUDADEV adouble operator / (const double v) const;
     108    CUDADEV adouble operator / (const adouble& a) const;
     109    CUDADEV friend
    92110    adouble operator / (const double v, const adouble& a);
    93111
    94112    // inc/dec
    95     __device__  inline adouble operator ++ ();
    96     __device__  inline adouble operator ++ (int);
    97     __device__  inline adouble operator -- ();
    98     __device__  inline adouble operator -- (int);
     113    CUDADEV adouble operator ++ ();
     114    CUDADEV adouble operator ++ (int);
     115    CUDADEV adouble operator -- ();
     116    CUDADEV adouble operator -- (int);
    99117
    100118    // functions
    101     __device__  inline friend adouble tan(const adouble &a);
    102     __device__  inline friend adouble exp(const adouble &a);
    103     __device__  inline friend adouble log(const adouble &a);
    104     __device__  inline friend adouble sqrt(const adouble &a);
    105     __device__  inline friend adouble sin(const adouble &a);
    106     __device__  inline friend adouble cos(const adouble &a);
    107     __device__  inline friend adouble asin(const adouble &a);
    108     __device__  inline friend adouble acos(const adouble &a);
    109     __device__  inline friend adouble atan(const adouble &a);
    110 
    111     __device__  inline friend adouble atan2(const adouble &a, const adouble &b);
    112     __device__  inline friend adouble pow(const adouble &a, double v);
    113     __device__  inline friend adouble pow(const adouble &a, const adouble &b);
    114     __device__  inline friend adouble pow(double v, const adouble &a);
    115     __device__  inline friend adouble log10(const adouble &a);
    116 
    117     __device__  inline friend adouble sinh (const adouble &a);
    118     __device__  inline friend adouble cosh (const adouble &a);
    119     __device__  inline friend adouble tanh (const adouble &a);
     119    CUDADEV friend adouble tan(const adouble &a);
     120    CUDADEV friend adouble exp(const adouble &a);
     121    CUDADEV friend adouble log(const adouble &a);
     122    CUDADEV friend adouble sqrt(const adouble &a);
     123    CUDADEV friend adouble sin(const adouble &a);
     124    CUDADEV friend adouble cos(const adouble &a);
     125    CUDADEV friend adouble asin(const adouble &a);
     126    CUDADEV friend adouble acos(const adouble &a);
     127    CUDADEV friend adouble atan(const adouble &a);
     128
     129    CUDADEV friend adouble atan2(const adouble &a, const adouble &b);
     130    CUDADEV friend adouble pow(const adouble &a, double v);
     131    CUDADEV friend adouble pow(const adouble &a, const adouble &b);
     132    CUDADEV friend adouble pow(double v, const adouble &a);
     133    CUDADEV friend adouble log10(const adouble &a);
     134
     135    CUDADEV friend adouble sinh (const adouble &a);
     136    CUDADEV friend adouble cosh (const adouble &a);
     137    CUDADEV friend adouble tanh (const adouble &a);
    120138#if defined(ATRIG_ERF)
    121     __device__  inline friend adouble asinh (const adouble &a);
    122     __device__  inline friend adouble acosh (const adouble &a);
    123     __device__  inline friend adouble atanh (const adouble &a);
    124 #endif
    125     __device__  inline friend adouble fabs (const adouble &a);
    126     __device__  inline friend adouble ceil (const adouble &a);
    127     __device__  inline friend adouble floor (const adouble &a);
    128     __device__  inline friend adouble fmax (const adouble &a, const adouble &b);
    129     __device__  inline friend adouble fmax (double v, const adouble &a);
    130     __device__  inline friend adouble fmax (const adouble &a, double v);
    131     __device__  inline friend adouble fmin (const adouble &a, const adouble &b);
    132     __device__  inline friend adouble fmin (double v, const adouble &a);
    133     __device__  inline friend adouble fmin (const adouble &a, double v);
    134     __device__  inline friend adouble ldexp (const adouble &a, const adouble &b);
    135     __device__  inline friend adouble ldexp (const adouble &a, const double v);
    136     __device__  inline friend adouble ldexp (const double v, const adouble &a);
    137     __device__  inline friend double frexp (const adouble &a, int* v);
     139    CUDADEV friend adouble asinh (const adouble &a);
     140    CUDADEV friend adouble acosh (const adouble &a);
     141    CUDADEV friend adouble atanh (const adouble &a);
     142#endif
     143    CUDADEV friend adouble fabs (const adouble &a);
     144    CUDADEV friend adouble ceil (const adouble &a);
     145    CUDADEV friend adouble floor (const adouble &a);
     146    CUDADEV friend adouble fmax (const adouble &a, const adouble &b);
     147    CUDADEV friend adouble fmax (double v, const adouble &a);
     148    CUDADEV friend adouble fmax (const adouble &a, double v);
     149    CUDADEV friend adouble fmin (const adouble &a, const adouble &b);
     150    CUDADEV friend adouble fmin (double v, const adouble &a);
     151    CUDADEV friend adouble fmin (const adouble &a, double v);
     152    CUDADEV friend adouble ldexp (const adouble &a, const adouble &b);
     153    CUDADEV friend adouble ldexp (const adouble &a, const double v);
     154    CUDADEV friend adouble ldexp (const double v, const adouble &a);
     155    CUDADEV friend double frexp (const adouble &a, int* v);
    138156#if defined(ATRIG_ERF)
    139     __device__  inline friend adouble erf (const adouble &a);
     157    CUDADEV friend adouble erf (const adouble &a);
    140158#endif
    141159
     
    143161    /*******************  nontemporary results  ***************************/
    144162    // assignment
    145     __device__  inline void operator = (const double v);
    146     __device__  inline void operator = (const adouble& a);
     163    CUDADEV void operator = (const double v);
     164    CUDADEV void operator = (const adouble& a);
    147165
    148166    // addition
    149     __device__  inline void operator += (const double v);
    150     __device__  inline void operator += (const adouble& a);
     167    CUDADEV void operator += (const double v);
     168    CUDADEV void operator += (const adouble& a);
    151169
    152170    // substraction
    153     __device__  inline void operator -= (const double v);
    154     __device__  inline void operator -= (const adouble& a);
     171    CUDADEV void operator -= (const double v);
     172    CUDADEV void operator -= (const adouble& a);
    155173
    156174    // multiplication
    157     __device__  inline void operator *= (const double v);
    158     __device__  inline void operator *= (const adouble& a);
     175    CUDADEV void operator *= (const double v);
     176    CUDADEV void operator *= (const adouble& a);
    159177
    160178    // division
    161     __device__  inline void operator /= (const double v);
    162     __device__  inline void operator /= (const adouble& a);
     179    CUDADEV void operator /= (const double v);
     180    CUDADEV void operator /= (const adouble& a);
    163181
    164182    // not
    165     __device__  inline int operator ! () const;
     183    CUDADEV int operator ! () const;
    166184
    167185    // comparision
    168     __device__  inline int operator != (const adouble&) const;
    169     __device__  inline int operator != (const double) const;
    170     __device__  inline friend int operator != (const double, const adouble&);
    171 
    172     __device__  inline int operator == (const adouble&) const;
    173     __device__  inline int operator == (const double) const;
    174     __device__  inline friend int operator == (const double, const adouble&);
    175 
    176     __device__  inline int operator <= (const adouble&) const;
    177     __device__  inline int operator <= (const double) const;
    178     __device__  inline friend int operator <= (const double, const adouble&);
    179 
    180     __device__  inline int operator >= (const adouble&) const;
    181     __device__  inline int operator >= (const double) const;
    182     __device__  inline friend int operator >= (const double, const adouble&);
    183 
    184     __device__  inline int operator >  (const adouble&) const;
    185     __device__  inline int operator >  (const double) const;
    186     __device__  inline friend int operator >  (const double, const adouble&);
    187 
    188     __device__  inline int operator <  (const adouble&) const;
    189     __device__  inline int operator <  (const double) const;
    190     __device__  inline friend int operator <  (const double, const adouble&);
     186    CUDADEV int operator != (const adouble&) const;
     187    CUDADEV int operator != (const double) const;
     188    CUDADEV friend int operator != (const double, const adouble&);
     189
     190    CUDADEV int operator == (const adouble&) const;
     191    CUDADEV int operator == (const double) const;
     192    CUDADEV friend int operator == (const double, const adouble&);
     193
     194    CUDADEV int operator <= (const adouble&) const;
     195    CUDADEV int operator <= (const double) const;
     196    CUDADEV friend int operator <= (const double, const adouble&);
     197
     198    CUDADEV int operator >= (const adouble&) const;
     199    CUDADEV int operator >= (const double) const;
     200    CUDADEV friend int operator >= (const double, const adouble&);
     201
     202    CUDADEV int operator >  (const adouble&) const;
     203    CUDADEV int operator >  (const double) const;
     204    CUDADEV friend int operator >  (const double, const adouble&);
     205
     206    CUDADEV int operator <  (const adouble&) const;
     207    CUDADEV int operator <  (const double) const;
     208    CUDADEV friend int operator <  (const double, const adouble&);
    191209
    192210    /*******************  getter / setter  ********************************/
    193     __device__  inline double getValue() const;
    194     __device__  inline void setValue(const double v);
    195     __device__  inline ADVAL_TYPE getADValue() const;
    196     __device__  inline void setADValue(ADVAL_TYPE v);
     211    CUDAHOSTDEV double getValue() const;
     212    CUDAHOSTDEV void setValue(const double v);
     213    CUDAHOSTDEV ADVAL_TYPE getADValue() const;
     214    CUDAHOSTDEV void setADValue(ADVAL_TYPE v);
    197215#if defined(NUMBER_DIRECTIONS)
    198     inline double getADValue(const unsigned int p) const;
    199     inline void setADValue(const unsigned int p, const double v);
     216    CUDAHOSTDEV double getADValue(const unsigned int p) const;
     217    CUDAHOSTDEV void setADValue(const unsigned int p, const double v);
    200218#endif
    201219
    202220    /*******************  i/o operations  *********************************/
    203     inline friend ostream& operator << ( ostream&, const adouble& );
    204     inline friend istream& operator >> ( istream&, adouble& );
    205 
     221    CUDAHOST friend ostream& operator << ( ostream&, const adouble& );
     222    CUDAHOST friend istream& operator >> ( istream&, adouble& );
    206223
    207224private:
    208225    // internal variables
    209226    double val;
    210     double ADVAL;
     227    double ADVAL_DECL;
    211228};
    212229 
    213230/*******************************  ctors  ************************************/
    214 adouble::adouble() {
     231CUDADEV adouble::adouble() {
    215232#if defined(DYNAMIC_DIRECTIONS)
    216233    adval = new double[ADOLC_numDir];
     
    218235}
    219236
    220 adouble::adouble(const double v) : val(v) {
     237CUDADEV adouble::adouble(const double v) : val(v) {
    221238#if defined(DYNAMIC_DIRECTIONS)
    222239    adval = new double[ADOLC_numDir];
     
    226243}
    227244
    228 adouble::adouble(const double v, ADVAL_TYPE adv) : val(v) {
     245CUDADEV adouble::adouble(const double v, ADVAL_TYPE_ADV) : val(v) {
    229246#if defined(DYNAMIC_DIRECTIONS)
    230247    adval = new double[ADOLC_numDir];
     
    234251}
    235252
    236 adouble::adouble(const adouble& a) : val(a.val) {
     253CUDADEV adouble::adouble(const adouble& a) : val(a.val) {
    237254#if defined(DYNAMIC_DIRECTIONS)
    238255    adval = new double[ADOLC_numDir];
     
    244261/*******************************  dtors  ************************************/
    245262#if defined(DYNAMIC_DIRECTIONS)
    246 adouble::~adouble() {
     263CUDADEV adouble::~adouble() {
    247264    delete[] adval;
    248265}
     
    251268/*************************  temporary results  ******************************/
    252269// sign
    253 adouble adouble::operator - () const {
     270CUDADEV adouble adouble::operator - () const {
    254271    adouble tmp;
    255272    tmp.val=-val;
     
    259276}
    260277
    261 adouble adouble::operator + () const {
     278CUDADEV adouble adouble::operator + () const {
    262279    return *this;
    263280}
    264281
    265282// addition
    266 adouble adouble::operator + (const double v) const {
     283CUDADEV adouble adouble::operator + (const double v) const {
    267284    return adouble(val+v, adval);
    268285}
    269286
    270 adouble adouble::operator + (const adouble& a) const {
     287CUDADEV adouble adouble::operator + (const adouble& a) const {
    271288    adouble tmp;
    272289    tmp.val=val+a.val;
     
    276293}
    277294
    278 adouble operator + (const double v, const adouble& a) {
     295CUDADEV adouble operator + (const double v, const adouble& a) {
    279296    return adouble(v+a.val, a.adval);
    280297}
    281298
    282299// subtraction
    283 adouble adouble::operator - (const double v) const {
     300CUDADEV adouble adouble::operator - (const double v) const {
    284301    return adouble(val-v, adval);
    285302}
    286303
    287 adouble adouble::operator - (const adouble& a) const {
     304CUDADEV adouble adouble::operator - (const adouble& a) const {
    288305    adouble tmp;
    289306    tmp.val=val-a.val;
     
    293310}
    294311
    295 adouble operator - (const double v, const adouble& a) {
     312CUDADEV adouble operator - (const double v, const adouble& a) {
    296313    adouble tmp;
    297314    tmp.val=v-a.val;
     
    302319
    303320// multiplication
    304 adouble adouble::operator * (const double v) const {
     321CUDADEV adouble adouble::operator * (const double v) const {
    305322    adouble tmp;
    306323    tmp.val=val*v;
     
    310327}
    311328
    312 adouble adouble::operator * (const adouble& a) const {
     329CUDADEV adouble adouble::operator * (const adouble& a) const {
    313330    adouble tmp;
    314331    tmp.val=val*a.val;
     
    318335}
    319336
    320 adouble operator * (const double v, const adouble& a) {
     337CUDADEV adouble operator * (const double v, const adouble& a) {
    321338    adouble tmp;
    322339    tmp.val=v*a.val;
     
    327344
    328345// division
    329 adouble adouble::operator / (const double v) const {
     346CUDADEV adouble adouble::operator / (const double v) const {
    330347    adouble tmp;
    331348    tmp.val=val/v;
     
    335352}
    336353
    337 adouble adouble::operator / (const adouble& a) const {
     354CUDADEV adouble adouble::operator / (const adouble& a) const {
    338355    adouble tmp;
    339356    tmp.val=val/a.val;
     
    343360}
    344361
    345 adouble operator / (const double v, const adouble& a) {
     362CUDADEV adouble operator / (const double v, const adouble& a) {
    346363    adouble tmp;
    347364    tmp.val=v/a.val;
     
    352369
    353370// inc/dec
    354 adouble adouble::operator ++ () {
     371CUDADEV adouble adouble::operator ++ () {
    355372    ++val;
    356373    return *this;
    357374}
    358375
    359 adouble adouble::operator ++ (int) {
     376CUDADEV adouble adouble::operator ++ (int) {
    360377    adouble tmp;
    361378    tmp.val=val++;
     
    365382}
    366383
    367 adouble adouble::operator -- () {
     384CUDADEV adouble adouble::operator -- () {
    368385    --val;
    369386    return *this;
    370387}
    371388
    372 adouble adouble::operator -- (int) {
     389CUDADEV adouble adouble::operator -- (int) {
    373390    adouble tmp;
    374391    tmp.val=val--;
     
    379396
    380397// functions
    381 adouble tan(const adouble& a) {
     398CUDADEV adouble tan(const adouble& a) {
    382399    adouble tmp;
    383400    double tmp2;
     
    390407}
    391408
    392 adouble exp(const adouble &a) {
     409CUDADEV adouble exp(const adouble &a) {
    393410    adouble tmp;
    394411    tmp.val=ADOLC_MATH_NSP::exp(a.val);
     
    398415}
    399416
    400 adouble log(const adouble &a) {
     417CUDADEV adouble log(const adouble &a) {
    401418    adouble tmp;
    402419    tmp.val=ADOLC_MATH_NSP::log(a.val);
     
    410427}
    411428
    412 adouble sqrt(const adouble &a) {
     429CUDADEV adouble sqrt(const adouble &a) {
    413430    adouble tmp;
    414431    tmp.val=ADOLC_MATH_NSP::sqrt(a.val);
     
    423440}
    424441
    425 adouble sin(const adouble &a) {
     442CUDADEV adouble sin(const adouble &a) {
    426443    adouble tmp;
    427444    double tmp2;
     
    433450}
    434451
    435 adouble cos(const adouble &a) {
     452CUDADEV adouble cos(const adouble &a) {
    436453    adouble tmp;
    437454    double tmp2;
     
    443460}
    444461
    445 adouble asin(const adouble &a) {
     462CUDADEV adouble asin(const adouble &a) {
    446463    adouble tmp;
    447464    tmp.val=ADOLC_MATH_NSP::asin(a.val);
     
    452469}
    453470
    454 adouble acos(const adouble &a) {
     471CUDADEV adouble acos(const adouble &a) {
    455472    adouble tmp;
    456473    tmp.val=ADOLC_MATH_NSP::acos(a.val);
     
    461478}
    462479
    463 adouble atan(const adouble &a) {
     480CUDADEV adouble atan(const adouble &a) {
    464481    adouble tmp;
    465482    tmp.val=ADOLC_MATH_NSP::atan(a.val);
     
    475492}
    476493
    477 adouble atan2(const adouble &a, const adouble &b) {
     494CUDADEV adouble atan2(const adouble &a, const adouble &b) {
    478495    adouble tmp;
    479496    tmp.val=ADOLC_MATH_NSP::atan2(a.val, b.val);
     
    490507}
    491508
    492 adouble pow(const adouble &a, double v) {
     509CUDADEV adouble pow(const adouble &a, double v) {
    493510    adouble tmp;
    494511    tmp.val=ADOLC_MATH_NSP::pow(a.val, v);
     
    499516}
    500517
    501 adouble pow(const adouble &a, const adouble &b) {
     518CUDADEV adouble pow(const adouble &a, const adouble &b) {
    502519    adouble tmp;
    503520    tmp.val=ADOLC_MATH_NSP::pow(a.val, b.val);
     
    509526}
    510527
    511 adouble pow(double v, const adouble &a) {
     528CUDADEV adouble pow(double v, const adouble &a) {
    512529    adouble tmp;
    513530    tmp.val=ADOLC_MATH_NSP::pow(v, a.val);
     
    518535}
    519536
    520 adouble log10(const adouble &a) {
     537CUDADEV adouble log10(const adouble &a) {
    521538    adouble tmp;
    522539    tmp.val=ADOLC_MATH_NSP::log10(a.val);
     
    527544}
    528545
    529 adouble sinh (const adouble &a) {
     546CUDADEV adouble sinh (const adouble &a) {
    530547    adouble tmp;
    531548    tmp.val=ADOLC_MATH_NSP::sinh(a.val);
     
    536553}
    537554
    538 adouble cosh (const adouble &a) {
     555CUDADEV adouble cosh (const adouble &a) {
    539556    adouble tmp;
    540557    tmp.val=ADOLC_MATH_NSP::cosh(a.val);
     
    545562}
    546563
    547 adouble tanh (const adouble &a) {
     564CUDADEV adouble tanh (const adouble &a) {
    548565    adouble tmp;
    549566    tmp.val=ADOLC_MATH_NSP::tanh(a.val);
     
    556573
    557574#if defined(ATRIG_ERF)
    558 adouble asinh (const adouble &a) {
     575CUDADEV adouble asinh (const adouble &a) {
    559576    adouble tmp;
    560577    tmp.val=ADOLC_MATH_NSP_ERF::asinh(a.val);
     
    565582}
    566583
    567 adouble acosh (const adouble &a) {
     584CUDADEV adouble acosh (const adouble &a) {
    568585    adouble tmp;
    569586    tmp.val=ADOLC_MATH_NSP_ERF::acosh(a.val);
     
    574591}
    575592
    576 adouble atanh (const adouble &a) {
     593CUDADEV adouble atanh (const adouble &a) {
    577594    adouble tmp;
    578595    tmp.val=ADOLC_MATH_NSP_ERF::atanh(a.val);
     
    584601#endif
    585602
    586 adouble fabs (const adouble &a) {
     603CUDADEV adouble fabs (const adouble &a) {
    587604    adouble tmp;
    588605    tmp.val=ADOLC_MATH_NSP::fabs(a.val);
     
    603620}
    604621
    605 adouble ceil (const adouble &a) {
     622CUDADEV adouble ceil (const adouble &a) {
    606623    adouble tmp;
    607624    tmp.val=ADOLC_MATH_NSP::ceil(a.val);
     
    611628}
    612629
    613 adouble floor (const adouble &a) {
     630CUDADEV adouble floor (const adouble &a) {
    614631    adouble tmp;
    615632    tmp.val=ADOLC_MATH_NSP::floor(a.val);
     
    619636}
    620637
    621 adouble fmax (const adouble &a, const adouble &b) {
     638CUDADEV adouble fmax (const adouble &a, const adouble &b) {
    622639    adouble tmp;
    623640    double tmp2=a.val-b.val;
     
    642659}
    643660
    644 adouble fmax (double v, const adouble &a) {
     661CUDADEV adouble fmax (double v, const adouble &a) {
    645662    adouble tmp;
    646663    double tmp2=v-a.val;
     
    665682}
    666683
    667 adouble fmax (const adouble &a, double v) {
     684CUDADEV adouble fmax (const adouble &a, double v) {
    668685    adouble tmp;
    669686    double tmp2=a.val-v;
     
    688705}
    689706
    690 adouble fmin (const adouble &a, const adouble &b) {
     707CUDADEV adouble fmin (const adouble &a, const adouble &b) {
    691708    adouble tmp;
    692709    double tmp2=a.val-b.val;
     
    711728}
    712729
    713 adouble fmin (double v, const adouble &a) {
     730CUDADEV adouble fmin (double v, const adouble &a) {
    714731    adouble tmp;
    715732    double tmp2=v-a.val;
     
    734751}
    735752
    736 adouble fmin (const adouble &a, double v) {
     753CUDADEV adouble fmin (const adouble &a, double v) {
    737754    adouble tmp;
    738755    double tmp2=a.val-v;
     
    757774}
    758775
    759 adouble ldexp (const adouble &a, const adouble &b) {
     776CUDADEV adouble ldexp (const adouble &a, const adouble &b) {
    760777    return a*pow(2.,b);
    761778}
    762779
    763 adouble ldexp (const adouble &a, const double v) {
     780CUDADEV adouble ldexp (const adouble &a, const double v) {
    764781    return a*ADOLC_MATH_NSP::pow(2.,v);
    765782}
    766783
    767 adouble ldexp (const double v, const adouble &a) {
     784CUDADEV adouble ldexp (const double v, const adouble &a) {
    768785    return v*pow(2.,a);
    769786}
    770787
    771 double frexp (const adouble &a, int* v) {
     788CUDADEV double frexp (const adouble &a, int* v) {
    772789    return ADOLC_MATH_NSP::frexp(a.val, v);
    773790}
    774791
    775792#if defined(ATRIG_ERF)
    776 adouble erf (const adouble &a) {
     793CUDADEV adouble erf (const adouble &a) {
    777794    adouble tmp;
    778795    tmp.val=ADOLC_MATH_NSP_ERF::erf(a.val);
     
    788805
    789806/*******************  nontemporary results  *********************************/
    790 void adouble::operator = (const double v) {
     807CUDADEV void adouble::operator = (const double v) {
    791808    val=v;
    792809    FOR_I_EQ_0_LT_NUMDIR
     
    794811}
    795812
    796 void adouble::operator = (const adouble& a) {
     813CUDADEV void adouble::operator = (const adouble& a) {
    797814    val=a.val;
    798815    FOR_I_EQ_0_LT_NUMDIR
     
    800817}
    801818
    802 void adouble::operator += (const double v) {
     819CUDADEV void adouble::operator += (const double v) {
    803820    val+=v;
    804821}
    805822
    806 void adouble::operator += (const adouble& a) {
     823CUDADEV void adouble::operator += (const adouble& a) {
    807824    val=val+a.val;
    808825    FOR_I_EQ_0_LT_NUMDIR
     
    810827}
    811828
    812 void adouble::operator -= (const double v) {
     829CUDADEV void adouble::operator -= (const double v) {
    813830    val-=v;
    814831}
    815832
    816 void adouble::operator -= (const adouble& a) {
     833CUDADEV void adouble::operator -= (const adouble& a) {
    817834    val=val-a.val;
    818835    FOR_I_EQ_0_LT_NUMDIR
     
    820837}
    821838
    822 void adouble::operator *= (const double v) {
     839CUDADEV void adouble::operator *= (const double v) {
    823840    val=val*v;
    824841    FOR_I_EQ_0_LT_NUMDIR
     
    826843}
    827844
    828 void adouble::operator *= (const adouble& a) {
     845CUDADEV void adouble::operator *= (const adouble& a) {
    829846    FOR_I_EQ_0_LT_NUMDIR
    830847    ADVAL_I=ADVAL_I*a.val+val*a.ADVAL_I;
     
    832849}
    833850
    834 void adouble::operator /= (const double v) {
     851CUDADEV void adouble::operator /= (const double v) {
    835852    val/=v;
    836853    FOR_I_EQ_0_LT_NUMDIR
     
    838855}
    839856
    840 void adouble::operator /= (const adouble& a) {
     857CUDADEV void adouble::operator /= (const adouble& a) {
    841858    FOR_I_EQ_0_LT_NUMDIR
    842859    ADVAL_I=(ADVAL_I*a.val-val*a.ADVAL_I)/(a.val*a.val);
     
    845862
    846863// not
    847 int adouble::operator ! () const {
     864CUDADEV int adouble::operator ! () const {
    848865    return val==0.0;
    849866}
    850867
    851868// comparision
    852 int adouble::operator != (const adouble &a) const {
     869CUDADEV int adouble::operator != (const adouble &a) const {
    853870    return val!=a.val;
    854871}
    855872
    856 int adouble::operator != (const double v) const {
     873CUDADEV int adouble::operator != (const double v) const {
    857874    return val!=v;
    858875}
    859876
    860 int operator != (const double v, const adouble &a) {
     877CUDADEV int operator != (const double v, const adouble &a) {
    861878    return v!=a.val;
    862879}
    863880
    864 int adouble::operator == (const adouble &a) const {
     881CUDADEV int adouble::operator == (const adouble &a) const {
    865882    return val==a.val;
    866883}
    867884
    868 int adouble::operator == (const double v) const {
     885CUDADEV int adouble::operator == (const double v) const {
    869886    return val==v;
    870887}
    871888
    872 int operator == (const double v, const adouble &a) {
     889CUDADEV int operator == (const double v, const adouble &a) {
    873890    return v==a.val;
    874891}
    875892
    876 int adouble::operator <= (const adouble &a) const {
     893CUDADEV int adouble::operator <= (const adouble &a) const {
    877894    return val<=a.val;
    878895}
    879896
    880 int adouble::operator <= (const double v) const {
     897CUDADEV int adouble::operator <= (const double v) const {
    881898    return val<=v;
    882899}
    883900
    884 int operator <= (const double v, const adouble &a) {
     901CUDADEV int operator <= (const double v, const adouble &a) {
    885902    return v<=a.val;
    886903}
    887904
    888 int adouble::operator >= (const adouble &a) const {
     905CUDADEV int adouble::operator >= (const adouble &a) const {
    889906    return val>=a.val;
    890907}
    891908
    892 int adouble::operator >= (const double v) const {
     909CUDADEV int adouble::operator >= (const double v) const {
    893910    return val>=v;
    894911}
    895912
    896 int operator >= (const double v, const adouble &a) {
     913CUDADEV int operator >= (const double v, const adouble &a) {
    897914    return v>=a.val;
    898915}
    899916
    900 int adouble::operator >  (const adouble &a) const {
     917CUDADEV int adouble::operator >  (const adouble &a) const {
    901918    return val>a.val;
    902919}
    903920
    904 int adouble::operator >  (const double v) const {
     921CUDADEV int adouble::operator >  (const double v) const {
    905922    return val>v;
    906923}
    907924
    908 int operator >  (const double v, const adouble &a) {
     925CUDADEV int operator >  (const double v, const adouble &a) {
    909926    return v>a.val;
    910927}
    911928
    912 int adouble::operator <  (const adouble &a) const {
     929CUDADEV int adouble::operator <  (const adouble &a) const {
    913930    return val<a.val;
    914931}
    915932
    916 int adouble::operator <  (const double v) const {
     933CUDADEV int adouble::operator <  (const double v) const {
    917934    return val<v;
    918935}
    919936
    920 int operator <  (const double v, const adouble &a) {
     937CUDADEV int operator <  (const double v, const adouble &a) {
    921938    return v<a.val;
    922939}
    923940
    924941/*******************  getter / setter  **************************************/
    925 double adouble::getValue() const {
     942CUDAHOSTDEV double adouble::getValue() const {
    926943    return val;
    927944}
    928945
    929 void adouble::setValue(const double v) {
     946CUDAHOSTDEV void adouble::setValue(const double v) {
    930947    val=v;
    931948}
    932949
    933 ADVAL_TYPE adouble::getADValue() const {
    934     return adval;
    935 }
    936 
    937 void adouble::setADValue(ADVAL_TYPE v) {
     950CUDAHOSTDEV ADVAL_TYPE adouble::getADValue() const {
     951    return (ADVAL_TYPE)adval;
     952}
     953
     954CUDAHOSTDEV void adouble::setADValue(ADVAL_TYPE v) {
    938955    FOR_I_EQ_0_LT_NUMDIR
    939956    ADVAL_I=V_I;
     
    941958
    942959#  if defined(NUMBER_DIRECTIONS)
    943 double adouble::getADValue(const unsigned int p) const {
    944     if (p>=NUMBER_DIRECTIONS) {
    945         fprintf(DIAG_OUT, "Derivative array accessed out of bounds"\
    946                 " while \"getADValue(...)\"!!!\n");
    947         exit(-1);
     960CUDAHOSTDEV double adouble::getADValue(const unsigned int p) const {
     961    unsigned int locp = p;
     962    if (locp>=ADOLC_numDir) {
     963        locp = ADOLC_numDir -1;
    948964    }
    949     return adval[p];
    950 }
    951 
    952 void adouble::setADValue(const unsigned int p, const double v) {
    953     if (p>=NUMBER_DIRECTIONS) {
    954         fprintf(DIAG_OUT, "Derivative array accessed out of bounds"\
    955                 " while \"setADValue(...)\"!!!\n");
    956         exit(-1);
     965    return adval[locp];
     966}
     967
     968CUDAHOSTDEV void adouble::setADValue(const unsigned int p, const double v) {
     969    unsigned int locp = p;
     970    if (locp>=ADOLC_numDir) {
     971        locp = ADOLC_numDir - 1;
    957972    }
    958     adval[p]=v;
     973    adval[locp]=v;
    959974}
    960975#  endif
    961976
    962977#if defined(NUMBER_DIRECTIONS)
    963 static void setNumDir(const unsigned int p) {
     978void setNumDir(const unsigned int p) {
    964979#if !defined(DYNAMIC_DIRECTIONS)
    965980    if (p>NUMBER_DIRECTIONS) ADOLC_numDir=NUMBER_DIRECTIONS;
     
    972987
    973988/*******************  i/o operations  ***************************************/
    974 ostream& operator << ( ostream& out, const adouble& a) {
     989CUDAHOST ostream& operator << ( ostream& out, const adouble& a) {
    975990    out << "Value: " << a.val;
    976991#if !defined(NUMBER_DIRECTIONS)
     
    9851000}
    9861001
    987 istream& operator >> ( istream& in, adouble& a) {
     1002CUDAHOST istream& operator >> ( istream& in, adouble& a) {
    9881003    char c;
    9891004    do {
  • trunk/ADOL-C/include/adolc/internal/paramfunc.h

    r537 r709  
    6969    inline friend adub fmin ( const pdouble&, const badouble& );
    7070    inline friend adub fmin ( const badouble&, const pdouble& );
     71    /*--------------------------------------------------------------------------*/
     72    /* unary operators (friends) */
     73    inline friend ADOLC_DLL_EXPORT adub exp  ( const pdouble& );
     74    inline friend ADOLC_DLL_EXPORT adub log  ( const pdouble& );
     75    inline friend ADOLC_DLL_EXPORT adub sqrt ( const pdouble& );
     76    inline friend ADOLC_DLL_EXPORT adub sin  ( const pdouble& );
     77    inline friend ADOLC_DLL_EXPORT adub cos  ( const pdouble& );
     78    inline friend ADOLC_DLL_EXPORT adub tan  ( const pdouble& );
     79    inline friend ADOLC_DLL_EXPORT adub asin ( const pdouble& );
     80    inline friend ADOLC_DLL_EXPORT adub acos ( const pdouble& );
     81    inline friend ADOLC_DLL_EXPORT adub atan ( const pdouble& );
     82
     83    /*--------------------------------------------------------------------------*/
     84    /* special operators (friends) */
     85    /* no internal use of condassign: */
     86    inline friend ADOLC_DLL_EXPORT adub    pow   ( const pdouble&, double );
     87    inline friend ADOLC_DLL_EXPORT adub    log10 ( const pdouble& );
     88
     89    /* Additional ANSI C standard Math functions Added by DWJ on 8/6/90 */
     90    inline friend ADOLC_DLL_EXPORT adub sinh  ( const pdouble& );
     91    inline friend ADOLC_DLL_EXPORT adub cosh  ( const pdouble& );
     92    inline friend ADOLC_DLL_EXPORT adub tanh  ( const pdouble& );
     93#if defined(ATRIG_ERF)
     94    inline friend ADOLC_DLL_EXPORT adub asinh ( const pdouble& );
     95    inline friend ADOLC_DLL_EXPORT adub acosh ( const pdouble& );
     96    inline friend ADOLC_DLL_EXPORT adub atanh ( const pdouble& );
     97    inline friend ADOLC_DLL_EXPORT adub erf   ( const pdouble& );
     98#endif
     99
     100    inline friend ADOLC_DLL_EXPORT adub fabs  ( const pdouble& );
     101    inline friend ADOLC_DLL_EXPORT adub ceil  ( const pdouble& );
     102    inline friend ADOLC_DLL_EXPORT adub floor ( const pdouble& );
     103
     104    inline friend ADOLC_DLL_EXPORT adub fmax ( const pdouble&, const pdouble& );
     105    inline friend ADOLC_DLL_EXPORT adub fmax ( double, const pdouble& );
     106    inline friend ADOLC_DLL_EXPORT adub fmax ( const pdouble&, double );
     107    inline friend ADOLC_DLL_EXPORT adub fmin ( const pdouble&, const pdouble& );
     108    inline friend ADOLC_DLL_EXPORT adub fmin ( double, const pdouble& );
     109    inline friend ADOLC_DLL_EXPORT adub fmin ( const pdouble&, double );
     110
     111    inline friend ADOLC_DLL_EXPORT adub ldexp ( const pdouble&, int );
     112    inline friend ADOLC_DLL_EXPORT adub frexp ( const pdouble&, int* );
     113
     114    /*--------------------------------------------------------------------------*/
     115
    71116#endif
    72117#endif
  • trunk/ADOL-C/include/adolc/param.h

    r593 r709  
    152152{ return fmin(a,adub(b)); }
    153153
     154/* unary operators (friends) */
     155inline adub exp  ( const pdouble& p)  { return exp(adub(p));   }
     156inline adub log  ( const pdouble& p)  { return log(adub(p));   }
     157inline adub sqrt ( const pdouble& p)  { return sqrt(adub(p));  }
     158inline adub sin  ( const pdouble& p)  { return sin(adub(p));   }
     159inline adub cos  ( const pdouble& p)  { return cos(adub(p));   }
     160inline adub tan  ( const pdouble& p)  { return tan(adub(p));   }
     161inline adub asin ( const pdouble& p)  { return asin(adub(p));  }
     162inline adub acos ( const pdouble& p)  { return acos(adub(p));  }
     163inline adub atan ( const pdouble& p)  { return atan(adub(p));  }
     164
     165/*--------------------------------------------------------------------------*/
     166/* special operators (friends) */
     167/* no internal use of condassign: */
     168inline adub    pow   ( const pdouble& p, double q) { return pow(adub(p),q); }
     169inline adub    log10 ( const pdouble& p) { return log10(adub(p)); }
     170
     171/* Additional ANSI C standard Math functions Added by DWJ on 8/6/90 */
     172inline adub sinh  ( const pdouble& p) { return sinh(adub(p)); }
     173inline adub cosh  ( const pdouble& p) { return cosh(adub(p)); }
     174inline adub tanh  ( const pdouble& p) { return tanh(adub(p)); }
     175#if defined(ATRIG_ERF)
     176inline adub asinh ( const pdouble& p) { return asinh(adub(p)); }
     177inline adub acosh ( const pdouble& p) { return acosh(adub(p)); }
     178inline adub atanh ( const pdouble& p) { return atanh(adub(p)); }
     179inline adub erf   ( const pdouble& p) { return erf(adub(p));   }
     180#endif
     181
     182inline adub fabs  ( const pdouble& p) { return fabs(adub(p));  }
     183inline adub ceil  ( const pdouble& p) { return ceil(adub(p));  }
     184inline adub floor ( const pdouble& p) { return floor(adub(p)); }
     185
     186inline adub fmax ( const pdouble& p, const pdouble& q)
     187{ return fmax(adub(p),adub(q)); }
     188inline adub fmax ( double p, const pdouble& q)
     189{ return fmax(p,adub(q)); }
     190inline adub fmax ( const pdouble& p, double q)
     191{ return fmax(adub(p),q); }
     192inline adub fmin ( const pdouble& p, const pdouble& q)
     193{ return fmin(adub(p),adub(q)); }
     194inline adub fmin ( double p, const pdouble& q)
     195{ return fmin(p,adub(q)); }
     196inline adub fmin ( const pdouble& p, double q)
     197{ return fmin(adub(p),q); }
     198
     199inline adub ldexp ( const pdouble& p, int n)
     200{ return ldexp(adub(p),n); }
     201inline adub frexp ( const pdouble& p, int* n)
     202{ return frexp(adub(p),n); }
     203
     204/*--------------------------------------------------------------------------*/
    154205#endif
    155206
Note: See TracChangeset for help on using the changeset viewer.