summaryrefslogtreecommitdiff
path: root/include/cl_event.h
blob: 39aa8261fda117d61987dc2e53e969aeb8b1ba04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * Copyright © 2012 Intel Corporation
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef __CL_EVENT_H__
#define __CL_EVENT_H__

#include <stdint.h>
#include "CL/cl.h"

typedef void (CL_CALLBACK *cl_event_notify)(cl_event event, cl_int event_command_exec_status, void *user_data);
typedef struct _cl_event_user_cb {
  cl_int status;                  /* The execution status */
  cl_bool executed;               /* Indicat the callback function been called or not */
  cl_event_notify pfn_notify;     /* Callback function */
  void* user_data;                /* Callback user data */
  struct _cl_event_user_cb* next; /* Next event callback in list */
} _cl_event_user_cb;

typedef struct _cl_event_user_cb* cl_event_user_cb;

typedef struct _cl_event {
  uint64_t magic;                 /* To identify it as a sampler object */
  volatile int ref_n;             /* We reference count this object */
  cl_event prev, next;            /* We chain the event in context together */
  cl_context ctx;                 /* The context associated with event */
  cl_command_queue queue;         /* The command queue associated with event, NULL for usr event */
  cl_command_type type;           /* The command type associated with event */
  cl_int status;                  /* The execution status */
  cl_event_user_cb user_cb;       /* User set callback. */
  cl_bool user_event;             /* User create event. */
  cl_int marker_or_barrier;       /* Is marker or barrier. 1 for marker, 2 for barrier. */
  cl_ulong timestamp[4];          /* The time stamps for profiling. */
  cl_event* wait_events;          /* The events we are waiting for. */
  cl_uint wait_event_num;         /* The waiting list number. */
  cl_int (*set_status)(cl_event event, cl_int status);  /* The function to update the status. */
  pthread_mutex_t lock;           /* The lock to protect the struct. */
} _cl_event;

typedef _cl_event* cl_event;

#define IS_MARKER_EVENT(E) (E->marker_or_barrier == 1)
#define IS_BARRIER_EVENT(E) (E->marker_or_barrier == 2)
#define SET_MARKER_EVENT(E) (E->marker_or_barrier = 1)
#define SET_BARRIER_EVENT(E) (E->marker_or_barrier = 2)

#endif /* __CL_EVENT_H__ */