53 RTOp_index_type global_offset, RTOp_index_type sub_dim
54 ,
const RTOp_value_type values[], ptrdiff_t values_stride
60 assert( values != NULL );
63 sub_vec->global_offset = global_offset;
64 sub_vec->sub_dim = sub_dim;
65 sub_vec->values = values;
66 sub_vec->values_stride = values_stride;
71 sub_vec->global_offset = 0;
73 sub_vec->values = NULL;
74 sub_vec->values_stride = 0;
78 RTOp_index_type global_offset, RTOp_index_type sub_dim
79 ,RTOp_value_type values[], ptrdiff_t values_stride
86 assert( values != NULL );
89 sub_vec->global_offset = global_offset;
90 sub_vec->sub_dim = sub_dim;
91 sub_vec->values = values;
92 sub_vec->values_stride = values_stride;
100 sub_vec->global_offset = 0;
101 sub_vec->sub_dim = 0;
102 sub_vec->values = NULL;
103 sub_vec->values_stride = 0;
110 ,
const char** op_name
133 assert( op->vtbl->obj_data_vtbl );
135 assert( num_values );
136 assert( num_indexes );
140 op->vtbl->obj_data_vtbl,op->obj_data
141 , num_values, num_indexes, num_chars );
147 ,RTOp_value_type value_data[]
149 ,RTOp_index_type index_data[]
151 ,RTOp_char_type char_data[]
157 assert( op->vtbl->obj_data_vtbl );
159 if(num_values) assert( value_data );
160 if(num_indexes) assert( index_data );
161 if(num_chars) assert( char_data );
164 op->vtbl->obj_data_vtbl, NULL, op->obj_data
165 , num_values, value_data
166 , num_indexes, index_data
167 , num_chars, char_data );
172 ,
const RTOp_value_type value_data[]
174 ,
const RTOp_index_type index_data[]
176 ,
const RTOp_char_type char_data[]
183 assert( op->vtbl->obj_data_vtbl );
184 assert( op->vtbl->obj_data_vtbl->
load_state );
185 if(num_values) assert( value_data );
186 if(num_indexes) assert( index_data );
187 if(num_chars) assert( char_data );
190 op->vtbl->obj_data_vtbl, NULL
191 ,num_values, value_data
192 ,num_indexes, index_data
193 ,num_chars, char_data
202 assert( op->vtbl->obj_data_vtbl );
203 assert( op->vtbl->obj_data_vtbl->
obj_free );
205 return op->vtbl->obj_data_vtbl->
obj_free(
206 op->vtbl->obj_data_vtbl,NULL,&op->obj_data );
219 assert( op->vtbl->reduct_vtbl );
221 assert( num_values );
222 assert( num_indexes );
226 op->vtbl->reduct_vtbl, op->obj_data
227 , num_values, num_indexes, num_chars );
231 , RTOp_ReductTarget* reduct_obj )
237 assert( op->vtbl->reduct_vtbl );
241 op->vtbl->reduct_vtbl,op->obj_data,reduct_obj );
245 op->vtbl,op->obj_data,*reduct_obj );
250 , RTOp_ReductTarget reduct_obj )
255 assert( op->vtbl->reduct_vtbl );
257 assert( reduct_obj != RTOp_REDUCT_OBJ_NULL );
261 op->vtbl,op->obj_data,reduct_obj );
264 op->vtbl->reduct_vtbl,op->obj_data,reduct_obj );
268 , RTOp_ReductTarget* reduct_obj )
273 assert( op->vtbl->reduct_vtbl );
274 assert( op->vtbl->reduct_vtbl->
obj_free );
276 return op->vtbl->reduct_vtbl->
obj_free(
277 op->vtbl->reduct_vtbl,op->obj_data,reduct_obj);
282 ,
const RTOp_ReductTarget reduct_obj
284 ,RTOp_value_type value_data[]
286 ,RTOp_index_type index_data[]
288 ,RTOp_char_type char_data[]
294 assert( op->vtbl->reduct_vtbl );
296 if(num_values) assert( value_data );
297 if(num_indexes) assert( index_data );
298 if(num_chars) assert( char_data );
301 op->vtbl->reduct_vtbl, op->obj_data, reduct_obj
302 ,num_values, value_data
303 ,num_indexes, index_data
304 ,num_chars, char_data );
310 ,
const RTOp_value_type value_data[]
312 ,
const RTOp_index_type index_data[]
314 ,
const RTOp_char_type char_data[]
315 ,RTOp_ReductTarget reduct_obj
318 RTOp_ReductTarget reduct_obj_in = reduct_obj;
323 assert( op->vtbl->reduct_vtbl );
325 if(num_values) assert( value_data );
326 if(num_indexes) assert( index_data );
327 if(num_chars) assert( char_data );
330 op->vtbl->reduct_vtbl, op->obj_data
331 ,num_values, value_data
332 ,num_indexes, index_data
333 ,num_chars, char_data
335 if(err != 0)
return err;
336 if( reduct_obj != reduct_obj_in )
337 return RTOp_ERR_INVALID_USAGE;
343 ,
int *coord_invariant
350 assert( coord_invariant );
353 *coord_invariant = 1;
360 , RTOp_ReductTarget reduct_obj )
365 assert( op->vtbl->apply_op );
366 if(num_vecs) assert(sub_vecs);
367 if(num_targ_vecs) assert(targ_sub_vecs);
369 return op->vtbl->apply_op(
370 op->vtbl,op->obj_data,num_vecs,sub_vecs,num_targ_vecs,targ_sub_vecs
375 , RTOp_ReductTarget in_reduct_obj, RTOp_ReductTarget inout_reduct_obj )
380 assert( op->vtbl->reduce_reduct_objs );
382 return op->vtbl->reduce_reduct_objs(op->vtbl,op->obj_data,in_reduct_obj,inout_reduct_obj);
386 , RTOp_reduct_op_func_ptr_t* reduct_op_func_ptr )
391 assert( op->vtbl->get_reduct_op );
393 return op->vtbl->get_reduct_op(op->vtbl,op->obj_data,reduct_op_func_ptr);
402 static int RTOp_Server_num_ops = 0;
404 #define RTOp_SERVER_MAX_NUM_ENTRIES 50
405 struct RTOp_Server_op_class_name {
406 char name[RTOp_SERVER_MAX_NUM_ENTRIES+1];
408 static struct RTOp_Server_op_class_name
409 RTOp_Server_op_names[RTOp_SERVER_MAX_NUM_ENTRIES];
411 static RTOp_RTOp_vtbl_t_ptr
412 RTOp_Server_op_vtbl[RTOp_SERVER_MAX_NUM_ENTRIES];
423 static int find_op_name(
const struct RTOp_Server_op_class_name op_name_tbl[]
424 ,
int num_entries,
const char op_name[] )
427 for( k = 0; k < num_entries; ++k )
429 if( strcmp( op_name_tbl[k].name, op_name ) == 0 )
437 static int find_op_vtbl(
const RTOp_RTOp_vtbl_t_ptr op_vtbl_tbl[]
438 ,
int num_entries, RTOp_RTOp_vtbl_t_ptr op_vtbl )
441 for( k = 0; k < num_entries; ++k )
443 if( op_vtbl_tbl[k] == op_vtbl )
457 if( strlen( op_class_name ) > RTOp_MAX_REDUCT_TRANS_OP_CLASS_NAME )
458 return RTOp_SERVER_OP_NAME_TOO_LONG;
459 if( (k = find_op_name( RTOp_Server_op_names
460 , RTOp_Server_num_ops, op_class_name ) ) >= 0 )
462 if( RTOp_Server_op_vtbl[k] != op_class_vtbl )
463 return RTOp_SERVER_INCOMPATIBLE_OPS;
466 strcpy( RTOp_Server_op_names[RTOp_Server_num_ops].name, op_class_name );
467 RTOp_Server_op_vtbl[RTOp_Server_num_ops] = op_class_vtbl;
468 ++RTOp_Server_num_ops;
473 ,
char op_class_name[] )
476 if( ( k = find_op_vtbl(RTOp_Server_op_vtbl,RTOp_Server_num_ops,op_class_vtbl) ) >= 0 )
478 strcpy( op_class_name, RTOp_Server_op_names[k].name );
485 const char op_class_name[]
487 ,
const RTOp_value_type value_data[]
489 ,
const RTOp_index_type index_data[]
491 ,
const RTOp_char_type char_data[]
497 if( strlen( op_class_name ) > RTOp_MAX_REDUCT_TRANS_OP_CLASS_NAME )
498 return RTOp_SERVER_OP_NAME_TOO_LONG;
499 if( ( k = find_op_name(RTOp_Server_op_names,RTOp_Server_num_ops, op_class_name) ) >= 0 )
502 op->vtbl = RTOp_Server_op_vtbl[k];
504 num_values,value_data,num_indexes,index_data,num_chars,char_data
515 fprintf( file,
"Class names and vtbl pointers for RTOp_RTOp subcasses\n" );
516 for( k = 0; k < RTOp_Server_num_ops; ++k ) {
517 jn = find_op_name( RTOp_Server_op_names
518 , RTOp_Server_num_ops, RTOp_Server_op_names[k].name );
519 jv = find_op_vtbl( RTOp_Server_op_vtbl, RTOp_Server_num_ops
520 , RTOp_Server_op_vtbl[k] );
522 ,
" class name = \"%s\"\n"
523 " looked up class name = \"%s\"\n"
525 " looked up vtbl = %p\n"
526 , RTOp_Server_op_names[k].name
527 , RTOp_Server_op_names[jn].name
528 , RTOp_Server_op_vtbl[k]
529 , RTOp_Server_op_vtbl[jv]
int RTOp_get_reduct_type_num_entries(const struct RTOp_RTOp *op, int *num_values, int *num_indexes, int *num_chars)
int RTOp_load_op_state(int num_values, const RTOp_value_type value_data[], int num_indexes, const RTOp_index_type index_data[], int num_chars, const RTOp_char_type char_data[], struct RTOp_RTOp *op)
int(* get_obj_type_num_entries)(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, int *num_values, int *num_indexes, int *num_chars)
int RTOp_load_reduct_obj_state(const struct RTOp_RTOp *op, int num_values, const RTOp_value_type value_data[], int num_indexes, const RTOp_index_type index_data[], int num_chars, const RTOp_char_type char_data[], RTOp_ReductTarget reduct_obj)
int RTOp_reduct_obj_create(const struct RTOp_RTOp *op, RTOp_ReductTarget *reduct_obj)
void RTOp_mutable_sub_vector(RTOp_index_type global_offset, RTOp_index_type sub_dim, RTOp_value_type values[], ptrdiff_t values_stride, struct RTOp_MutableSubVector *sub_vec)
int RTOp_reduce_reduct_objs(const struct RTOp_RTOp *op, RTOp_ReductTarget in_reduct_obj, RTOp_ReductTarget inout_reduct_obj)
int(* obj_create)(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, void **obj)
int RTOp_extract_reduct_obj_state(const struct RTOp_RTOp *op, const RTOp_ReductTarget reduct_obj, int num_values, RTOp_value_type value_data[], int num_indexes, RTOp_index_type index_data[], int num_chars, RTOp_char_type char_data[])
int(* extract_state)(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, void *obj, int num_values, RTOp_value_type value_data[], int num_indexes, RTOp_index_type index_data[], int num_chars, RTOp_char_type char_data[])
void RTOp_sub_vector(RTOp_index_type global_offset, RTOp_index_type sub_dim, const RTOp_value_type values[], ptrdiff_t values_stride, struct RTOp_SubVector *sub_vec)
int RTOp_reduct_obj_free(const struct RTOp_RTOp *op, RTOp_ReductTarget *reduct_obj)
int RTOp_get_op_type_num_entries(const struct RTOp_RTOp *op, int *num_values, int *num_indexes, int *num_chars)
int RTOp_get_op_name(const struct RTOp_RTOp *op, const char **op_name)
int RTOp_apply_op(const struct RTOp_RTOp *op, const int num_vecs, const struct RTOp_SubVector sub_vecs[], const int num_targ_vecs, const struct RTOp_MutableSubVector targ_sub_vecs[], RTOp_ReductTarget reduct_obj)
int RTOp_Server_lookup_op_name(const struct RTOp_RTOp_vtbl_t *op_class_vtbl, char op_class_name[])
int RTOp_Server_add_op_name_vtbl(const char op_class_name[], const struct RTOp_RTOp_vtbl_t *op_class_vtbl)
int RTOp_free_op(struct RTOp_RTOp *op)
int RTOp_extract_op_state(const struct RTOp_RTOp *op, int num_values, RTOp_value_type value_data[], int num_indexes, RTOp_index_type index_data[], int num_chars, RTOp_char_type char_data[])
int(* obj_free)(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, void **obj)
int(* obj_reinit)(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, void *obj)
int(* reduct_obj_reinit)(const struct RTOp_RTOp_vtbl_t *vtbl, const void *obj_data, RTOp_ReductTarget reduct_obj)
int RTOp_Server_construct_op(const char op_class_name[], int num_values, const RTOp_value_type value_data[], int num_indexes, const RTOp_index_type index_data[], int num_chars, const RTOp_char_type char_data[], struct RTOp_RTOp *op)
int(* load_state)(const struct RTOp_obj_type_vtbl_t *vtbl, const void *instance_data, int num_values, const RTOp_value_type value_data[], int num_indexes, const RTOp_index_type index_data[], int num_chars, const RTOp_char_type char_data[], void **obj)
void RTOp_mutable_sub_vector_null(struct RTOp_MutableSubVector *sub_vec)
int RTOp_reduct_obj_reinit(const struct RTOp_RTOp *op, RTOp_ReductTarget reduct_obj)
int RTOp_get_reduct_op(const struct RTOp_RTOp *op, RTOp_reduct_op_func_ptr_t *reduct_op_func_ptr)
void RTOp_Server_dump(FILE *file)
void RTOp_sub_vector_null(struct RTOp_SubVector *sub_vec)
int RTOp_coord_invariant(const struct RTOp_RTOp *op, int *coord_invariant)