include/ccKVS/inline_util.h
static inline void forge_bcast_wrs_LIN(uint16_t op_i, struct extended_cache_op *ops, struct cache_op *ack_bcast_ops,
									   uint16_t *ack_pop_ptr, struct hrd_ctrl_blk *cb, struct ibv_sge *coh_send_sgl,
									   struct ibv_send_wr *coh_send_wr, uint16_t coh_message_count[][MACHINE_NUM],
									   struct mica_op *coh_buf, uint16_t *coh_buf_i, long long *br_tx,
									   uint16_t local_client_id,
									   uint16_t *updates_sent, uint16_t br_i, uint8_t credits[][MACHINE_NUM], uint8_t vc)
{
	uint16_t i;
	struct ibv_wc signal_send_wc;
	if (op_i < CACHE_BATCH_SIZE) {
		ops[op_i].opcode = CACHE_OP_INV;
		ops[op_i].key.meta.cid = (uint8_t) machine_id;
		coh_send_sgl[br_i].addr = (uint64_t) (uintptr_t) (ops + op_i);
		coh_send_sgl[br_i].length = HERD_GET_REQ_SIZE;
		c_stats[local_client_id].invs_per_client++;
		if (CLIENT_ENABLE_INLINING == 0) {
			for (i = 0; i < MESSAGES_IN_BCAST; i++)
				coh_send_wr[(br_i * MESSAGES_IN_BCAST) + i].send_flags = IBV_SEND_INLINE;// we should inline invalidations
		}
		//		 green_printf("CLIENT %d : I BROADCAST with %s credits: %d, key: %d, cid: %d and version: %d \n", local_client_id,
		//                  code_to_str(ops[op_i].opcode), credits[vc][(machine_id + 1) % MACHINE_NUM],
		//                  ops[op_i].key.tag, ops[op_i].key.meta.cid, 	ops[op_i].key.meta.version);
	}
	else { // create the Update
		coh_message_count[ACK_VC][ack_bcast_ops[*ack_pop_ptr].key.meta.cid]++; // we are emptying that buffer space
		ack_bcast_ops[*ack_pop_ptr].key.meta.cid = (uint8_t) machine_id;
		if (CLIENT_ENABLE_INLINING == 1)	coh_send_sgl[br_i].addr = (uint64_t) (uintptr_t) (ack_bcast_ops + (*ack_pop_ptr));
		if (CLIENT_ENABLE_INLINING == 0) {
			if (ENABLE_ASSERTIONS == 1) assert(*coh_buf_i < COH_BUF_SLOTS);
			memcpy(coh_buf + (*coh_buf_i), ack_bcast_ops + (*ack_pop_ptr), HERD_PUT_REQ_SIZE);
			coh_send_sgl[br_i].addr = (uint64_t) (uintptr_t) (coh_buf + (*coh_buf_i));
			MOD_ADD_WITH_BASE(*coh_buf_i, COH_BUF_SLOTS, 0);
			for (i = 0; i < MESSAGES_IN_BCAST; i++)
				coh_send_wr[(br_i * MESSAGES_IN_BCAST) + i].send_flags = 0;
		}
		coh_send_sgl[br_i].length = HERD_PUT_REQ_SIZE;
		(*updates_sent)++;
		c_stats[local_client_id].updates_per_client++;
		//      green_printf("CLIENT %d : I BROADCAST with %s credits: %d, key: %d, cid: %d and version: %d \n", local_client_id, code_to_str(ack_bcast_ops[*ack_pop_ptr].opcode), credits[vc][(machine_id + 1) % MACHINE_NUM],
		//                   ack_bcast_ops[*ack_pop_ptr].key.tag, ack_bcast_ops[*ack_pop_ptr].key.meta.cid, 	ack_bcast_ops[*ack_pop_ptr].key.meta.version);
		HRD_MOD_ADD(*ack_pop_ptr, BCAST_TO_CACHE_BATCH);
	}
	// Do a Signaled Send every BROADCAST_SS_BATCH broadcasts (BROADCAST_SS_BATCH * (MACHINE_NUM - 1) messages)
	if ((*br_tx) % BROADCAST_SS_BATCH == 0) coh_send_wr[0].send_flags |= IBV_SEND_SIGNALED;
	(*br_tx)++;
	if((*br_tx) % BROADCAST_SS_BATCH == BROADCAST_SS_BATCH - 1) {
		hrd_poll_cq(cb->dgram_send_cq[BROADCAST_UD_QP_ID], 1, &signal_send_wc);
	}
	// SET THE LAST COH_SEND_WR TO POINT TO NULL
	if (br_i > 0)
		coh_send_wr[(br_i * MESSAGES_IN_BCAST) - 1].next = &coh_send_wr[br_i * MESSAGES_IN_BCAST];
}
// Form Broadcast work requests specifically for LIN
Form Broadcast work requests specifically for LIN
Form Broadcast work requests specifically for LIN
static inline void forge_bcast_wrs_LIN(uint16_t op_i, struct extended_cache_op *ops, struct cache_op *ack_bcast_ops,
									   uint16_t *ack_pop_ptr, struct hrd_ctrl_blk *cb, struct ibv_sge *coh_send_sgl,
									   struct ibv_send_wr *coh_send_wr, uint16_t coh_message_count[][MACHINE_NUM],
									   struct mica_op *coh_buf, uint16_t *coh_buf_i, long long *br_tx,
									   uint16_t local_client_id,
									   uint16_t *updates_sent, uint16_t br_i, uint8_t credits[][MACHINE_NUM], uint8_t vc)
{
	uint16_t i;
	struct ibv_wc signal_send_wc;
	if (op_i < CACHE_BATCH_SIZE) {
		ops[op_i].opcode = CACHE_OP_INV;
		ops[op_i].key.meta.cid = (uint8_t) machine_id;
		coh_send_sgl[br_i].addr = (uint64_t) (uintptr_t) (ops + op_i);
		coh_send_sgl[br_i].length = HERD_GET_REQ_SIZE;
		c_stats[local_client_id].invs_per_client++;
		if (CLIENT_ENABLE_INLINING == 0) {
			for (i = 0; i < MESSAGES_IN_BCAST; i++)
				coh_send_wr[(br_i * MESSAGES_IN_BCAST) + i].send_flags = IBV_SEND_INLINE;
		}
	}
	else { 
		coh_message_count[ACK_VC][ack_bcast_ops[*ack_pop_ptr].key.meta.cid]++; 
		ack_bcast_ops[*ack_pop_ptr].key.meta.cid = (uint8_t) machine_id;
		if (CLIENT_ENABLE_INLINING == 1)	coh_send_sgl[br_i].addr = (uint64_t) (uintptr_t) (ack_bcast_ops + (*ack_pop_ptr));
		if (CLIENT_ENABLE_INLINING == 0) {
			if (ENABLE_ASSERTIONS == 1) assert(*coh_buf_i < COH_BUF_SLOTS);
			memcpy(coh_buf + (*coh_buf_i), ack_bcast_ops + (*ack_pop_ptr), HERD_PUT_REQ_SIZE);
			coh_send_sgl[br_i].addr = (uint64_t) (uintptr_t) (coh_buf + (*coh_buf_i));
			MOD_ADD_WITH_BASE(*coh_buf_i, COH_BUF_SLOTS, 0);
			for (i = 0; i < MESSAGES_IN_BCAST; i++)
				coh_send_wr[(br_i * MESSAGES_IN_BCAST) + i].send_flags = 0;
		}
		coh_send_sgl[br_i].length = HERD_PUT_REQ_SIZE;
		(*updates_sent)++;
		c_stats[local_client_id].updates_per_client++;
		HRD_MOD_ADD(*ack_pop_ptr, BCAST_TO_CACHE_BATCH);
	}
	if ((*br_tx) % BROADCAST_SS_BATCH == 0) coh_send_wr[0].send_flags |= IBV_SEND_SIGNALED;
	(*br_tx)++;
	if((*br_tx) % BROADCAST_SS_BATCH == BROADCAST_SS_BATCH - 1) {
		hrd_poll_cq(cb->dgram_send_cq[BROADCAST_UD_QP_ID], 1, &signal_send_wc);
	}
	if (br_i > 0)
		coh_send_wr[(br_i * MESSAGES_IN_BCAST) - 1].next = &coh_send_wr[br_i * MESSAGES_IN_BCAST];
}
static inline void forge_bcast_wrs_LIN ( uint16_t op_i , struct extended_cache_op * ops , struct cache_op * ack_bcast_ops , uint16_t * ack_pop_ptr , struct hrd_ctrl_blk * cb , struct ibv_sge * coh_send_sgl , struct ibv_send_wr * coh_send_wr , uint16_t coh_message_count [ ] [ MACHINE_NUM ] , struct mica_op * coh_buf , uint16_t * coh_buf_i , long long * br_tx , uint16_t local_client_id , uint16_t * updates_sent , uint16_t br_i , uint8_t credits [ ] [ MACHINE_NUM ] , uint8_t vc ) { uint16_t i ; struct ibv_wc signal_send_wc ; if ( op_i < CACHE_BATCH_SIZE ) { ops [ op_i ] . opcode = CACHE_OP_INV ; ops [ op_i ] . key . meta . cid = ( uint8_t ) machine_id ; coh_send_sgl [ br_i ] . addr = ( uint64_t ) ( uintptr_t ) ( ops + op_i ) ; coh_send_sgl [ br_i ] . length = HERD_GET_REQ_SIZE ; c_stats [ local_client_id ] . invs_per_client ++ ; if ( CLIENT_ENABLE_INLINING == 0 ) { for ( i = 0 ; i < MESSAGES_IN_BCAST ; i ++ ) coh_send_wr [ ( br_i * MESSAGES_IN_BCAST ) + i ] . send_flags = IBV_SEND_INLINE ; } } else { coh_message_count [ ACK_VC ] [ ack_bcast_ops [ * ack_pop_ptr ] . key . meta . cid ] ++ ; ack_bcast_ops [ * ack_pop_ptr ] . key . meta . cid = ( uint8_t ) machine_id ; if ( CLIENT_ENABLE_INLINING == 1 ) coh_send_sgl [ br_i ] . addr = ( uint64_t ) ( uintptr_t ) ( ack_bcast_ops + ( * ack_pop_ptr ) ) ; if ( CLIENT_ENABLE_INLINING == 0 ) { if ( ENABLE_ASSERTIONS == 1 ) assert ( * coh_buf_i < COH_BUF_SLOTS ) ; memcpy ( coh_buf + ( * coh_buf_i ) , ack_bcast_ops + ( * ack_pop_ptr ) , HERD_PUT_REQ_SIZE ) ; coh_send_sgl [ br_i ] . addr = ( uint64_t ) ( uintptr_t ) ( coh_buf + ( * coh_buf_i ) ) ; MOD_ADD_WITH_BASE ( * coh_buf_i , COH_BUF_SLOTS , 0 ) ; for ( i = 0 ; i < MESSAGES_IN_BCAST ; i ++ ) coh_send_wr [ ( br_i * MESSAGES_IN_BCAST ) + i ] . send_flags = 0 ; } coh_send_sgl [ br_i ] . length = HERD_PUT_REQ_SIZE ; ( * updates_sent ) ++ ; c_stats [ local_client_id ] . updates_per_client ++ ; HRD_MOD_ADD ( * ack_pop_ptr , BCAST_TO_CACHE_BATCH ) ; } if ( ( * br_tx ) % BROADCAST_SS_BATCH == 0 ) coh_send_wr [ 0 ] . send_flags |= IBV_SEND_SIGNALED ; ( * br_tx ) ++ ; if ( ( * br_tx ) % BROADCAST_SS_BATCH == BROADCAST_SS_BATCH - 1 ) { hrd_poll_cq ( cb -> dgram_send_cq [ BROADCAST_UD_QP_ID ] , 1 , & signal_send_wc ) ; } if ( br_i > 0 ) coh_send_wr [ ( br_i * MESSAGES_IN_BCAST ) - 1 ] . next = & coh_send_wr [ br_i * MESSAGES_IN_BCAST ] ; }
Form Broadcast work requests specifically for LIN
Form Broadcast work requests specifically for LIN
// we should inline invalidations //		 green_printf("CLIENT %d : I BROADCAST with %s credits: %d, key: %d, cid: %d and version: %d \n", local_client_id, //                  code_to_str(ops[op_i].opcode), credits[vc][(machine_id + 1) % MACHINE_NUM], //                  ops[op_i].key.tag, ops[op_i].key.meta.cid, 	ops[op_i].key.meta.version); // create the Update // we are emptying that buffer space //      green_printf("CLIENT %d : I BROADCAST with %s credits: %d, key: %d, cid: %d and version: %d \n", local_client_id, code_to_str(ack_bcast_ops[*ack_pop_ptr].opcode), credits[vc][(machine_id + 1) % MACHINE_NUM], //                   ack_bcast_ops[*ack_pop_ptr].key.tag, ack_bcast_ops[*ack_pop_ptr].key.meta.cid, 	ack_bcast_ops[*ack_pop_ptr].key.meta.version); // Do a Signaled Send every BROADCAST_SS_BATCH broadcasts (BROADCAST_SS_BATCH * (MACHINE_NUM - 1) messages) // SET THE LAST COH_SEND_WR TO POINT TO NULL