starpu_calibrate_bus.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011, 2012, 2017 CNRS
  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. #include <starpu.h>
  17. #include <stdio.h>
  18. #if defined(_WIN32) && !defined(__CYGWIN__)
  19. #include <windows.h>
  20. #endif
  21. #define PROGNAME "starpu_calibrate_bus"
  22. static void usage(void)
  23. {
  24. (void) fprintf(stdout,
  25. "Force a bus calibration.\n\
  26. \n\
  27. Usage: %s [OPTION]\n\
  28. \n\
  29. Options:\n\
  30. -h, --help display this help and exit\n\
  31. -v, --version output version information and exit\n\
  32. \n\
  33. Report bugs to <%s>.\n", PROGNAME, PACKAGE_BUGREPORT);
  34. }
  35. static void parse_args(int argc, char **argv)
  36. {
  37. if (argc == 1)
  38. return;
  39. if (argc > 2)
  40. {
  41. usage();
  42. exit(EXIT_FAILURE);
  43. }
  44. if (strcmp(argv[1], "-h") == 0 ||
  45. strcmp(argv[1], "--help") == 0)
  46. {
  47. usage();
  48. exit(EXIT_SUCCESS);
  49. }
  50. else if (strcmp(argv[1], "-v") == 0 ||
  51. strcmp(argv[1], "--version") == 0)
  52. {
  53. fputs(PROGNAME " (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stderr);
  54. exit(EXIT_SUCCESS);
  55. }
  56. else
  57. {
  58. (void) fprintf(stderr, "Unknown arg %s\n", argv[1]);
  59. exit(EXIT_FAILURE);
  60. }
  61. }
  62. int main(int argc, char **argv)
  63. {
  64. int ret;
  65. struct starpu_conf conf;
  66. parse_args(argc, argv);
  67. starpu_conf_init(&conf);
  68. conf.bus_calibrate = 1;
  69. ret = starpu_init(&conf);
  70. if (ret == -ENODEV) return 77;
  71. if (ret != 0) return ret;
  72. starpu_shutdown();
  73. return 0;
  74. }