feed.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #ifdef STARPU_USE_OPENCL
  22. #include <starpu_opencl.h>
  23. #endif
  24. #include "../helper.h"
  25. static struct starpu_perfmodel model =
  26. {
  27. .type = STARPU_REGRESSION_BASED,
  28. .symbol = "feed"
  29. };
  30. static struct starpu_perfmodel nl_model =
  31. {
  32. .type = STARPU_NL_REGRESSION_BASED,
  33. .symbol = "nlfeed"
  34. };
  35. static struct starpu_codelet cl =
  36. {
  37. .model = &model,
  38. .nbuffers = 1,
  39. .modes = {STARPU_W}
  40. };
  41. int main(int argc, char **argv)
  42. {
  43. struct starpu_task task;
  44. int ret;
  45. ret = starpu_init(NULL);
  46. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  47. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  48. starpu_task_init(&task);
  49. task.cl = &cl;
  50. int size;
  51. for (size = 1024; size < 16777216; size *= 2)
  52. {
  53. float measured_fast, measured_slow;
  54. starpu_data_handle_t handle;
  55. starpu_vector_data_register(&handle, -1, 0, size, sizeof(float));
  56. task.handles[0] = handle;
  57. /* Simulate Fast GPU. In real applications this would be
  58. * replaced by fetching from actual measurement */
  59. measured_fast = 0.002+size*0.00000001;
  60. measured_slow = 0.001+size*0.0000001;
  61. /* Simulate Fast GPU */
  62. starpu_perfmodel_update_history(&model, &task, STARPU_CUDA_DEFAULT, 0, 0, measured_fast);
  63. starpu_perfmodel_update_history(&nl_model, &task, STARPU_CUDA_DEFAULT, 0, 0, measured_fast);
  64. /* Simulate Slow GPU */
  65. starpu_perfmodel_update_history(&model, &task, STARPU_CUDA_DEFAULT + 1, 0, 0, measured_slow);
  66. starpu_perfmodel_update_history(&nl_model, &task, STARPU_CUDA_DEFAULT + 1, 0, 0, measured_slow);
  67. starpu_task_clean(&task);
  68. starpu_data_unregister(handle);
  69. }
  70. starpu_shutdown();
  71. return EXIT_SUCCESS;
  72. }