TraceGenHandler.java 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // StarPU --- Runtime system for heterogeneous multicore architectures.
  2. //
  3. // Copyright (C) 2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. //
  5. // StarPU 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. // StarPU 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. package starpu.handlers;
  17. import java.awt.EventQueue;
  18. import java.io.File;
  19. import org.eclipse.core.commands.AbstractHandler;
  20. import org.eclipse.core.commands.ExecutionEvent;
  21. import org.eclipse.core.commands.ExecutionException;
  22. import org.eclipse.jface.dialogs.MessageDialog;
  23. import org.eclipse.ui.IWorkbenchWindow;
  24. import org.eclipse.ui.handlers.HandlerUtil;
  25. public class TraceGenHandler extends AbstractHandler {
  26. @Override
  27. public Object execute(ExecutionEvent event) throws ExecutionException {
  28. IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
  29. MessageDialog.openInformation(window.getShell(), "StarPU FxT Tool",
  30. "Running Starpu FxT Tool: generation of different trace formats");
  31. EventQueue.invokeLater(() -> {
  32. try {
  33. String value = System.getenv("STARPU_FXT_PREFIX");
  34. if (value != null) {
  35. System.out.println("STARPU_FXT_PREFIX=" + value);
  36. } else {
  37. System.out.println("STARPU_FXT_PREFIX does not have a value");
  38. value = "/tmp";
  39. }
  40. String value1 = System.getenv("STARPU_FXT_SUFFIX");
  41. if (value1 != null) {
  42. System.out.println("STARPU_FXT_SUFFIX=" + value1);
  43. } else {
  44. System.out.println("STARPU_FXT_SUFFIX does not have a value");
  45. String value2 = System.getenv("USER");
  46. value1 = "prof_file_" + value2 + "_0";
  47. }
  48. String inputfilename = value + "/" + value1;
  49. File f = new File(inputfilename);
  50. if (!f.isFile())
  51. throw new Exception("File <" + inputfilename + "> does not exist. Have you run your application?");
  52. String[] command = {"starpu_fxt_tool", "-i", inputfilename, "-d", TraceUtils.getRandomDirectoryName(), "-c", "-no-acquire"};
  53. TraceUtils.runCommand(command);
  54. } catch (Exception e) {
  55. TraceUtils.displayMessage("Error: " + e.toString());
  56. e.printStackTrace();
  57. }
  58. });
  59. return null;
  60. }
  61. }