perfmodel-display.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 <starpu.h>
  17. #include <assert.h>
  18. #include <stdio.h>
  19. #include <starpu-perfmodel.h>
  20. static struct starpu_perfmodel_t model;
  21. static void display_perf_model(struct starpu_perfmodel_t *model, enum starpu_perf_archtype arch)
  22. {
  23. struct starpu_per_arch_perfmodel_t *arch_model = &model->per_arch[arch];
  24. fprintf(stderr, "\tRegression : #sample = %d (%s)\n",
  25. arch_model->regression.nsample, arch_model->regression.valid?"VALID":"INVALID");
  26. /* Only display the regression model if we could actually build a model */
  27. if (arch_model->regression.valid)
  28. {
  29. fprintf(stderr, "\tLinear: y = alpha size ^ beta\n");
  30. fprintf(stderr, "\t\talpha = %le\n", arch_model->regression.alpha);
  31. fprintf(stderr, "\t\tbeta = %le\n", arch_model->regression.beta);
  32. fprintf(stderr, "\tNon-Linear: y = a size ^b + c\n");
  33. fprintf(stderr, "\t\ta = %le\n", arch_model->regression.a);
  34. fprintf(stderr, "\t\tb = %le\n", arch_model->regression.b);
  35. fprintf(stderr, "\t\tc = %le\n", arch_model->regression.c);
  36. }
  37. }
  38. static void display_all_perf_models(struct starpu_perfmodel_t *model)
  39. {
  40. /* yet, we assume there is a single performance model per architecture */
  41. fprintf(stderr, "performance model for CPUs :\n");
  42. display_perf_model(model, STARPU_CORE_DEFAULT);
  43. fprintf(stderr, "performance model for CUDA :\n");
  44. display_perf_model(model, STARPU_CUDA_DEFAULT);
  45. fprintf(stderr, "performance model for GORDON :\n");
  46. display_perf_model(model, STARPU_GORDON_DEFAULT);
  47. }
  48. int main(int argc, char **argv)
  49. {
  50. assert(argc == 2);
  51. const char *symbol = argv[1];
  52. fprintf(stderr, "symbol : %s\n", symbol);
  53. int ret = starpu_load_history_debug(symbol, &model);
  54. if (ret == 1)
  55. {
  56. fprintf(stderr, "The performance model could not be loaded\n");
  57. return 1;
  58. }
  59. fprintf(stderr, "Performance loaded\n");
  60. display_all_perf_models(&model);
  61. return 0;
  62. }