// Initialize the NoC void noc_init(void) { /* if (CORE_ID == NOC_MASTER) puts("noc_configure"); */ noc_configure(); /* if (CORE_ID == NOC_MASTER) puts("noc_sync"); */ noc_sync(); /* if (CORE_ID == NOC_MASTER) puts("noc_done"); */ }
int main() { #ifdef MEASUREMENT timeStamps_master[0] = TDM_P_COUNTER; //start master initialization measurement #endif noc_configure(); noc_enable(); unsigned i; int slave_param = 1; int id = get_cpuid(); int cnt = get_cpucnt(); #ifdef MEASUREMENT timeStamps_master[1] = TDM_P_COUNTER; //stop master initialization measurement #endif #define PROD_CONS #ifdef PROD_CONS corethread_create(1, &producer, (void*)slave_param); corethread_create(2, &intermediate, (void*)slave_param); corethread_create(3, &consumer, (void*)slave_param); #endif #define MULTICORE_N #ifdef MULTICORE for (i=2; i<cnt; ++i) { int core_id = i; // The core number corethread_create(core_id, &slave, (void*)slave_param); } #endif printf("Threats are started!\n"); for(;;){ #define PRINT_ARRAY #ifdef PRINT_ARRAY for(int i=0;i<MSG_SIZE;i++){ printf("The Intermediate modified: data[%d] = %d \n",i, debug_print_interm[i]); printf("The Consumer modified: data[%d] = %d \n",i, debug_print_cons[i]); } #endif #ifdef MEASUREMENT // Producer timing metrics printf("-----------Producer Timing Metrics--------------------\n"); printf("Producer starts at %d TDM cycles\n", timeStamps_slave1[0]); printf("Producer end of computation at %d TDM cycles\n", timeStamps_slave1[1]); printf("Producer initialization Latency is %d TDM cycles\n", timeStamps_slave1[1]-timeStamps_slave1[0]); printf("Producer triggered at %d TDM cycles\n", timeStamps_slave1[2]); printf("Producer polls for %d TDM cycles\n", timeStamps_slave1[2]-timeStamps_slave1[1]); printf("Producer stops at %d TDM cycles\n", timeStamps_slave1[3]); printf("Producer communication Latency is %d TDM cycles\n", timeStamps_slave1[3]-timeStamps_slave1[2]); // slave 2 timing metrics printf("-----------Slave 2 Timing Metrics--------------------\n"); printf("Slave 2 starts at %d TDM cycles\n", timeStamps_slave2[0]); printf("Slave 2 end of computation at %d TDM cycles\n", timeStamps_slave2[1]); printf("Slave 2 initialization Latency is %d TDM cycles\n", timeStamps_slave2[1]-timeStamps_slave2[0]); printf("Slave 2 triggered at %d TDM cycles\n", timeStamps_slave2[2]); printf("Slave 2 polls for %d TDM cycles\n", timeStamps_slave2[2]-timeStamps_slave2[1]); printf("Slave 2 stops at %d TDM cycles\n", timeStamps_slave2[3]); printf("Slave 2 communication Latency is %d TDM cycles\n", timeStamps_slave2[3]-timeStamps_slave2[2]); // Consumer timing metrics printf("-----------Consumer Timing Metrics--------------------\n"); printf("Consumer starts at %d TDM cycles\n", timeStamps_slave3[0]); printf("Consumer end of computation at %d TDM cycles\n", timeStamps_slave3[1]); printf("Consumer initialization Latency is %d TDM cycles\n", timeStamps_slave3[1]-timeStamps_slave3[0]); printf("Consumer triggered at %d TDM cycles\n", timeStamps_slave3[2]); printf("Consumer polls for %d TDM cycles\n", timeStamps_slave3[2]-timeStamps_slave3[1]); printf("Consumer stops at %d TDM cycles\n", timeStamps_slave3[3]); printf("Consumer communication Latency is %d TDM cycles\n", timeStamps_slave3[3]-timeStamps_slave3[2]); //master printf("-----------Master Timing Metrics--------------------\n"); printf("Master starts at %d TDM cycles\n", timeStamps_master[0]); printf("The master initialization Latency is %d TDM cycles\n", timeStamps_master[1]-timeStamps_master[0]); printf("The End to End latency is %d TDM cycles\n", timeStamps_slave2[2]-timeStamps_master[0]); #endif } return 0; }