123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- #include "fxt_tool.h"
- int find_sync_point(char *filename_in, uint64_t *offset, int *key, int *rank)
- {
- STARPU_ASSERT(offset);
-
- int fd_in;
- fd_in = open(filename_in, O_RDONLY);
- if (fd_in < 0) {
- perror("open failed :");
- exit(-1);
- }
- static fxt_t fut;
- fut = fxt_fdopen(fd_in);
- if (!fut) {
- perror("fxt_fdopen :");
- exit(-1);
- }
-
- fxt_blockev_t block;
- block = fxt_blockev_enter(fut);
- struct fxt_ev_64 ev;
- int func_ret = -1;
- unsigned found = 0;
- while(!found) {
- int ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
- if (ret != FXT_EV_OK) {
- fprintf(stderr, "no more block ...\n");
- break;
- }
- if (ev.code == FUT_MPI_BARRIER)
- {
-
- *offset = ev.time;
- *rank = ev.param[0];
- *key = ev.param[2];
- found = 1;
- func_ret = 0;
- }
- }
-
- if (close(fd_in))
- {
- perror("close failed :");
- exit(-1);
- }
- return func_ret;
- }
- static struct mpi_transfer *mpi_sends[64] = {NULL};
- static struct mpi_transfer *mpi_recvs[64] = {NULL};
- unsigned mpi_sends_list_size[64] = {0};
- unsigned mpi_recvs_list_size[64] = {0};
- unsigned mpi_sends_used[64] = {0};
- unsigned mpi_recvs_used[64] = {0};
- unsigned mpi_recvs_matched[64] = {0};
- void add_mpi_send_transfer(int src, int dst, int mpi_tag, size_t size, float date)
- {
- unsigned slot = mpi_sends_used[src]++;
- if (mpi_sends_used[src] > mpi_sends_list_size[src])
- {
- if (mpi_sends_list_size[src] > 0)
- {
- mpi_sends_list_size[src] *= 2;
- }
- else {
- mpi_sends_list_size[src] = 1;
- }
- mpi_sends[src] = realloc(mpi_sends[src], mpi_sends_list_size[src]*sizeof(struct mpi_transfer));
- }
- mpi_sends[src][slot].matched = 0;
- mpi_sends[src][slot].other_rank = dst;
- mpi_sends[src][slot].mpi_tag = mpi_tag;
- mpi_sends[src][slot].size = size;
- mpi_sends[src][slot].date = date;
- }
- void add_mpi_recv_transfer(int src, int dst, int mpi_tag, float date)
- {
- unsigned slot = mpi_recvs_used[dst]++;
- if (mpi_recvs_used[dst] > mpi_recvs_list_size[dst])
- {
- if (mpi_recvs_list_size[dst] > 0)
- {
- mpi_recvs_list_size[dst] *= 2;
- }
- else {
- mpi_recvs_list_size[dst] = 1;
- }
- mpi_recvs[dst] = realloc(mpi_recvs[dst], mpi_recvs_list_size[dst]*sizeof(struct mpi_transfer));
- }
- mpi_recvs[dst][slot].matched = 0;
- mpi_recvs[dst][slot].other_rank = dst;
- mpi_recvs[dst][slot].mpi_tag = mpi_tag;
- mpi_recvs[dst][slot].date = date;
- }
- struct mpi_transfer *try_to_match_send_transfer(int src, int dst, int mpi_tag)
- {
- unsigned slot;
- unsigned firstslot = mpi_recvs_matched[dst];
- unsigned all_previous_were_matched = 1;
- for (slot = firstslot; slot < mpi_recvs_used[dst]; slot++)
- {
- if (!mpi_recvs[dst][slot].matched)
- {
- if (mpi_recvs[dst][slot].mpi_tag == mpi_tag)
- {
-
- mpi_recvs[dst][slot].matched = 1;
- return &mpi_recvs[dst][slot];
- }
- all_previous_were_matched = 0;
- }
- else {
- if (all_previous_were_matched)
- {
-
- mpi_recvs_matched[dst] = slot;
- }
- }
- }
-
- return NULL;
- }
- static unsigned long mpi_com_id = 0;
- void display_all_transfers_from_trace(FILE *out_paje_file, int src)
- {
- unsigned slot;
- for (slot = 0; slot < mpi_sends_used[src]; slot++)
- {
- int dst = mpi_sends[src][slot].other_rank;
- int mpi_tag = mpi_sends[src][slot].mpi_tag;
- float start_date = mpi_sends[src][slot].date;
- size_t size = mpi_sends[src][slot].size;
- struct mpi_transfer *match;
- match = try_to_match_send_transfer(src, dst, mpi_tag);
- if (match)
- {
- float end_date = match->date;
- unsigned long id = mpi_com_id++;
-
- fprintf(out_paje_file, "18 %f MPIL MPIroot %d mpi_%d_p mpicom_%ld\n", start_date, size, src, id);
- fprintf(out_paje_file, "19 %f MPIL MPIroot %d mpi_%d_p mpicom_%ld\n", end_date, size, dst, id);
- }
- else
- {
- fprintf(stderr, "Warning, could not match MPI transfer from %d to %d (tag %x) starting at %f\n",
- src, dst, mpi_tag, start_date);
- }
- }
- }
|