Changeset 252 for branches


Ignore:
Timestamp:
Jun 21, 2011 8:43:13 AM (7 years ago)
Author:
kulshres
Message:

merge branch 'mpi' of 'gitclone' into 'svn'

The following changes have been merged:

commit 9837594c0c3b7320710f91af8b6021ea53070b84
Author: Benjamin Letschert <letschi@…>
Date: Thu Jun 16 14:35:11 2011 +0200

Fixing MPI and KEEP definitions in uni4_for.c

commit 8e96964a3d91efcc9d71d0284a32793c7fb289a7
Author: Benjamin Letschert <letschi@…>
Date: Thu Jun 16 14:33:17 2011 +0200

Fixing Send-Recv-Bcast calls in parallel sparsedrivers

commit 646cca9fbd00151ec000f174efcfbf88e6c166ec
Author: Benjamin Letschert <letschi@…>
Date: Thu Jun 16 14:30:02 2011 +0200

Adding parallel hov_forward and hov_reverse to interfaces_mpi and fixing parameter values

commit 2e535a4170054544c9dd3d673c5977ec307d895f
Author: Benjamin Letschert <letschi@…>
Date: Thu Jun 16 14:27:01 2011 +0200

Bugfix by computing jacobian

commit f3602696f00c79a1f09ce970fbdb7700b9b54594
Author: Benjamin Letschert <letschi@…>
Date: Wed Jun 15 13:54:31 2011 +0200

Bugfix by tape access

commit 242c9d101569438d1846c26b14b5658d45c285ac
Author: Benjamin Letschert <letschi@…>
Date: Wed Jun 15 13:51:21 2011 +0200

delete parallel sparsedrivers in serial version

commit 03af94bb5102f30e118763787cc3267680639b8d
Author: Benjamin Letschert <letschi@…>
Date: Wed Jun 15 12:52:31 2011 +0200

seperate parallel headers and functions to its own parallel library
to avoid linking problems

Signed-off-by: Benjamin Letschert <letschi@…>

Location:
branches/MPI
Files:
19 added
14 edited

Legend:

