Skip to content

Commit

Permalink
Additional verbs configuration options and packet pacing testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaycedowell committed Dec 11, 2023
1 parent e59a8ca commit 451650b
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 1 deletion.
88 changes: 88 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,9 @@ HAVE_CUDA
CUDA_HOME
RDMA_MAXMEM
HAVE_RDMA
VERBS_SEND_PACING
VERBS_SEND_NPKTBUF
VERBS_NPKTBUF
HAVE_VERBS
HAVE_VMA
HAVE_HWLOC
Expand Down Expand Up @@ -856,6 +859,8 @@ with_ctags
enable_hwloc
enable_vma
enable_verbs
with_rx_buffer_size
with_tx_buffer_size
enable_rdma
with_rdma_max_mem
with_cuda_home
Expand Down Expand Up @@ -1572,6 +1577,10 @@ Optional Packages:
--with-sysroot[=DIR] Search for dependent libraries within DIR (or the
compiler's sysroot if not specified).
--with-ctags=[PATH] absolute path to ctags executable
--with-rx-buffer-size=N default Infiniband verbs receive buffer size in
packets (default=8192)
--with-tx-buffer-size=N default Infiniband verbs send buffer size in packets
(default=512)
--with-rdma-max-mem=N maximum RDMA buffer size in bytes
(default=134217728)
--with-cuda-home CUDA install path (default=/usr/local/cuda)
Expand Down Expand Up @@ -21240,6 +21249,85 @@ fi

fi


# Check whether --with-rx-buffer-size was given.
if test ${with_rx_buffer_size+y}
then :
withval=$with_rx_buffer_size;
else $as_nop
with_rx_buffer_size=8192
fi

VERBS_NPKTBUF=$with_rx_buffer_size

if test x$HAVE_VERBS = x0
then :
VERBS_NPKTBUF=0

fi


# Check whether --with-tx-buffer-size was given.
if test ${with_tx_buffer_size+y}
then :
withval=$with_tx_buffer_size;
else $as_nop
with_tx_buffer_size=512
fi

VERBS_SEND_NPKTBUF=$with_tx_buffer_size

if test x$HAVE_VERBS = x0
then :
VERBS_SEND_NPKTBUF=0

fi

if test x$HAVE_VERBS != x0
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Infiniband verbs packet pacing support" >&5
printf %s "checking for Infiniband verbs packet pacing support... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */


#include <infiniband/verbs.h>
int
main (void)
{

int ndev, d;
ibv_device** ibv_dev_list = NULL;
ibv_context* ibv_ctx = NULL;
ibv_device_attr_ex ibv_dev_attr;

ibv_dev_list = ibv_get_device_list(&ndev);
for(d=0; d<ndev; d++) {
ibv_ctx = ibv_open_device(ibv_dev_list[d]);
ibv_query_device_ex(ibv_ctx, NULL, &ibv_dev_attr);
ibv_is_qpt_supported(ibv_dev_attr.packet_pacing_caps.supported_qpts, IBV_QPT_RAW_PACKET);
}

;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"
then :
VERBS_SEND_PACING=1

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
else $as_nop
VERBS_SEND_PACING=0

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext

fi

#
# RDMA
#
Expand Down
42 changes: 42 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,48 @@ AS_IF([test x$enable_verbs != xno],
[AC_SUBST([HAVE_VERBS], [1])
LIBS="$LIBS -libverbs"])])

AC_ARG_WITH([rx-buffer-size],
[AS_HELP_STRING([--with-rx-buffer-size=N],
[default Infiniband verbs receive buffer size in packets (default=8192)])],
[],
[with_rx_buffer_size=8192])
AC_SUBST([VERBS_NPKTBUF], [$with_rx_buffer_size])
AS_IF([test x$HAVE_VERBS = x0],
[AC_SUBST([VERBS_NPKTBUF], [0])])

