feed.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2012 Université de Bordeaux 1
  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. /*
  17. * Test the starpu_perfmodel_update_history function
  18. */
  19. #include <config.h>
  20. #include <starpu.h>
  21. #include "../helper.h"
  22. static struct starpu_perfmodel model =
  23. {
  24. .type = STARPU_REGRESSION_BASED,
  25. .symbol = "feed"
  26. };
  27. static struct starpu_perfmodel nl_model =
  28. {
  29. .type = STARPU_NL_REGRESSION_BASED,
  30. .symbol = "nlfeed"
  31. };
  32. static struct starpu_codelet cl =
  33. {
  34. .model = &model,
  35. .nbuffers = 1,
  36. .modes = {STARPU_W}
  37. };
  38. int main(int argc, char **argv)
  39. {
  40. struct starpu_task task;
  41. int ret;
  42. ret = starpu_init(NULL);
  43. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  44. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  45. if(starpu_worker_get_count_by_type(STARPU_CUDA_WORKER) < 2)
  46. return STARPU_TEST_SKIPPED;
  47. starpu_task_init(&task);
  48. task.cl = &cl;
  49. int size;
  50. for (size = 1024; size < 16777216; size *= 2)
  51. {
  52. float measured_fast, measured_slow;
  53. starpu_data_handle_t handle;
  54. starpu_vector_data_register(&handle, -1, 0, size, sizeof(float));
  55. task.handles[0] = handle;
  56. /* Simulate Fast GPU. In real applications this would be
  57. * replaced by fetching from actual measurement */
  58. measured_fast = 0.002+size*0.00000001;
  59. measured_slow = 0.001+size*0.0000001;
  60. struct starpu_perfmodel_arch arch;
  61. arch.type = STARPU_CUDA_WORKER;
  62. arch.ncore = 0;
  63. /* Simulate Fast GPU */
  64. arch.devid = 0;
  65. starpu_perfmodel_update_history(&model, &task, &arch, 0, 0, measured_fast);
  66. starpu_perfmodel_update_history(&nl_model, &task, &arch, 0, 0, measured_fast);
  67. /* Simulate Slow GPU */
  68. arch.devid = 1;
  69. starpu_perfmodel_update_history(&model, &task, &arch, 0, 0, measured_slow);
  70. starpu_perfmodel_update_history(&nl_model, &task, &arch, 0, 0, measured_slow);
  71. starpu_task_clean(&task);
  72. starpu_data_unregister(handle);
  73. }
  74. starpu_shutdown();
  75. return EXIT_SUCCESS;
  76. }