#include #include #include #include #include #include typedef struct{ int64_t dest; int64_t payload[3]; } packet_t; int main(void){ shared packet_t *sh_buf; packet_t *pr_buf; sh_buf = upc_all_alloc(9000*THREADS,sizeof(packet_t)); pr_buf = (packet_t *)(&sh_buf[MYTHREAD]); // generate lots of packets with random dest and correct src int64_t i; int64_t n_packet; if((100%THREADS) != 0){ if(MYTHREAD==0) printf("we require threads to divide 100\n"); return 1; } int64_t idx=0; for(n_packet=7000; n_packet<9000; n_packet+=100){ idx++; if(MYTHREAD==0) { printf("starting n_packet = %"PRId64"\n",n_packet); fflush(stdout); } // the bug only happens when we calloc each time packet_t *packet = calloc(n_packet,sizeof(packet_t)); // populate packets with destination and current idx int64_t width = n_packet/THREADS; for(i=0; i