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 #include <assert.h>
00042 
00043 #include "RTOp_MPI_config.h"
00044 
00045 #ifdef __cplusplus
00046 extern "C" {
00047 #endif
00048 
00049 typedef Teuchos_Index RTOp_index_type;
00050 typedef double        RTOp_value_type;
00051 typedef char          RTOp_char_type;
00052 
00163 
00170 
00172 typedef void*   RTOp_ReductTarget;     /*< The type for reduction target objects. */
00173 #define         RTOp_REDUCT_OBJ_NULL 0 /*< Value given to a a \c NULL reduction target object */
00174 #define         RTOp_NUM_DATA_TYPES 3  /*< Number of primative data types used in \c RTOp */
00175 /* */
00238 typedef void (*RTOp_reduct_op_func_ptr_t) ( void *, void *, int *, RTOp_Datatype * ); 
00241 
00242 /* */
00243 #define RTOp_ERR_INVALID_USAGE            -1
00244 /* */
00245 #define RTOp_ERR_INVALID_NUM_VECS         -2
00246 /* */
00247 #define RTOp_ERR_INVALID_NUM_TARG_VECS    -3
00248 /* */
00249 #define RTOp_ERR_INCOMPATIBLE_VECS        -5
00250 /* */
00251 #define RTOp_SERVER_INCOMPATIBLE_OPS      -6
00252 /* */
00253 #define RTOp_SERVER_OP_NAME_TOO_LONG      -7
00254 
00255 /* */
00276 struct RTOp_SubVector {
00277   /* Offset for the sub-vector into the global vector */
00278   RTOp_index_type                  global_offset;
00279   /* Dimension of the sub-vector */
00280   RTOp_index_type                  sub_dim;
00281   /* Array (size min{|<tt>value_stride*sub_nz</tt>|,1}) for the values in the vector */
00282   const RTOp_value_type            *values;
00283   /* Stride between elements in <tt>values[]</tt> */
00284   ptrdiff_t                        values_stride;
00285 };
00286 /* */
00309 struct RTOp_MutableSubVector {
00310   /* Offset for the sub-vector into the global vector */
00311   RTOp_index_type                  global_offset;
00312   /* Dimension of the sub-vector */
00313   RTOp_index_type                  sub_dim;
00314   /* Array (size min{|<tt>value_stride*sub_dim</tt>|,1}) for the values in the vector */
00315   RTOp_value_type                  *values;
00316   /* Stride between elements in <tt>values[]</tt> */
00317   ptrdiff_t                        values_stride;
00318 };
00319 /* */
00322 void RTOp_sub_vector(
00323   RTOp_index_type global_offset, RTOp_index_type sub_dim
00324   ,const RTOp_value_type values[], ptrdiff_t values_stride
00325   ,struct RTOp_SubVector *sub_vec
00326   );
00327 /* */
00330 void RTOp_sub_vector_null( struct RTOp_SubVector *sub_vec );
00331 /* */
00334 void RTOp_mutable_sub_vector(
00335   RTOp_index_type global_offset, RTOp_index_type sub_dim
00336   ,RTOp_value_type values[], ptrdiff_t values_stride
00337   ,struct RTOp_MutableSubVector *sub_vec
00338   );
00339 /* */
00342 void RTOp_mutable_sub_vector_null( struct RTOp_MutableSubVector *sub_vec );
00343 
00386 
00388 struct RTOp_RTOp;
00389 
00390 /* */
00403 int RTOp_get_op_name(
00404   const struct RTOp_RTOp* op
00405   ,const char** op_name
00406   );
00407 
00408 /* */
00420 int RTOp_get_op_type_num_entries(
00421   const struct RTOp_RTOp* op
00422   ,int* num_values
00423   ,int* num_indexes
00424   ,int* num_chars
00425   );
00426 
00427 /* */
00438 int RTOp_extract_op_state(
00439   const struct RTOp_RTOp    *op
00440   ,int                      num_values
00441   ,RTOp_value_type          value_data[]
00442   ,int                      num_indexes
00443   ,RTOp_index_type          index_data[]
00444   ,int                      num_chars
00445   ,RTOp_char_type           char_data[]
00446   );
00447 /* */
00461 int RTOp_load_op_state(
00462   int                       num_values
00463   ,const RTOp_value_type    value_data[]
00464   ,int                      num_indexes
00465   ,const RTOp_index_type    index_data[]
00466   ,int                      num_chars
00467   ,const RTOp_char_type     char_data[]
00468   ,struct RTOp_RTOp*        op
00469   );
00470 /* */
00481 int RTOp_free_op( struct RTOp_RTOp* op );
00482 /* */
00494 int RTOp_get_reduct_type_num_entries(
00495   const struct RTOp_RTOp     *op
00496   ,int                       *num_values
00497   ,int                       *num_indexes
00498   ,int                       *num_chars
00499   );
00500 /* */
00520 int RTOp_reduct_obj_create(
00521   const struct RTOp_RTOp   *op
00522   ,RTOp_ReductTarget       *reduct_obj
00523   );
00524 /* */
00543 int RTOp_reduct_obj_reinit(
00544   const struct RTOp_RTOp    *op
00545   ,RTOp_ReductTarget        reduct_obj
00546   );
00547 /* */
00567 int RTOp_reduct_obj_free( const struct RTOp_RTOp* op
00568   , RTOp_ReductTarget* reduct_obj );
00569 /* */
00580 int RTOp_extract_reduct_obj_state(
00581   const struct RTOp_RTOp    *op
00582   ,const RTOp_ReductTarget  reduct_obj
00583   ,int                      num_values
00584   ,RTOp_value_type          value_data[]
00585   ,int                      num_indexes
00586   ,RTOp_index_type          index_data[]
00587   ,int                      num_chars
00588   ,RTOp_char_type           char_data[]
00589   );
00590 /* */
00600 int RTOp_load_reduct_obj_state(
00601   const struct RTOp_RTOp   *op
00602   ,int                     num_values
00603   ,const RTOp_value_type   value_data[]
00604   ,int                     num_indexes
00605   ,const RTOp_index_type   index_data[]
00606   ,int                     num_chars
00607   ,const RTOp_char_type    char_data[]
00608   ,RTOp_ReductTarget       reduct_obj
00609   );
00610 /* */
00618 int RTOp_coord_invariant(
00619   const struct RTOp_RTOp   *op
00620   ,int                     *coord_invariant
00621   );
00622 /* */
00686 int RTOp_apply_op(
00687   const struct RTOp_RTOp                  *op
00688   ,const int                              num_vecs
00689   ,const struct RTOp_SubVector            sub_vecs[]
00690   ,const int                              num_targ_vecs
00691   ,const struct RTOp_MutableSubVector     targ_sub_vecs[]
00692   ,RTOp_ReductTarget                      reduct_obj
00693   );
00694 /* */
00719 int RTOp_reduce_reduct_objs(
00720   const struct RTOp_RTOp     *op
00721   ,RTOp_ReductTarget         in_reduct_obj
00722   ,RTOp_ReductTarget         inout_reduct_obj
00723   );
00724 /* */
00747 int RTOp_get_reduct_op(
00748   const struct RTOp_RTOp       *op
00749   ,RTOp_reduct_op_func_ptr_t   *reduct_op_func_ptr
00750   );
00751 
00759 
00761 struct RTOp_RTOp_vtbl_t;
00762 
00763 /* */
00777 struct RTOp_RTOp {
00778   /* Pointer to the object data for an instantiation */
00779   void                           *obj_data;
00780   /* Pointer to the virtual function table */
00781   const struct RTOp_RTOp_vtbl_t  *vtbl;
00782 };
00783 
00784 /* */
00796 struct RTOp_RTOp_vtbl_t {
00797   /* Pointer to the virtual function table for the operator object instance data. */
00798   const struct RTOp_obj_type_vtbl_t  *obj_data_vtbl;
00799   /* Pointer to the virtual function table for the manipulation of the reduction object. */
00800   const struct RTOp_obj_type_vtbl_t  *reduct_vtbl;
00801   /* */
00804   const char* op_name;
00805   /* */
00813   int (*reduct_obj_reinit)(
00814     const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data
00815     ,RTOp_ReductTarget reduct_obj );
00816 /*  /// Called by <tt>RTOp_coord_invariant()</tt> */
00817 /*  int (*coord_invariant) ( */
00818 /*    const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data */
00819 /*    ,int *coord_invariant ); */
00820   /* Called by <tt>RTOp_apply_op()</tt> */
00821   int (*apply_op)(
00822     const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data
00823     ,const int num_vecs, const struct RTOp_SubVector sub_vecs[]
00824     ,const int num_targ_vecs, const struct RTOp_MutableSubVector targ_sub_vecs[]
00825     ,RTOp_ReductTarget reduct_obj );
00826   /* Called by <tt>RTOp_reduce_reduct_objs()</tt> */
00827   int (*reduce_reduct_objs)(
00828     const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data
00829     ,RTOp_ReductTarget in_reduct_obj, RTOp_ReductTarget inout_reduct_obj );
00830   /* Called by <tt>RTOp_get_reduct_op()</tt> */
00831   int (*get_reduct_op)(
00832     const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data
00833     ,RTOp_reduct_op_func_ptr_t* reduct_op_func_ptr );
00834 };
00835 
00836 /* */
00851 struct RTOp_obj_type_vtbl_t {
00852   /* */
00886   int (*get_obj_type_num_entries)(
00887     const struct RTOp_obj_type_vtbl_t    *vtbl
00888     ,const void*                         instance_data
00889     ,int*                                num_values
00890     ,int*                                num_indexes
00891     ,int*                                num_chars
00892     );
00893   /* */
00920   int (*obj_create)(
00921     const struct RTOp_obj_type_vtbl_t   *vtbl
00922     ,const void                         *instance_data
00923     ,void                               ** obj
00924     );
00925   /* */
00958   int (*obj_reinit)(
00959     const struct RTOp_obj_type_vtbl_t    *vtbl
00960     ,const void                          *instance_data
00961     ,void                                *obj
00962     );
00963   /* */
00998   int (*obj_free)(
00999     const struct RTOp_obj_type_vtbl_t   *vtbl
01000     ,const void                         *instance_data
01001     ,void                               **obj
01002     );
01003   /* */
01031   int (*extract_state)(
01032     const struct RTOp_obj_type_vtbl_t    *vtbl
01033     ,const void                          *instance_data
01034     ,void                                *obj
01035     ,int                                 num_values
01036     ,RTOp_value_type                     value_data[]
01037     ,int                                 num_indexes
01038     ,RTOp_index_type                     index_data[]
01039     ,int                                 num_chars
01040     ,RTOp_char_type                      char_data[]
01041     );
01042   /* */
01076   int (*load_state)(
01077     const struct RTOp_obj_type_vtbl_t    *vtbl
01078     ,const void                          *instance_data
01079     ,int                                 num_values
01080     ,const RTOp_value_type               value_data[]
01081     ,int                                 num_indexes
01082     ,const RTOp_index_type               index_data[]
01083     ,int                                 num_chars
01084     ,const RTOp_char_type                char_data[]
01085     ,void                                **obj
01086     );
01087 };
01088 
01113 
01115 /* */
01159 int RTOp_Server_add_op_name_vtbl(
01160   const char                       op_class_name[]
01161   ,const struct RTOp_RTOp_vtbl_t   *op_class_vtbl
01162   );
01163 
01164 /* */
01187 int RTOp_Server_lookup_op_name(
01188   const struct RTOp_RTOp_vtbl_t   *op_class_vtbl
01189   ,char                           op_class_name[]
01190   );
01191 
01192 /* */
01217 int RTOp_Server_construct_op(
01218   const char               op_class_name[]
01219   ,int                     num_values
01220   ,const RTOp_value_type   value_data[]
01221   ,int                     num_indexes
01222   ,const RTOp_index_type   index_data[]
01223   ,int                     num_chars
01224   ,const RTOp_char_type    char_data[]
01225   ,struct RTOp_RTOp        *op
01226   );
01227 
01228 /* */
01232 void RTOp_Server_dump( FILE* file );
01233 
01236 
01238 #ifdef __cplusplus
01239 }
01240 #endif
01241 
01242 #endif /* REDUCT_TRANS_VECTOR_OPERATORS_H */

Generated on Tue Oct 20 12:51:49 2009 for MOOCHO (Single Doxygen Collection) by doxygen 1.4.7