event.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010,2011 University of Bordeaux
  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. static int id = 1;
  22. return __sync_fetch_and_add(&id,1);
  23. }
  24. /**
  25. * Create a new event
  26. *
  27. * Events have one-to-one relation with tag. Tag number is event ID
  28. */
  29. cl_event event_create(void) {
  30. cl_event ev;
  31. ev = gc_entity_alloc(sizeof(struct _cl_event), release_callback_event, "event");
  32. ev->id = event_unique_id();
  33. ev->status = CL_SUBMITTED;
  34. ev->command = NULL;
  35. ev->profiling_info = NULL;
  36. ev->cq = NULL;
  37. return ev;
  38. }
  39. static void release_callback_event(void * e) {
  40. cl_event event = (cl_event)e;
  41. gc_entity_unstore(&event->cq);
  42. /* Destruct object */
  43. //FIXME
  44. //starpu_tag_remove(event->id);
  45. if (event->profiling_info != NULL) {
  46. free(event->profiling_info);
  47. event->profiling_info = NULL;
  48. }
  49. }