blob: 87ad48bbf9791a11052e1040983e32d6031ea2ce (
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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${DRM_INCLUDE_DIRS}
${DRM_INCLUDE_DIRS}/../
${CMAKE_CURRENT_SOURCE_DIR}/../backend/src/backend/
${CMAKE_CURRENT_SOURCE_DIR}/../include
${LLVM_INCLUDE_DIR}
${OPENGL_INCLUDE_DIRS}
${EGL_INCLUDE_DIRS})
macro (MakeKernelBinStr KERNEL_DIST KERNEL_SOURCE KERNEL_FILES)
foreach (KF ${KERNEL_FILES})
set (input_file ${KERNEL_SOURCE}/${KF}.cl)
set (output_file ${KERNEL_DIST}/${KF}_str.c)
list (APPEND KERNEL_STR_FILES ${output_file})
list (GET GBE_BIN_GENERATER -1 GBE_BIN_FILE)
if(GEN_PCI_ID)
add_custom_command(
OUTPUT ${output_file}
COMMAND rm -rf ${output_file}
COMMAND ${GBE_BIN_GENERATER} -s -o${output_file} -t${GEN_PCI_ID} ${input_file}
DEPENDS ${input_file} ${GBE_BIN_FILE} beignet_bitcode)
else(GEN_PCI_ID)
add_custom_command(
OUTPUT ${output_file}
COMMAND rm -rf ${output_file}
COMMAND ${GBE_BIN_GENERATER} -s -o${output_file} ${input_file}
DEPENDS ${input_file} ${GBE_BIN_FILE} beignet_bitcode)
endif(GEN_PCI_ID)
endforeach (KF)
endmacro (MakeKernelBinStr)
macro (MakeBuiltInKernelStr KERNEL_PATH KERNEL_FILES)
set (output_file ${KERNEL_PATH}/${BUILT_IN_NAME}.cl)
set (file_content)
file (REMOVE ${output_file})
foreach (KF ${KERNEL_NAMES})
set (input_file ${CMAKE_CURRENT_SOURCE_DIR}/kernels/${KF}.cl)
file(READ ${input_file} file_content )
STRING(REGEX REPLACE ";" "\\\\;" file_content "${file_content}")
file(APPEND ${output_file} ${file_content})
endforeach (KF)
endmacro (MakeBuiltInKernelStr)
set (KERNEL_STR_FILES)
set (KERNEL_NAMES cl_internal_copy_buf_align4
cl_internal_copy_buf_align16 cl_internal_copy_buf_unalign_same_offset
cl_internal_copy_buf_unalign_dst_offset cl_internal_copy_buf_unalign_src_offset
cl_internal_copy_buf_rect cl_internal_copy_buf_rect_align4
cl_internal_copy_image_1d_to_1d cl_internal_copy_image_2d_to_2d
cl_internal_copy_image_3d_to_2d cl_internal_copy_image_2d_to_3d cl_internal_copy_image_3d_to_3d
cl_internal_copy_image_2d_to_2d_array cl_internal_copy_image_1d_array_to_1d_array
cl_internal_copy_image_2d_array_to_2d_array cl_internal_copy_image_2d_array_to_2d
cl_internal_copy_image_2d_array_to_3d cl_internal_copy_image_3d_to_2d_array
cl_internal_copy_image_2d_to_buffer cl_internal_copy_image_2d_to_buffer_align16 cl_internal_copy_image_3d_to_buffer
cl_internal_copy_buffer_to_image_2d cl_internal_copy_buffer_to_image_2d_align16 cl_internal_copy_buffer_to_image_3d
cl_internal_copy_buffer_to_image_2d_align4 cl_internal_copy_image_2d_to_buffer_align4
cl_internal_fill_buf_align8 cl_internal_fill_buf_align4
cl_internal_fill_buf_align2 cl_internal_fill_buf_unalign
cl_internal_fill_buf_align128 cl_internal_fill_image_1d
cl_internal_fill_image_1d_array cl_internal_fill_image_2d
cl_internal_fill_image_2d_array cl_internal_fill_image_3d
cl_internal_block_motion_estimate_intel)
set (BUILT_IN_NAME cl_internal_built_in_kernel)
MakeBuiltInKernelStr ("${CMAKE_CURRENT_BINARY_DIR}/kernels/" "${KERNEL_NAMES}")
MakeKernelBinStr ("${CMAKE_CURRENT_BINARY_DIR}/kernels/" "${CMAKE_CURRENT_SOURCE_DIR}/kernels/" "${KERNEL_NAMES}")
MakeKernelBinStr ("${CMAKE_CURRENT_BINARY_DIR}/kernels/" "${CMAKE_CURRENT_BINARY_DIR}/kernels/" "${BUILT_IN_NAME}")
set(OPENCL_SRC
${KERNEL_STR_FILES}
cl_base_object.c
cl_api.c
cl_api_platform_id.c
cl_api_device_id.c
cl_api_mem.c
cl_api_kernel.c
cl_api_command_queue.c
cl_api_event.c
cl_api_context.c
cl_api_sampler.c
cl_api_program.c
cl_alloc.c
cl_kernel.c
cl_program.c
cl_gbe_loader.cpp
cl_sampler.c
cl_accelerator_intel.c
cl_event.c
cl_enqueue.c
cl_image.c
cl_mem.c
cl_platform_id.c
cl_extensions.c
cl_device_id.c
cl_context.c
cl_command_queue.c
cl_command_queue.h
cl_device_enqueue.c
cl_device_enqueue.h
cl_command_queue_gen7.c
cl_command_queue_enqueue.c
cl_utils.c
cl_driver.h
cl_driver.cpp
cl_driver_defs.c
intel/intel_gpgpu.c
intel/intel_batchbuffer.c
intel/intel_driver.c
performance.c)
if (X11_FOUND)
set(CMAKE_CXX_FLAGS "-DHAS_X11 ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-DHAS_X11 ${CMAKE_C_FLAGS}")
set(OPENCL_SRC
${OPENCL_SRC}
x11/dricommon.c
x11/va_dri2.c)
endif (X11_FOUND)
if (CMRT_FOUND)
set(CMAKE_CXX_FLAGS "-DHAS_CMRT ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "-DCMRT_PATH=${CMRT_LIBDIR}/libcmrt.so.1 ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-DHAS_CMRT ${CMAKE_C_FLAGS}")
set(OPENCL_SRC ${OPENCL_SRC} cl_cmrt.cpp)
endif (CMRT_FOUND)
if (OPENGL_FOUND AND EGL_FOUND)
set (OPENCL_SRC ${OPENCL_SRC} cl_mem_gl.c cl_gl_api.c )
SET(CMAKE_CXX_FLAGS "-DHAS_GL_EGL ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "-DHAS_GL_EGL ${CMAKE_C_FLAGS}")
endif (OPENGL_FOUND AND EGL_FOUND)
if (OCLIcd_FOUND)
set (OPENCL_SRC ${OPENCL_SRC} cl_khr_icd.c)
SET(CMAKE_CXX_FLAGS "-DHAS_OCLIcd ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "-DHAS_OCLIcd ${CMAKE_C_FLAGS}")
endif (OCLIcd_FOUND)
if (HAVE_DRM_INTEL_USERPTR)
SET(CMAKE_CXX_FLAGS "-DHAS_USERPTR ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "-DHAS_USERPTR ${CMAKE_C_FLAGS}")
endif (HAVE_DRM_INTEL_USERPTR)
if (HAVE_DRM_INTEL_EU_TOTAL)
SET(CMAKE_CXX_FLAGS "-DHAS_EU_TOTAL ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "-DHAS_EU_TOTAL ${CMAKE_C_FLAGS}")
endif (HAVE_DRM_INTEL_EU_TOTAL)
if (HAVE_DRM_INTEL_SUBSLICE_TOTAL)
SET(CMAKE_CXX_FLAGS "-DHAS_SUBSLICE_TOTAL ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "-DHAS_SUBSLICE_TOTAL ${CMAKE_C_FLAGS}")
endif (HAVE_DRM_INTEL_SUBSLICE_TOTAL)
if (HAVE_DRM_INTEL_POOLED_EU)
SET(CMAKE_CXX_FLAGS "-DHAS_POOLED_EU ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "-DHAS_POOLED_EU ${CMAKE_C_FLAGS}")
endif (HAVE_DRM_INTEL_POOLED_EU)
if (HAVE_DRM_INTEL_MIN_EU_IN_POOL)
SET(CMAKE_CXX_FLAGS "-DHAS_MIN_EU_IN_POOL ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "-DHAS_MIN_EU_IN_POOL ${CMAKE_C_FLAGS}")
endif (HAVE_DRM_INTEL_MIN_EU_IN_POOL)
if (HAVE_DRM_INTEL_BO_SET_SOFTPIN)
SET(CMAKE_CXX_FLAGS "-DHAS_BO_SET_SOFTPIN ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "-DHAS_BO_SET_SOFTPIN ${CMAKE_C_FLAGS}")
endif (HAVE_DRM_INTEL_BO_SET_SOFTPIN)
set(GIT_SHA1 "git_sha1.h")
add_custom_target(${GIT_SHA1} ALL
COMMAND chmod +x ${CMAKE_CURRENT_SOURCE_DIR}/git_sha1.sh
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/git_sha1.sh ${CMAKE_CURRENT_SOURCE_DIR} ${GIT_SHA1}
)
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic,--allow-shlib-undefined")
link_directories (${LLVM_LIBRARY_DIR} ${DRM_LIBDIR} ${OPENGL_LIBDIR} ${EGL_LIBDIR})
add_library(cl SHARED ${OPENCL_SRC})
ADD_DEPENDENCIES(cl ${GIT_SHA1})
target_link_libraries(
cl
rt
${X11_LIBRARIES}
${XEXT_LIBRARIES}
${XFIXES_LIBRARIES}
${DRM_INTEL_LIBRARIES}
${DRM_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS}
${OPENGL_LIBRARIES}
${EGL_LIBRARIES})
install (TARGETS cl LIBRARY DESTINATION ${BEIGNET_INSTALL_DIR})
|