include/ccKVS/inline_util.h
static inline void copy_op_to_next_op(struct extended_cache_op* ops, struct extended_cache_op* next_ops,
									  struct mica_resp* resp, struct mica_resp* next_resp,
									  struct key_home* key_homes, struct key_home* next_key_homes,
									  uint16_t op_i, uint16_t* next_op_i, struct latency_flags* latency_info,
									  uint16_t* hottest_keys_pointers)
{
	if (ENABLE_ASSERTIONS) {
		if (!(resp[op_i].type == CACHE_GET_STALL ||
			  resp[op_i].type == CACHE_PUT_STALL ||
			  resp[op_i].type == UNSERVED_CACHE_MISS ||
			  ops[op_i].opcode == CACHE_OP_BRC))
			printf(" Code %s : %s\n", code_to_str(ops[op_i].opcode), code_to_str(resp[op_i].type));
	}
	uint16_t size_of_op;
	if (ops[op_i].opcode == CACHE_OP_BRC || ops[op_i].opcode == CACHE_OP_PUT ||
		ops[op_i].opcode == CACHE_OP_INV || ops[op_i].opcode == CACHE_OP_UPD)  // not sure if all of these opcodes can occur
		size_of_op = HERD_PUT_REQ_SIZE;
	else if (ops[op_i].opcode == CACHE_OP_GET)
		size_of_op = ENABLE_HOT_KEY_TRACKING == 1 ? HERD_GET_REQ_SIZE + 2 : HERD_GET_REQ_SIZE; // when tracking hot keys we use the val_len and the first byte of the value
	else if (ENABLE_ASSERTIONS) {
		printf("unexpected opcode %d \n", ops[op_i].opcode);
		assert(false);
	}
	if ((ENABLE_HOT_KEY_TRACKING == 1) && (resp[op_i].type == CACHE_GET_STALL)) {
		if ((ops[(op_i)].value[0]) < HOTTEST_KEYS_TO_TRACK) {
			if (hottest_keys_pointers[ops[(op_i)].value[0]]  == (op_i + 1)) {
				hottest_keys_pointers[ops[(op_i)].value[0]] = (*next_op_i) + 1; // we store the op_i + 1 because '0' has special meaning
			}
		}

	}
	memcpy(next_ops + (*next_op_i), ops + op_i, size_of_op);
	memcpy(next_resp + (*next_op_i), resp + op_i, sizeof(struct mica_resp));
	memcpy(next_key_homes + (*next_op_i), key_homes + op_i, sizeof(struct key_home));

	if ((MEASURE_LATENCY == 1) && (op_i == latency_info->last_measured_op_i) &&
		((latency_info->measured_req_flag == LOCAL_REQ) || (latency_info->measured_req_flag == HOT_READ_REQ) ||
		 (latency_info->measured_req_flag == HOT_WRITE_REQ_BEFORE_SAVING_KEY))) {
		latency_info->last_measured_op_i = *next_op_i; // if the local req has been issued this is useless, but harmless
//			yellow_printf("Changing op_i from %d to %d \n", op_i, latency_info->last_measured_op_i);
	}
	(*next_op_i)++;
}
// Copy the current op to the next buffer to be used as it cannot be used in this cycle
Copy the current op to the next buffer to be used as it cannot be used in this cycle
Copy the current op to the next buffer to be used as it cannot be used in this cycle
static inline void copy_op_to_next_op(struct extended_cache_op* ops, struct extended_cache_op* next_ops,
									  struct mica_resp* resp, struct mica_resp* next_resp,
									  struct key_home* key_homes, struct key_home* next_key_homes,
									  uint16_t op_i, uint16_t* next_op_i, struct latency_flags* latency_info,
									  uint16_t* hottest_keys_pointers)
{
	if (ENABLE_ASSERTIONS) {
		if (!(resp[op_i].type == CACHE_GET_STALL ||
			  resp[op_i].type == CACHE_PUT_STALL ||
			  resp[op_i].type == UNSERVED_CACHE_MISS ||
			  ops[op_i].opcode == CACHE_OP_BRC))
			printf(" Code %s : %s\n", code_to_str(ops[op_i].opcode), code_to_str(resp[op_i].type));
	}
	uint16_t size_of_op;
	if (ops[op_i].opcode == CACHE_OP_BRC || ops[op_i].opcode == CACHE_OP_PUT ||
		ops[op_i].opcode == CACHE_OP_INV || ops[op_i].opcode == CACHE_OP_UPD)  
		size_of_op = HERD_PUT_REQ_SIZE;
	else if (ops[op_i].opcode == CACHE_OP_GET)
		size_of_op = ENABLE_HOT_KEY_TRACKING == 1 ? HERD_GET_REQ_SIZE + 2 : HERD_GET_REQ_SIZE; 
	else if (ENABLE_ASSERTIONS) {
		printf("unexpected opcode %d \n", ops[op_i].opcode);
		assert(false);
	}
	if ((ENABLE_HOT_KEY_TRACKING == 1) && (resp[op_i].type == CACHE_GET_STALL)) {
		if ((ops[(op_i)].value[0]) < HOTTEST_KEYS_TO_TRACK) {
			if (hottest_keys_pointers[ops[(op_i)].value[0]]  == (op_i + 1)) {
				hottest_keys_pointers[ops[(op_i)].value[0]] = (*next_op_i) + 1; 
			}
		}
	}
	memcpy(next_ops + (*next_op_i), ops + op_i, size_of_op);
	memcpy(next_resp + (*next_op_i), resp + op_i, sizeof(struct mica_resp));
	memcpy(next_key_homes + (*next_op_i), key_homes + op_i, sizeof(struct key_home));
	if ((MEASURE_LATENCY == 1) && (op_i == latency_info->last_measured_op_i) &&
		((latency_info->measured_req_flag == LOCAL_REQ) || (latency_info->measured_req_flag == HOT_READ_REQ) ||
		 (latency_info->measured_req_flag == HOT_WRITE_REQ_BEFORE_SAVING_KEY))) {
		latency_info->last_measured_op_i = *next_op_i; 
	}
	(*next_op_i)++;
}
static inline void copy_op_to_next_op ( struct extended_cache_op * ops , struct extended_cache_op * next_ops , struct mica_resp * resp , struct mica_resp * next_resp , struct key_home * key_homes , struct key_home * next_key_homes , uint16_t op_i , uint16_t * next_op_i , struct latency_flags * latency_info , uint16_t * hottest_keys_pointers ) { if ( ENABLE_ASSERTIONS ) { if ( ! ( resp [ op_i ] . type == CACHE_GET_STALL || resp [ op_i ] . type == CACHE_PUT_STALL || resp [ op_i ] . type == UNSERVED_CACHE_MISS || ops [ op_i ] . opcode == CACHE_OP_BRC ) ) printf ( " \n " , code_to_str ( ops [ op_i ] . opcode ) , code_to_str ( resp [ op_i ] . type ) ) ; } uint16_t size_of_op ; if ( ops [ op_i ] . opcode == CACHE_OP_BRC || ops [ op_i ] . opcode == CACHE_OP_PUT || ops [ op_i ] . opcode == CACHE_OP_INV || ops [ op_i ] . opcode == CACHE_OP_UPD ) size_of_op = HERD_PUT_REQ_SIZE ; else if ( ops [ op_i ] . opcode == CACHE_OP_GET ) size_of_op = ENABLE_HOT_KEY_TRACKING == 1 ? HERD_GET_REQ_SIZE + 2 : HERD_GET_REQ_SIZE ; else if ( ENABLE_ASSERTIONS ) { printf ( " \n " , ops [ op_i ] . opcode ) ; assert ( false ) ; } if ( ( ENABLE_HOT_KEY_TRACKING == 1 ) && ( resp [ op_i ] . type == CACHE_GET_STALL ) ) { if ( ( ops [ ( op_i ) ] . value [ 0 ] ) < HOTTEST_KEYS_TO_TRACK ) { if ( hottest_keys_pointers [ ops [ ( op_i ) ] . value [ 0 ] ] == ( op_i + 1 ) ) { hottest_keys_pointers [ ops [ ( op_i ) ] . value [ 0 ] ] = ( * next_op_i ) + 1 ; } } } memcpy ( next_ops + ( * next_op_i ) , ops + op_i , size_of_op ) ; memcpy ( next_resp + ( * next_op_i ) , resp + op_i , sizeof ( struct mica_resp ) ) ; memcpy ( next_key_homes + ( * next_op_i ) , key_homes + op_i , sizeof ( struct key_home ) ) ; if ( ( MEASURE_LATENCY == 1 ) && ( op_i == latency_info -> last_measured_op_i ) && ( ( latency_info -> measured_req_flag == LOCAL_REQ ) || ( latency_info -> measured_req_flag == HOT_READ_REQ ) || ( latency_info -> measured_req_flag == HOT_WRITE_REQ_BEFORE_SAVING_KEY ) ) ) { latency_info -> last_measured_op_i = * next_op_i ; } ( * next_op_i ) ++ ; }
Copy the current op to the next buffer to be used as it cannot be used in this cycle
Copy the current op to the next buffer to be used as it cannot be used in this cycle
// not sure if all of these opcodes can occur // when tracking hot keys we use the val_len and the first byte of the value // we store the op_i + 1 because '0' has special meaning // if the local req has been issued this is useless, but harmless //			yellow_printf("Changing op_i from %d to %d \n", op_i, latency_info->last_measured_op_i);