pack.c 2.1 KB

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