starpu_calibrate_bus.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2012 Inria
  4. * Copyright (C) 2009-2012,2014 Université de Bordeaux
  5. * Copyright (C) 2010-2012,2015,2017 CNRS
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #include <common/config.h>
  19. #include <starpu.h>
  20. #include <stdio.h>
  21. #if defined(_WIN32) && !defined(__CYGWIN__)
  22. #include <windows.h>
  23. #endif
  24. #define PROGNAME "starpu_calibrate_bus"
  25. static void usage(void)
  26. {
  27. (void) fprintf(stdout,
  28. "Force a bus calibration.\n\
  29. \n\
  30. Usage: %s [OPTION]\n\
  31. \n\
  32. Options:\n\
  33. -h, --help display this help and exit\n\
  34. -v, --version output version information and exit\n\
  35. \n\
  36. Report bugs to <%s>.\n", PROGNAME, PACKAGE_BUGREPORT);
  37. }
  38. static void parse_args(int argc, char **argv)
  39. {
  40. if (argc == 1)
  41. return;
  42. if (argc > 2)
  43. {
  44. usage();
  45. exit(EXIT_FAILURE);
  46. }
  47. if (strcmp(argv[1], "-h") == 0 ||
  48. strcmp(argv[1], "--help") == 0)
  49. {
  50. usage();
  51. exit(EXIT_SUCCESS);
  52. }
  53. else if (strcmp(argv[1], "-v") == 0 ||
  54. strcmp(argv[1], "--version") == 0)
  55. {
  56. fputs(PROGNAME " (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stderr);
  57. exit(EXIT_SUCCESS);
  58. }
  59. else
  60. {
  61. (void) fprintf(stderr, "Unknown arg %s\n", argv[1]);
  62. exit(EXIT_FAILURE);
  63. }
  64. }
  65. int main(int argc, char **argv)
  66. {
  67. int ret;
  68. struct starpu_conf conf;
  69. parse_args(argc, argv);
  70. starpu_conf_init(&conf);
  71. conf.bus_calibrate = 1;
  72. ret = starpu_init(&conf);
  73. if (ret == -ENODEV) return 77;
  74. if (ret != 0) return ret;
  75. starpu_shutdown();
  76. return 0;
  77. }