readonly.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012 Centre National de la Recherche Scientifique
  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. #ifdef STARPU_USE_OPENCL
  19. #include <starpu_opencl.h>
  20. #endif
  21. #include "../helper.h"
  22. static void codelet(void *descr[], __attribute__ ((unused)) void *_args)
  23. {
  24. FPRINTF(stderr, "codelet\n");
  25. }
  26. static struct starpu_codelet cl =
  27. {
  28. #ifdef STARPU_USE_OPENCL
  29. .opencl_funcs = {codelet, NULL},
  30. #endif
  31. .nbuffers = 1,
  32. .modes = {STARPU_R}
  33. };
  34. int main(int argc, char **argv)
  35. {
  36. int ret;
  37. int var = 42;
  38. starpu_data_handle_t handle;
  39. ret = starpu_init(NULL);
  40. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  41. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  42. int copy = starpu_asynchronous_copy_disabled();
  43. FPRINTF(stderr, "copy %d\n", copy);
  44. starpu_variable_data_register(&handle, 0, (uintptr_t)&var, sizeof(var));
  45. ret = starpu_insert_task(&cl,
  46. STARPU_R, handle,
  47. 0);
  48. if (ret == -ENODEV) goto enodev;
  49. STARPU_CHECK_RETURN_VALUE(ret, "starpu_insert_task");
  50. starpu_task_wait_for_all();
  51. starpu_data_unregister(handle);
  52. starpu_shutdown();
  53. return 0;
  54. enodev:
  55. starpu_data_unregister(handle);
  56. starpu_shutdown();
  57. /* yes, we do not perform the computation but we did detect that no one
  58. * could perform the kernel, so this is not an error from StarPU */
  59. fprintf(stderr, "WARNING: No one can execute this task\n");
  60. return STARPU_TEST_SKIPPED;
  61. }