diff --git a/ompi/op/op.c b/ompi/op/op.c index f07c97e1db..ba58073f7a 100644 --- a/ompi/op/op.c +++ b/ompi/op/op.c @@ -555,8 +555,9 @@ int ompi_op_init(void) /* Fill in the ddt.id->op_position map */ - for (i = 0; i < DT_MAX_PREDEFINED; ++i) + for (i = 0; i < DT_MAX_PREDEFINED; ++i) { ompi_op_ddt_map[i] = -1; + } ompi_op_ddt_map[DT_BYTE] = OMPI_OP_TYPE_BYTE; ompi_op_ddt_map[DT_SHORT] = OMPI_OP_TYPE_SHORT; @@ -677,22 +678,13 @@ ompi_op_t *ompi_op_create(bool commute, static int add_intrinsic(ompi_op_t *op, int fort_handle) { - int ret_val; - /* Add the op to the table */ - ret_val = ompi_pointer_array_add(ompi_op_f_to_c_table, op); - if (-1 == ret_val){ - return OMPI_ERROR; + OBJ_CONSTRUCT(op, ompi_op_t); + if (op->o_f_to_c_index != fort_handle) { + return OMPI_ERROR; } - /* Make sure that the op is in the right location in the table */ - - if (fort_handle != ret_val) { - return OMPI_ERROR; - }; - op->o_f_to_c_index = ret_val; - /* All done */ return OMPI_SUCCESS; diff --git a/ompi/op/op.h b/ompi/op/op.h index a09d2b58f0..e78425e14e 100644 --- a/ompi/op/op.h +++ b/ompi/op/op.h @@ -501,6 +501,7 @@ static inline void ompi_op_reduce(ompi_op_t *op, void *source, void *target, * :-) */ + OBJ_RETAIN(op); if (0 != (op->o_flags & OMPI_OP_FLAGS_INTRINSIC) && dtype->id < DT_MAX_PREDEFINED) { if (0 != (op->o_flags & OMPI_OP_FLAGS_FORTRAN_FUNC)) { @@ -523,6 +524,7 @@ static inline void ompi_op_reduce(ompi_op_t *op, void *source, void *target, } else { op->o_func[0].c_fn(source, target, &count, &dtype); } + OBJ_RELEASE(op); } #endif /* OMPI_OP_H */