hello_world_msvc.c 1.8 KB

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