memory.c 1.7 KB

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