include/ccKVS/inline_util.h
static inline void find_responses_to_enable_multi_batching(double empty_req_percentage, struct hrd_ctrl_blk* cb,
														   struct ibv_wc* wc, uint8_t* per_worker_outstanding, uint32_t* outstanding_rem_reqs,
														   uint16_t local_client_id)
{
	uint16_t j;
	uint32_t min_batch_ability;
	int responses_found = 0;
	// BACK-OFF Mechanism to make sure the buffer will get a chance to empty
	if (empty_req_percentage < MIN_EMPTY_PERCENTAGE)
		min_batch_ability = MAX_OUTSTANDING_REQS - 1;
	else min_batch_ability = MINIMUM_BATCH_ABILITY;

	/* Poll for whatever responses are ready until there are enough credits,
	 	such that the minimum-size can be created */
	do {
		responses_found = ibv_poll_cq(cb->dgram_recv_cq[REMOTE_UD_QP_ID], MAX_OUTSTANDING_REQS, wc);
		if(responses_found != 0) {
			if(wc[responses_found -1].status != 0) {
				fprintf(stderr, "Polling remote recv req: Bad wc status %d\n", wc[responses_found -1].status);
				exit(0);
			}
			for (j = 0; j < responses_found; j++) {
				if (ENABLE_ASSERTIONS == 1) assert(wc[j].imm_data < WORKER_NUM);
				per_worker_outstanding[wc[j].imm_data]--;
				if (ENABLE_ASSERTIONS == 1) assert(per_worker_outstanding[wc[j].imm_data] <= WS_PER_WORKER);
			}
		}
		(*outstanding_rem_reqs) -= responses_found;
		if (ENABLE_ASSERTIONS == 1) assert((*outstanding_rem_reqs) <= MAX_OUTSTANDING_REQS);
		c_stats[local_client_id].stalled_time_per_client++;
	} while (MAX_OUTSTANDING_REQS - (*outstanding_rem_reqs) < min_batch_ability);
}
/* Poll the remote recv q to find enough credits to for the smaler batch allowed
			---------------UNTESTED-------------------------- */
Poll the remote recv q to find enough credits to for the smaler batch allowed
UNTESTED
Poll the remote recv q to find enough credits to for the smaler batch allowed UNTESTED
static inline void find_responses_to_enable_multi_batching(double empty_req_percentage, struct hrd_ctrl_blk* cb,
														   struct ibv_wc* wc, uint8_t* per_worker_outstanding, uint32_t* outstanding_rem_reqs,
														   uint16_t local_client_id)
{
	uint16_t j;
	uint32_t min_batch_ability;
	int responses_found = 0;
	if (empty_req_percentage < MIN_EMPTY_PERCENTAGE)
		min_batch_ability = MAX_OUTSTANDING_REQS - 1;
	else min_batch_ability = MINIMUM_BATCH_ABILITY;
	do {
		responses_found = ibv_poll_cq(cb->dgram_recv_cq[REMOTE_UD_QP_ID], MAX_OUTSTANDING_REQS, wc);
		if(responses_found != 0) {
			if(wc[responses_found -1].status != 0) {
				fprintf(stderr, "Polling remote recv req: Bad wc status %d\n", wc[responses_found -1].status);
				exit(0);
			}
			for (j = 0; j < responses_found; j++) {
				if (ENABLE_ASSERTIONS == 1) assert(wc[j].imm_data < WORKER_NUM);
				per_worker_outstanding[wc[j].imm_data]--;
				if (ENABLE_ASSERTIONS == 1) assert(per_worker_outstanding[wc[j].imm_data] <= WS_PER_WORKER);
			}
		}
		(*outstanding_rem_reqs) -= responses_found;
		if (ENABLE_ASSERTIONS == 1) assert((*outstanding_rem_reqs) <= MAX_OUTSTANDING_REQS);
		c_stats[local_client_id].stalled_time_per_client++;
	} while (MAX_OUTSTANDING_REQS - (*outstanding_rem_reqs) < min_batch_ability);
}
static inline void find_responses_to_enable_multi_batching ( double empty_req_percentage , struct hrd_ctrl_blk * cb , struct ibv_wc * wc , uint8_t * per_worker_outstanding , uint32_t * outstanding_rem_reqs , uint16_t local_client_id ) { uint16_t j ; uint32_t min_batch_ability ; int responses_found = 0 ; if ( empty_req_percentage < MIN_EMPTY_PERCENTAGE ) min_batch_ability = MAX_OUTSTANDING_REQS - 1 ; else min_batch_ability = MINIMUM_BATCH_ABILITY ; do { responses_found = ibv_poll_cq ( cb -> dgram_recv_cq [ REMOTE_UD_QP_ID ] , MAX_OUTSTANDING_REQS , wc ) ; if ( responses_found != 0 ) { if ( wc [ responses_found - 1 ] . status != 0 ) { fprintf ( stderr , " \n " , wc [ responses_found - 1 ] . status ) ; exit ( 0 ) ; } for ( j = 0 ; j < responses_found ; j ++ ) { if ( ENABLE_ASSERTIONS == 1 ) assert ( wc [ j ] . imm_data < WORKER_NUM ) ; per_worker_outstanding [ wc [ j ] . imm_data ] -- ; if ( ENABLE_ASSERTIONS == 1 ) assert ( per_worker_outstanding [ wc [ j ] . imm_data ] <= WS_PER_WORKER ) ; } } ( * outstanding_rem_reqs ) -= responses_found ; if ( ENABLE_ASSERTIONS == 1 ) assert ( ( * outstanding_rem_reqs ) <= MAX_OUTSTANDING_REQS ) ; c_stats [ local_client_id ] . stalled_time_per_client ++ ; } while ( MAX_OUTSTANDING_REQS - ( * outstanding_rem_reqs ) < min_batch_ability ) ; }
Poll the remote recv q to find enough credits to for the smaler batch allowed
UNTESTED
Poll the remote recv q to find enough credits to for the smaler batch allowed UNTESTED
// BACK-OFF Mechanism to make sure the buffer will get a chance to empty /* Poll for whatever responses are ready until there are enough credits,
	 	such that the minimum-size can be created */