summaryrefslogtreecommitdiff
path: root/src/cl_enqueue.h
blob: 50a54fcd94f027cb7dbd04a41e95b48e5a910a94 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 * 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/>.
 *
 * Author: Rong Yang <rong.r.yang@intel.com>
 */
#ifndef __CL_ENQUEUE_H__
#define __CL_ENQUEUE_H__

#include "cl_internals.h"
#include "cl_driver.h"
#include "CL/cl.h"

typedef enum {
  EnqueueReturnSuccesss = 0, /* For some case, we have nothing to do, just return SUCCESS. */
  EnqueueReadBuffer,
  EnqueueReadBufferRect,
  EnqueueWriteBuffer,
  EnqueueWriteBufferRect,
  EnqueueCopyBuffer,
  EnqueueCopyBufferRect,
  EnqueueReadImage,
  EnqueueWriteImage,
  EnqueueCopyImage,
  EnqueueCopyImageToBuffer,
  EnqueueCopyBufferToImage,
  EnqueueMapBuffer,
  EnqueueMapImage,
  EnqueueUnmapMemObject,
  EnqueueNDRangeKernel,
  EnqueueNativeKernel,
  EnqueueMarker,
  EnqueueBarrier,
  EnqueueFillBuffer,
  EnqueueFillImage,
  EnqueueMigrateMemObj,
  EnqueueSVMFree,
  EnqueueSVMMemCopy,
  EnqueueSVMMemFill,
  EnqueueInvalid
} enqueue_type;

typedef struct _enqueue_data {
  enqueue_type type;         /* Command type */
  cl_mem mem_obj;            /* Enqueue's cl_mem */
  cl_command_queue queue;    /* Command queue */
  size_t offset;             /* Mem object's offset */
  size_t size;               /* Size */
  size_t origin[3];          /* Origin */
  size_t host_origin[3];     /* Origin */
  size_t region[3];          /* Region */
  size_t row_pitch;          /* Row pitch */
  size_t slice_pitch;        /* Slice pitch */
  size_t host_row_pitch;     /* Host row pitch, used in read/write buffer rect */
  size_t host_slice_pitch;   /* Host slice pitch, used in read/write buffer rect */
  const void *const_ptr;     /* Const ptr for memory read */
  void *ptr;                 /* Ptr for write and return value */
  const cl_mem *mem_list;    /* mem_list of clEnqueueNativeKernel */
  uint8_t unsync_map;        /* Indicate the clEnqueueMapBuffer/Image is unsync map */
  uint8_t write_map;         /* Indicate if the clEnqueueMapBuffer is write enable */
  void ** pointers;          /* The svm_pointers of clEnqueueSVMFree  */
  size_t  pattern_size;      /* the pattern_size of clEnqueueSVMMemFill */
  void (*user_func)(void *); /* pointer to a host-callable user function */
  void (CL_CALLBACK *free_func)( cl_command_queue queue,
                                 cl_uint num_svm_pointers,
                                 void *svm_pointers[],
                                 void *user_data);  /* pointer to pfn_free_func of clEnqueueSVMFree */
  cl_gpgpu gpgpu;
  cl_bool mid_event_of_enq;  /* For non-uniform ndrange, one enqueue have a sequence event, the
                                last event need to parse device enqueue information.
                                0 : last event; 1: non-last event */
} enqueue_data;

/* Do real enqueue commands */
extern cl_int cl_enqueue_handle(enqueue_data *data, cl_int status);
extern void cl_enqueue_delete(enqueue_data *data);

#endif /* __CL_ENQUEUE_H__ */