|
RTOpPack: Extra C/C++ Code for Vector Reduction/Transformation Operators
Version of the Day
|
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 // Redistribution and use in source and binary forms, with or without 00012 // modification, are permitted provided that the following conditions are 00013 // met: 00014 // 00015 // 1. Redistributions of source code must retain the above copyright 00016 // notice, this list of conditions and the following disclaimer. 00017 // 00018 // 2. Redistributions in binary form must reproduce the above copyright 00019 // notice, this list of conditions and the following disclaimer in the 00020 // documentation and/or other materials provided with the distribution. 00021 // 00022 // 3. Neither the name of the Corporation nor the names of the 00023 // contributors may be used to endorse or promote products derived from 00024 // this software without specific prior written permission. 00025 // 00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00037 // 00038 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00039 // 00040 // *********************************************************************** 00041 // @HEADER 00042 */ 00043 00044 #ifndef RTOP_GET_REDUCT_OP_H 00045 #define RTOP_GET_REDUCT_OP_H 00046 00047 #define INSERT_GET_REDUCT_OP_FUNCS( \ 00048 num_values,num_indexes,num_chars,reduct_obj_t,reduce_reduct_obj,targ_load_state,targ_extract_state \ 00049 ,external_reduct_op,get_reduct_op \ 00050 ) \ 00051 static void CALL_API external_reduct_op( void* in_targ_array, void* inout_targ_array \ 00052 , int* len, RTOp_Datatype* datatype ) \ 00053 { \ 00054 struct reduct_obj_t \ 00055 in_obj, *in_obj_p = &in_obj, inout_obj, *inout_obj_p = &inout_obj; \ 00056 const int \ 00057 values_off = 3*sizeof(RTOp_value_type), \ 00058 indexes_off = values_off + num_values*sizeof(RTOp_value_type), \ 00059 chars_off = indexes_off + num_indexes*sizeof(RTOp_index_type); \ 00060 const int size_obj = chars_off + (num_chars)*sizeof(RTOp_index_type); \ 00061 char \ 00062 *in_array = in_targ_array, \ 00063 *inout_array = inout_targ_array; \ 00064 int i; \ 00065 for( i = 0; i < *len; ++i, in_array += size_obj, inout_array += size_obj ) { \ 00066 targ_load_state( \ 00067 NULL, NULL \ 00068 ,num_values, num_values ? (RTOp_value_type*)(in_array + values_off) : NULL \ 00069 ,num_indexes, num_indexes ? (RTOp_index_type*)(in_array + values_off) : NULL \ 00070 ,num_chars, num_chars ? (RTOp_char_type*) (in_array + values_off) : NULL \ 00071 ,(void**)&in_obj_p ); \ 00072 targ_load_state( \ 00073 NULL, NULL \ 00074 ,num_values, num_values ? (RTOp_value_type*)(inout_array + values_off) : NULL \ 00075 ,num_indexes, num_indexes ? (RTOp_index_type*)(inout_array + values_off) : NULL \ 00076 ,num_chars, num_chars ? (RTOp_char_type*) (inout_array + values_off) : NULL \ 00077 ,(void**)&inout_obj_p ); \ 00078 reduce_reduct_objs( NULL, NULL, &in_obj, &inout_obj ); \ 00079 targ_extract_state( \ 00080 NULL, NULL, &inout_obj \ 00081 ,num_values, num_values ? (RTOp_value_type*)(inout_array + values_off) : NULL \ 00082 ,num_indexes, num_indexes ? (RTOp_index_type*)(inout_array + values_off) : NULL \ 00083 ,num_chars, num_chars ? (RTOp_char_type*) (inout_array + values_off) : NULL \ 00084 ); \ 00085 } \ 00086 } \ 00087 static int get_reduct_op( \ 00088 const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data \ 00089 , RTOp_reduct_op_func_ptr_t* reduct_op_func_ptr ) \ 00090 { \ 00091 *reduct_op_func_ptr = external_reduct_op; \ 00092 return 0; \ 00093 } 00094 00095 #endif
1.7.6.1