From d47d550dfc3ea09ae79d7628c460c7a6867a0205 Mon Sep 17 00:00:00 2001 From: Mike Dubman Date: Mon, 5 Nov 2012 14:02:37 +0000 Subject: [PATCH] performance optimization: process completions in the batch manner This commit was SVN r27559. --- ompi/mca/btl/openib/btl_openib.h | 2 ++ ompi/mca/btl/openib/btl_openib_component.c | 8 +++++--- ompi/mca/btl/openib/btl_openib_mca.c | 6 ++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ompi/mca/btl/openib/btl_openib.h b/ompi/mca/btl/openib/btl_openib.h index baa5ecf87c..9161e0006b 100644 --- a/ompi/mca/btl/openib/btl_openib.h +++ b/ompi/mca/btl/openib/btl_openib.h @@ -57,6 +57,7 @@ BEGIN_C_DECLS #define MCA_BTL_IB_LEAVE_PINNED 1 #define IB_DEFAULT_GID_PREFIX 0xfe80000000000000ll #define MCA_BTL_IB_PKEY_MASK 0x7fff +#define MCA_BTL_OPENIB_CQ_POLL_BATCH_DEFAULT (256) /*--------------------------------------------------------------------*/ @@ -278,6 +279,7 @@ struct mca_btl_openib_component_t { bool use_message_coalescing; uint32_t cq_poll_ratio; uint32_t cq_poll_progress; + uint32_t cq_poll_batch; uint32_t eager_rdma_poll_ratio; #ifdef HAVE_IBV_FORK_INIT /** Whether we want fork support or not */ diff --git a/ompi/mca/btl/openib/btl_openib_component.c b/ompi/mca/btl/openib/btl_openib_component.c index 572b24cab4..9d6397e556 100644 --- a/ompi/mca/btl/openib/btl_openib_component.c +++ b/ompi/mca/btl/openib/btl_openib_component.c @@ -3461,12 +3461,13 @@ static int poll_device(mca_btl_openib_device_t* device, int count) { int ne = 0, cq; uint32_t hp_iter = 0; - struct ibv_wc wc; + struct ibv_wc wc[MCA_BTL_OPENIB_CQ_POLL_BATCH_DEFAULT]; + int i; device->pollme = false; for(cq = 0; cq < 2 && hp_iter < mca_btl_openib_component.cq_poll_progress;) { - ne = ibv_poll_cq(device->ib_cq[cq], 1, &wc); + ne = ibv_poll_cq(device->ib_cq[cq], mca_btl_openib_component.cq_poll_batch, wc); if(0 == ne) { /* don't check low prio cq if there was something in high prio cq, * but for each cq_poll_ratio hp cq polls poll lp cq once */ @@ -3488,7 +3489,8 @@ static int poll_device(mca_btl_openib_device_t* device, int count) device->hp_cq_polls--; } - handle_wc(device, cq, &wc); + for (i = 0; i < ne; i++) + handle_wc(device, cq, &wc[i]); } return count; diff --git a/ompi/mca/btl/openib/btl_openib_mca.c b/ompi/mca/btl/openib/btl_openib_mca.c index 2fd13bf413..b520842055 100644 --- a/ompi/mca/btl/openib/btl_openib_mca.c +++ b/ompi/mca/btl/openib/btl_openib_mca.c @@ -174,6 +174,12 @@ int btl_openib_register_mca_params(void) 0, &ival, 0)); mca_btl_openib_component.abort_not_enough_reg_mem = (0 != ival); + CHECK(reg_int("poll_cq_batch", NULL, + "Retrieve up to poll_cq_batch completions from CQ", + MCA_BTL_OPENIB_CQ_POLL_BATCH_DEFAULT, &ival, REGINT_GE_ONE)); + + mca_btl_openib_component.cq_poll_batch = (ival > MCA_BTL_OPENIB_CQ_POLL_BATCH_DEFAULT)? MCA_BTL_OPENIB_CQ_POLL_BATCH_DEFAULT : ival; + if (OMPI_HAVE_IBV_FORK_INIT) { ival2 = -1; } else {