summaryrefslogtreecommitdiff
path: root/include/cl_program.h
blob: f8e57e7dfd4c4b657e685bc081eee558adaafb82 (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
/*
 * 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_PROGRAM_H__
#define __CL_PROGRAM_H__

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

enum {
  FROM_SOURCE = 0,
  FROM_BINARY = 1,
  FROM_SPIR = 2,
};

#define CL_BUILD_LOG_MAX_SZ 1024

typedef struct _cl_program_device_status {
  char *build_opts;                       /* The build options for this program */
  uint32_t binary_type;                   /* binary type: spir, executable, etc. */
  int32_t build_status;                   /* build status. */
  char build_log[CL_BUILD_LOG_MAX_SZ];    /* The build log for this program, each device has its own. */
  size_t build_log_sz;                    /* The actual build log size for each device.*/
} _cl_program_device_status;
typedef _cl_program_device_status* cl_program_device_status;

/* This define an OCL file containing some kernels */
typedef struct _cl_program {
  uint64_t magic;                         /* To identify it as a program */
  volatile int ref_n;                     /* We reference count this object */
  cl_program prev, next;                  /* We chain the programs together */
  cl_kernel kernels;                      /* All kernels created in this program. */
  uint32_t kernel_num;                    /* Number of declared kernels */
  uint32_t kernel_created;                /* Number of created kernels */
  char *kernel_names;                     /* Program sources */
  cl_context ctx;                         /* Its parent context */
  char *source;                           /* Program sources */
  uint32_t source_type;                   /* Built from binary, source, spir, etc. */
  cl_program_device_status device_status; /* The build status for each device. */
  pthread_mutex_t lock;                   /* The lock to protect the program. */
  void *notify_data;
  void *pdata;
} _cl_program;

#endif /* __CL_PROGRAM_H__ */