hello_world_msvc.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-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. struct params
  18. {
  19. int i;
  20. float f;
  21. };
  22. void cpu_func(void *buffers[], void *cl_arg)
  23. {
  24. struct params *params = cl_arg;
  25. printf("Hello world (params = {%i, %f} )\n", params->i, params->f);
  26. }
  27. void callback_func(void *callback_arg)
  28. {
  29. printf("Callback function (arg %p)\n", callback_arg);
  30. }
  31. int main(int argc, char **argv)
  32. {
  33. int ret;
  34. struct starpu_codelet cl;
  35. struct starpu_task *task;
  36. struct params params;
  37. starpu_codelet_init(&cl);
  38. cl.cpu_funcs[0] = cpu_func;
  39. cl.nbuffers = 0;
  40. /* initialize StarPU */
  41. ret = starpu_init(NULL);
  42. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  43. task = starpu_task_create();
  44. task->cl = &cl; /* Pointer to the codelet defined above */
  45. params.i = 1;
  46. params.f = 2.0f;
  47. task->cl_arg = &params;
  48. task->cl_arg_size = sizeof(params);
  49. task->callback_func = callback_func;
  50. task->callback_arg = (void*) (uintptr_t) 0x42;
  51. /* starpu_task_submit will be a blocking call */
  52. task->synchronous = 1;
  53. /* submit the task to StarPU */
  54. ret = starpu_task_submit(task);
  55. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  56. /* terminate StarPU */
  57. starpu_shutdown();
  58. return 0;
  59. }