memory.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2014, 2015 CNRS
  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 <config.h>
  17. #include <starpu.h>
  18. #include <core/perfmodel/perfmodel.h>
  19. #include "../helper.h"
  20. /*
  21. * Test providing the memory perfmodel function
  22. */
  23. void func(void *descr[], void *arg)
  24. {
  25. }
  26. static struct starpu_perfmodel my_model =
  27. {
  28. .type = STARPU_HISTORY_BASED,
  29. .symbol = "my_model",
  30. };
  31. static struct starpu_codelet my_codelet =
  32. {
  33. .cpu_funcs = {func},
  34. .cpu_funcs_name = {"func"},
  35. .model = &my_model
  36. };
  37. double cuda_cost_function(struct starpu_task *t, struct starpu_perfmodel_arch *a, unsigned i)
  38. {
  39. t;
  40. a;
  41. return (double)i;
  42. }
  43. int main(int argc, char **argv)
  44. {
  45. int ret;
  46. ret = starpu_init(NULL);
  47. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  48. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  49. starpu_perfmodel_init(&my_model);
  50. starpu_perfmodel_set_per_devices_cost_function(&my_model, 0, cuda_cost_function, STARPU_CUDA_WORKER, 0, 1, -1);
  51. ret = starpu_task_insert(&my_codelet, 0);
  52. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  53. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  54. starpu_task_wait_for_all();
  55. starpu_shutdown();
  56. return EXIT_SUCCESS;
  57. }