starpu_insert_task.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * StarPU
  3. * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
  4. *
  5. * This program 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. * This program 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. /* This file provides an interface that is very similar to that of the Quark
  17. * scheduler from the PLASMA project (see http://icl.cs.utk.edu/plasma/). */
  18. #include <starpu.h>
  19. #include <common/config.h>
  20. #include <stdarg.h>
  21. #include <util/starpu_insert_task_utils.h>
  22. void starpu_unpack_cl_args(void *_cl_arg, ...)
  23. {
  24. unsigned char *cl_arg = _cl_arg;
  25. unsigned current_arg_offset = 0;
  26. va_list varg_list;
  27. va_start(varg_list, _cl_arg);
  28. /* We fill the different pointers with the appropriate arguments */
  29. unsigned char nargs = cl_arg[0];
  30. current_arg_offset += sizeof(char);
  31. unsigned arg;
  32. for (arg = 0; arg < nargs; arg++)
  33. {
  34. void *argptr = va_arg(varg_list, void *);
  35. size_t arg_size = *(size_t *)&cl_arg[current_arg_offset];
  36. current_arg_offset += sizeof(size_t);
  37. memcpy(argptr, &cl_arg[current_arg_offset], arg_size);
  38. current_arg_offset += arg_size;
  39. }
  40. va_end(varg_list);
  41. /* XXX this should not really be done in StarPU but well .... */
  42. free(_cl_arg);
  43. }
  44. void starpu_insert_task(starpu_codelet *cl, ...)
  45. {
  46. va_list varg_list;
  47. /* The buffer will contain : nargs, {size, content} (x nargs)*/
  48. /* Compute the size */
  49. size_t arg_buffer_size = 0;
  50. va_start(varg_list, cl);
  51. arg_buffer_size = starpu_insert_task_get_arg_size(varg_list);
  52. va_start(varg_list, cl);
  53. struct starpu_task *task = starpu_task_create();
  54. starpu_insert_task_create_and_submit(arg_buffer_size, cl, &task, varg_list);
  55. }