memory.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. void func(void *descr[], void *arg)
  21. {
  22. }
  23. static struct starpu_perfmodel my_model =
  24. {
  25. .type = STARPU_HISTORY_BASED,
  26. .symbol = "my_model",
  27. };
  28. static struct starpu_codelet my_codelet =
  29. {
  30. .cpu_funcs = {func},
  31. .cpu_funcs_name = {"func"},
  32. .model = &my_model
  33. };
  34. double cuda_cost_function(struct starpu_task *t, struct starpu_perfmodel_arch *a, unsigned i)
  35. {
  36. t;
  37. a;
  38. return (double)i;
  39. }
  40. int main(int argc, char **argv)
  41. {
  42. int ret;
  43. ret = starpu_init(NULL);
  44. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  45. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  46. starpu_perfmodel_init(&my_model);
  47. starpu_perfmodel_set_per_devices_cost_function(&my_model, 0, cuda_cost_function, STARPU_CUDA_WORKER, 0, 1, -1);
  48. ret = starpu_task_insert(&my_codelet, 0);
  49. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  50. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  51. starpu_task_wait_for_all();
  52. starpu_shutdown();
  53. return EXIT_SUCCESS;
  54. }