Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ompi/op: change reduce function prototypes to use a const source pointer #12284

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ompi/op/op.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ BEGIN_C_DECLS
* repeated code, but it's better this way (and this typedef will
* never change, so there's not much of a maintenance worry).
*/
typedef void (ompi_op_c_handler_fn_t)(void *, void *, int *,
typedef void (ompi_op_c_handler_fn_t)(const void *, void *, int *,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to change the signatures of the implementations that are used to set these in ompi_op_t?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which ones? I looked for implementations (ompi/mca/op/base/op_base_functions.c for example) and seems to me like all the functions already adhere to this prototype. Maybe I missed some?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, looks like the build is clean 👍

struct ompi_datatype_t **);

/**
* Typedef for fortran user-defined MPI_Ops.
*/
typedef void (ompi_op_fortran_handler_fn_t)(void *, void *,
typedef void (ompi_op_fortran_handler_fn_t)(const void *, void *,
MPI_Fint *, MPI_Fint *);

/**
* Typedef for Java op functions intercept (used for user-defined
* MPI.Ops).
*/
typedef void (ompi_op_java_handler_fn_t)(void *, void *, int *,
typedef void (ompi_op_java_handler_fn_t)(const void *, void *, int *,
struct ompi_datatype_t **,
int baseType,
void *jnienv, void *object);
Expand Down Expand Up @@ -500,7 +500,7 @@ static inline bool ompi_op_is_valid(ompi_op_t * op, ompi_datatype_t * ddt,
* optimization). If you give it an intrinsic op with a datatype that
* is not defined to have that operation, it is likely to seg fault.
*/
static inline void ompi_op_reduce(ompi_op_t * op, void *source,
static inline void ompi_op_reduce(ompi_op_t * op, const void *source,
void *target, size_t full_count,
ompi_datatype_t * dtype)
{
Expand Down Expand Up @@ -531,7 +531,7 @@ static inline void ompi_op_reduce(ompi_op_t * op, void *source,
}
shift = done_count * ext;
// Recurse one level in iterations of 'int'
ompi_op_reduce(op, (char*)source + shift, (char*)target + shift, iter_count, dtype);
ompi_op_reduce(op, (const char*)source + shift, (char*)target + shift, iter_count, dtype);
done_count += iter_count;
}
return;
Expand Down Expand Up @@ -595,7 +595,7 @@ static inline void ompi_op_reduce(ompi_op_t * op, void *source,
static inline void ompi_3buff_op_user (ompi_op_t *op, void * restrict source1, void * restrict source2,
void * restrict result, int count, struct ompi_datatype_t *dtype)
{
ompi_datatype_copy_content_same_ddt (dtype, count, result, source1);
ompi_datatype_copy_content_same_ddt (dtype, count, (char*)result, (char*)source1);
op->o_func.c_fn (source2, result, &count, &dtype);
}

Expand Down
Loading