AC_ARG_WITH([tx-buffer-size],
[AS_HELP_STRING([--with-tx-buffer-size=N],
[default Infiniband verbs send buffer size in packets (default=512)])],
[],
[with_tx_buffer_size=512])
AC_SUBST([VERBS_SEND_NPKTBUF], [$with_tx_buffer_size])
AS_IF([test x$HAVE_VERBS = x0],
[AC_SUBST([VERBS_SEND_NPKTBUF], [0])])

AS_IF([test x$HAVE_VERBS != x0],
[AC_MSG_CHECKING([for Infiniband verbs packet pacing support])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
#include <infiniband/verbs.h>]],
[[
int ndev, d;
ibv_device** ibv_dev_list = NULL;
ibv_context* ibv_ctx = NULL;
ibv_device_attr_ex ibv_dev_attr;
ibv_dev_list = ibv_get_device_list(&ndev);
for(d=0; d<ndev; d++) {
ibv_ctx = ibv_open_device(ibv_dev_list[d]);
ibv_query_device_ex(ibv_ctx, NULL, &ibv_dev_attr);
ibv_is_qpt_supported(ibv_dev_attr.packet_pacing_caps.supported_qpts, IBV_QPT_RAW_PACKET);
}
]])],
[AC_SUBST([VERBS_SEND_PACING], [1])
AC_MSG_RESULT([yes])],
[AC_SUBST([VERBS_SEND_PACING], [0])
AC_MSG_RESULT([no])])
])

#
# RDMA
#
Expand Down
3 changes: 3 additions & 0 deletions src/bifrost/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ extern "C" {
#define BF_HWLOC_ENABLED @HAVE_HWLOC@
#define BF_VMA_ENABLED @HAVE_VMA@
#define BF_VERBS_ENABLED @HAVE_VERBS@
#define BF_VERBS_NPKTBUF @VERBS_NPKTBUF@
#define BF_VERBS_SEND_NPKTBUF @VERBS_SEND_NPKTBUF@
#define BF_VERBS_SEND_PACING @VERBS_SEND_PACING@
#define BF_RDMA_ENABLED @HAVE_RDMA@
#define BF_RDMA_MAXMEM @RDMA_MAXMEM@

Expand Down
9 changes: 8 additions & 1 deletion src/ib_verbs_send.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
#define BF_VERBS_SEND_NPKTBURST 16
#endif

#ifndef BF_VERBS_SEND_PACING
#define BF_VERBS_SEND_PACING 0
#endif

#define BF_VERBS_SEND_PAYLOAD_OFFSET 42

struct bf_ibv_send_pkt{
Expand Down Expand Up @@ -334,11 +338,12 @@ class VerbsSend {
std::cout << "_verbs.offload_csum: " << (int) _verbs.offload_csum << std::endl;

_verbs.hardware_pacing = 0;
#if defined BF_VERBS_SEND_PACING && BF_VERBS_SEND_PACING
if( ibv_is_qpt_supported(ibv_dev_attr.packet_pacing_caps.supported_qpts, IBV_QPT_RAW_PACKET) ) {
_verbs.hardware_pacing = ibv_dev_attr.packet_pacing_caps.qp_rate_limit_max;
}
std::cout << "_verbs.hardware_pacing: " << (int) _verbs.hardware_pacing << std::endl;

#endif
break;
}
}
Expand Down Expand Up @@ -731,6 +736,7 @@ class VerbsSend {
}

// Apply the rate limit
#if defined BF_VERBS_SEND_PACING && BF_VERBS_SEND_PACING
ibv_qp_rate_limit_attr rl_attr;
::memset(&rl_attr, 0, sizeof(ibv_qp_rate_limit_attr));
rl_attr.rate_limit = rate_limit;
Expand All @@ -740,6 +746,7 @@ class VerbsSend {
check_error(ibv_modify_qp_rate_limit(_verbs.qp[i], &rl_attr),
"set queue pair rate limit");
}
#endif

_rate_limit = rate_limit;
}
Expand Down

0 comments on commit 451650b

Please sign in to comment.