fxt-tool-mpi.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2010 (see AUTHORS file)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include "fxt-tool.h"
  17. /* Returns 0 if a barrier is found, -1 otherwise. In case of success, offset is
  18. * filled with the timestamp of the barrier */
  19. int find_sync_point(char *filename_in, uint64_t *offset, int *key)
  20. {
  21. STARPU_ASSERT(offset);
  22. /* Open the trace file */
  23. int fd_in;
  24. fd_in = open(filename_in, O_RDONLY);
  25. if (fd_in < 0) {
  26. perror("open failed :");
  27. exit(-1);
  28. }
  29. static fxt_t fut;
  30. fut = fxt_fdopen(fd_in);
  31. if (!fut) {
  32. perror("fxt_fdopen :");
  33. exit(-1);
  34. }
  35. fxt_blockev_t block;
  36. block = fxt_blockev_enter(fut);
  37. struct fxt_ev_64 ev;
  38. int func_ret = -1;
  39. unsigned found = 0;
  40. while(!found) {
  41. int ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
  42. if (ret != FXT_EV_OK) {
  43. fprintf(stderr, "no more block ...\n");
  44. break;
  45. }
  46. if (ev.code == FUT_MPI_BARRIER)
  47. {
  48. /* We found the sync point */
  49. *offset = ev.time;
  50. *key = ev.param[2];
  51. found = 1;
  52. func_ret = 0;
  53. }
  54. }
  55. /* Close the trace file */
  56. if (close(fd_in))
  57. {
  58. perror("close failed :");
  59. exit(-1);
  60. }
  61. return func_ret;
  62. }