event.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  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 "socl.h"
  17. #include "event.h"
  18. #include "gc.h"
  19. static void release_callback_event(void * e);
  20. int event_unique_id()
  21. {
  22. static int id = 1;
  23. return __sync_fetch_and_add(&id,1);
  24. }
  25. /**
  26. * Create a new event
  27. *
  28. * Events have one-to-one relation with tag. Tag number is event ID
  29. */
  30. cl_event event_create(void)
  31. {
  32. cl_event ev;
  33. ev = gc_entity_alloc(sizeof(struct _cl_event), release_callback_event, "event");
  34. ev->id = event_unique_id();
  35. ev->status = CL_SUBMITTED;
  36. ev->command = NULL;
  37. ev->prof_queued = 0L;
  38. ev->prof_submit = 0L;
  39. ev->prof_start = 0L;
  40. ev->prof_end = 0L;
  41. ev->cq = NULL;
  42. return ev;
  43. }
  44. void event_complete(cl_event ev)
  45. {
  46. ev->status = CL_COMPLETE;
  47. ev->prof_end = _socl_nanotime();
  48. /* Trigger the tag associated to the command event */
  49. DEBUG_MSG("Trigger event %d\n", ev->id);
  50. starpu_tag_notify_from_apps(ev->id);
  51. }
  52. static void release_callback_event(void * e)
  53. {
  54. cl_event event = (cl_event)e;
  55. gc_entity_unstore(&event->cq);
  56. /* Destruct object */
  57. //FIXME
  58. //starpu_tag_remove(event->id);
  59. }