include/ccKVS/inline_util.h
static inline void poll_workers_recv_completions(uint16_t* per_qp_received_messages, uint16_t received_messages,
												 struct hrd_ctrl_blk* cb, struct ibv_wc* wc, bool multiget, uint32_t* debug_recv,
												 uint16_t wr_i, uint16_t wrkr_lid, uint32_t max_reqs)
{
	uint16_t wc_i = 0, qp_i;
	for (qp_i = 0; qp_i < WORKER_NUM_UD_QPS; qp_i++) { // take care to poll the correct recv queues
		//      printf("Polling wr_i= %d, received_messages = %d, per_qp_received_messages[qp_i] = %d, qp_i =%d \n", wr_i,
		//      						received_messages, per_qp_received_messages[qp_i], qp_i );
		if (per_qp_received_messages[qp_i] > 0) {
			if (ENABLE_ASSERTIONS) {
				assert(per_qp_received_messages[qp_i] <= WS_PER_WORKER * (CLIENT_NUM - CLIENTS_PER_MACHINE));
				if (WORKER_NUM_UD_QPS == 1) assert(per_qp_received_messages[qp_i] == received_messages);
			}
			hrd_poll_cq(cb->dgram_recv_cq[qp_i], per_qp_received_messages[qp_i], &wc[wc_i]);
			if (DEBUG_WORKER_RECVS) *debug_recv-= per_qp_received_messages[qp_i];
			wc_i += per_qp_received_messages[qp_i];
		}
	}
	if (ENABLE_ASSERTIONS == 1) {
		assert(multiget == false);
		assert(wc_i == received_messages);
		assert(wr_i <= WORKER_MAX_BATCH);
		if (received_messages * MAX_COALESCE_PER_MACH < wr_i)
			red_printf("Worker %d: wr_i = %d, received_messages %d, max reqs %d \n",
					   wrkr_lid, wr_i, received_messages, max_reqs);
		assert(received_messages <= max_reqs);
		if (WORKER_NUM_UD_QPS == 1)
			assert(per_qp_received_messages[0] == received_messages);
		assert(received_messages <= WORKER_MAX_BATCH);
	}
}
// poll the worker's receive completions according to the messages that have been polled from the REquest Region
poll the worker's receive completions according to the messages that have been polled from the REquest Region
poll the worker ' s receive completions according to the messages that have been polled from the REquest Region
static inline void poll_workers_recv_completions(uint16_t* per_qp_received_messages, uint16_t received_messages,
												 struct hrd_ctrl_blk* cb, struct ibv_wc* wc, bool multiget, uint32_t* debug_recv,
												 uint16_t wr_i, uint16_t wrkr_lid, uint32_t max_reqs)
{
	uint16_t wc_i = 0, qp_i;
	for (qp_i = 0; qp_i < WORKER_NUM_UD_QPS; qp_i++) { 
		if (per_qp_received_messages[qp_i] > 0) {
			if (ENABLE_ASSERTIONS) {
				assert(per_qp_received_messages[qp_i] <= WS_PER_WORKER * (CLIENT_NUM - CLIENTS_PER_MACHINE));
				if (WORKER_NUM_UD_QPS == 1) assert(per_qp_received_messages[qp_i] == received_messages);
			}
			hrd_poll_cq(cb->dgram_recv_cq[qp_i], per_qp_received_messages[qp_i], &wc[wc_i]);
			if (DEBUG_WORKER_RECVS) *debug_recv-= per_qp_received_messages[qp_i];
			wc_i += per_qp_received_messages[qp_i];
		}
	}
	if (ENABLE_ASSERTIONS == 1) {
		assert(multiget == false);
		assert(wc_i == received_messages);
		assert(wr_i <= WORKER_MAX_BATCH);
		if (received_messages * MAX_COALESCE_PER_MACH < wr_i)
			red_printf("Worker %d: wr_i = %d, received_messages %d, max reqs %d \n",
					   wrkr_lid, wr_i, received_messages, max_reqs);
		assert(received_messages <= max_reqs);
		if (WORKER_NUM_UD_QPS == 1)
			assert(per_qp_received_messages[0] == received_messages);
		assert(received_messages <= WORKER_MAX_BATCH);
	}
}
static inline void poll_workers_recv_completions ( uint16_t * per_qp_received_messages , uint16_t received_messages , struct hrd_ctrl_blk * cb , struct ibv_wc * wc , bool multiget , uint32_t * debug_recv , uint16_t wr_i , uint16_t wrkr_lid , uint32_t max_reqs ) { uint16_t wc_i = 0 , qp_i ; for ( qp_i = 0 ; qp_i < WORKER_NUM_UD_QPS ; qp_i ++ ) { if ( per_qp_received_messages [ qp_i ] > 0 ) { if ( ENABLE_ASSERTIONS ) { assert ( per_qp_received_messages [ qp_i ] <= WS_PER_WORKER * ( CLIENT_NUM - CLIENTS_PER_MACHINE ) ) ; if ( WORKER_NUM_UD_QPS == 1 ) assert ( per_qp_received_messages [ qp_i ] == received_messages ) ; } hrd_poll_cq ( cb -> dgram_recv_cq [ qp_i ] , per_qp_received_messages [ qp_i ] , & wc [ wc_i ] ) ; if ( DEBUG_WORKER_RECVS ) * debug_recv -= per_qp_received_messages [ qp_i ] ; wc_i += per_qp_received_messages [ qp_i ] ; } } if ( ENABLE_ASSERTIONS == 1 ) { assert ( multiget == false ) ; assert ( wc_i == received_messages ) ; assert ( wr_i <= WORKER_MAX_BATCH ) ; if ( received_messages * MAX_COALESCE_PER_MACH < wr_i ) red_printf ( " \n " , wrkr_lid , wr_i , received_messages , max_reqs ) ; assert ( received_messages <= max_reqs ) ; if ( WORKER_NUM_UD_QPS == 1 ) assert ( per_qp_received_messages [ 0 ] == received_messages ) ; assert ( received_messages <= WORKER_MAX_BATCH ) ; } }
poll the worker's receive completions according to the messages that have been polled from the REquest Region
poll the worker ' s receive completions according to the messages that have been polled from the REquest Region
// take care to poll the correct recv queues //      printf("Polling wr_i= %d, received_messages = %d, per_qp_received_messages[qp_i] = %d, qp_i =%d \n", wr_i, //      						received_messages, per_qp_received_messages[qp_i], qp_i );