|
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 // 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 #define MY_MAX(a,b) a > b ? a : b 00032 00033 #include "RTOp_reduct_max_value.h" 00034 00035 int RTOp_reduct_max_value( 00036 const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data 00037 , RTOp_ReductTarget in_targ_obj, RTOp_ReductTarget inout_targ_obj ) 00038 { 00039 /* inout_dot_prod += in_dot_prod */ 00040 *((RTOp_value_type*)inout_targ_obj) 00041 = MY_MAX( *((RTOp_value_type*)inout_targ_obj) 00042 ,*((RTOp_value_type*)in_targ_obj) 00043 ); 00044 return 0; 00045 } 00046 00047 static void CALL_API external_reduct_op( void* in_targ_array, void* inout_targ_array 00048 , int* len, RTOp_Datatype* datatype ) 00049 { 00050 /* inout_dot_prod += in_dot_prod */ 00051 RTOp_value_type /* index past the size members */ 00052 *in_targs = (RTOp_value_type*)in_targ_array + 3, 00053 *inout_targs = (RTOp_value_type*)inout_targ_array + 3; 00054 int i; 00055 for( i = 0; i < *len; ++i, inout_targs += 4, in_targs += 4 ) 00056 *inout_targs = MY_MAX(*inout_targs,*in_targs); 00057 } 00058 00059 int RTOp_get_reduct_max_value_op( 00060 const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data 00061 , RTOp_reduct_op_func_ptr_t* reduct_op_func_ptr ) 00062 { 00063 *reduct_op_func_ptr = external_reduct_op; 00064 return 0; 00065 }
1.7.4