starpu_calibrate_bus.c 1.9 KB

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