Skip to content

Commit

Permalink
ch4/ofi: move some inline util functions
Browse files Browse the repository at this point in the history
Move these utility functions to ofi_impl.h since they are simple and
non-specific. It also simplifies figuring out which file to include
especially for .c files.
  • Loading branch information
hzhou committed Feb 8, 2024
1 parent c24a4a9 commit bdd903e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 38 deletions.
25 changes: 0 additions & 25 deletions src/mpid/ch4/netmod/ofi/ofi_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,6 @@
int MPIDI_OFI_rma_done_event(int vci, struct fi_cq_tagged_entry *wc, MPIR_Request * in_req);
int MPIDI_OFI_dispatch_function(int vci, struct fi_cq_tagged_entry *wc, MPIR_Request * req);

MPL_STATIC_INLINE_PREFIX MPL_gpu_engine_type_t MPIDI_OFI_gpu_get_recv_engine_type(int cvar)
{
if (cvar == MPIR_CVAR_CH4_OFI_GPU_RECEIVE_ENGINE_TYPE_compute) {
return MPL_GPU_ENGINE_TYPE_COMPUTE;
} else if (cvar == MPIR_CVAR_CH4_OFI_GPU_RECEIVE_ENGINE_TYPE_copy_high_bandwidth) {
return MPL_GPU_ENGINE_TYPE_COPY_HIGH_BANDWIDTH;
} else if (cvar == MPIR_CVAR_CH4_OFI_GPU_RECEIVE_ENGINE_TYPE_copy_low_latency) {
return MPL_GPU_ENGINE_TYPE_COPY_LOW_LATENCY;
} else {
return MPL_GPU_ENGINE_TYPE_LAST;
}
}

MPL_STATIC_INLINE_PREFIX int MPIDI_OFI_cqe_get_source(struct fi_cq_tagged_entry *wc, bool has_err)
{
if (MPIDI_OFI_ENABLE_DATA) {
if (unlikely(has_err)) {
return wc->data & ((1 << MPIDI_OFI_IDATA_SRC_BITS) - 1);
}
return wc->data;
} else {
return MPIDI_OFI_init_get_source(wc->tag);
}
}

MPL_STATIC_INLINE_PREFIX int MPIDI_OFI_send_event(int vci,
struct fi_cq_tagged_entry *wc /* unused */ ,
MPIR_Request * sreq, int event_id)
Expand Down
38 changes: 38 additions & 0 deletions src/mpid/ch4/netmod/ofi/ofi_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,44 @@ MPL_STATIC_INLINE_PREFIX int MPIDI_OFI_gpu_free_pack_buffer(void *ptr)
}
}

MPL_STATIC_INLINE_PREFIX MPL_gpu_engine_type_t MPIDI_OFI_gpu_get_send_engine_type(int cvar)
{
if (cvar == MPIR_CVAR_CH4_OFI_GPU_SEND_ENGINE_TYPE_compute) {
return MPL_GPU_ENGINE_TYPE_COMPUTE;
} else if (cvar == MPIR_CVAR_CH4_OFI_GPU_SEND_ENGINE_TYPE_copy_high_bandwidth) {
return MPL_GPU_ENGINE_TYPE_COPY_HIGH_BANDWIDTH;
} else if (cvar == MPIR_CVAR_CH4_OFI_GPU_SEND_ENGINE_TYPE_copy_low_latency) {
return MPL_GPU_ENGINE_TYPE_COPY_LOW_LATENCY;
} else {
return MPL_GPU_ENGINE_TYPE_LAST;
}
}

MPL_STATIC_INLINE_PREFIX MPL_gpu_engine_type_t MPIDI_OFI_gpu_get_recv_engine_type(int cvar)
{
if (cvar == MPIR_CVAR_CH4_OFI_GPU_RECEIVE_ENGINE_TYPE_compute) {
return MPL_GPU_ENGINE_TYPE_COMPUTE;
} else if (cvar == MPIR_CVAR_CH4_OFI_GPU_RECEIVE_ENGINE_TYPE_copy_high_bandwidth) {
return MPL_GPU_ENGINE_TYPE_COPY_HIGH_BANDWIDTH;
} else if (cvar == MPIR_CVAR_CH4_OFI_GPU_RECEIVE_ENGINE_TYPE_copy_low_latency) {
return MPL_GPU_ENGINE_TYPE_COPY_LOW_LATENCY;
} else {
return MPL_GPU_ENGINE_TYPE_LAST;
}
}

MPL_STATIC_INLINE_PREFIX int MPIDI_OFI_cqe_get_source(struct fi_cq_tagged_entry *wc, bool has_err)
{
if (MPIDI_OFI_ENABLE_DATA) {
if (unlikely(has_err)) {
return wc->data & ((1 << MPIDI_OFI_IDATA_SRC_BITS) - 1);
}
return wc->data;
} else {
return MPIDI_OFI_init_get_source(wc->tag);
}
}

int MPIDI_OFI_gpu_pipeline_send(MPIR_Request * sreq, const void *send_buf,
MPI_Aint count, MPI_Datatype datatype,
MPL_pointer_attr_t attr, MPI_Aint data_sz,
Expand Down
13 changes: 0 additions & 13 deletions src/mpid/ch4/netmod/ofi/ofi_send.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@

#include "ofi_impl.h"

MPL_STATIC_INLINE_PREFIX MPL_gpu_engine_type_t MPIDI_OFI_gpu_get_send_engine_type(int cvar)
{
if (cvar == MPIR_CVAR_CH4_OFI_GPU_SEND_ENGINE_TYPE_compute) {
return MPL_GPU_ENGINE_TYPE_COMPUTE;
} else if (cvar == MPIR_CVAR_CH4_OFI_GPU_SEND_ENGINE_TYPE_copy_high_bandwidth) {
return MPL_GPU_ENGINE_TYPE_COPY_HIGH_BANDWIDTH;
} else if (cvar == MPIR_CVAR_CH4_OFI_GPU_SEND_ENGINE_TYPE_copy_low_latency) {
return MPL_GPU_ENGINE_TYPE_COPY_LOW_LATENCY;
} else {
return MPL_GPU_ENGINE_TYPE_LAST;
}
}

MPL_STATIC_INLINE_PREFIX int MPIDI_OFI_send_lightweight(const void *buf,
size_t data_sz,
uint64_t cq_data,
Expand Down

0 comments on commit bdd903e

Please sign in to comment.