event.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2012,2017 CNRS
  4. * Copyright (C) 2010-2013 Université de Bordeaux
  5. * Copyright (C) 2011,2012 Inria
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #include "socl.h"
  19. #include "event.h"
  20. #include "gc.h"
  21. static void release_callback_event(void * e);
  22. int event_unique_id()
  23. {
  24. static int id = 1;
  25. return __sync_fetch_and_add(&id,1);
  26. }
  27. /**
  28. * Create a new event
  29. *
  30. * Events have one-to-one relation with tag. Tag number is event ID
  31. */
  32. cl_event event_create(void)
  33. {
  34. cl_event ev;
  35. ev = gc_entity_alloc(sizeof(struct _cl_event), release_callback_event, "event");
  36. ev->id = event_unique_id();
  37. ev->status = CL_SUBMITTED;
  38. ev->command = NULL;
  39. ev->prof_queued = 0L;
  40. ev->prof_submit = 0L;
  41. ev->prof_start = 0L;
  42. ev->prof_end = 0L;
  43. ev->cq = NULL;
  44. return ev;
  45. }
  46. void event_complete(cl_event ev)
  47. {
  48. ev->status = CL_COMPLETE;
  49. ev->prof_end = _socl_nanotime();
  50. /* Trigger the tag associated to the command event */
  51. DEBUG_MSG("Trigger event %d\n", ev->id);
  52. starpu_tag_notify_from_apps(ev->id);
  53. }
  54. static void release_callback_event(void * e)
  55. {
  56. cl_event event = (cl_event)e;
  57. gc_entity_unstore(&event->cq);
  58. /* Destruct object */
  59. //FIXME
  60. //starpu_tag_remove(event->id);
  61. }