-
Notifications
You must be signed in to change notification settings - Fork 297
/
omc_ocl_common_header.h
116 lines (85 loc) · 2.89 KB
/
omc_ocl_common_header.h
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Linköping University,
* Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
* AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
* ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from Linköping University, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
* OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/
/*
Common hader file included by other headers in the openCLRuntime
Mahder.Gebremedhin@liu.se 2012-03-31
*/
#ifndef _OMC_OCL_COMMON_HEADER
#define _OMC_OCL_COMMON_HEADER
#define CL_TARGET_OPENCL_VERSION 120
#include <stdio.h>
#ifdef __APPLE__
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif
#include <openmodelica.h>
#include <stdarg.h>
#include <sys/time.h>
#define MAX_DEVICE 4
#define SHOW_DEVICE_SELECTION
// #define SHOW_ARG_SET_ERRORS
#define DEFAULT_DEVICE 1
#define OCL_BUFFER_SIZE_FRACTION 4
// DEFINED IN: omc_ocl_util
void ocl_initialize();
void ocl_error_check(int operation, cl_int error_code);
cl_program ocl_build_p_from_src(const char* source, int isfile);
cl_kernel ocl_create_kernel(cl_program program, const char* kernel_name);
//executes a kernel
void ocl_execute_kernel(cl_kernel kernel);
typedef cl_mem device_integer;
typedef cl_mem device_real;
struct dev_buff{
cl_mem buffer;
modelica_integer size;
};
typedef struct dev_buff device_buffer;
typedef struct dev_arr{
cl_mem data;
cl_mem info_dev;
modelica_integer* info;
} device_array;
typedef device_array device_integer_array;
typedef device_array device_real_array;
// typedef struct dev_local_arr{
// cl_mem data;
// cl_mem info_dev;
// modelica_integer* info;
// } device_local_array;
typedef device_array device_local_real_array;
typedef device_array device_local_integer_array;
enum ocl_error {OCL_BUILD_PROGRAM, OCL_CREATE_KERNEL, OCL_CREATE_BUFFER, OCL_CREATE_CONTEXT,
OCL_CREATE_COMMAND_QUEUE, OCL_SET_KER_ARGS, OCL_ENQUE_ND_RANGE_KERNEL, OCL_COPY_DEV_TO_DEV,
OCL_COPY_HOST_TO_DEV, OCL_COPY_DEV_TO_HOST, OCL_REALEASE_MEM_OBJECT};
// Defined in: omc_ocl_interface.cpp
size_t device_array_nr_of_elements(device_array *a);
#endif