fxt.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (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 <common/fxt.h>
  17. #define PROF_BUFFER_SIZE (8*1024*1024)
  18. static char PROF_FILE_USER[128];
  19. static int fxt_started = 0;
  20. static void profile_stop(void)
  21. {
  22. fut_endup(PROF_FILE_USER);
  23. }
  24. static void profile_set_tracefile(char *fmt, ...)
  25. {
  26. va_list vl;
  27. va_start(vl, fmt);
  28. vsprintf(PROF_FILE_USER, fmt, vl);
  29. va_end(vl);
  30. strcat(PROF_FILE_USER, "_user_");
  31. }
  32. void start_fxt_profiling(void)
  33. {
  34. unsigned threadid;
  35. if (!fxt_started) {
  36. fxt_started = 1;
  37. profile_set_tracefile("/tmp/prof_file");
  38. }
  39. threadid = syscall(SYS_gettid);
  40. atexit(profile_stop);
  41. if(fut_setup(PROF_BUFFER_SIZE, FUT_KEYMASKALL, threadid) < 0) {
  42. perror("fut_setup");
  43. STARPU_ASSERT(0);
  44. }
  45. fut_keychange(FUT_ENABLE, FUT_KEYMASKALL, threadid);
  46. return;
  47. }
  48. void fxt_register_thread(unsigned coreid)
  49. {
  50. FUT_DO_PROBE2(FUT_NEW_LWP_CODE, coreid, syscall(SYS_gettid));
  51. }