Unmodified
Added
Removed
  • branches/MPI/ADOL-C/Makefile.am

    r171 r252  
    33## Revision: $Id: Makefile.am 38 2009-06-17 15:48:09Z awalther $
    44##
    5 ## Copyright (C) Andrea Walther, Andreas Kowarz
     5## Copyright (C) Andrea Walther, Andreas Kowarz, Kshitij Kulshreshtha
    66##
    77## This file is part of ADOL-C. This software is provided as open source.
  • branches/MPI/ADOL-C/src/Makefile.am

    r240 r252  
    33## Revision: $Id$
    44##
    5 ## Copyright (C) Andrea Walther, Andreas Kowarz
     5## Copyright (C) Andrea Walther, Andreas Kowarz, Kshitij Kulshreshtha
    66##
    77## This file is part of ADOL-C. This software is provided as open source.
     
    8383
    8484if HAVE_MPI
     85lib_LTLIBRARIES += libadolc_mpi.la
    8586AM_CPPFLAGS += @MPICPPFLAGS@
    86 libadolc_la_SOURCES +=  adolc_mpi.cpp interfaces_mpi.cpp
    87 libadolc_la_LDFLAGS  += @MPILIBS@ @LIBMPI@
     87libadolc_mpi_la_SOURCES =  adolc_mpi.cpp interfaces_mpi.cpp \
     88                           zos_forward_mpi.c fos_forward_mpi.c fov_forward_mpi.c \
     89                           hos_forward_mpi.c hov_forward_mpi.c \
     90                           fos_reverse_mpi.c fov_reverse_mpi.c \
     91                           hos_reverse_mpi.c hov_reverse_mpi.c \
     92                           int_forward_s_mpi.c int_forward_t_mpi.c \
     93                           indopro_forward_s_mpi.c indopro_forward_t_mpi.c \
     94                           nonl_ind_forward_s_mpi.c nonl_ind_forward_t_mpi.c \
     95                           int_reverse_s_mpi.c int_reverse_t_mpi.c
     96
     97libadolc_mpi_la_LIBADD = libadolc.la
     98if SPARSE
     99libadolc_mpi_la_LIBADD += sparse/libsparse_mpi.la
     100endif
     101libadolc_mpi_la_LDFLAGS = @MPILIBS@ @LIBMPI@
    88102pkginclude_HEADERS += adolc_mpi.h interfaces_mpi.h
    89103endif
  • branches/MPI/ADOL-C/src/adolc_mpi.cpp

    r245 r252  
    2121#include <adolc/tapedoc/tapedoc.h>
    2222#include <adolc/adalloc.h>
    23 #include <adolc/interfaces.h>
     23#include <adolc/interfaces_mpi.h>
    2424#include <adolc/convolut.h>
    2525
     
    3434int trace_on( int id,
    3535              int size,
    36               short tag
    37 ){
    38     int this_tag = size*tag + id;
    39     return trace_on( this_tag );
     36              short tag,
     37              int keepTaylors
     38){
     39    return trace_on(id+size*tag,keepTaylors);
    4040}
    4141
     
    238238
    239239int function(int id, int size,short tag,int m,int n,double* argument ,double* result){
    240         int rc =-1;
    241         int this_tag = tag*size + id;
    242         if( id == 0)
    243                 rc = function(this_tag,m,n,argument,result);
    244         else
    245                 rc = function(this_tag,0,0,NULL,NULL);
    246         return rc;
    247 }
    248 
    249 int gradient(int id,int size,short tag ,int n, double* x,double* result){
    250         int rc=-1;
    251         int this_tag = tag*size + id;
    252         double one =1.0;
    253         if( id == 0)
    254                 rc = gradient(this_tag , n , x , result);
    255         else {
    256                 rc = zos_forward(this_tag,0,0,1,NULL,NULL);
    257                 if(rc <0){
    258                         printf("Failure by computing parallel hessian, process id %d!\n",id);
    259                         return rc;
    260                 }
    261                 rc = fos_reverse(this_tag,0,0,&one,result);
    262         }
    263         return rc;
    264 }
    265 
    266 int jacobian(int id, int size ,short tag ,int m,int n,const double* a,double** result){
    267         int rc=-1;
    268         int this_tag = size*tag + id;
    269 
    270         if(id==0){
    271                 rc = jacobian(this_tag,m,n,a,result);
    272         } else {
    273                 if (n/2 < m) {
    274                         rc = fov_forward(this_tag,0,0,n,NULL,NULL,NULL,NULL);
    275                 } else {
    276                         rc = zos_forward(this_tag,0,0,1,a,NULL);
    277                         if(rc <0){
    278                                 printf("Failure by computing parallel jacobian, process id %d!\n",id);
    279                                 return rc;
    280                         }
    281                         rc = fov_reverse(this_tag,0,0,m,NULL,result);
    282                 }
    283         }
    284         return rc;
    285 }
    286 
    287 int hessian(int id,int size,short tag ,int n,double* x ,double** result){
    288         int rc =-3,i;
    289         int this_tag = tag*size + id;
    290         if ( id == 0){
    291          rc = hessian(this_tag,n,x,result);
    292         }
    293         else {
     240     return function_mpi(id,size,tag,m,n,argument,result);
     241}
     242
     243int gradient(int id,int size,short tag,int n,double *x,double *y)
     244{
     245     return gradient_mpi(id,size,tag,n,x,y);
     246}
     247
     248int hessian(int id,int size,short tag,int n,double *x,double **x_pp)
     249{
     250     return hessian_mpi(id,size,tag,n,x,x_pp);
     251}
     252
     253int jacobian(int id,int size,short tag,int m,int n,const double *x,double **x_pp)
     254{
     255return jacobian_mpi(id,size,tag,m,n,x,x_pp);
     256}
     257
     258int vec_jac(int id,int size,short tag,int m,int n,int p,double *x,double *y, double *z)
     259{
     260return vec_jac_mpi(id,size,tag,m,n,p,x,y,z);
     261}
     262
     263int jac_vec(int id,int size,short tag,int m,int n,double *x,double *y,double *z)
     264{
     265return jac_vec_mpi(id,size,tag,m,n,x,y,z);
     266}
     267
     268int hess_vec(int id,int size,short tag,int n,double *x,double *y,double *z)
     269{
     270return hess_vec_mpi(id,size,tag,n,x,y,z);
     271}
     272
     273int lagra_hess_vec(int id,int size,short tag,int n,int p,double *x,double *y,double *t,double *z)
     274{
     275return lagra_hess_vec_mpi(id,size,tag,n,p,x,y,t,z);
     276}
     277
     278void tape_doc(int id,int size,short tag, int m,int n, double *x, double *y)
     279{
     280return tape_doc_mpi(id,size,tag,m,n,x,y);
     281}
     282
     283BEGIN_C_DECLS
     284
     285/* C - functions                                   */
     286int function_mpi(int id, int size,short tag,int m,int n,double* argument ,double* result){
     287     int rc =-1;
     288     if( id == 0)
     289          rc = zos_forward_mpi(id,size,tag,m,n,0,argument,result);
     290     else
     291          rc = zos_forward_mpi(id,size,tag,0,0,0,NULL,NULL);
     292     return rc;
     293}
     294
     295int gradient_mpi(int id,int size,short tag ,int n, double* x,double* result){
     296
     297     int rc=-1;
     298     double one =1.0;
     299     if( id == 0){
     300          rc = zos_forward_mpi(id,size,tag,1,n,1,x,result);
     301          if(rc <0){
     302               printf("Failure by computing parallel hessian, process id %d!\n",id);
     303               return rc;
     304          }
     305          rc = fos_reverse_mpi(id,size,tag,1,n,&one,result);
     306     } else {
     307          rc = zos_forward_mpi(id,size,tag,0,0,1,NULL,NULL);
     308          if(rc <0){
     309               printf("Failure by computing parallel hessian, process id %d!\n",id);
     310               return rc;
     311          }
     312          rc = fos_reverse_mpi(id,size,tag,0,0,&one,result);
     313     }
     314     return rc;
     315}
     316
     317int jacobian_mpi(int id, int size ,short tag ,int m,int n,const double* x,double** jacobian){
     318    int rc=-1;
     319    double *result = NULL , **I = NULL;
     320
     321    if(id == 0){
     322        result = myalloc1(m);
     323        if (n/2 < m) {
     324            I = myallocI2(n);
     325            rc = fov_forward_mpi(id,size,tag,m,n,n,x,I,result,jacobian);
     326            myfreeI2(n, I);
     327        } else {
     328            I = myallocI2(m);
     329            rc = zos_forward_mpi(id,size,tag,m,n,1,x,result);
     330            if(rc <0){
     331               printf("Failure by computing parallel jacobian, process id %d!\n",id);
     332               return rc;
     333            }
     334            rc = fov_reverse_mpi(id,size,tag,m,n,m,I,jacobian);
     335            myfreeI2(m, I);
     336        }
     337        myfree1(result);
     338     } else {
     339        if (n/2 < m) {
     340            rc = fov_forward_mpi(id,size,tag,0,0,n,NULL,NULL,NULL,NULL);
     341        } else {
     342            rc = zos_forward_mpi(id,size,tag,0,0,1,NULL,NULL);
     343            if(rc <0){
     344               printf("Failure by computing parallel jacobian, process id %d!\n",id);
     345               return rc;
     346            }
     347            rc = fov_reverse_mpi(id,size,tag,0,0,m,NULL,NULL);
     348           }
     349     }
     350     return rc;
     351}
     352
     353int hessian_mpi(int id,int size,short tag ,int n,double* x ,double** result){
     354     int rc =-3,i,j;
     355     if ( id == 0){
     356        double *v = myalloc1(n);
     357        double *w = myalloc1(n);
     358        for(i=0;i<n;i++) v[i] = 0;
     359        for(i=0;i<n;i++) {
     360           v[i] = 1;
     361           MINDEC(rc, hess_vec_mpi(id,size,tag, n, x, v, w));
     362        if(rc <0){
     363           printf("Failure by computing parallel hessian, process id %d!\n",id);
     364           free((char *)v);
     365           free((char *) w);
     366           return rc;
     367        }
     368        for(j=0;j<=i;j++)
     369            result[i][j] = w[j];
     370        v[i] = 0;
     371        }
     372        free((char *)v);
     373        free((char *) w);
     374     } else {
    294375        for (i=0; i<n; i++){
    295             rc = fos_forward(this_tag, 0,0,2,NULL,NULL,NULL,NULL);
     376            rc = fos_forward_mpi(id,size,tag, 0,0,2,NULL,NULL,NULL,NULL);
    296377            if (rc <0){
    297378               printf("Failure by computing parallel hessian, process id %d!\n",id);
    298379               return rc;
    299380            }
    300             rc = hos_reverse(this_tag,0,0,1, NULL,NULL);
     381            rc = hos_reverse_mpi(id,size,tag,0,0,1, NULL,NULL);
    301382        }
    302383     }
     
    305386
    306387/* vec_jac(rank,size,tag, m, n, repeat, x[n], u[m], v[n])                             */
    307 int vec_jac( int id,int size,short tag,int m,int n,int repeat ,double *x,double *u,double *v){
    308      int this_tag = size*tag + id;
     388int vec_jac_mpi( int id,int size,short tag,int m,int n,int repeat ,double *x,double *u,double *v){
    309389     int rc = -3;
    310      if (id == 0)
    311         rc = vec_jac(this_tag, m,n,repeat,x,u,v);
    312      else{
     390     double *y = NULL;
     391     if (id == 0){
    313392        if(!repeat) {
    314            rc = zos_forward(this_tag,0,0,1,NULL,NULL);
     393            y = myalloc1(m);
     394            rc = zos_forward_mpi(id,size,tag,m,n,1, x, y);
     395            if (rc <0){
     396               printf("Failure by computing parallel vec_jac, process id %d!\n",id);
     397               return rc;
     398            }
     399        }
     400       MINDEC(rc, fos_reverse_mpi(id,size,tag,m,n,u,v));
     401       if (!repeat) myfree1(y);
     402     } else{
     403        if(!repeat) {
     404           rc = zos_forward_mpi(id,size,tag,0,0,1,NULL,NULL);
    315405        if(rc < 0) return rc;
    316406        }
    317         rc = fos_reverse(this_tag,0,0,NULL,NULL);
     407        rc = fos_reverse_mpi(id,size,tag,0,0,NULL,NULL);
    318408     }
    319409     return rc;
     
    321411
    322412/* jac_vec(rank,size,tag, m, n, x[n], v[n], u[m]);                                    */
    323 int jac_vec(int id,int size,short tag,int m,int n,double *x,double *v, double *u){
    324      int this_tag = size*tag + id;
     413int jac_vec_mpi(int id,int size,short tag,int m,int n,double *x,double *v, double *u){
    325414     int rc = -3;
    326      if (id == 0)
    327         rc = jac_vec(this_tag, m,n,x,u,v);
    328      else
    329         rc = fos_forward(this_tag, 0, 0, 0, NULL, NULL, NULL,NULL);
     415     double *y = NULL;
     416     if (id == 0){
     417         y = myalloc1(m);
     418         rc = fos_forward_mpi(id,size,tag, m, n, 0, x, v, y, u);
     419         myfree1(y);
     420     } else{
     421         rc = fos_forward_mpi(id,size,tag, 0, 0, 0, NULL, NULL, NULL,NULL);
     422     }
    330423     return rc;
    331424}
    332425
    333426/* hess_vec(rank,size,tag, n, x[n], v[n], w[n])                                       */
    334 int hess_vec(int id,int size,short tag,int n,double *x,double *v,double *w){
     427int hess_vec_mpi(int id,int size,short tag,int n,double *x,double *v,double *w){
    335428     double one = 1.0;
    336      return lagra_hess_vec(id,size,tag,1,n,x,v,&one,w);
    337 }
    338 
    339 /* hess_mat(rank,size,tag, n, q, x[n], V[n][q], W[n][q])                              */
    340 int hess_mat(int id,int size,short tag,int n,int q,double *x,double **V, double **W){
    341      double one = 1.0;
    342      int this_tag = size*tag + id;
    343      int rc = -3,i,degree=1, keep=2;
    344      if (id == 0)
    345         rc = hess_mat(this_tag,n,q,x,V,W);
    346      else{
    347         rc = hov_wk_forward(this_tag, 0, 0, 1, 2, q, NULL, NULL, &one,NULL);
    348         if(rc < 0) return rc;
    349         rc = hos_ov_reverse(this_tag, 0, 0, 1, q, NULL, NULL);
    350      }
    351      return rc;
     429     return lagra_hess_vec_mpi(id,size,tag,1,n,x,v,&one,w);
    352430}
    353431
    354432/* lagra_hess_vec(tag, m, n, x[n], v[n], u[m], w[n])                        */
    355 int lagra_hess_vec(int id, int size, short tag,
     433int lagra_hess_vec_mpi(int id, int size, short tag,
    356434                   int m,
    357435                   int n,
     
    364442    int degree = 1;
    365443    int keep = degree+1;
    366     int this_tag = size*tag + id;
    367 
    368      if (id == 0 )
    369         rc = lagra_hess_vec(this_tag,m,n,argument,tangent,lagrange,result);
    370      else {
    371         rc = fos_forward(this_tag, 0, 0, keep, NULL, lagrange , NULL, NULL);
    372 
    373         if(rc < 0) return rc;
    374         rc = hos_reverse(this_tag, 0, 0, degree, lagrange, NULL );
    375      }
    376     return rc;
    377 }
    378 
    379 void tape_doc( int id,int size,short tag, int m,int n, double* x, double* y){
    380         int this_tag = tag*size +id;
    381         if(id==0)
    382         tape_doc(this_tag,m,n,x,y);
    383         else
    384         tape_doc(this_tag,0,0,x,y);
    385 }
    386 
    387 
    388 /* C - functions                                   */
    389 int trace_on_p(int id, int size , short tag)
    390 {
    391      return trace_on(id,size,tag);
    392 }
    393 
    394 int gradient_p(int id,int size,short tag,int n,double *x,double *y)
    395 {
    396      return gradient(id,size,tag,n,x,y);
    397 }
    398 
    399 int hessian_p(int id,int size,short tag,int n,double *x,double **x_pp)
    400 {
    401      return hessian(id,size,tag,n,x,x_pp);
    402 }
    403 
    404 int jacobian_p(int id,int size,short tag,int m,int n,const double *x,double **x_pp)
    405 {
    406 return jacobian(id,size,tag,m,n,x,x_pp);
    407 }
    408 
    409 int vec_jac_p(int id,int size,short tag,int m,int n,int p,double *x,double *y, double *z)
    410 {
    411 return vec_jac(id,size,tag,m,n,p,x,y,z);
    412 }
    413 
    414 int jac_vec_p(int id,int size,short tag,int m,int n,double *x,double *y,double *z)
    415 {
    416 return jac_vec(id,size,tag,m,n,x,y,z);
    417 }
    418 
    419 int hess_vec_p(int id,int size,short tag,int n,double *x,double *y,double *z)
    420 {
    421 return hess_vec(id,size,tag,n,x,y,z);
    422 }
    423 
    424 int hess_mat_p(int id,int size,short tag,int n,int p,double *x,double **y,double **z)
    425 {
    426 return hess_mat(id,size,tag,n,p,x,y,z);
    427 }
    428 
    429 int lagra_hess_vec_p(int id,int size,short tag,int n,int p,double *x,double *y,double *t,double *z)
    430 {
    431 return lagra_hess_vec(id,size,tag,n,p,x,y,t,z);
    432 }
    433 
    434 void tape_doc_p(int id,int size,short tag, int m,int n, double *x, double *y)
    435 {
    436 return tape_doc(id,size,tag,m,n,x,y);
    437 }
    438 
     444    double **X, *y, *y_tangent;
     445
     446     if (id == 0 ){
     447        X = myalloc2(n,2);
     448        y = myalloc1(m);
     449        y_tangent = myalloc1(m);
     450        rc = fos_forward_mpi(id,size,tag, m, n, keep, argument, tangent, y, y_tangent);
     451        if (rc <0){
     452           printf("Failure by computing parallel lagra_hess_vec, process id %d!\n",id);
     453           return rc;
     454        }
     455        MINDEC(rc, hos_reverse_mpi(id,size,tag, m, n, degree, lagrange, X));
     456        for(i = 0; i < n; ++i)
     457            result[i] = X[i][1];
     458        myfree1(y_tangent);
     459        myfree1(y);
     460        myfree2(X);
     461     } else {
     462        rc = fos_forward_mpi(id,size,tag, 0, 0, keep, NULL, lagrange , NULL, NULL);
     463        if (rc <0){
     464           printf("Failure by computing parallel vec_jac, process id %d!\n",id);
     465           return rc;
     466        }
     467        rc = hos_reverse_mpi(id,size,tag, 0, 0, degree, lagrange, NULL );
     468     }
     469     return rc;
     470}
     471
     472void tape_doc_mpi( int id,int size,short tag, int m,int n, double* x, double* y){
     473     if(id==0)
     474        tape_doc(id+size*tag,m,n,x,y);
     475     else
     476        tape_doc(id+size*tag,0,0,x,y);
     477}
     478
     479END_C_DECLS
    439480
    440481/* That's all*/
  • branches/MPI/ADOL-C/src/adolc_mpi.h

    r245 r252  
    4949BEGIN_C_DECLS
    5050
    51 int ADOLC_MPI_Init(int* a, char*** b);
    52 int ADOLC_MPI_Comm_size(ADOLC_MPI_Comm comm, int* size);
    53 int ADOLC_MPI_Comm_rank(ADOLC_MPI_Comm vomm , int* rank);
    54 int ADOLC_MPI_Get_processor_name(char* a, int* b) ;
    55 int ADOLC_MPI_Barrier(ADOLC_MPI_Comm comm);
    56 int ADOLC_MPI_Finalize() ;
     51ADOLC_DLL_EXPORT int ADOLC_MPI_Init(int* a, char*** b);
     52ADOLC_DLL_EXPORT int ADOLC_MPI_Comm_size(ADOLC_MPI_Comm comm, int* size);
     53ADOLC_DLL_EXPORT int ADOLC_MPI_Comm_rank(ADOLC_MPI_Comm vomm , int* rank);
     54ADOLC_DLL_EXPORT int ADOLC_MPI_Get_processor_name(char* a, int* b) ;
     55ADOLC_DLL_EXPORT int ADOLC_MPI_Barrier(ADOLC_MPI_Comm comm);
     56ADOLC_DLL_EXPORT int ADOLC_MPI_Finalize() ;
    5757
    5858MPI_Op adolc_to_mpi_op(ADOLC_MPI_Op);
     
    6464
    6565#ifdef __cplusplus
    66 int ADOLC_MPI_Send(
     66ADOLC_DLL_EXPORT int ADOLC_MPI_Send(
    6767    adouble *buf, int count, ADOLC_MPI_Datatype datatype, int dest,
    6868    int tag, ADOLC_MPI_Comm comm );
    6969
    70 int ADOLC_MPI_Recv(
     70ADOLC_DLL_EXPORT int ADOLC_MPI_Recv(
    7171    adouble *buf, int count, ADOLC_MPI_Datatype datatype, int dest,
    7272    int tag, ADOLC_MPI_Comm comm );
    7373
    74 int ADOLC_MPI_Bcast(
     74ADOLC_DLL_EXPORT int ADOLC_MPI_Bcast(
    7575    adouble *buf, int count, ADOLC_MPI_Datatype datatype, int root,
    7676    ADOLC_MPI_Comm comm);
    7777
    78 int ADOLC_MPI_Reduce(
     78ADOLC_DLL_EXPORT int ADOLC_MPI_Reduce(
    7979    adouble *sendbuf, adouble* rec_buf, int count, ADOLC_MPI_Datatype type,
    8080    ADOLC_MPI_Op op, int root, ADOLC_MPI_Comm comm);
    8181
    82 int trace_on(int, int, short);
     82ADOLC_DLL_EXPORT int trace_on(int, int, short, int keep = 0);
    8383
    8484/*********************************************************************/
    8585/* Algorithmic Differentation Programs                               */
     86ADOLC_DLL_EXPORT int function(int, int, short, int , int, double*,double*);
     87
    8688
    8789/* gradient(rank,size,tag, n, x[n], g[n])          */
    88 int gradient(
     90ADOLC_DLL_EXPORT int gradient(
    8991    int,int,short,int,double*,double*);
    9092
    9193/* hessian(rank,size,tag, n, x[n], H[n][n])         */
    92 int hessian(
     94ADOLC_DLL_EXPORT int hessian(
    9395    int,int,short,int,double*,double**);
    9496
    9597/* jacobian(rank,size,tag, m, n, x[n], J[m][n])                 */
    96 int jacobian(
     98ADOLC_DLL_EXPORT int jacobian(
    9799    int,int,short,int,int,const double*,double**);
    98100
    99101/* vec_jac(rank,size,tag, m, n, repeat, x[n], u[m], v[n])                             */
    100 int vec_jac(
     102ADOLC_DLL_EXPORT int vec_jac(
    101103    int,int,short,int,int,int,double*,double*,double*);
    102104
    103105/* jac_vec(rank,size,tag, m, n, x[n], v[n], u[m]);                                    */
    104 int jac_vec(
     106ADOLC_DLL_EXPORT int jac_vec(
    105107    int,int,short,int,int,double*,double*,double*);
    106108
    107109/* hess_vec(rank,size,tag, n, x[n], v[n], w[n])                                       */
    108 int hess_vec(
     110ADOLC_DLL_EXPORT int hess_vec(
    109111    int,int,short,int,double*,double*,double*);
    110112
    111 /* hess_mat(rank,size,tag, n, q, x[n], V[n][q], W[n][q])                              */
    112 int hess_mat(
    113     int,int,short,int,int,double*,double**,double**);
    114 
    115 
    116113/* lagra_hess_vec(rank,size, tag, m, n, x[n], v[n], u[m], w[n])                        */
    117 int lagra_hess_vec(
     114ADOLC_DLL_EXPORT int lagra_hess_vec(
    118115    int,int,short,int,int,double*,double*,double*,double*);
    119116
    120117/* generating tapes by process id, processes count, used tag, m,n, x[n], y[m] */
    121 void tape_doc(
     118ADOLC_DLL_EXPORT void tape_doc(
    122119    int,int,short, int,int, double*, double*);
    123120#endif /*__cplusplus*/
    124121
    125 #ifdef __cplusplus
    126 extern "C" {
    127 #endif
     122BEGIN_C_DECLS
     123/* C - functions                                   */
    128124
    129 /* C - functions                                   */
    130 int trace_on_p(
    131     int, int, short);
     125ADOLC_DLL_EXPORT int function_mpi(int, int, short, int , int, double*,double*);
    132126
    133 int gradient_p(
     127ADOLC_DLL_EXPORT int gradient_mpi(
    134128    int,int,short,int,double*,double*);
    135 int hessian_p(
     129
     130ADOLC_DLL_EXPORT int hessian_mpi(
    136131    int,int,short,int,double*,double**);
    137132
    138 int jacobian_p(
     133ADOLC_DLL_EXPORT int jacobian_mpi(
    139134    int,int,short,int,int,const double*,double**);
    140135
    141 int vec_jac_p(
     136ADOLC_DLL_EXPORT int vec_jac_mpi(
    142137    int,int,short,int,int,int,double*,double*,double*);
    143138
    144 int jac_vec_p(
     139ADOLC_DLL_EXPORT int jac_vec_mpi(
    145140    int,int,short,int,int,double*,double*,double*);
    146141
    147 int hess_vec_p(
     142ADOLC_DLL_EXPORT int hess_vec_mpi(
    148143    int,int,short,int,double*,double*,double*);
    149144
    150 int hess_mat_p(
    151     int,int,short,int,int,double*,double**,double**);
    152 
    153 int lagra_hess_vec_p(
     145ADOLC_DLL_EXPORT int lagra_hess_vec_mpi(
    154146    int,int,short,int,int,double*,double*,double*,double*);
    155147
    156 void tape_doc_p(
     148ADOLC_DLL_EXPORT void tape_doc_mpi(
    157149    int,int,short, int,int, double*, double*);
    158 
    159 #ifdef __cplusplus
    160 }
    161 #endif
     150END_C_DECLS
    162151
    163152#endif /*HAVE_MPI*/
  • branches/MPI/ADOL-C/src/fo_rev.c

    r240 r252  
    6464/*--------------------------------------------------------------------------*/
    6565#ifdef _FOS_
     66#if defined(_MPI_)
     67#define GENERATED_FILENAME "fos_reverse_mpi"
     68#else
    6669#define GENERATED_FILENAME "fos_reverse"
     70#endif
    6771
    6872#define RESULTS(l,indexi)  results[indexi]
     
    7175/*--------------------------------------------------------------------------*/
    7276#elif _FOV_
     77#if defined(_MPI_)
     78#define GENERATED_FILENAME "fov_reverse_mpi"
     79#else
    7380#define GENERATED_FILENAME "fov_reverse"
     81#endif
    7482
    7583#define _ADOLC_VECTOR_
     
    8189#if defined(_INT_REV_)
    8290#if defined(_TIGHT_)
     91#if defined(_MPI_)
     92#define GENERATED_FILENAME "int_reverse_t_mpi"
     93#else
    8394#define GENERATED_FILENAME "int_reverse_t"
    8495#endif
     96#endif
    8597#if defined(_NTIGHT_)
     98#if defined(_MPI_)
     99#define GENERATED_FILENAME "int_reverse_s_mpi"
     100#else
    86101#define GENERATED_FILENAME "int_reverse_s"
     102#endif
    87103#endif
    88104#define RESULTS(l,indexi)  results[l][indexi]
     
    197213#include <math.h>
    198214
    199 #if defined(HAVE_MPI_MPI_H)
    200 #include <mpi/mpi.h>
    201 #elif defined(HAVE_MPI_H)
    202 #include <mpi.h>
     215#if defined(_MPI_)
     216#include <adolc/adolc_mpi.h>
    203217#endif
    204218
     
    212226/* First-Order Scalar Reverse Pass.                                         */
    213227/****************************************************************************/
    214 int fos_reverse(short   tnum,       /* tape id */
     228#if defined(_MPI_)
     229int fos_reverse_mpi( int mpi_id, int mpi_size,
     230#else
     231int fos_reverse(
     232#endif
     233                short   tnum,       /* tape id */
    215234                int     depen,      /* consistency chk on # of deps */
    216235                int     indep,      /* consistency chk on # of indeps */
     
    223242/* First-Order Vector Reverse Pass.                                         */
    224243/****************************************************************************/
    225 
    226 int fov_reverse(short   tnum,        /* tape id */
     244#if defined(_MPI_)
     245int fov_reverse_mpi( int mpi_id, int mpi_size,
     246#else
     247int fov_reverse(
     248#endif
     249                short   tnum,        /* tape id */
    227250                int     depen,       /* consistency chk on # of deps */
    228251                int     indep,       /* consistency chk on # of indeps */
     
    237260/* First Order Vector version of the reverse mode for bit patterns, tight   */
    238261/****************************************************************************/
     262#if defined(_MPI_)
     263int int_reverse_tight_mpi( int mpi_id, int mpi_size,
     264#else
    239265int int_reverse_tight(
     266#endif
    240267        short             tnum,  /* tape id                               */
    241268        int               depen, /* consistency chk on # of deps          */
     
    250277/* First Order Vector version of the reverse mode, bit pattern, safe        */
    251278/****************************************************************************/
     279#if defined(_MPI_)
     280int int_reverse_safe_mpi( int mpi_id, int mpi_size,
     281#else
    252282int int_reverse_safe(
     283#endif
    253284        short             tnum,  /* tape id                               */
    254285        int               depen, /* consistency chk on # of deps          */
     
    272303    locint arg1 = 0;
    273304    locint arg2 = 0;
     305
     306#if defined(_MPI_)
     307     short this_tnum = mpi_size*tnum + mpi_id;
     308#endif
     309
    274310
    275311#if !defined (_NTIGHT_)
     
    362398    /*                                                           DEBUG MESSAGES */
    363399    fprintf(DIAG_OUT,"Call of %s(..) with tag: %d, n: %d, m %d,\n",
    364             GENERATED_FILENAME, tnum, indep, depen);
     400            GENERATED_FILENAME,
     401#if defined(_MPI_)
     402this_tnum,
     403#else
     404 tnum,
     405#endif
     406           indep, depen);
    365407#ifdef _ADOLC_VECTOR_
    366408    fprintf(DIAG_OUT,"                    p: %d\n\n",nrows);
     
    369411#endif
    370412
    371 #if defined(HAVE_MPI)
     413#if defined(_MPI_)
    372414        double *trade, *rec_buf;
    373415        MPI_Status status_MPI;
     
    382424
    383425    /* Initialize the Reverse Sweep */
     426#ifdef _MPI_
     427    init_rev_sweep(this_tnum);
     428#else
    384429    init_rev_sweep(tnum);
     430#endif
    385431
    386432    failAdditionalInfo3 = depen;
     
    466512#if !defined(_NTIGHT_)
    467513    ADOLC_CURRENT_TAPE_INFOS.rp_T = rp_T;
    468 
     514#if defined(_MPI_)
     515    taylor_back(this_tnum, &numdep, &numind, &taycheck);
     516#else
    469517    taylor_back(tnum, &numdep, &numind, &taycheck);
     518#endif
    470519
    471520    if (taycheck < 0) {
     
    930979
    931980                FOR_0_LE_l_LT_p
    932                 { 
     981                {
    933982#if defined(_INT_REV_)
    934983                  AARG2_INC |= ARES;
     
    17861835#endif /* !_INT_REV_ */
    17871836                /*--------------------------------------------------------------------------*/
    1788 #if defined(HAVE_MPI)
     1837#if defined(_MPI_)
    17891838            case receive_data:  // MPI-Send
    17901839                res = get_locint_r(); // tag
  • branches/MPI/ADOL-C/src/ho_rev.c

    r241 r252  
    6060/*--------------------------------------------------------------------------*/
    6161#ifdef _HOS_
     62#if defined(_MPI_)
     63#define GENERATED_FILENAME "hos_reverse_mpi"
     64#else
    6265#define GENERATED_FILENAME "hos_reverse"
    63 
     66#endif
    6467#define _HIGHER_ORDER_
    6568
     
    9699/*--------------------------------------------------------------------------*/
    97100#elif _HOV_
     101#if defined(_MPI_)
     102#define GENERATED_FILENAME "hov_reverse_mpi"
     103#else
    98104#define GENERATED_FILENAME "hov_reverse"
     105#endif
    99106
    100107#define _ADOLC_VECTOR_
     
    274281#include <math.h>
    275282
    276 #if defined(HAVE_MPI)
     283#if defined(_MPI_)
    277284#include <adolc/adolc_mpi.h>
    278285#endif /* ADOLC_Parallel */
     
    291298/* Higher Order Scalar Reverse Pass.                                       */
    292299/***************************************************************************/
    293 int hos_reverse(short   tnum,        /* tape id */
     300#if defined(_MPI_)
     301int hos_reverse_mpi( int mpi_id, int mpi_size,
     302#else
     303int hos_reverse(
     304#endif
     305                short   tnum,        /* tape id */
    294306                int     depen,       /* consistency chk on # of deps */
    295307                int     indep,       /* consistency chk on # of indeps */
     
    306318            L[i][j] = 0.0;
    307319    }
     320#if defined(_MPI_)
     321    rc = hos_ti_reverse(mpi_id+mpi_size*tnum,depen,indep,degre,L,results);
     322#else
    308323    rc = hos_ti_reverse(tnum,depen,indep,degre,L,results);
     324#endif
    309325        if((depen!=0) && (indep != 0)) myfree2(L);
    310326    return rc;
     
    336352/* Higher Order Vector Reverse Pass.                                       */
    337353/***************************************************************************/
    338 int hov_reverse(short   tnum,        /* tape id */
     354#if defined(_MPI_)
     355int hov_reverse_mpi( int mpi_id, int mpi_size,
     356#else
     357int hov_reverse(
     358#endif
     359                short   tnum,        /* tape id */
    339360                int     depen,       /* consistency chk on # of deps */
    340361                int     indep,       /* consistency chk on # of indeps */
     
    352373                L[k][i][j] = 0.0;
    353374        }
     375#if defined(_MPI_)
     376    rc = hov_ti_reverse(mpi_size*tnum + mpi_id,depen,indep,degre,nrows,L,results,nonzero);
     377#else
    354378    rc = hov_ti_reverse(tnum,depen,indep,degre,nrows,L,results,nonzero);
     379#endif
    355380    myfree3(L);
    356381    return rc;
     
    592617#endif /* ADOLC_DEBUG */
    593618
    594 #if defined(HAVE_MPI)
     619#if defined(_MPI_)
    595620        MPI_Status status_MPI;
    596621        double *trade, *rec_buf;
     
    20942119                /*--------------------------------------------------------------------------*/
    20952120
    2096 #if defined(HAVE_MPI)
     2121#if defined(_MPI_)
    20972122               case receive_data:       // MPI-Send
    20982123                   res  = get_locint_r(); // tag
  • branches/MPI/ADOL-C/src/interfaces_mpi.cpp

    r245 r252  
    3030                 double* y
    3131){
    32     int this_tag = size*tag + id, rc=-3;
    33     if (id==0)
    34        rc = zos_forward(this_tag,m,n,keep,x,y);
    35     else
    36        rc = zos_forward(this_tag,0,0,keep,NULL,NULL);
     32    int rc=-3;
     33    if (id==0)
     34       rc = zos_forward_mpi(id,size,tag,m,n,keep,x,y);
     35    else
     36       rc = zos_forward_mpi(id,size,tag,0,0,keep,NULL,NULL);
    3737    return rc;
    3838}
     
    5050                 double* b
    5151){
    52     int this_tag = size*tag + id;
    53     int rc=-3;
    54     if (id==0)
    55        rc = fos_forward(this_tag,m,n,keep,x,a,y,b);
    56     else
    57        rc = fos_forward(this_tag,0,0,keep,NULL,NULL,NULL,NULL);
     52    int rc=-3;
     53    if (id==0)
     54       rc = fos_forward_mpi(id,size,tag,m,n,keep,x,a,y,b);
     55    else
     56       rc = fos_forward_mpi(id,size,tag,0,0,keep,NULL,NULL,NULL,NULL);
    5857    return rc;
    5958}
     
    6867                 double* z
    6968){
    70     int this_tag = size*tag + id, rc=-3;
    71     if (id==0)
    72        rc = fos_reverse(this_tag,m,n,u,z);
    73     else
    74        rc = fos_reverse(this_tag,0,0,NULL,NULL);
     69    int rc=-3;
     70    if (id==0)
     71       rc = fos_reverse_mpi(id,size,tag,m,n,u,z);
     72    else
     73       rc = fos_reverse_mpi(id,size,tag,0,0,NULL,NULL);
    7574    return rc;
    7675}
     
    8988                 double** taylors)
    9089{
    91     int this_tag = size*tag + id, rc=-3;
    92     if (id==0)
    93        rc = hos_forward(this_tag,depen,indep,d,keep,basepoints,argument,valuepoints,taylors);
    94     else
    95        rc = hos_forward(this_tag,0,0,d,keep,NULL,NULL,NULL,NULL);
     90    int rc=-3;
     91    if (id==0)
     92       rc = hos_forward_mpi(id,size,tag,depen,indep,d,keep,basepoints,argument,valuepoints,taylors);
     93    else
     94       rc = hos_forward_mpi(id,size,tag,0,0,d,keep,NULL,NULL,NULL,NULL);
    9695    return rc;
    9796}
     
    108107                 double** z
    109108){
    110     int this_tag = size*tag + id, rc=-3;
    111     if (id==0)
    112        rc = hos_reverse(this_tag,m,n,d,u,z);
    113     else
    114        rc = hos_reverse(this_tag,0,0,d,NULL,NULL);
     109    int rc=-3;
     110    if (id==0)
     111       rc = hos_reverse_mpi(id,size,tag,m,n,d,u,z);
     112    else
     113       rc = hos_reverse_mpi(id,size,tag,0,0,d,NULL,NULL);
    115114    return rc;
    116115}
     
    128127                 double** b
    129128){
    130     int this_tag = size*tag + id;
    131     int rc=-3;
    132     if (id==0)
    133        rc = fov_forward(this_tag,m,n,p,x,a,y,b);
    134     else
    135        rc = fov_forward(this_tag,0,0,p,NULL,a,NULL,b);
     129    int rc=-3;
     130    if (id==0)
     131       rc = fov_forward_mpi(id,size,tag,m,n,p,x,a,y,b);
     132    else
     133       rc = fov_forward_mpi(id,size,tag,0,0,p,NULL,a,NULL,b);
    136134    return rc;
    137135}
     
    146144                 double** z
    147145){
    148     int this_tag = size*tag + id;
    149     int rc=-3;
    150     if (id==0)
    151        rc = fov_reverse(this_tag,m,n,p,u,z);
    152     else
    153        rc = fov_reverse(this_tag,0,0,p,NULL,NULL);
     146    int rc=-3;
     147    if (id==0)
     148       rc = fov_reverse_mpi(id,size,tag,m,n,p,u,z);
     149    else
     150       rc = fov_reverse_mpi(id,size,tag,0,0,p,NULL,NULL);
     151    return rc;
     152}
     153
     154int hov_reverse(
     155      int id, int size, short tag, int m, int n, int degre,
     156      int nrows, double **lagrange, double ***results,
     157      short **nonzero){
     158int rc = -3;
     159    if (id==0)
     160       rc = hov_reverse_mpi(id,size,tag,m,n,degre,nrows, lagrange,results,nonzero);
     161    else
     162       rc = hov_reverse_mpi(id,size,tag,0,0,degre,0, NULL,NULL,NULL);
     163    return rc;
     164}
     165
     166int hov_forward(
     167      int id, int size, short tag, int m, int n, int degre,
     168      int p,double *x, double ***a, double *v,
     169      double ***taylors){
     170int rc = -3;
     171    if (id==0)
     172       rc = hov_forward_mpi(id,size,tag,m,n,degre, p,x,a,v,taylors);
     173    else
     174       rc = hov_forward_mpi(id,size,tag,0,0,degre,p,
     175       NULL,NULL,NULL,NULL);
    154176    return rc;
    155177}
     
    158180int int_forward_tight(
    159181    int id,int size,short tag,
    160     int m,int n,int p,double* x,
     182    int m,int n,int p, const double* x,
    161183    unsigned long int** x_pp,double* y,unsigned long int** y_pp){
    162184
    163     int this_tag = size*tag + id;
    164     int rc=-3;
    165     if (id==0)
    166        rc = int_forward_tight(this_tag,m,n,p,x,x_pp,y,y_pp);
    167     else
    168        rc = int_forward_tight(this_tag,0,0,p,NULL,NULL,NULL,NULL);
     185    int rc=-3;
     186    if (id==0)
     187       rc = int_forward_tight_mpi(id,size,tag,m,n,p,x,x_pp,y,y_pp);
     188    else
     189       rc = int_forward_tight_mpi(id,size,tag,0,0,p,NULL,NULL,NULL,NULL);
    169190    return rc;
    170191}
     
    174195    int id,int size,short tag,int m,int n,int p,unsigned long int **x_pp,unsigned long int **y_pp){
    175196
    176     int this_tag = size*tag + id;
    177     int rc=-3;
    178     if (id==0)
    179        rc = int_forward_safe(this_tag,m,n,p,x_pp,y_pp);
    180     else
    181        rc = int_forward_safe(this_tag,0,0,p,NULL,NULL);
     197    int rc=-3;
     198    if (id==0)
     199       rc = int_forward_safe_mpi(id,size,tag,m,n,p,x_pp,y_pp);
     200    else
     201       rc = int_forward_safe_mpi(id,size,tag,0,0,p,NULL,NULL);
    182202    return rc;
    183203}
     
    185205/* indopro_forward_tight(rank,size, tag, m, n, x[n], *crs[m])                         */
    186206int indopro_forward_tight(
    187     int id, int size, short tag, int m, int n, double *x, unsigned int **crs ){
    188 
    189     int this_tag = size*tag + id;
    190     int rc=-3;
    191     if (id==0)
    192        rc = indopro_forward_tight(this_tag,m,n,x,crs);
    193     else
    194        rc = indopro_forward_tight(this_tag,0,0,NULL,NULL);
     207    int id, int size, short tag, int m, int n,const double *x, unsigned int **crs ){
     208
     209    int rc=-3;
     210    if (id==0)
     211       rc = indopro_forward_tight_mpi(id,size,tag,m,n,x,crs);
     212    else
     213       rc = indopro_forward_tight_mpi(id,size,tag,0,0,x,NULL);
    195214    return rc;
    196215}
     
    198217/* indopro_forward_safe( tag, m, n, x[n], *crs[m])                                   */
    199218int indopro_forward_safe(
    200    int id, int size, short tag, int m, int n, double *x, unsigned int **crs ){
    201 
    202     int this_tag = size*tag + id;
    203     int rc=-3;
    204     if (id==0)
    205        rc = indopro_forward_safe(this_tag,m,n,x,crs);
    206     else
    207        rc = indopro_forward_safe(this_tag,0,0,NULL,NULL);
     219   int id, int size, short tag, int m, int n,const double *x, unsigned int **crs ){
     220
     221    int rc=-3;
     222    if (id==0)
     223       rc = indopro_forward_safe_mpi(id,size,tag,m,n,x,crs);
     224    else
     225       rc = indopro_forward_safe_mpi(id,size,tag,0,0,NULL,NULL);
    208226    return rc;
    209227}
     
    211229/* indopro_forward_tight( tag, m, n, x[n], *crs[m])   */
    212230int nonl_ind_forward_tight(
    213    int id, int size, short tag, int m, int n, double *x, unsigned int **crs ){
    214 
    215     int this_tag = size*tag + id;
    216     int rc=-3;
    217     if (id==0)
    218        rc = nonl_ind_forward_tight(this_tag,m,n,x,crs);
    219     else
    220        rc = nonl_ind_forward_tight(this_tag,0,0,NULL,NULL);
     231   int id, int size, short tag, int m, int n,const double *x, unsigned int **crs ){
     232
     233    int rc=-3;
     234    if (id==0)
     235       rc = nonl_ind_forward_tight_mpi(id,size,tag,m,n,x,crs);
     236    else
     237       rc = nonl_ind_forward_tight_mpi(id,size,tag,0,0,NULL,NULL);
    221238    return rc;
    222239}
     
    224241/* indopro_forward_safe( tag, m, n, x[n], *crs[m])   */
    225242int nonl_ind_forward_safe(
    226    int id, int size, short tag, int m, int n, double *x, unsigned int **crs ){
    227 
    228     int this_tag = size*tag + id;
    229     int rc=-3;
    230     if (id==0)
    231        rc = indopro_forward_safe(this_tag,m,n,x,crs);
    232     else
    233        rc = indopro_forward_safe(this_tag,0,0,NULL,NULL);
    234     return rc;
    235 }
    236 
    237 
    238 /*  for extern "C"           */
    239 BEGIN_C_DECLS
    240 int zos_forward_p( int id,
    241                  int size,
    242                  short tag,
    243                  int m,
    244                  int n,
    245                  int keep,
    246                  const double* x,
    247                  double* y
    248 ){
    249    return zos_forward(id,size,tag,m,n,keep,x,y);
    250 }
    251 
    252 int fos_forward_p( int id,
    253                  int size,
    254                  short tag,
    255                  int m,
    256                  int n,
    257                  int keep,
    258                  const double* x,
    259                  double* a,
    260                  double* y,
    261                  double* b
    262 ){
    263    return fos_forward(id,size,tag,m,n,keep,x,a,y,b);
    264 }
    265 
    266 int fos_reverse_p( int id,
    267                  int size,
    268                  short tag,
    269                  int m,
    270                  int n,
    271                  double* u,
    272                  double* z
    273 ){
    274     return fos_reverse(id,size,tag,m,n,u,z);
    275 }
    276 
    277 int hos_forward_p( int id,
    278                  int size,
    279                  short tag,
    280                  int depen,
    281                  int indep,
    282                  int d,
    283                  int keep,
    284                  double* basepoints,
    285                  double** argument,
    286                  double* valuepoints,
    287                  double** taylors)
    288 {
    289     return hos_forward(id,size,tag,depen,indep,d,keep,basepoints,argument,valuepoints,taylors);
    290 }
    291 
    292 int hos_reverse_p( int id,
    293                  int size,
    294                  short tag,
    295                  int m,
    296                  int n,
    297                  int d,
    298                  double* u,
    299                  double** z
    300 ){
    301     return hos_reverse(id,size,tag,m,n,d,u,z);
    302 }
    303 
    304 int fov_forward_p( int id,
    305                  int size,
    306                  short tag,
    307                  int m,
    308                  int n,
    309                  int p,
    310                  const double* x,
    311                  double** a,
    312                  double* y,
    313                  double** b
    314 ){
    315     return fov_forward(id,size,tag,m,n,p,x,a,y,b);
    316 }
    317 
    318 int fov_reverse_p( int id,
    319                  int size,
    320                  short tag,
    321                  int m,
    322                  int n,
    323                  int p,
    324                  double** u,
    325                  double** z
    326 ){
    327     return fov_reverse(id,size,tag,m,n,p,u,z);
    328 }
    329 
    330 int int_forward_tight_p(
    331     int id,int size,short tag,
    332     int m,int n,int p,double* x,
    333     unsigned long int** x_pp,double* y,unsigned long int** y_pp
    334 ){
    335     return int_forward_tight(id,size,tag,m,n,p,x,x_pp,y,y_pp);
    336 }
    337 
    338 int int_forward_safe_p(
    339     int id,int size,short tag,int m,int n,int p,unsigned long int **x_pp,unsigned long int **y_pp
    340 ){
    341     return int_forward_safe(id,size,tag,m,n,p,x_pp,y_pp);
    342 }
    343 
    344 int indopro_forward_tight_p(
    345     int id, int size, short tag, int m, int n, double *x, unsigned int **crs
    346 ){
    347     return indopro_forward_tight(id,size,tag,m,n,x,crs);
    348 }
    349 
    350 int indopro_forward_safe_p(
    351    int id, int size, short tag, int m, int n, double *x, unsigned int **crs
    352 ){
    353     return indopro_forward_safe(id,size,tag,m,n,x,crs);
    354 }
    355 
    356 int nonl_ind_forward_tight_p(
    357    int id, int size, short tag, int m, int n, double *x, unsigned int **crs
    358 ){
    359     return nonl_ind_forward_tight(id,size,tag,m,n,x,crs);
    360 }
    361 
    362 int nonl_ind_forward_safe_p(
    363    int id, int size, short tag, int m, int n, double *x, unsigned int **crs
    364 ){
    365     return indopro_forward_safe(id,size,tag,m,n,x,crs);
    366 }
    367 END_C_DECLS
     243   int id, int size, short tag, int m, int n,const double *x, unsigned int **crs ){
     244
     245    int rc=-3;
     246    if (id==0)
     247       rc = indopro_forward_safe_mpi(id,size,tag,m,n,x,crs);
     248    else
     249       rc = indopro_forward_safe_mpi(id,size,tag,0,0,NULL,NULL);
     250    return rc;
     251}
     252
     253
  • branches/MPI/ADOL-C/src/interfaces_mpi.h

    r245 r252  
    3333
    3434/* zos_forward(process id,procsize, tag, m, n, keep, x[n], y[m])*/
    35 int zos_forward(
     35ADOLC_DLL_EXPORT int zos_forward(
    3636    int,int,short,int,int,int,const double*,double*);
    3737
    3838/* fos_forward(process id,procsize, tag, m, n, keep, x[n], X[n], y[m], Y[m])*/
    39 int fos_forward(
     39ADOLC_DLL_EXPORT int fos_forward(
     40    int,int,short,int,int,int,const double*, double*,double*,double*);
     41/* fos_reverse(process id, procsize, tag, m, n, u[m], z[n])     */
     42ADOLC_DLL_EXPORT int fos_reverse(
     43    int, int, short,int,int, double*,double*);
     44
     45/* hos_forward(process id,procsize, tag, m, n, d, keep, x[n], X[n][d], y[m], Y[m][d]) */
     46ADOLC_DLL_EXPORT int hos_forward(
     47    int, int, short, int, int, int, int, double*, double**, double*, double**);
     48
     49/*  hos_reverse(process id,procsize, tag, m, n, d, u[m], Z[n][d+1])  */
     50ADOLC_DLL_EXPORT int hos_reverse(
     51    int, int, short, int, int, int, double*, double** );
     52
     53/* fov_forward(process id, procsize, tag, m, n, p, x[n], X[n][p], y[m], Y[m][p]) */
     54ADOLC_DLL_EXPORT int fov_forward(
     55    int,int,short,int,int,int,const double*, double**,double*,double**);
     56/* fov_reverse(process id, procsize, tag, m, n, d, p, U[p][m], Z[p][n])  */
     57ADOLC_DLL_EXPORT int fov_reverse(
     58    int, int, short,int,int,int,double**,double**);
     59
     60ADOLC_DLL_EXPORT int hov_forward(
     61    int, int, short,int,int,int,int, double*,double***,double*,double***);
     62
     63ADOLC_DLL_EXPORT int hov_reverse(
     64    int, int, short,int,int,int,int, double**,double***,short*);
     65
     66/* int_forward_tight(rank,size,tag, m, n, p, x[n], X[n][p], y[m], Y[m][p])            */
     67ADOLC_DLL_EXPORT int int_forward_tight(
     68    int,int,short,int,int,int,const double*,unsigned long int**,double*,unsigned long int**);
     69
     70/* int_forward_safe(rank,size, tag, m, n, p, X[n][p], Y[m][p])                        */
     71ADOLC_DLL_EXPORT int int_forward_safe(
     72    int,int,short,int,int,int,unsigned long int**,unsigned long int**);
     73
     74/* indopro_forward_tight(rank,size, tag, m, n, x[n], *crs[m])                         */
     75ADOLC_DLL_EXPORT int indopro_forward_tight(
     76    int, int, short, int, int,const double*, unsigned int** );
     77
     78/* indopro_forward_safe( tag, m, n, x[n], *crs[m])                                   */
     79ADOLC_DLL_EXPORT int indopro_forward_safe(
     80    int, int, short, int, int,const double*,unsigned int**);
     81
     82/* indopro_forward_tight( tag, m, n, x[n], *crs[m])   */
     83ADOLC_DLL_EXPORT int nonl_ind_forward_tight(
     84    int,int, short, int, int,const double*, unsigned int**);
     85
     86/* indopro_forward_safe( tag, m, n, x[n], *crs[m])   */
     87ADOLC_DLL_EXPORT int nonl_ind_forward_safe(
     88    int, int, short, int, int,const double*, unsigned int**);
     89
     90#endif /* __cplusplus */
     91
     92
     93BEGIN_C_DECLS
     94/* zos_forward(process id,procsize, tag, m, n, keep, x[n], y[m])*/
     95ADOLC_DLL_EXPORT int zos_forward_mpi(
     96    int,int,short,int,int,int,const double*,double*);
     97
     98/* fos_forward(process id,procsize, tag, m, n, keep, x[n], X[n], y[m], Y[m])*/
     99ADOLC_DLL_EXPORT int fos_forward_mpi(
    40100    int,int,short,int,int,int,const double*,double*,double*,double*);
    41101/* fos_reverse(process id, procsize, tag, m, n, u[m], z[n])     */
    42 int fos_reverse(
     102ADOLC_DLL_EXPORT int fos_reverse_mpi(
    43103    int, int, short,int,int,double*,double*);
    44104
    45105/* hos_forward(process id,procsize, tag, m, n, d, keep, x[n], X[n][d], y[m], Y[m][d]) */
    46 int hos_forward(
     106ADOLC_DLL_EXPORT int hos_forward_mpi(
    47107    int, int, short, int, int, int, int, double*, double**, double*, double**);
    48108/*  hos_reverse(process id,procsize, tag, m, n, d, u[m], Z[n][d+1])  */
    49 int hos_reverse(
     109ADOLC_DLL_EXPORT int hos_reverse_mpi(
    50110    int, int, short, int, int, int, double*, double** );
    51111
     112ADOLC_DLL_EXPORT int hov_forward_mpi(
     113    int, int, short,int,int,int,int, double*,double***,double*,double***);
     114
     115ADOLC_DLL_EXPORT int hov_reverse_mpi(
     116    int, int, short,int,int,int,int, double**,double***,short**);
     117
    52118/* fov_forward(process id, procsize, tag, m, n, p, x[n], X[n][p], y[m], Y[m][p]) */
    53 int fov_forward(
     119ADOLC_DLL_EXPORT int fov_forward_mpi(
    54120    int,int,short,int,int,int,const double*,double**,double*,double**);
    55121/* fov_reverse(process id, procsize, tag, m, n, d, p, U[p][m], Z[p][n])  */
    56 int fov_reverse(
     122ADOLC_DLL_EXPORT int fov_reverse_mpi(
    57123    int, int, short,int,int,int,double**,double**);
    58124
    59125/* int_forward_tight(rank,size,tag, m, n, p, x[n], X[n][p], y[m], Y[m][p])            */
    60 int int_forward_tight(
    61     int,int,short,int,int,int,double*,unsigned long int**,double*,unsigned long int**);
     126ADOLC_DLL_EXPORT int int_forward_tight_mpi(
     127    int,int,short,int,int,int,const double*,unsigned long int**,double*,unsigned long int**);
    62128
    63129/* int_forward_safe(rank,size, tag, m, n, p, X[n][p], Y[m][p])                        */
    64 int int_forward_safe(
     130ADOLC_DLL_EXPORT int int_forward_safe_mpi(
    65131    int,int,short,int,int,int,unsigned long int**,unsigned long int**);
    66132
    67133/* indopro_forward_tight(rank,size, tag, m, n, x[n], *crs[m])                         */
    68 int indopro_forward_tight(
    69     int, int, short, int, int, double*, unsigned int** );
     134ADOLC_DLL_EXPORT int indopro_forward_tight_mpi(
     135    int, int, short, int, int,const double*, unsigned int** );
    70136
    71137/* indopro_forward_safe( tag, m, n, x[n], *crs[m])                                   */
    72 int indopro_forward_safe(
    73     int, int, short, int, int, double*,unsigned int**);
     138ADOLC_DLL_EXPORT int indopro_forward_safe_mpi(
     139    int, int, short, int, int,const double*,unsigned int**);
    74140
    75141/* indopro_forward_tight( tag, m, n, x[n], *crs[m])   */
    76 int nonl_ind_forward_tight(
    77     int,int, short, int, int, double*, unsigned int**);
     142ADOLC_DLL_EXPORT int nonl_ind_forward_tight_mpi(
     143    int,int, short, int, int,const double*, unsigned int**);
    78144
    79145/* indopro_forward_safe( tag, m, n, x[n], *crs[m])   */
    80 int nonl_ind_forward_safe(
    81     int, int, short, int, int, double*, unsigned int**);
    82 
    83 #endif /* __cplusplus */
    84 
    85 BEGIN_C_DECLS
    86 int zos_forward_p(
    87     int,int,short,int,int,int,const double*,double*);
    88 
    89 /* fos_forward(process id,procsize, tag, m, n, keep, x[n], X[n], y[m], Y[m])*/
    90 int fos_forward_p(
    91     int,int,short,int,int,int,const double*,double*,double*,double*);
    92 /* fos_reverse(process id, procsize, tag, m, n, u[m], z[n])     */
    93 int fos_reverse_p(
    94     int, int, short,int,int,double*,double*);
    95 
    96 /* hos_forward(process id,procsize, tag, m, n, d, keep, x[n], X[n][d], y[m], Y[m][d]) */
    97 int hos_forward_p(
    98     int, int, short, int, int, int, int, double*, double**, double*, double**);
    99 /*  hos_reverse(process id,procsize, tag, m, n, d, u[m], Z[n][d+1])  */
    100 int hos_reverse_p(
    101     int, int, short, int, int, int, double*, double** );
    102 
    103 /* fov_forward(process id, procsize, tag, m, n, p, x[n], X[n][p], y[m], Y[m][p]) */
    104 int fov_forward_p(
    105     int,int,short,int,int,int,const double*,double**,double*,double**);
    106 /* fov_reverse(process id, procsize, tag, m, n, d, p, U[p][m], Z[p][n])  */
    107 int fov_reverse_p(
    108     int, int, short,int,int,int,double**,double**);
    109 
    110 /* int_forward_tight(rank,size,tag, m, n, p, x[n], X[n][p], y[m], Y[m][p])            */
    111 int int_forward_tight_p(
    112     int,int,short,int,int,int,double*,unsigned long int**,double*,unsigned long int**);
    113 
    114 /* int_forward_safe(rank,size, tag, m, n, p, X[n][p], Y[m][p])                        */
    115 int int_forward_safe_p(
    116     int,int,short,int,int,int,unsigned long int**,unsigned long int**);
    117 
    118 /* indopro_forward_tight(rank,size, tag, m, n, x[n], *crs[m])                         */
    119 int indopro_forward_tight_p(
    120     int, int, short, int, int, double*, unsigned int** );
    121 
    122 /* indopro_forward_safe( tag, m, n, x[n], *crs[m])                                   */
    123 int indopro_forward_safe_p(
    124     int, int, short, int, int, double*,unsigned int**);
    125 
    126 /* indopro_forward_tight( tag, m, n, x[n], *crs[m])   */
    127 int nonl_ind_forward_tight_p(
    128     int,int, short, int, int, double*, unsigned int**);
    129 
    130 /* indopro_forward_safe( tag, m, n, x[n], *crs[m])   */
    131 int nonl_ind_forward_safe_p(
    132     int, int, short, int, int, double*, unsigned int**);
     146ADOLC_DLL_EXPORT int nonl_ind_forward_safe_mpi(
     147    int, int, short, int, int,const double*, unsigned int**);
    133148
    134149END_C_DECLS
  • branches/MPI/ADOL-C/src/sparse/Makefile.am

    r240 r252  
    33## Revision: $Id$
    44##
    5 ## Copyright (C)  Andrea Walther, Andreas Kowarz
     5## Copyright (C)  Andrea Walther, Andreas Kowarz, Kshitij Kulshreshtha
    66##
    77## This file is part of ADOL-C. This software is provided as open source.
     
    2727libsparse_la_SOURCES     = sparse_fo_rev.cpp sparsedrivers.cpp
    2828if HAVE_MPI
     29noinst_LTLIBRARIES              += libsparse_mpi.la
    2930AM_CPPFLAGS += @MPICPPFLAGS@
     31libsparse_mpi_la_SOURCES = sparsedrivers_mpi.cpp
     32libsparseinclude_HEADERS += sparsedrivers_mpi.h
    3033endif
  • branches/MPI/ADOL-C/src/sparse/sparsedrivers.cpp

    r240 r252  
    11041104/****************************************************************************/
    11051105/*                                                               THAT'S ALL */
    1106 #ifdef HAVE_MPI
    1107 #include <adolc/adolc_mpi.h>
    1108 
    1109 int jac_pat(int id, int size, short tag, int depen,int indep, const double *basepoint, unsigned int **crs, int *options ){
    1110      int rc= -1;
    1111      int this_tag = tag*size + id;
    1112 
    1113      if (options[0] !=0 ) {
    1114         if (id==0) printf("This operation is not yet implemented.\n");
    1115         return rc;
    1116      }
    1117      if ( id==0)
    1118         jac_pat(this_tag,depen,indep,basepoint,crs,options);
    1119      else{
    1120         if (( options[0] < 0 ) || (options[0] > 1 ))
    1121            options[0] = 0; /* default */
    1122         if (( options[1] < 0 ) || (options[1] > 1 ))
    1123            options[1] = 0; /* default */
    1124         if (( options[2] < -1 ) || (options[2] > 2 ))
    1125            options[2] = 0; /* default */
    1126 
    1127         if (options[1] == 1)
    1128            rc = indopro_forward_tight(this_tag, 0, 0, NULL, crs);
    1129         else
    1130            rc = indopro_forward_safe(this_tag, 0, 0, NULL, crs);
    1131      }
    1132      return(rc);
    1133 }
    1134 
    1135 int sparse_jac(int id,int size, short tag, int depen, int indep, int repeat, const double* basepoint, int *nnz, unsigned int **rind, unsigned int **cind, double **values, int *options)
    1136 {
    1137 #ifdef HAVE_LIBCOLPACK
    1138      int this_tag = size*tag +id;
    1139      int rc =-3, tmp;
    1140      bool forward, tight;
    1141 
    1142      if (options[0] != 0){
    1143         if (id==0)
    1144            fprintf(DIAG_OUT,"ADOL-C error: Propagation of bit pattern not yet implemented.\n");
    1145         exit(-1);
    1146      }
    1147      if (id==0){
    1148         int i;
    1149         unsigned int j;
    1150         SparseJacInfos sJinfos;
    1151         int dummy;
    1152         BipartiteGraphPartialColoringInterface *g;
    1153         TapeInfos *tapeInfos;
    1154         JacobianRecovery1D *jr1d;
    1155         JacobianRecovery1D jr1d_loc;
    1156 
    1157         ADOLC_OPENMP_THREAD_NUMBER;
    1158         ADOLC_OPENMP_GET_THREAD_NUMBER;
    1159 
    1160         if (repeat == 0) {
    1161            if (( options[0] < 0 ) || (options[0] > 1 ))
    1162               options[0] = 0; /* default */
    1163            if (( options[1] < 0 ) || (options[1] > 1 ))
    1164               options[1] = 0; /* default */
    1165            if (( options[2] < -1 ) || (options[2] > 2 ))
    1166               options[2] = 0; /* default */
    1167            if (( options[3] < 0 ) || (options[3] > 1 ))
    1168               options[3] = 0; /* default */
    1169 
    1170            sJinfos.JP = (unsigned int **) malloc(depen*sizeof(unsigned int *));
    1171            rc = jac_pat(this_tag, depen, indep, basepoint, sJinfos.JP, options);
    1172 
    1173            if (rc < 0) {
    1174               fprintf(DIAG_OUT,"ADOL-C error in parallel sparse_jac() computing jac_pat()\n");
    1175               exit(rc);
    1176            }
    1177 
    1178            sJinfos.depen = depen;
    1179            sJinfos.nnz_in = depen;
    1180            sJinfos.nnz_in = 0;
    1181            for (i=0;i<depen;i++) {
    1182                for (j=1;j<=sJinfos.JP[i][0];j++)
    1183                    sJinfos.nnz_in++;
    1184            }
    1185 
    1186            *nnz = sJinfos.nnz_in;
    1187 
    1188            if (options[2] == -1){
    1189               (*rind) = new unsigned int[*nnz];
    1190               (*cind) = new unsigned int[*nnz];
    1191               unsigned int index = 0;
    1192               for (i=0;i<depen;i++)
    1193                   for (j=1;j<=sJinfos.JP[i][0];j++){
    1194                       (*rind)[index] = i;
    1195                       (*cind)[index++] = sJinfos.JP[i][j];
    1196                   }
    1197            }
    1198 
    1199            /* sJinfos.Seed is memory managed by ColPack and will be deleted
    1200             * along with g. We only keep it in sJinfos for the repeat != 0 case */
    1201 
    1202            g = new BipartiteGraphPartialColoringInterface(SRC_MEM_ADOLC, sJinfos.JP, depen, indep);
    1203            jr1d = new JacobianRecovery1D;
    1204 
    1205            if (options[3] == 1) {
    1206               g->GenerateSeedJacobian(&(sJinfos.Seed), &(sJinfos.seed_rows),&(sJinfos.seed_clms),  "SMALLEST_LAST","ROW_PARTIAL_DISTANCE_TWO");
    1207               sJinfos.seed_clms = indep;
    1208            }
    1209            else
    1210            {
    1211               g->GenerateSeedJacobian(&(sJinfos.Seed), &(sJinfos.seed_rows),
    1212                                 &(sJinfos.seed_clms), "SMALLEST_LAST","COLUMN_PARTIAL_DISTANCE_TWO");
    1213               sJinfos.seed_rows = depen;
    1214            }
    1215 
    1216            sJinfos.B = myalloc2(sJinfos.seed_rows,sJinfos.seed_clms);
    1217            sJinfos.y = myalloc1(depen);
    1218 
    1219            sJinfos.g = (void *) g;
    1220            sJinfos.jr1d = (void *) jr1d;
    1221            setTapeInfoJacSparse(this_tag, sJinfos);
    1222            tapeInfos=getTapeInfos(this_tag);
    1223            memcpy(&ADOLC_CURRENT_TAPE_INFOS, tapeInfos, sizeof(TapeInfos));
    1224         }
    1225         else
    1226         {
    1227            tapeInfos=getTapeInfos(this_tag);
    1228            memcpy(&ADOLC_CURRENT_TAPE_INFOS, tapeInfos, sizeof(TapeInfos));
    1229            sJinfos.depen    = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sJinfos.depen;
    1230            sJinfos.nnz_in    = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sJinfos.nnz_in;
    1231            sJinfos.JP        = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sJinfos.JP;
    1232            sJinfos.B         = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sJinfos.B;
    1233            sJinfos.y         = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sJinfos.y;
    1234            sJinfos.Seed      = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sJinfos.Seed;
    1235            sJinfos.seed_rows = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sJinfos.seed_rows;
    1236            sJinfos.seed_clms = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sJinfos.seed_clms;
    1237            g = (BipartiteGraphPartialColoringInterface *)ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sJinfos.g;
    1238            jr1d = (JacobianRecovery1D *)ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sJinfos.jr1d;
    1239         }
    1240 
    1241         if (sJinfos.nnz_in != *nnz) {
    1242            fprintf(DIAG_OUT," ADOL-C error in parallel sparse_jac():"
    1243                " Number of nonzeros not consistent,"
    1244                " repeat call with repeat = 0 \n");
    1245            exit(-3);
    1246         }
    1247 
    1248         if (options[2] == -1)
    1249            return rc;
    1250 
    1251         // send count for depth
    1252         if (options[3] == 1)
    1253            tmp = sJinfos.seed_rows;
    1254         else
    1255            tmp = sJinfos.seed_clms;
    1256 
    1257         for(i=1; i < size ; i++)
    1258              MPI_Send(&tmp,1,MPI_INT,i,0,MPI_COMM_WORLD);
    1259         MPI_Barrier(MPI_COMM_WORLD);
    1260 
    1261         /* compute jacobian times matrix product */
    1262         if (options[3] == 1){
    1263            rc = zos_forward(this_tag,depen,indep,1,basepoint,sJinfos.y);
    1264            if (rc < 0)
    1265               return rc;
    1266            rc = fov_reverse(this_tag,depen,indep,sJinfos.seed_rows,sJinfos.Seed,sJinfos.B);
    1267         }
    1268         else
    1269         {
    1270            rc = fov_forward(this_tag, depen, indep, sJinfos.seed_clms, basepoint, sJinfos.Seed, sJinfos.y, sJinfos.B);
    1271         }
    1272 
    1273         /* recover compressed Jacobian => ColPack library */
    1274 
    1275         if (*values != NULL && *rind != NULL && *cind != NULL) {
    1276         // everything is preallocated, we assume correctly
    1277         // call usermem versions
    1278            if (options[3] == 1)
    1279               jr1d->RecoverD2Row_CoordinateFormat_usermem(g, sJinfos.B, sJinfos.JP, rind, cind, values);
    1280            else
    1281               jr1d->RecoverD2Cln_CoordinateFormat_usermem(g, sJinfos.B, sJinfos.JP, rind, cind, values);
    1282         } else {
    1283       // at least one of rind cind values is not allocated, deallocate others
    1284       // and call unmanaged versions
    1285            if (*values != NULL)
    1286               free(*values);
    1287            if (*rind != NULL)
    1288               free(*rind);
    1289            if (*cind != NULL)
    1290               free(*cind);
    1291            if (options[3] == 1)
    1292               jr1d->RecoverD2Row_CoordinateFormat_unmanaged(g, sJinfos.B, sJinfos.JP, rind, cind, values);
    1293            else
    1294               jr1d->RecoverD2Cln_CoordinateFormat_unmanaged(g, sJinfos.B, sJinfos.JP, rind, cind, values);
    1295         }
    1296      } // end of id == 0
    1297      else {
    1298           if (repeat == 0) {
    1299              if (( options[0] < 0 ) || (options[0] > 1 ))
    1300                 options[0] = 0; /* default */
    1301              if (( options[1] < 0 ) || (options[1] > 1 ))
    1302                 options[1] = 0; /* default */
    1303              if (( options[2] < -1 ) || (options[2] > 2 ))
    1304                 options[2] = 0; /* default */
    1305              if (( options[3] < 0 ) || (options[3] > 1 ))
    1306                 options[3] = 0; /* default */
    1307 
    1308              rc = jac_pat(id,size,tag,depen,indep,NULL,NULL,options);
    1309 
    1310              if (rc < 0) {
    1311                   fprintf(DIAG_OUT," ADOL-C error in parallel sparse_jac() computing jac_pat()\n");
    1312                   exit(rc);
    1313              }
    1314           } // end of sparse_jac doings
    1315 
    1316           if (options[2] == -1)
    1317                   return rc;
    1318 
    1319           MPI_Status status;
    1320           MPI_Recv(&tmp,1,MPI_INT,0,0,MPI_COMM_WORLD, &status);
    1321           MPI_Barrier(MPI_COMM_WORLD);
    1322 
    1323 
    1324           if (options[3] == 1){
    1325              rc = zos_forward(this_tag,0,0,1,NULL,NULL);
    1326              if (rc < 0) {
    1327                    fprintf(DIAG_OUT,"ADOL-C error in parallel sparse_jac() computing zos_forward()\n");
    1328                    exit(rc);
    1329              }
    1330              rc = fov_reverse(this_tag,0,0,tmp,NULL,NULL);
    1331           }
    1332           else {
    1333              rc = fov_forward(this_tag, 0,0, tmp, NULL, NULL, NULL, NULL);
    1334           }
    1335      } // end repeat == 0
    1336 
    1337      return rc;
    1338 #else
    1339     fprintf(DIAG_OUT, "ADOL-C error: function %s can only be used if linked with ColPack\n", __FUNCTION__);
    1340     exit(-1);
    1341 #endif
    1342 }
    1343 
    1344 int hess_pat(
    1345      int id,
    1346      int size,
    1347      short          tag,        /* tape identification                        */
    1348      int            indep,      /* number of independent variables            */
    1349      const double  *basepoint,  /* independant variable values                */
    1350      unsigned int **crs,
    1351      /* returned compressed row block-index storage                         */
    1352      int          option
    1353      /* control option
    1354         option : test the computational graph control flow
    1355                                0 - safe mode (default)
    1356                                1 - tight mode                              */
    1357 
    1358 ) {
    1359      int this_tag = size*tag + id;
    1360      int rc= -1;
    1361      int i;
    1362 
    1363      if (id == 0) {
    1364         if (crs == NULL) {
    1365            fprintf(DIAG_OUT,"ADOL-C user error in parallel hess_pat(...) : "
    1366                 "parameter crs may not be NULL !\n");
    1367            exit(-1);
    1368         }else
    1369            for (i=0; i<indep; i++)
    1370                crs[i] = NULL;
    1371 
    1372         if (( option < 0 ) || (option > 2 ))
    1373            option = 0;   /* default */
    1374 
    1375         if (option == 1)
    1376            rc = nonl_ind_forward_tight(this_tag, 1, indep, basepoint, crs);
    1377         else
    1378            rc = nonl_ind_forward_safe(this_tag, 1, indep, basepoint, crs);
    1379      } // end of id == 0
    1380      else {
    1381         if (( option < 0 ) || (option > 2 ))
    1382            option = 0;   /* default */
    1383         if (option == 1)
    1384            rc = nonl_ind_forward_tight(this_tag, 0, 0, NULL, crs);
    1385         else
    1386            rc = nonl_ind_forward_safe(this_tag, 0, 0, NULL, crs);
    1387      }
    1388      return rc;
    1389 }
    1390 
    1391 int sparse_hess(
    1392      int id,
    1393      int size,
    1394      short          tag,        /* tape identification                     */
    1395      int            indep,      /* number of independent variables         */
    1396      int            repeat,     /* indicated repeated call with same seed  */
    1397      const double  *basepoint,  /* independant variable values             */
    1398      int           *nnz,        /* number of nonzeros                      */
    1399      unsigned int **rind,       /* row index                               */
    1400      unsigned int **cind,       /* column index                            */
    1401      double       **values,     /* non-zero values                         */
    1402      int           *options
    1403      /* control options
    1404                     options[0] :test the computational graph control flow
    1405                                0 - safe mode (default)
    1406                                1 - tight mode
    1407                     options[1] : way of recovery
    1408                                0 - indirect recovery
    1409                                1 - direct recovery                         */
    1410 ) {
    1411 #ifdef HAVE_LIBCOLPACK
    1412      int i, l, tmp;
    1413      int this_tag = size*tag + id;
    1414      unsigned int j;
    1415      SparseHessInfos sHinfos;
    1416      double **Seed;
    1417      int dummy;
    1418      double y;
    1419      int ret_val=-1;
    1420      GraphColoringInterface *g;
    1421      TapeInfos *tapeInfos;
    1422      double *v, *w, **X, yt, lag=1;
    1423      HessianRecovery *hr;
    1424 
    1425      ADOLC_OPENMP_THREAD_NUMBER;
    1426      ADOLC_OPENMP_GET_THREAD_NUMBER;
    1427 
    1428      /* Generate sparsity pattern, determine nnz, allocate memory */
    1429      if( id ==0){
    1430         if (repeat <= 0) {
    1431            if (( options[0] < 0 ) || (options[0] > 1 ))
    1432               options[0] = 0; /* default */
    1433            if (( options[1] < 0 ) || (options[1] > 1 ))
    1434               options[1] = 0; /* default */
    1435 
    1436            if (repeat == 0) {
    1437               sHinfos.HP    = (unsigned int **) malloc(indep*sizeof(unsigned int *));
    1438               /* generate sparsity pattern */
    1439               ret_val = hess_pat(id,size,tag, indep, basepoint, sHinfos.HP, options[0]);
    1440               if (ret_val < 0) {
    1441                  fprintf(DIAG_OUT," ADOL-C error in parallel sparse_hess() \n");
    1442                  exit(ret_val);
    1443               }
    1444            }
    1445            else {
    1446               tapeInfos=getTapeInfos(this_tag);
    1447               memcpy(&ADOLC_CURRENT_TAPE_INFOS, tapeInfos, sizeof(TapeInfos));
    1448               if (indep != ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sHinfos.indep) {
    1449                  fprintf(DIAG_OUT,"ADOL-C Error: wrong number of independents stored in parallel hessian pattern.\n");
    1450                  exit(-1);
    1451               }
    1452               deepcopy_HP(&sHinfos.HP,ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sHinfos.HP,indep);
    1453            }
    1454 
    1455            sHinfos.indep = indep;
    1456            sHinfos.nnz_in = 0;
    1457 
    1458            for (i=0;i<indep;i++) {
    1459                for (j=1;j<=sHinfos.HP[i][0];j++)
    1460                    if ((int) sHinfos.HP[i][j] >= i)
    1461                       sHinfos.nnz_in++;
    1462            }
    1463 
    1464            *nnz = sHinfos.nnz_in;
    1465 
    1466            /* compute seed matrix => ColPack library */
    1467 
    1468            Seed = NULL;
    1469 
    1470            g = new GraphColoringInterface(SRC_MEM_ADOLC, sHinfos.HP, indep);
    1471            hr = new HessianRecovery;
    1472 
    1473            if (options[1] == 0)
    1474               g->GenerateSeedHessian(&Seed, &dummy, &sHinfos.p,"SMALLEST_LAST","ACYCLIC_FOR_INDIRECT_RECOVERY");
    1475            else
    1476               g->GenerateSeedHessian(&Seed, &dummy, &sHinfos.p,"SMALLEST_LAST","STAR");
    1477 
    1478            sHinfos.Hcomp = myalloc2(indep,sHinfos.p);
    1479            sHinfos.Xppp = myalloc3(indep,sHinfos.p,1);
    1480 
    1481            for (i=0; i<indep; i++)
    1482                for (l=0;l<sHinfos.p;l++)
    1483                    sHinfos.Xppp[i][l][0] = Seed[i][l];
    1484 
    1485            /* Seed will be freed by ColPack when g is freed */
    1486            Seed = NULL;
    1487 
    1488            sHinfos.Yppp = myalloc3(1,sHinfos.p,1);
    1489            sHinfos.Zppp = myalloc3(sHinfos.p,indep,2);
    1490            sHinfos.Upp = myalloc2(1,2);
    1491            sHinfos.Upp[0][0] = 1;
    1492            sHinfos.Upp[0][1] = 0;
    1493            sHinfos.g = (void *) g;
    1494            sHinfos.hr = (void *) hr;
    1495 
    1496            setTapeInfoHessSparse(this_tag, sHinfos);
    1497 
    1498            tapeInfos=getTapeInfos(this_tag);
    1499            memcpy(&ADOLC_CURRENT_TAPE_INFOS, tapeInfos, sizeof(TapeInfos));
    1500         } // end of repeat == 0
    1501         else
    1502         {
    1503            tapeInfos=getTapeInfos(this_tag);
    1504            memcpy(&ADOLC_CURRENT_TAPE_INFOS, tapeInfos, sizeof(TapeInfos));
    1505            sHinfos.nnz_in = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sHinfos.nnz_in;
    1506            sHinfos.HP     = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sHinfos.HP;
    1507            sHinfos.Hcomp  = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sHinfos.Hcomp;
    1508            sHinfos.Xppp   = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sHinfos.Xppp;
    1509            sHinfos.Yppp   = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sHinfos.Yppp;
    1510            sHinfos.Zppp   = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sHinfos.Zppp;
    1511            sHinfos.Upp    = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sHinfos.Upp;
    1512            sHinfos.p      = ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sHinfos.p;
    1513            g = (GraphColoringInterface *)ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sHinfos.g;
    1514            hr = (HessianRecovery *)ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sHinfos.hr;
    1515         }
    1516 
    1517         if (sHinfos.Upp == NULL) {
    1518            fprintf(DIAG_OUT," ADOL-C error in parallel sparse_hess():\n First call with repeat = 0 \n");
    1519            exit(-3);
    1520         }
    1521 
    1522         if (sHinfos.nnz_in != *nnz) {
    1523            fprintf(DIAG_OUT," ADOL-C error in parallel sparse_hess():\n Number of nonzeros not consistent,\n new call with repeat = 0 \n");
    1524            exit(-3);
    1525         }
    1526 
    1527         if (repeat == -1)
    1528            return ret_val;
    1529 
    1530         v    = (double*) malloc(indep*sizeof(double));
    1531         w    = (double*) malloc(indep*sizeof(double));
    1532         X = myalloc2(indep,2);
    1533 
    1534         tmp = sHinfos.p;
    1535         MPI_Bcast(&tmp,1, MPI_INT,0,MPI_COMM_WORLD);
    1536 
    1537         for (i = 0; i < sHinfos.p; ++i) {
    1538             for (l = 0; l < indep; ++l)
    1539                 v[l] = sHinfos.Xppp[l][i][0];
    1540 
    1541             ret_val = fos_forward(this_tag, 1, indep, 2, basepoint, v, &y, &yt);
    1542             MINDEC(ret_val, hos_reverse(this_tag, 1, indep, 1, &lag, X));
    1543             for (l = 0; l < indep; ++l)
    1544                 sHinfos.Hcomp[l][i] = X[l][1];
    1545         }
    1546 
    1547         myfree1(v);
    1548         myfree1(w);
    1549         myfree2(X);
    1550 
    1551         if (*values != NULL && *rind != NULL && *cind != NULL) {
    1552            // everything is preallocated, we assume correctly
    1553            // call usermem versions
    1554            if (options[1] == 0)
    1555               hr->IndirectRecover_CoordinateFormat_usermem(g, sHinfos.Hcomp, sHinfos.HP, rind, cind, values);
    1556            else
    1557               hr->DirectRecover_CoordinateFormat_usermem(g, sHinfos.Hcomp, sHinfos.HP, rind, cind, values);
    1558         } else {
    1559            // at least one of rind cind values is not allocated, deallocate others
    1560            // and call unmanaged versions
    1561           if (*values != NULL)
    1562              free(*values);
    1563           if (*rind != NULL)
    1564              free(*rind);
    1565           if (*cind != NULL)
    1566              free(*cind);
    1567 
    1568           if (options[1] == 0)
    1569              hr->IndirectRecover_CoordinateFormat_unmanaged(g, sHinfos.Hcomp, sHinfos.HP, rind, cind, values);
    1570           else
    1571              hr->DirectRecover_CoordinateFormat_unmanaged(g, sHinfos.Hcomp, sHinfos.HP, rind, cind, values);
    1572         }
    1573      } // ende id == 0
    1574      else {
    1575         if (repeat <= 0) {
    1576            if (( options[0] < 0 ) || (options[0] > 1 ))
    1577               options[0] = 0; /* default */
    1578            if (( options[1] < 0 ) || (options[1] > 1 ))
    1579               options[1] = 0; /* default */
    1580 
    1581            if (repeat == 0){
    1582               /* generate sparsity pattern */
    1583               ret_val = hess_pat(id,size,tag, indep, basepoint, NULL, options[0]);
    1584               if (ret_val < 0) {
    1585                  fprintf(DIAG_OUT," ADOL-C error in parallel sparse_hess() \n");
    1586                  exit(ret_val);
    1587               }
    1588            }
    1589         }
    1590 
    1591         if (repeat == -1)
    1592            return ret_val;
    1593 
    1594         MPI_Bcast(&tmp,1, MPI_INT,0,MPI_COMM_WORLD);
    1595 
    1596         for (i = 0; i < tmp; ++i) {
    1597             ret_val = fos_forward(this_tag, 0, 0, 2, NULL, NULL, NULL, NULL);
    1598             MINDEC(ret_val, hos_reverse(this_tag, 0, 0, 1, &lag, NULL ) );
    1599         }
    1600      } // end id else
    1601      return ret_val;
    1602 #else
    1603     fprintf(DIAG_OUT, "ADOL-C error: function %s can only be used if linked with ColPack\n", __FUNCTION__);
    1604     exit(-1);
    1605 #endif
    1606 }
    1607 #endif
  • branches/MPI/ADOL-C/src/sparse/sparsedrivers.h

    r240 r252  
    1616
    1717#include <adolc/common.h>
    18 
    19 
    20 
    2118BEGIN_C_DECLS
    22 
    23 
    24 
    2519/****************************************************************************/
    2620
     
    9286
    9387/* Max. number of unsigned ints to store the seed / jacobian matrix strips.
    94    Reduce this value to x if your system happens to run out of memory. 
     88   Reduce this value to x if your system happens to run out of memory.
    9589   x < 10 makes no sense. x = 50 or 100 is better
    96    x stays for ( x * sizeof(unsigned long int) * 8 ) 
     90   x stays for ( x * sizeof(unsigned long int) * 8 )
    9791   (block) variables at once                                            */
    9892
     
    10599END_C_DECLS
    106100
    107 
    108 /*************************************************************************************************/
    109 /*****                          Now parallel ColPack-Drivers                                 *****/
    110 #if defined(__cplusplus) && defined(HAVE_MPI)
    111 int jac_pat(
    112     int id, int size, short tag, int depen, int indep, const double *basepoint, unsigned int **crs, int *options);
    113 
    114 int hess_pat
    115 ( int id, int size, short tag, int indep, const double *basepoint, unsigned int **crs, int option);
    116 
    117 int sparse_jac(
    118     int id,int size ,short tag, int depen, int indep, int repeat, const double *basepoint, int *nnz, unsigned int **rind,
    119     unsigned int **cind, double **values,int *options );
    120 
    121 int sparse_hess
    122 ( int id, int size ,short tag ,int indep,int repeat, const double *basepoint, int *nnz ,unsigned int **rind, unsigned int **cind, double **values, int *options);
    123 
    124101#endif
    125 
    126 #endif
  • branches/MPI/ADOL-C/src/uni5_for.c

    r241 r252  
    4343#endif /* ADOLC_DEBUG */
    4444
    45 #if defined(HAVE_MPI)
     45#if defined(_MPI_)
    4646#include <adolc/adolc_mpi.h>
    4747#endif
     
    5656/*--------------------------------------------------------------------------*/
    5757#if defined(_ZOS_)
     58#if defined(_MPI_)
     59#  define GENERATED_FILENAME "zos_forward_mpi"
     60#else
    5861#  define GENERATED_FILENAME "zos_forward"
    59 
     62#endif
    6063/*--------------------------------------------------------------------------*/
    6164#else
    6265#if defined(_FOS_)
     66#if defined(_MPI_)
     67#define GENERATED_FILENAME "fos_forward_mpi"
     68#else
    6369#define GENERATED_FILENAME "fos_forward"
     70#endif
    6471
    6572#define ARGUMENT(indexi,l,i) argument[indexi]
     
    6976#else
    7077#if defined(_FOV_)
     78#if defined(_MPI_)
     79#define GENERATED_FILENAME "fov_forward_mpi"
     80#else
    7181#define GENERATED_FILENAME "fov_forward"
     82#endif
    7283
    7384#define _ADOLC_VECTOR_
     
    8495#else
    8596#if defined(_HOS_)
     97#if defined(_MPI_)
     98#define GENERATED_FILENAME "hos_forward_mpi"
     99#else
    86100#define GENERATED_FILENAME "hos_forward"
     101#endif
    87102
    88103#define _HIGHER_ORDER_
     
    94109#else
    95110#if defined(_HOV_)
     111#if defined(_MPI_)
     112#define GENERATED_FILENAME "hov_forward_mpi"
     113#else
    96114#define GENERATED_FILENAME "hov_forward"
     115#endif
    97116
    98117#define _ADOLC_VECTOR_
     
    117136#if defined(_INT_FOR_)
    118137#if defined(_TIGHT_)
     138#if defined(_MPI_)
     139#define GENERATED_FILENAME "int_forward_t_mpi"
     140#else
    119141#define GENERATED_FILENAME "int_forward_t"
    120142#endif
     143#endif
     144
    121145#if defined(_NTIGHT_)
     146#if defined(_MPI_)
     147#define GENERATED_FILENAME "int_forward_s_mpi"
     148#else
    122149#define GENERATED_FILENAME "int_forward_s"
     150#endif
    123151#endif
    124152#define ARGUMENT(indexi,l,i) argument[indexi][l]
     
    131159void combine_2_index_domains(int res, int arg1, int arg2, locint **ind_dom);
    132160void merge_3_index_domains(int res, int arg1, int arg2, locint **ind_dom);
    133 #if defined(HAVE_MPI)
     161#if defined(_MPI_)
    134162void combine_index_domain_received_data(int res, int count, locint **ind_dom, locint *trade);
    135163#endif
     
    140168#if defined(_INDOPRO_)
    141169#if defined(_TIGHT_)
     170#if defined(_MPI_)
     171#define GENERATED_FILENAME "indopro_forward_t_mpi"
     172#else
    142173#define GENERATED_FILENAME "indopro_forward_t"
    143174#endif
     175#endif
     176
    144177#if defined(_NTIGHT_)
     178#if defined(_MPI_)
     179#define GENERATED_FILENAME "indopro_forward_s_mpi"
     180#else
    145181#define GENERATED_FILENAME "indopro_forward_s"
     182#endif
    146183#endif
    147184#endif
     
    160197(int arg1, int arg2, locint **ind_dom, locint **nonl_dom);
    161198
    162 #if defined(HAVE_MPI)
     199#if defined(_MPI_)
    163200void extend_nonlinearity_domain_combine_received_trade
    164201(int arg1, int counts, locint **nonl_dom, locint *trade);
     
    167204
    168205#if defined(_TIGHT_)
     206#if defined(_MPI_)
     207#define GENERATED_FILENAME "nonl_ind_forward_t_mpi"
     208#else
    169209#define GENERATED_FILENAME "nonl_ind_forward_t"
    170210#endif
     211#endif
     212
    171213#if defined(_NTIGHT_)
     214#if defined(_MPI_)
     215#define GENERATED_FILENAME "nonl_ind_forward_s_mpi"
     216#else
    172217#define GENERATED_FILENAME "nonl_ind_forward_s"
     218#endif
    173219#endif
    174220#endif
     
    463509/* Zero Order Scalar version of the forward mode.                           */
    464510/****************************************************************************/
     511#if defined(_MPI_)
     512int zos_forward_mpi(
     513    int mpi_id, int mpi_size,
     514#else
    465515#if defined(_KEEP_)
    466516int  zos_forward(
    467517#else
    468518int  zos_forward_nk(
     519#endif
    469520#endif
    470521    short  tnum,              /* tape id */
     
    482533/* First Order Scalar version of the forward mode.                          */
    483534/****************************************************************************/
     535#if defined(_MPI_)
     536int  fos_forward_mpi(
     537    int mpi_id, int mpi_size,
     538#else
    484539#if defined(_KEEP_)
    485540int  fos_forward(
    486541#else
    487542int  fos_forward_nk(
     543#endif
    488544#endif
    489545    short  tnum,        /* tape id */
     
    505561/* First Order Vector version of the forward mode for bit patterns, tight   */
    506562/****************************************************************************/
     563#if defined(_MPI_)
     564int int_forward_tight_mpi(
     565    int mpi_id, int mpi_size,
     566#else
    507567int int_forward_tight(
     568#endif
    508569    short               tnum,     /* tape id                              */
    509570    int                 depcheck, /* consistency chk on # of dependents   */
     
    534595/* First Order Vector version of the forward mode, bit pattern, safe        */
    535596/****************************************************************************/
     597#if defined(_MPI_)
     598int int_forward_safe_mpi(
     599    int mpi_id, int mpi_size,
     600#else
    536601int int_forward_safe(
     602#endif
    537603    short             tnum,     /* tape id                              */
    538604    int               depcheck, /* consistency chk on # of dependents   */
     
    561627/* First Order Vector version of the forward mode for bit patterns, tight   */
    562628/****************************************************************************/
     629#if defined(_MPI_)
     630int indopro_forward_tight_mpi(
     631    int mpi_id, int mpi_size,
     632#else
    563633int indopro_forward_tight(
     634#endif
    564635    short             tnum,        /* tape id                              */
    565636    int               depcheck,    /* consistency chk on # of dependents   */
     
    578649/* First Order Vector version of the forward mode, bit pattern, safe        */
    579650/****************************************************************************/
     651#if defined(_MPI_)
     652int indopro_forward_safe_mpi(
     653    int mpi_id, int mpi_size,
     654#else
    580655int indopro_forward_safe(
     656#endif
    581657    short             tnum,        /* tape id                              */
    582658    int               depcheck,    /* consistency chk on # of dependents   */
     
    595671/* First Order Vector version of the forward mode for bit patterns, tight   */
    596672/****************************************************************************/
     673#if defined(_MPI_)
     674int nonl_ind_forward_tight_mpi(
     675    int mpi_id, int mpi_size,
     676#else
    597677int nonl_ind_forward_tight(
     678#endif
    598679    short             tnum,        /* tape id                              */
    599680    int               depcheck,    /* consistency chk on # of dependents   */
     
    611692/* First Order Vector version of the forward mode, bit pattern, safe        */
    612693/****************************************************************************/
     694#if defined(_MPI_)
     695int nonl_ind_forward_safe_mpi(
     696    int mpi_id, int mpi_size,
     697#else
    613698int nonl_ind_forward_safe(
     699#endif
    614700    short             tnum,        /* tape id                              */
    615701    int               depcheck,    /* consistency chk on # of dependents   */
     
    644730/* First Order Vector version of the forward mode.                          */
    645731/****************************************************************************/
     732#if defined(_MPI_)
     733int  fov_forward_mpi(
     734    int mpi_id, int mpi_size,
     735#else
    646736int  fov_forward(
     737#endif
    647738    short         tnum,        /* tape id */
    648739    int           depcheck,    /* consistency chk on # of deps */
     
    661752/* Higher Order Scalar version of the forward mode.                         */
    662753/****************************************************************************/
     754#if defined(_MPI_)
     755int  hos_forward_mpi(
     756    int mpi_id, int mpi_size,
     757#else
    663758#if defined(_KEEP_)
    664759int  hos_forward(
    665760#else
    666761int  hos_forward_nk(
     762#endif
    667763#endif
    668764    short  tnum,        /* tape id */
     
    683779/* Higher Order Vector version of the forward mode.                         */
    684780/****************************************************************************/
     781#if defined(_MPI_)
     782int hov_forward_mpi(int mpi_id, int mpi_size,
     783#else
    685784#if defined(_KEEP_)
    686785int  hov_wk_forward(
    687786#else
    688787int  hov_forward(
     788#endif
    689789#endif
    690790    short  tnum,        /* tape id */
     
    724824
    725825    int indexi = 0,  indexd = 0;
     826#if defined(_MPI_)
     827    short this_tnum = mpi_size*tnum + mpi_id;
     828#endif
    726829
    727830    /* loop indices */
     
    887990    /*                                                           DEBUG MESSAGES */
    888991    fprintf(DIAG_OUT,"Call of %s(..) with tag: %d, n: %d, m %d,\n",
    889             GENERATED_FILENAME, tnum, indcheck, depcheck);
     992            GENERATED_FILENAME,
     993#if defined(_MPI_)
     994            this_tnum,
     995#else
     996            tnum,
     997#endif
     998            indcheck, depcheck);
    890999#if defined(_KEEP_)
    8911000    fprintf(DIAG_OUT,"                    keep: %d\n", keep);
     
    9071016
    9081017    /* Initialize the Forward Sweep */
    909 
     1018#if defined(_MPI_)
     1019    init_for_sweep(this_tnum);
     1020#else
    9101021    init_for_sweep(tnum);
    911 
     1022#endif
    9121023      if ( (depcheck != ADOLC_CURRENT_TAPE_INFOS.stats[NUM_DEPENDENTS]) ||
    9131024            (indcheck != ADOLC_CURRENT_TAPE_INFOS.stats[NUM_INDEPENDENTS]) ) {
     
    9151026                "Number of dependent(%u) and/or independent(%u) variables passed"
    9161027                " to forward is\ninconsistent with number "
    917                 "recorded on tape (%d, %d) \n", tnum,
     1028                "recorded on tape (%d, %d) \n",
     1029# if defined(_MPI_)
     1030this_tnum,
     1031#else
     1032tnum,
     1033#endif
    9181034                depcheck, indcheck,
    9191035                ADOLC_CURRENT_TAPE_INFOS.stats[NUM_DEPENDENTS],
     
    9211037        exit (-1);
    9221038    }
    923 #if defined(HAVE_MPI)
     1039#if defined(_MPI_)
    9241040     double *trade, *rec_buf;
    9251041     MPI_Status status_MPI;
    9261042     int mpi_i , loc_send,loc_recv;
    9271043     ADOLC_MPI_Op mpi_op;
    928      int myid,root, count, id;
    929      MPI_Comm_rank(MPI_COMM_WORLD, &id);
     1044     int myid,root, count, id=mpi_id;
    9301045#if defined(_NONLIND_)
    9311046     locint *tmp_element;
     
    9341049     int *trade_loc, *rec_buf_loc;
    9351050     int *counts, *tmp_counts;
    936      int anz, mpi_id;
     1051     int anz;
    9371052#endif
    9381053#if defined(_INT_FOR_)
     
    10071122    max_ind_dom = ADOLC_CURRENT_TAPE_INFOS.stats[NUM_MAX_LIVES];
    10081123#if defined(_NONLIND_)
    1009 #if defined(HAVE_MPI)
     1124#if defined(_MPI_)
    10101125    int s_r_indep =indcheck;
    10111126    if (mpi_initialized) {
     
    36903805#endif
    36913806                /*--------------------------------------------------------------------------*/
    3692 #if defined(HAVE_MPI)
     3807#if defined(_MPI_)
    36933808      case send_data:   // MPI-Send-Befehl
    36943809              arg = get_locint_f(); // first Buffer
     
    43344449
    43354450#if defined(_NONLIND_)
    4336 #if defined(HAVE_MPI)
     4451#if defined(_MPI_)
    43374452    if (mpi_initialized){
    43384453       indcheck = s_r_indep;
     
    44074522
    44084523
    4409 void merge_2_index_domains(int res, int arg, locint **ind_dom) 
     4524void merge_2_index_domains(int res, int arg, locint **ind_dom)
    44104525{
    44114526
     
    44284543          if (num2 < num1+num)
    44294544            num2 = num1+num;
    4430          
     4545
    44314546          temp_array = (locint *)  malloc(sizeof(locint)* (num2+2));
    44324547          temp_array[1] = num2;
     
    44544569                    {
    44554570                      temp_array[k] = arg_ind_dom[j];
    4456                       j++;k++;               
     4571                      j++;k++;
    44574572                    }
    44584573                }
     
    44914606
    44924607
    4493 #if defined(HAVE_MPI)
     4608#if defined(_MPI_)
    44944609void combine_index_domain_received_data(int res, int count, locint **ind_dom, locint *trade) {
    44954610
     
    45744689
    45754690void extend_nonlinearity_domain_binary_step
    4576 (int arg1, int arg2, locint **ind_dom, locint **nonl_dom) 
     4691(int arg1, int arg2, locint **ind_dom, locint **nonl_dom)
    45774692{
    45784693  int index,num,num1, num2, i,j,k,l,m;
     
    45814696  num = ind_dom[arg2][0];
    45824697
    4583   for(m=2;m<ind_dom[arg1][0]+2;m++) 
     4698  for(m=2;m<ind_dom[arg1][0]+2;m++)
    45844699    {
    45854700      index = ind_dom[arg1][m];
     
    45974712            index_nonl_dom[i] = ind_dom[arg2][i];
    45984713          index_nonl_dom[0] = num;
    4599         } 
    4600       else 
     4714        }
     4715      else
    46014716        { /* merge lists */
    46024717          num1 = index_nonl_dom[0];
    46034718          num2 = index_nonl_dom[1];
    4604          
     4719
    46054720          if (num1+num > num2)
    46064721            num2 = num1+num;
    4607          
     4722
    46084723          temp_nonl = (locint*) malloc(sizeof(locint)*(num2+2));
    46094724          temp_nonl[1] = num2;
    4610          
     4725
    46114726          i = 2;
    46124727          k = 2;
     
    46364751            k++;
    46374752          }
    4638           temp_nonl[0] = k-2; 
     4753          temp_nonl[0] = k-2;
    46394754          free((char*) nonl_dom[index]);
    46404755          nonl_dom[index] = temp_nonl;
     
    46554770
    46564771
    4657 #if defined(HAVE_MPI)
     4772#if defined(_MPI_)
    46584773void extend_nonlinearity_domain_combine_received_trade(int index, int counts, locint **nonl_dom, locint *trade) {
    46594774    int num, i,j,k,l,m;
  • branches/MPI/Makefile.am

    r226 r252  
    33## Revision: $Id$
    44##
    5 ## Copyright (C) Andrea Walther, Andreas Kowarz
     5## Copyright (C) Andrea Walther, Andreas Kowarz, Kshitij Kulshreshtha
    66##
    77## This file is part of ADOL-C. This software is provided as open source.
  • branches/MPI/configure.ac

    r246 r252  
    33# Revision: $Id$
    44#
    5 # Copyright (C) Andrea Walther, Andreas Kowarz
    6 #               
     5# Copyright (C) Andrea Walther, Andreas Kowarz, Kshitij Kulshreshtha
     6#
    77# contains patches from the COIN OR libtool
    88#
Note: See TracChangeset for help on using the changeset viewer.