include/ccKVS/inline_util.h
static inline void invs_bookkeeping(uint16_t inv_ops_i, struct mica_resp* inv_resp, uint16_t coh_message_count[][MACHINE_NUM],
									struct small_cache_op* inv_ops, struct small_cache_op* inv_to_send_ops, uint16_t* inv_push_ptr,
									uint16_t* inv_size, uint16_t* debug_ptr)
{
	uint16_t j, i;
	for (j = 0; j < inv_ops_i; j++) {
		// printf("response: %s to the Invalidation refers to key %d with cid %d and version %d\n", code_to_str(inv_resp[j].type),
		// 			inv_ops[j].key.tag, inv_ops[j].key.meta.cid, inv_ops[j].key.meta.version);
		if (inv_resp[j].type != CACHE_INV_SUCCESS) {
			coh_message_count[INV_VC][inv_ops[j].key.meta.cid]++;
			continue;
		}
		i = 0;
		do { // Look for an empty slot in the inv_to_send_ops buffer
			if (inv_to_send_ops[(*inv_push_ptr + i) % BCAST_TO_CACHE_BATCH].opcode != CACHE_OP_BRC) {
				*inv_push_ptr = (*inv_push_ptr + i) % BCAST_TO_CACHE_BATCH; // the use of the inv_push_ptr is not mandatory but only for performance
				break;
			}
			else i++;
		} while (i < BCAST_TO_CACHE_BATCH);
		if (ENABLE_ASSERTIONS) {
			if (unlikely(i == BCAST_TO_CACHE_BATCH)) {
				printf("Something is wrong with the invalidation back pressure\n"); // Back pressure if no empty slots
				printf("Inv size %d, looking at %d/%d\n", *inv_size, j, inv_ops_i);
			}
		}
		memcpy(inv_to_send_ops + (*inv_push_ptr), &(inv_ops[j]), HERD_GET_REQ_SIZE);
		if (ENABLE_ASSERTIONS == 1) {
			assert(inv_to_send_ops[*inv_push_ptr].opcode != CACHE_OP_BRC);
			assert(inv_to_send_ops[*inv_push_ptr].key.meta.cid <= MACHINE_NUM);
		}
		inv_to_send_ops[*inv_push_ptr].opcode = CACHE_OP_BRC;
		(*inv_size)++;
	}
}
// Find out which invalidations were successful and set up a buffer to be used to send the acks
Find out which invalidations were successful and set up a buffer to be used to send the acks
Find out which invalidations were successful and set up a buffer to be used to send the acks
static inline void invs_bookkeeping(uint16_t inv_ops_i, struct mica_resp* inv_resp, uint16_t coh_message_count[][MACHINE_NUM],
									struct small_cache_op* inv_ops, struct small_cache_op* inv_to_send_ops, uint16_t* inv_push_ptr,
									uint16_t* inv_size, uint16_t* debug_ptr)
{
	uint16_t j, i;
	for (j = 0; j < inv_ops_i; j++) {
		if (inv_resp[j].type != CACHE_INV_SUCCESS) {
			coh_message_count[INV_VC][inv_ops[j].key.meta.cid]++;
			continue;
		}
		i = 0;
		do { 
			if (inv_to_send_ops[(*inv_push_ptr + i) % BCAST_TO_CACHE_BATCH].opcode != CACHE_OP_BRC) {
				*inv_push_ptr = (*inv_push_ptr + i) % BCAST_TO_CACHE_BATCH; 
				break;
			}
			else i++;
		} while (i < BCAST_TO_CACHE_BATCH);
		if (ENABLE_ASSERTIONS) {
			if (unlikely(i == BCAST_TO_CACHE_BATCH)) {
				printf("Something is wrong with the invalidation back pressure\n"); 
				printf("Inv size %d, looking at %d/%d\n", *inv_size, j, inv_ops_i);
			}
		}
		memcpy(inv_to_send_ops + (*inv_push_ptr), &(inv_ops[j]), HERD_GET_REQ_SIZE);
		if (ENABLE_ASSERTIONS == 1) {
			assert(inv_to_send_ops[*inv_push_ptr].opcode != CACHE_OP_BRC);
			assert(inv_to_send_ops[*inv_push_ptr].key.meta.cid <= MACHINE_NUM);
		}
		inv_to_send_ops[*inv_push_ptr].opcode = CACHE_OP_BRC;
		(*inv_size)++;
	}
}
static inline void invs_bookkeeping ( uint16_t inv_ops_i , struct mica_resp * inv_resp , uint16_t coh_message_count [ ] [ MACHINE_NUM ] , struct small_cache_op * inv_ops , struct small_cache_op * inv_to_send_ops , uint16_t * inv_push_ptr , uint16_t * inv_size , uint16_t * debug_ptr ) { uint16_t j , i ; for ( j = 0 ; j < inv_ops_i ; j ++ ) { if ( inv_resp [ j ] . type != CACHE_INV_SUCCESS ) { coh_message_count [ INV_VC ] [ inv_ops [ j ] . key . meta . cid ] ++ ; continue ; } i = 0 ; do { if ( inv_to_send_ops [ ( * inv_push_ptr + i ) % BCAST_TO_CACHE_BATCH ] . opcode != CACHE_OP_BRC ) { * inv_push_ptr = ( * inv_push_ptr + i ) % BCAST_TO_CACHE_BATCH ; break ; } else i ++ ; } while ( i < BCAST_TO_CACHE_BATCH ) ; if ( ENABLE_ASSERTIONS ) { if ( unlikely ( i == BCAST_TO_CACHE_BATCH ) ) { printf ( " \n " ) ; printf ( " \n " , * inv_size , j , inv_ops_i ) ; } } memcpy ( inv_to_send_ops + ( * inv_push_ptr ) , & ( inv_ops [ j ] ) , HERD_GET_REQ_SIZE ) ; if ( ENABLE_ASSERTIONS == 1 ) { assert ( inv_to_send_ops [ * inv_push_ptr ] . opcode != CACHE_OP_BRC ) ; assert ( inv_to_send_ops [ * inv_push_ptr ] . key . meta . cid <= MACHINE_NUM ) ; } inv_to_send_ops [ * inv_push_ptr ] . opcode = CACHE_OP_BRC ; ( * inv_size ) ++ ; } }
Find out which invalidations were successful and set up a buffer to be used to send the acks
Find out which invalidations were successful and set up a buffer to be used to send the acks
// printf("response: %s to the Invalidation refers to key %d with cid %d and version %d\n", code_to_str(inv_resp[j].type), // 			inv_ops[j].key.tag, inv_ops[j].key.meta.cid, inv_ops[j].key.meta.version); // Look for an empty slot in the inv_to_send_ops buffer // the use of the inv_push_ptr is not mandatory but only for performance // Back pressure if no empty slots