RTOp.h

Go to the documentation of this file.
00001 /*
00002 // @HEADER
00003 // ***********************************************************************
00004 // 
00005 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00006 //                  Copyright (2003) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00026 // 
00027 // ***********************************************************************
00028 // @HEADER
00029 */
00030 
00031 /* If the macro RTOp_USE_MPI is defined, then these */
00032 /* declarations will be MPI compatible.  If not then */
00033 /* dummy MPI declarations will be used. */
00034 /* */
00035 
00036 #ifndef REDUCT_TRANS_VECTOR_OPERATORS_H
00037 #define REDUCT_TRANS_VECTOR_OPERATORS_H
00038 
00039 #include <stddef.h>
00040 #include <stdio.h>
00041 
00042 #include "RTOp_MPI_config.h"
00043 
00044 #ifdef __cplusplus
00045 extern "C" {
00046 #endif
00047 
00048 typedef Teuchos_Index RTOp_index_type;
00049 typedef double        RTOp_value_type;
00050 typedef char          RTOp_char_type;
00051 
00162 
00169 
00171 typedef void*   RTOp_ReductTarget;     /*< The type for reduction target objects. */
00172 #define         RTOp_REDUCT_OBJ_NULL 0 /*< Value given to a a \c NULL reduction target object */
00173 #define         RTOp_NUM_DATA_TYPES 3  /*< Number of primative data types used in \c RTOp */
00174 /* */
00237 typedef void (*RTOp_reduct_op_func_ptr_t) ( void *, void *, int *, RTOp_Datatype * ); 
00240 
00241 /* */
00242 #define RTOp_ERR_INVALID_USAGE            -1
00243 /* */
00244 #define RTOp_ERR_INVALID_NUM_VECS         -2
00245 /* */
00246 #define RTOp_ERR_INVALID_NUM_TARG_VECS    -3
00247 /* */
00248 #define RTOp_ERR_INCOMPATIBLE_VECS        -5
00249 /* */
00250 #define RTOp_SERVER_INCOMPATIBLE_OPS      -6
00251 /* */
00252 #define RTOp_SERVER_OP_NAME_TOO_LONG      -7
00253 
00254 /* */
00275 struct RTOp_SubVector {
00276   /* Offset for the sub-vector into the global vector */
00277   RTOp_index_type                  global_offset;
00278   /* Dimension of the sub-vector */
00279   RTOp_index_type                  sub_dim;
00280   /* Array (size min{|<tt>value_stride*sub_nz</tt>|,1}) for the values in the vector */
00281   const RTOp_value_type            *values;
00282   /* Stride between elements in <tt>values[]</tt> */
00283   ptrdiff_t                        values_stride;
00284 };
00285 /* */
00308 struct RTOp_MutableSubVector {
00309   /* Offset for the sub-vector into the global vector */
00310   RTOp_index_type                  global_offset;
00311   /* Dimension of the sub-vector */
00312   RTOp_index_type                  sub_dim;
00313   /* Array (size min{|<tt>value_stride*sub_dim</tt>|,1}) for the values in the vector */
00314   RTOp_value_type                  *values;
00315   /* Stride between elements in <tt>values[]</tt> */
00316   ptrdiff_t                        values_stride;
00317 };
00318 /* */
00321 void RTOp_sub_vector(
00322   RTOp_index_type global_offset, RTOp_index_type sub_dim
00323   ,const RTOp_value_type values[], ptrdiff_t values_stride
00324   ,struct RTOp_SubVector *sub_vec
00325   );
00326 /* */
00329 void RTOp_sub_vector_null( struct RTOp_SubVector *sub_vec );
00330 /* */
00333 void RTOp_mutable_sub_vector(
00334   RTOp_index_type global_offset, RTOp_index_type sub_dim
00335   ,RTOp_value_type values[], ptrdiff_t values_stride
00336   ,struct RTOp_MutableSubVector *sub_vec
00337   );
00338 /* */
00341 void RTOp_mutable_sub_vector_null( struct RTOp_MutableSubVector *sub_vec );
00342 
00385 
00387 struct RTOp_RTOp;
00388 
00389 /* */
00402 int RTOp_get_op_name(
00403   const struct RTOp_RTOp* op
00404   ,const char** op_name
00405   );
00406 
00407 /* */
00419 int RTOp_get_op_type_num_entries(
00420   const struct RTOp_RTOp* op
00421   ,int* num_values
00422   ,int* num_indexes
00423   ,int* num_chars
00424   );
00425 
00426 /* */
00437 int RTOp_extract_op_state(
00438   const struct RTOp_RTOp    *op
00439   ,int                      num_values
00440   ,RTOp_value_type          value_data[]
00441   ,int                      num_indexes
00442   ,RTOp_index_type          index_data[]
00443   ,int                      num_chars
00444   ,RTOp_char_type           char_data[]
00445   );
00446 /* */
00460 int RTOp_load_op_state(
00461   int                       num_values
00462   ,const RTOp_value_type    value_data[]
00463   ,int                      num_indexes
00464   ,const RTOp_index_type    index_data[]
00465   ,int                      num_chars
00466   ,const RTOp_char_type     char_data[]
00467   ,struct RTOp_RTOp*        op
00468   );
00469 /* */
00480 int RTOp_free_op( struct RTOp_RTOp* op );
00481 /* */
00493 int RTOp_get_reduct_type_num_entries(
00494   const struct RTOp_RTOp     *op
00495   ,int                       *num_values
00496   ,int                       *num_indexes
00497   ,int                       *num_chars
00498   );
00499 /* */
00519 int RTOp_reduct_obj_create(
00520   const struct RTOp_RTOp   *op
00521   ,RTOp_ReductTarget       *reduct_obj
00522   );
00523 /* */
00542 int RTOp_reduct_obj_reinit(
00543   const struct RTOp_RTOp    *op
00544   ,RTOp_ReductTarget        reduct_obj
00545   );
00546 /* */
00566 int RTOp_reduct_obj_free( const struct RTOp_RTOp* op
00567   , RTOp_ReductTarget* reduct_obj );
00568 /* */
00579 int RTOp_extract_reduct_obj_state(
00580   const struct RTOp_RTOp    *op
00581   ,const RTOp_ReductTarget  reduct_obj
00582   ,int                      num_values
00583   ,RTOp_value_type          value_data[]
00584   ,int                      num_indexes
00585   ,RTOp_index_type          index_data[]
00586   ,int                      num_chars
00587   ,RTOp_char_type           char_data[]
00588   );
00589 /* */
00599 int RTOp_load_reduct_obj_state(
00600   const struct RTOp_RTOp   *op
00601   ,int                     num_values
00602   ,const RTOp_value_type   value_data[]
00603   ,int                     num_indexes
00604   ,const RTOp_index_type   index_data[]
00605   ,int                     num_chars
00606   ,const RTOp_char_type    char_data[]
00607   ,RTOp_ReductTarget       reduct_obj
00608   );
00609 /* */
00617 int RTOp_coord_invariant(
00618   const struct RTOp_RTOp   *op
00619   ,int                     *coord_invariant
00620   );
00621 /* */
00685 int RTOp_apply_op(
00686   const struct RTOp_RTOp                  *op
00687   ,const int                              num_vecs
00688   ,const struct RTOp_SubVector            sub_vecs[]
00689   ,const int                              num_targ_vecs
00690   ,const struct RTOp_MutableSubVector     targ_sub_vecs[]
00691   ,RTOp_ReductTarget                      reduct_obj
00692   );
00693 /* */
00718 int RTOp_reduce_reduct_objs(
00719   const struct RTOp_RTOp     *op
00720   ,RTOp_ReductTarget         in_reduct_obj
00721   ,RTOp_ReductTarget         inout_reduct_obj
00722   );
00723 /* */
00746 int RTOp_get_reduct_op(
00747   const struct RTOp_RTOp       *op
00748   ,RTOp_reduct_op_func_ptr_t   *reduct_op_func_ptr
00749   );
00750 
00758 
00760 struct RTOp_RTOp_vtbl_t;
00761 
00762 /* */
00776 struct RTOp_RTOp {
00777   /* Pointer to the object data for an instantiation */
00778   void                           *obj_data;
00779   /* Pointer to the virtual function table */
00780   const struct RTOp_RTOp_vtbl_t  *vtbl;
00781 };
00782 
00783 /* */
00795 struct RTOp_RTOp_vtbl_t {
00796   /* Pointer to the virtual function table for the operator object instance data. */
00797   const struct RTOp_obj_type_vtbl_t  *obj_data_vtbl;
00798   /* Pointer to the virtual function table for the manipulation of the reduction object. */
00799   const struct RTOp_obj_type_vtbl_t  *reduct_vtbl;
00800   /* */
00803   const char* op_name;
00804   /* */
00812   int (*reduct_obj_reinit)(
00813     const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data
00814     ,RTOp_ReductTarget reduct_obj );
00815 /*  /// Called by <tt>RTOp_coord_invariant()</tt> */
00816 /*  int (*coord_invariant) ( */
00817 /*    const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data */
00818 /*    ,int *coord_invariant ); */
00819   /* Called by <tt>RTOp_apply_op()</tt> */
00820   int (*apply_op)(
00821     const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data
00822     ,const int num_vecs, const struct RTOp_SubVector sub_vecs[]
00823     ,const int num_targ_vecs, const struct RTOp_MutableSubVector targ_sub_vecs[]
00824     ,RTOp_ReductTarget reduct_obj );
00825   /* Called by <tt>RTOp_reduce_reduct_objs()</tt> */
00826   int (*reduce_reduct_objs)(
00827     const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data
00828     ,RTOp_ReductTarget in_reduct_obj, RTOp_ReductTarget inout_reduct_obj );
00829   /* Called by <tt>RTOp_get_reduct_op()</tt> */
00830   int (*get_reduct_op)(
00831     const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data
00832     ,RTOp_reduct_op_func_ptr_t* reduct_op_func_ptr );
00833 };
00834 
00835 /* */
00850 struct RTOp_obj_type_vtbl_t {
00851   /* */
00885   int (*get_obj_type_num_entries)(
00886     const struct RTOp_obj_type_vtbl_t    *vtbl
00887     ,const void*                         instance_data
00888     ,int*                                num_values
00889     ,int*                                num_indexes
00890     ,int*                                num_chars
00891     );
00892   /* */
00919   int (*obj_create)(
00920     const struct RTOp_obj_type_vtbl_t   *vtbl
00921     ,const void                         *instance_data
00922     ,void                               ** obj
00923     );
00924   /* */
00957   int (*obj_reinit)(
00958     const struct RTOp_obj_type_vtbl_t    *vtbl
00959     ,const void                          *instance_data
00960     ,void                                *obj
00961     );
00962   /* */
00997   int (*obj_free)(
00998     const struct RTOp_obj_type_vtbl_t   *vtbl
00999     ,const void                         *instance_data
01000     ,void                               **obj
01001     );
01002   /* */
01030   int (*extract_state)(
01031     const struct RTOp_obj_type_vtbl_t    *vtbl
01032     ,const void                          *instance_data
01033     ,void                                *obj
01034     ,int                                 num_values
01035     ,RTOp_value_type                     value_data[]
01036     ,int                                 num_indexes
01037     ,RTOp_index_type                     index_data[]
01038     ,int                                 num_chars
01039     ,RTOp_char_type                      char_data[]
01040     );
01041   /* */
01075   int (*load_state)(
01076     const struct RTOp_obj_type_vtbl_t    *vtbl
01077     ,const void                          *instance_data
01078     ,int                                 num_values
01079     ,const RTOp_value_type               value_data[]
01080     ,int                                 num_indexes
01081     ,const RTOp_index_type               index_data[]
01082     ,int                                 num_chars
01083     ,const RTOp_char_type                char_data[]
01084     ,void                                **obj
01085     );
01086 };
01087 
01112 
01114 /* */
01158 int RTOp_Server_add_op_name_vtbl(
01159   const char                       op_class_name[]
01160   ,const struct RTOp_RTOp_vtbl_t   *op_class_vtbl
01161   );
01162 
01163 /* */
01186 int RTOp_Server_lookup_op_name(
01187   const struct RTOp_RTOp_vtbl_t   *op_class_vtbl
01188   ,char                           op_class_name[]
01189   );
01190 
01191 /* */
01216 int RTOp_Server_construct_op(
01217   const char               op_class_name[]
01218   ,int                     num_values
01219   ,const RTOp_value_type   value_data[]
01220   ,int                     num_indexes
01221   ,const RTOp_index_type   index_data[]
01222   ,int                     num_chars
01223   ,const RTOp_char_type    char_data[]
01224   ,struct RTOp_RTOp        *op
01225   );
01226 
01227 /* */
01231 void RTOp_Server_dump( FILE* file );
01232 
01235 
01237 #ifdef __cplusplus
01238 }
01239 #endif
01240 
01241 #endif /* REDUCT_TRANS_VECTOR_OPERATORS_H */

Generated on Thu Sep 18 12:35:19 2008 for MOOCHO (Single Doxygen Collection) by doxygen 1.3.9.1