memory.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2014,2015,2017 CNRS
  4. * Copyright (C) 2014-2016 Université de Bordeaux
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  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. (void)descr;
  26. (void)arg;
  27. }
  28. static struct starpu_perfmodel my_model =
  29. {
  30. .type = STARPU_HISTORY_BASED,
  31. .symbol = "my_model",
  32. };
  33. static struct starpu_codelet my_codelet =
  34. {
  35. .cpu_funcs = {func},
  36. .cpu_funcs_name = {"func"},
  37. .model = &my_model
  38. };
  39. double cuda_cost_function(struct starpu_task *t, struct starpu_perfmodel_arch *a, unsigned i)
  40. {
  41. t;
  42. a;
  43. return (double)i;
  44. }
  45. int main(void)
  46. {
  47. int ret;
  48. ret = starpu_init(NULL);
  49. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  50. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  51. starpu_perfmodel_init(&my_model);
  52. starpu_perfmodel_set_per_devices_cost_function(&my_model, 0, cuda_cost_function, STARPU_CUDA_WORKER, 0, 1, -1);
  53. ret = starpu_task_insert(&my_codelet, 0);
  54. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  55. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  56. starpu_task_wait_for_all();
  57. starpu_shutdown();
  58. return EXIT_SUCCESS;
  59. }