memory.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2014 Centre National de la Recherche Scientifique
  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. .model = &my_model
  32. };
  33. double cuda_cost_function(struct starpu_task *t, struct starpu_perfmodel_arch *a, unsigned i)
  34. {
  35. t;
  36. a;
  37. return (double)i;
  38. }
  39. int main(int argc, char **argv)
  40. {
  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. starpu_perfmodel_init(NULL, &my_model);
  46. starpu_perfmodel_set_per_devices_cost_function(&my_model, 0, cuda_cost_function, STARPU_CUDA_WORKER, 0, 1, -1);
  47. ret = starpu_task_insert(&my_codelet, 0);
  48. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  49. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  50. starpu_task_wait_for_all();
  51. starpu_shutdown();
  52. return EXIT_SUCCESS;
  53. }