Actual source code: ad_grad_macro_axpys.h

      1: /*
      2:   THIS PROGRAM DISCLOSES MATERIAL PROTECTABLE UNDER COPYRIGHT
      3:   LAWS OF THE UNITED STATES.  FOR LICENSING INFORMATION CONTACT:

      5:   Christian Bischof or Lucas Roh, Mathematics and Computer Science Division,
      6:   Argonne National Laboratory, 9700 S. Cass Avenue, Argonne IL 60439,
      7:   {bischof,roh}@mcs.anl.gov.
      8: */

     10: /*
     11:    This for PETSc where we KNOW that ad_grad_size is ad_GRAD_MAX thus we KNOW at COMPILE time the
     12:  size of the loops; by passing this information to the compiler it may compile faster code?
     13: */
     14: #if (ad_GRAD_MAX == 1)
     15: #define ad_grad_axpy_n mfad_grad_axpy_n
     16: #endif

     18: #ifdef __cplusplus
     20: #endif

     22: void ad_grad_axpy_n(int, void*, ...);

     24: #ifdef __cplusplus
     25: }
     26: #endif

     28: #if defined(ad_grad_axpy_0)
     29: #undef ad_grad_axpy_0
     30: #endif
     31: #define ad_grad_axpy_0(ggz) \
     32:                 { int iWiLlNeVeRCoNfLiCt; double *gz = DERIV_grad(*(ggz)); \
     33:                 for (iWiLlNeVeRCoNfLiCt = 0 ; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX ; iWiLlNeVeRCoNfLiCt++) {\
     34:                     gz[iWiLlNeVeRCoNfLiCt] = 0.0;\
     35:                 } }
     36:
     37: #if defined(ad_grad_axpy_zero)
     38: #undef ad_grad_axpy_zero
     39: #endif
     40: #define ad_grad_axpy_zero(gz) ad_grad_axpy_0(gz)
     41:
     42: #if defined(ad_grad_axpy_copy)
     43: #undef ad_grad_axpy_copy
     44: #endif
     45: #define ad_grad_axpy_copy(ggz,ggx) \
     46:                 { int iWiLlNeVeRCoNfLiCt; double *gz = DERIV_grad(*(ggz)),  *gx = DERIV_grad(*(ggx)); \
     47:                 for (iWiLlNeVeRCoNfLiCt = 0 ; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX ; iWiLlNeVeRCoNfLiCt++) {\
     48:                     gz[iWiLlNeVeRCoNfLiCt] = gx[iWiLlNeVeRCoNfLiCt];\
     49:                 } }
     50:
     51: #if defined(ad_grad_axpy_1)
     52: #undef ad_grad_axpy_1
     53: #endif
     54: #define ad_grad_axpy_1(ggz, ca, gga)\
     55:                 { int iWiLlNeVeRCoNfLiCt; double *gz = DERIV_grad(*(ggz)) , *ga = DERIV_grad(*(gga));\
     56:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
     57:                     gz[iWiLlNeVeRCoNfLiCt] =  +(ca)*ga[iWiLlNeVeRCoNfLiCt];\
     58:                 } }

     60: #if defined(ad_grad_axpy_2)
     61: #undef ad_grad_axpy_2
     62: #endif
     63: #define ad_grad_axpy_2(ggz, ca, gga, cb, ggb)\
     64:                 { int iWiLlNeVeRCoNfLiCt; double *gz = DERIV_grad(*(ggz)) , *ga = DERIV_grad(*(gga)), *gb = DERIV_grad(*(ggb));\
     65:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
     66:                     gz[iWiLlNeVeRCoNfLiCt] =  +(ca)*ga[iWiLlNeVeRCoNfLiCt] +(cb)*gb[iWiLlNeVeRCoNfLiCt];\
     67:                 } }

     69: #if defined(ad_grad_axpy_3)
     70: #undef ad_grad_axpy_3
     71: #endif
     72: #define ad_grad_axpy_3(ggz, ca, gga, cb, ggb, cc, ggc)\
     73:                 { int iWiLlNeVeRCoNfLiCt; double *gz = DERIV_grad(*(ggz)) , *ga = DERIV_grad(*(gga)), *gb = DERIV_grad(*(ggb)), *gc = DERIV_grad(*(ggc));\
     74:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
     75:                     gz[iWiLlNeVeRCoNfLiCt] =  +(ca)*ga[iWiLlNeVeRCoNfLiCt] +(cb)*gb[iWiLlNeVeRCoNfLiCt] +(cc)*gc[iWiLlNeVeRCoNfLiCt];\
     76:                 } }

     78: #if defined(ad_grad_axpy_4)
     79: #undef ad_grad_axpy_4
     80: #endif
     81: #define ad_grad_axpy_4(ggz, ca, gga, cb, ggb, cc, ggc, cd, ggd)\
     82:                 { int iWiLlNeVeRCoNfLiCt; double *gz = DERIV_grad(*(ggz)) , *ga = DERIV_grad(*(gga)), *gb = DERIV_grad(*(ggb)), *gc = DERIV_grad(*(ggc)), *gd = DERIV_grad(*(ggd));\
     83:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
     84:                     gz[iWiLlNeVeRCoNfLiCt] =  +(ca)*ga[iWiLlNeVeRCoNfLiCt] +(cb)*gb[iWiLlNeVeRCoNfLiCt] +(cc)*gc[iWiLlNeVeRCoNfLiCt] +(cd)*gd[iWiLlNeVeRCoNfLiCt];\
     85:                 } }

     87: #if defined(ad_grad_axpy_5)
     88: #undef ad_grad_axpy_5
     89: #endif
     90: #define ad_grad_axpy_5(ggz, ca, gga, cb, ggb, cc, ggc, cd, ggd, ce, gge)\
     91:                 { int iWiLlNeVeRCoNfLiCt; double *gz = DERIV_grad(*(ggz)) , *ga = DERIV_grad(*(gga)), *gb = DERIV_grad(*(ggb)), *gc = DERIV_grad(*(ggc)), *gd = DERIV_grad(*(ggd)), *ge = DERIV_grad(*(gge));\
     92:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
     93:                     gz[iWiLlNeVeRCoNfLiCt] =  +(ca)*ga[iWiLlNeVeRCoNfLiCt] +(cb)*gb[iWiLlNeVeRCoNfLiCt] +(cc)*gc[iWiLlNeVeRCoNfLiCt] +(cd)*gd[iWiLlNeVeRCoNfLiCt] +(ce)*ge[iWiLlNeVeRCoNfLiCt];\
     94:                 } }

     96: #if defined(ad_grad_axpy_6)
     97: #undef ad_grad_axpy_6
     98: #endif
     99: #define ad_grad_axpy_6(ggz, ca, gga, cb, ggb, cc, ggc, cd, ggd, ce, gge, cf, ggf)\
    100:                 { int iWiLlNeVeRCoNfLiCt; double *gz = DERIV_grad(*(ggz)) , *ga = DERIV_grad(*(gga)), *gb = DERIV_grad(*(ggb)), *gc = DERIV_grad(*(ggc)), *gd = DERIV_grad(*(ggd)), *ge = DERIV_grad(*(gge)), *gf = DERIV_grad(*(ggf));\
    101:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
    102:                     gz[iWiLlNeVeRCoNfLiCt] =  +(ca)*ga[iWiLlNeVeRCoNfLiCt] +(cb)*gb[iWiLlNeVeRCoNfLiCt] +(cc)*gc[iWiLlNeVeRCoNfLiCt] +(cd)*gd[iWiLlNeVeRCoNfLiCt] +(ce)*ge[iWiLlNeVeRCoNfLiCt] +(cf)*gf[iWiLlNeVeRCoNfLiCt];\
    103:                 } }

    105: #if defined(ad_grad_axpy_7)
    106: #undef ad_grad_axpy_7
    107: #endif
    108: #define ad_grad_axpy_7(ggz, ca, gga, cb, ggb, cc, ggc, cd, ggd, ce, gge, cf, ggf, cg, ggg)\
    109:                 { int iWiLlNeVeRCoNfLiCt; double *gz = DERIV_grad(*(ggz)) , *ga = DERIV_grad(*(gga)), *gb = DERIV_grad(*(ggb)), *gc = DERIV_grad(*(ggc)), *gd = DERIV_grad(*(ggd)), *ge = DERIV_grad(*(gge)), *gf = DERIV_grad(*(ggf)), *gg = DERIV_grad(*(ggg));\
    110:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
    111:                     gz[iWiLlNeVeRCoNfLiCt] =  +(ca)*ga[iWiLlNeVeRCoNfLiCt] +(cb)*gb[iWiLlNeVeRCoNfLiCt] +(cc)*gc[iWiLlNeVeRCoNfLiCt] +(cd)*gd[iWiLlNeVeRCoNfLiCt] +(ce)*ge[iWiLlNeVeRCoNfLiCt] +(cf)*gf[iWiLlNeVeRCoNfLiCt] +(cg)*gg[iWiLlNeVeRCoNfLiCt];\
    112:                 } }

    114: #if defined(ad_grad_axpy_8)
    115: #undef ad_grad_axpy_8
    116: #endif
    117: #define ad_grad_axpy_8(ggz, ca, gga, cb, ggb, cc, ggc, cd, ggd, ce, gge, cf, ggf, cg, ggg, ch, ggh)\
    118:                 { int iWiLlNeVeRCoNfLiCt; double *gz = DERIV_grad(*(ggz)) , *ga = DERIV_grad(*(gga)), *gb = DERIV_grad(*(ggb)), *gc = DERIV_grad(*(ggc)), *gd = DERIV_grad(*(ggd)), *ge = DERIV_grad(*(gge)), *gf = DERIV_grad(*(ggf)), *gg = DERIV_grad(*(ggg)), *gh = DERIV_grad(*(ggh)); \
    119:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
    120:                     gz[iWiLlNeVeRCoNfLiCt] =  +(ca)*ga[iWiLlNeVeRCoNfLiCt] +(cb)*gb[iWiLlNeVeRCoNfLiCt] +(cc)*gc[iWiLlNeVeRCoNfLiCt] +(cd)*gd[iWiLlNeVeRCoNfLiCt] +(ce)*ge[iWiLlNeVeRCoNfLiCt] +(cf)*gf[iWiLlNeVeRCoNfLiCt] +(cg)*gg[iWiLlNeVeRCoNfLiCt] +(ch)*gh[iWiLlNeVeRCoNfLiCt];\
    121:                 } }

    123: #if defined(ad_grad_axpy_9)
    124: #undef ad_grad_axpy_9
    125: #endif
    126: #define ad_grad_axpy_9(ggz, ca, gga, cb, ggb, cc, ggc, cd, ggd, ce, gge, cf, ggf, cg, ggg, ch, ggh, ci, ggi)\
    127:                 { int iWiLlNeVeRCoNfLiCt; double *gz = DERIV_grad(*(ggz)) , *ga = DERIV_grad(*(gga)), *gb = DERIV_grad(*(ggb)), *gc = DERIV_grad(*(ggc)), *gd = DERIV_grad(*(ggd)), *ge = DERIV_grad(*(gge)), *gf = DERIV_grad(*(ggf)), *gg = DERIV_grad(*(ggg)), *gh = DERIV_grad(*(ggh)), *gi = DERIV_grad(*(ggi));\
    128:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
    129:                     gz[iWiLlNeVeRCoNfLiCt] =  +(ca)*ga[iWiLlNeVeRCoNfLiCt] +(cb)*gb[iWiLlNeVeRCoNfLiCt] +(cc)*gc[iWiLlNeVeRCoNfLiCt] +(cd)*gd[iWiLlNeVeRCoNfLiCt] +(ce)*ge[iWiLlNeVeRCoNfLiCt] +(cf)*gf[iWiLlNeVeRCoNfLiCt] +(cg)*gg[iWiLlNeVeRCoNfLiCt] +(ch)*gh[iWiLlNeVeRCoNfLiCt] +(ci)*gi[iWiLlNeVeRCoNfLiCt];\
    130:                 } }

    132: #if defined(ad_grad_axpy_10)
    133: #undef ad_grad_axpy_10
    134: #endif
    135: #define ad_grad_axpy_10(ggz, ca, gga, cb, ggb, cc, ggc, cd, ggd, ce, gge, cf, ggf, cg, ggg, ch, ggh, ci, ggi, cj, ggj)\
    136:                 { int iWiLlNeVeRCoNfLiCt; double *gz = DERIV_grad(*(ggz)) , *ga = DERIV_grad(*(gga)), *gb = DERIV_grad(*(ggb)), *gc = DERIV_grad(*(ggc)), *gd = DERIV_grad(*(ggd)), *ge = DERIV_grad(*(gge)), *gf = DERIV_grad(*(ggf)), *gg = DERIV_grad(*(ggg)), *gh = DERIV_grad(*(ggh)), *gi = DERIV_grad(*(ggi)), *gj = DERIV_grad(*(ggj));\
    137:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
    138:                     gz[iWiLlNeVeRCoNfLiCt] =  +(ca)*ga[iWiLlNeVeRCoNfLiCt] +(cb)*gb[iWiLlNeVeRCoNfLiCt] +(cc)*gc[iWiLlNeVeRCoNfLiCt] +(cd)*gd[iWiLlNeVeRCoNfLiCt] +(ce)*ge[iWiLlNeVeRCoNfLiCt] +(cf)*gf[iWiLlNeVeRCoNfLiCt] +(cg)*gg[iWiLlNeVeRCoNfLiCt] +(ch)*gh[iWiLlNeVeRCoNfLiCt] +(ci)*gi[iWiLlNeVeRCoNfLiCt] +(cj)*gj[iWiLlNeVeRCoNfLiCt];\
    139:                 } }