readonly.c 2.0 KB

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