Line 1... |
Line 1... |
#ifndef TRAFFIC_SYNTHETIC_H
|
#ifndef TRAFFIC_SYNTHETIC_H
|
#define TRAFFIC_SYNTHETIC_H
|
#define TRAFFIC_SYNTHETIC_H
|
|
|
|
|
#include "topology.h"
|
#define INJECT_OFF -1
|
|
|
|
//#include "topology.h"
|
|
|
|
|
extern int TRAFFIC_TYPE;
|
extern int TRAFFIC_TYPE;
|
extern int HOTSPOT_NUM;
|
extern int HOTSPOT_NUM;
|
extern char * TRAFFIC;
|
extern char * TRAFFIC;
|
extern unsigned char NEw;
|
extern unsigned char NEw;
|
|
|
|
int custom_traffic_table[NE];
|
|
|
typedef struct HOTSPOT_NODE {
|
typedef struct HOTSPOT_NODE {
|
int ip_num;
|
int ip_num;
|
char send_enable;
|
char send_enable;
|
int percentage; // x10
|
int percentage; // x10
|
} hotspot_st;
|
} hotspot_st;
|
|
|
hotspot_st * hotspots;
|
hotspot_st * hotspots;
|
|
|
|
unsigned int pck_dst_gen_1D (unsigned int);
|
|
|
// number, b:bit location W: number width log2(num)
|
// number, b:bit location W: number width log2(num)
|
int getBit(int num, int b, int W)
|
int getBit(int num, int b, int W)
|
{
|
{
|
while(b<0) b+=W;
|
while(b<0) b+=W;
|
Line 41... |
Line 43... |
else *num = *num | mask; // deassert bit
|
else *num = *num | mask; // deassert bit
|
|
|
}
|
}
|
|
|
|
|
|
unsigned int get_rnd_ip (unsigned int core_num){
|
|
unsigned int rnd=rand()%NE;
|
|
if(IS_SELF_LOOP_EN) return rnd;
|
|
//make sure its not same as sender core
|
|
while (rnd==core_num) rnd=rand()%NE;
|
|
return rnd;
|
|
}
|
|
|
|
#if (defined (IS_MESH) || defined (IS_TORUS) || defined (IS_LINE) || defined (IS_RING) )
|
|
|
unsigned int pck_dst_gen_2D (unsigned int core_num){
|
unsigned int pck_dst_gen_2D (unsigned int core_num){
|
//for mesh-tori
|
//for mesh-tori
|
unsigned int current_l,current_x, current_y;
|
unsigned int current_l,current_x, current_y;
|
unsigned int dest_l,dest_x,dest_y;
|
unsigned int dest_l,dest_x,dest_y;
|
Line 56... |
Line 65... |
unsigned int rnd100=0;
|
unsigned int rnd100=0;
|
unsigned int max_percent=100/HOTSPOT_NUM;
|
unsigned int max_percent=100/HOTSPOT_NUM;
|
int i;
|
int i;
|
|
|
if((strcmp (TRAFFIC,"RANDOM")==0) || (strcmp (TRAFFIC,"random")==0)){
|
if((strcmp (TRAFFIC,"RANDOM")==0) || (strcmp (TRAFFIC,"random")==0)){
|
do{
|
//get a random IP core
|
rnd=rand()%NE;
|
return endp_addr_encoder(get_rnd_ip(core_num));
|
}while (rnd==core_num); // get a random IP core, make sure its not same as sender core
|
|
return endp_addr_encoder(rnd);
|
|
}
|
}
|
|
|
if ((strcmp(TRAFFIC,"HOTSPOT")==0) || (strcmp (TRAFFIC,"hot spot")==0)){
|
if ((strcmp(TRAFFIC,"HOTSPOT")==0) || (strcmp (TRAFFIC,"hot spot")==0)){
|
unsigned int rnd1000=0;
|
unsigned int rnd1000=0;
|
do{
|
rnd=get_rnd_ip(core_num);
|
rnd=rand()%NE;
|
|
}while (rnd==core_num); // get a random IP core, make sure its not same as sender core
|
|
rnd1000=rand()%1000; // generate a random number between 0 & 1000
|
rnd1000=rand()%1000; // generate a random number between 0 & 1000
|
for (i=0;i<HOTSPOT_NUM; i++){
|
for (i=0;i<HOTSPOT_NUM; i++){
|
if ( hotspots[i].send_enable == 0 && core_num ==hotspots[i].ip_num){
|
if ( hotspots[i].send_enable == 0 && core_num ==hotspots[i].ip_num){
|
rnd = core_num; // turn off the core
|
//rnd = core_num; // turn off the core
|
return endp_addr_encoder(rnd);
|
//return endp_addr_encoder(rnd);
|
|
return INJECT_OFF;
|
}
|
}
|
}
|
}
|
for (i=0;i<HOTSPOT_NUM; i++){
|
for (i=0;i<HOTSPOT_NUM; i++){
|
if (rnd1000 < hotspots[i].percentage && core_num !=hotspots[i].ip_num) {
|
if (rnd1000 < hotspots[i].percentage && core_num !=hotspots[i].ip_num) {
|
rnd = hotspots[i].ip_num;
|
rnd = hotspots[i].ip_num;
|
Line 140... |
Line 147... |
dest_y = (current_y + 1)%T2;
|
dest_y = (current_y + 1)%T2;
|
dest_l = current_l;
|
dest_l = current_l;
|
return mesh_tori_addr_join(dest_x,dest_y,dest_l);
|
return mesh_tori_addr_join(dest_x,dest_y,dest_l);
|
}
|
}
|
|
|
if( strcmp(TRAFFIC ,"CUSTOM") == 0){
|
if(( strcmp(TRAFFIC ,"CUSTOM") == 0)|| (strcmp (TRAFFIC,"custom")==0)){
|
//[(x+(k/2-1)) mod k, (y+(k/2-1)) mod k],
|
if (custom_traffic_table[core_num]== INJECT_OFF) return INJECT_OFF;
|
if(current_x ==0 && current_y == 0 && current_l==0 ){
|
return endp_addr_encoder(custom_traffic_table[core_num]);
|
// dest_x = T1-1;
|
|
// dest_y = T2-1;
|
|
// dest_l = T3-1;
|
|
dest_x = 0;
|
|
dest_y = 0;
|
|
dest_l = 1;
|
|
return mesh_tori_addr_join(dest_x,dest_y,dest_l);
|
|
}// make it invalid
|
|
dest_x = current_x;
|
|
dest_y = current_y;
|
|
dest_l = current_l;
|
|
return mesh_tori_addr_join(dest_x,dest_y,dest_l);
|
|
|
|
}
|
}
|
|
|
printf ("traffic %s is an unsupported traffic pattern\n",TRAFFIC);
|
fprintf (stderr,"ERROR: traffic %s is an unsupported traffic pattern\n",TRAFFIC);
|
dest_x = current_x;
|
return INJECT_OFF;
|
dest_y = current_y;
|
|
dest_l = current_l;
|
|
return mesh_tori_addr_join(dest_x,dest_y,dest_l);
|
|
}
|
}
|
|
|
|
#else
|
|
|
|
unsigned int pck_dst_gen_2D (unsigned int core_num){
|
|
return pck_dst_gen_1D (core_num);
|
|
}
|
|
|
|
#endif
|
|
|
|
|
unsigned int pck_dst_gen_1D (unsigned int core_num){
|
unsigned int pck_dst_gen_1D (unsigned int core_num){
|
|
|
unsigned int rnd=0;
|
unsigned int rnd=0;
|
Line 177... |
Line 176... |
unsigned int max_percent=100/HOTSPOT_NUM;
|
unsigned int max_percent=100/HOTSPOT_NUM;
|
int i;
|
int i;
|
|
|
|
|
if((strcmp (TRAFFIC,"RANDOM")==0) || (strcmp (TRAFFIC,"random")==0)){
|
if((strcmp (TRAFFIC,"RANDOM")==0) || (strcmp (TRAFFIC,"random")==0)){
|
do{
|
return endp_addr_encoder(get_rnd_ip(core_num));
|
rnd=rand()%NE;
|
|
}while (rnd==core_num); // get a random IP core, make sure its not same as sender core
|
|
|
|
return endp_addr_encoder(rnd);
|
|
}
|
}
|
|
|
if ((strcmp(TRAFFIC,"HOTSPOT")==0) || (strcmp (TRAFFIC,"hot spot")==0)){
|
if ((strcmp(TRAFFIC,"HOTSPOT")==0) || (strcmp (TRAFFIC,"hot spot")==0)){
|
unsigned int rnd1000=0;
|
unsigned int rnd1000=0;
|
int i;
|
int i;
|
do{
|
rnd=get_rnd_ip(core_num);
|
rnd=rand()%NE;
|
|
}while (rnd==core_num); // get a random IP core, make sure its not same as sender core
|
|
rnd1000=rand()%1000; // generate a random number between 0 & 1000
|
rnd1000=rand()%1000; // generate a random number between 0 & 1000
|
for (i=0;i<HOTSPOT_NUM; i++){
|
for (i=0;i<HOTSPOT_NUM; i++){
|
if ( hotspots[i].send_enable == 0 && core_num ==hotspots[i].ip_num){
|
if ( hotspots[i].send_enable == 0 && core_num ==hotspots[i].ip_num){
|
rnd = core_num; // turn off the core
|
|
return endp_addr_encoder(rnd);
|
return INJECT_OFF;
|
}
|
}
|
}
|
}
|
|
|
for (i=0;i<HOTSPOT_NUM; i++){
|
for (i=0;i<HOTSPOT_NUM; i++){
|
if (rnd1000 < hotspots[i].percentage && core_num !=hotspots[i].ip_num) {
|
if (rnd1000 < hotspots[i].percentage && core_num !=hotspots[i].ip_num) {
|
Line 252... |
Line 245... |
if(( strcmp(TRAFFIC ,"NEIGHBOR") == 0)|| (strcmp (TRAFFIC,"neighbor")==0)){
|
if(( strcmp(TRAFFIC ,"NEIGHBOR") == 0)|| (strcmp (TRAFFIC,"neighbor")==0)){
|
//dx = sx + 1 mod k
|
//dx = sx + 1 mod k
|
return endp_addr_encoder((core_num + 1)%NE);
|
return endp_addr_encoder((core_num + 1)%NE);
|
}
|
}
|
|
|
if( strcmp(TRAFFIC ,"CUSTOM") == 0){
|
if(( strcmp(TRAFFIC ,"CUSTOM") == 0)|| (strcmp (TRAFFIC,"custom")==0)){
|
//[(x+(k/2-1)) mod k, (y+(k/2-1)) mod k],
|
if (custom_traffic_table[core_num]== INJECT_OFF) return INJECT_OFF;
|
if(core_num ==2 ) return endp_addr_encoder(6);
|
return endp_addr_encoder(custom_traffic_table[core_num]);
|
return endp_addr_encoder(core_num);
|
|
}
|
}
|
|
|
printf ("traffic %s is an unsupported traffic pattern\n",TRAFFIC);
|
fprintf (stderr,"ERROR: traffic %s is an unsupported traffic pattern\n",TRAFFIC);
|
return endp_addr_encoder(core_num);
|
return INJECT_OFF;
|
}
|
}
|
|
|
|
|
unsigned int rnd_between (unsigned int a, unsigned int b){
|
unsigned int rnd_between (unsigned int a, unsigned int b){
|
unsigned int rnd,diff,min;
|
unsigned int rnd,diff,min;
|