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: #elif defined(ad_grad_axpy_n)
     17: #undef ad_grad_axpy_n
     18: #endif

     20: #ifdef __cplusplus
     22: #endif

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

     26: #ifdef __cplusplus
     27: }
     28: #endif

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

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

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

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

     89: #if defined(ad_grad_axpy_5)
     90: #undef ad_grad_axpy_5
     91: #endif
     92: #define ad_grad_axpy_5(ggz, ca, gga, cb, ggb, cc, ggc, cd, ggd, ce, gge)\
     93:                 { 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));\
     94:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
     95:                     gz[iWiLlNeVeRCoNfLiCt] =  +(ca)*ga[iWiLlNeVeRCoNfLiCt] +(cb)*gb[iWiLlNeVeRCoNfLiCt] +(cc)*gc[iWiLlNeVeRCoNfLiCt] +(cd)*gd[iWiLlNeVeRCoNfLiCt] +(ce)*ge[iWiLlNeVeRCoNfLiCt];\
     96:                 } }

     98: #if defined(ad_grad_axpy_6)
     99: #undef ad_grad_axpy_6
    100: #endif
    101: #define ad_grad_axpy_6(ggz, ca, gga, cb, ggb, cc, ggc, cd, ggd, ce, gge, cf, ggf)\
    102:                 { 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));\
    103:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
    104:                     gz[iWiLlNeVeRCoNfLiCt] =  +(ca)*ga[iWiLlNeVeRCoNfLiCt] +(cb)*gb[iWiLlNeVeRCoNfLiCt] +(cc)*gc[iWiLlNeVeRCoNfLiCt] +(cd)*gd[iWiLlNeVeRCoNfLiCt] +(ce)*ge[iWiLlNeVeRCoNfLiCt] +(cf)*gf[iWiLlNeVeRCoNfLiCt];\
    105:                 } }

    107: #if defined(ad_grad_axpy_7)
    108: #undef ad_grad_axpy_7
    109: #endif
    110: #define ad_grad_axpy_7(ggz, ca, gga, cb, ggb, cc, ggc, cd, ggd, ce, gge, cf, ggf, cg, ggg)\
    111:                 { 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));\
    112:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
    113:                     gz[iWiLlNeVeRCoNfLiCt] =  +(ca)*ga[iWiLlNeVeRCoNfLiCt] +(cb)*gb[iWiLlNeVeRCoNfLiCt] +(cc)*gc[iWiLlNeVeRCoNfLiCt] +(cd)*gd[iWiLlNeVeRCoNfLiCt] +(ce)*ge[iWiLlNeVeRCoNfLiCt] +(cf)*gf[iWiLlNeVeRCoNfLiCt] +(cg)*gg[iWiLlNeVeRCoNfLiCt];\
    114:                 } }

    116: #if defined(ad_grad_axpy_8)
    117: #undef ad_grad_axpy_8
    118: #endif
    119: #define ad_grad_axpy_8(ggz, ca, gga, cb, ggb, cc, ggc, cd, ggd, ce, gge, cf, ggf, cg, ggg, ch, ggh)\
    120:                 { 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)); \
    121:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
    122:                     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];\
    123:                 } }

    125: #if defined(ad_grad_axpy_9)
    126: #undef ad_grad_axpy_9
    127: #endif
    128: #define ad_grad_axpy_9(ggz, ca, gga, cb, ggb, cc, ggc, cd, ggd, ce, gge, cf, ggf, cg, ggg, ch, ggh, ci, ggi)\
    129:                 { 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));\
    130:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
    131:                     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];\
    132:                 } }

    134: #if defined(ad_grad_axpy_10)
    135: #undef ad_grad_axpy_10
    136: #endif
    137: #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)\
    138:                 { 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));\
    139:                 for (iWiLlNeVeRCoNfLiCt = 0; iWiLlNeVeRCoNfLiCt < ad_GRAD_MAX; iWiLlNeVeRCoNfLiCt++) {\
    140:                     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];\
    141:                 } }