pack.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 "../helper.h"
  19. void func_cpu(void *descr[], void *_args)
  20. {
  21. int factor;
  22. char c;
  23. int x;
  24. starpu_codelet_unpack_args(_args, &factor, &c, &x);
  25. FPRINTF(stderr, "values: %d %c %d\n", factor, c, x);
  26. assert(factor == 12 && c == 'n' && x == 42);
  27. }
  28. struct starpu_codelet mycodelet =
  29. {
  30. .cpu_funcs = {func_cpu},
  31. .cpu_funcs_name = {"func_cpu"},
  32. .nbuffers = 0
  33. };
  34. int main(int argc, char **argv)
  35. {
  36. int i, ret;
  37. int x=42;
  38. int factor=12;
  39. char c='n';
  40. struct starpu_task *task;
  41. ret = starpu_init(NULL);
  42. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  43. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  44. FPRINTF(stderr, "values: %d %c %d\n", factor, c, x);
  45. task = starpu_task_create();
  46. task->synchronous = 1;
  47. task->cl = &mycodelet;
  48. task->cl_arg_free = 1;
  49. starpu_codelet_pack_args(&task->cl_arg, &task->cl_arg_size,
  50. STARPU_VALUE, &factor, sizeof(factor),
  51. STARPU_VALUE, &c, sizeof(c),
  52. STARPU_VALUE, &x, sizeof(x),
  53. 0);
  54. ret = starpu_task_submit(task);
  55. if (ret != -ENODEV)
  56. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  57. starpu_shutdown();
  58. if (ret == -ENODEV)
  59. {
  60. fprintf(stderr, "WARNING: No one can execute this task\n");
  61. /* yes, we do not perform the computation but we did detect that no one
  62. * could perform the kernel, so this is not an error from StarPU */
  63. return STARPU_TEST_SKIPPED;
  64. }
  65. else
  66. return 0;
  67. }