Skip to content

Commit cf3ac89

Browse files
committed
dbk: fix circular dependency
1 parent 93c5b5c commit cf3ac89

9 files changed

+45
-33
lines changed

lib/CL/devices/CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,11 @@ if(HAVE_ONNXRT)
223223
target_link_libraries("pocl-devices" PRIVATE onnxruntime::onnxruntime)
224224
endif ()
225225
if(HAVE_OPENCV)
226-
add_dependencies("pocl-devices" pocl_dbk_khr_dnn_utils)
227-
target_link_libraries("pocl-devices" PRIVATE $<TARGET_OBJECTS:pocl_dbk_khr_dnn_utils> opencv_dnn)
226+
# add_dependencies("pocl-devices" pocl_dbk_khr_dnn_utils)
227+
# target_link_libraries("pocl-devices" PRIVATE
228+
# $<TARGET_OBJECTS:pocl_dbk_khr_dnn_utils>
229+
# opencv_dnn)
230+
target_link_libraries("pocl-devices" PRIVATE opencv_dnn)
228231
endif ()
229232

230233
set(POCL_DEVICES_OBJS "${POCL_DEVICES_OBJS}"

lib/CL/devices/common_utils.c

-21
Original file line numberDiff line numberDiff line change
@@ -891,27 +891,6 @@ pocl_cpu_build_defined_builtin (cl_program program, cl_uint device_i)
891891
"The CPU driver has not been compiled with support for DBKs\n");
892892
}
893893

894-
/**
895-
* Get the device memory pointer of the supplied pocl argument.
896-
*
897-
* \param global_mem_id [in] This is needed to get the device specific pointer.
898-
* \return NULL if arg->value is NULL and otherwise the requested pointer.
899-
*/
900-
void *
901-
pocl_cpu_get_ptr (struct pocl_argument *arg, unsigned global_mem_id)
902-
{
903-
if (arg->value == NULL)
904-
return NULL;
905-
906-
if (arg->is_raw_ptr)
907-
return *(void **)arg->value;
908-
909-
cl_mem mem = *(cl_mem *)(arg->value);
910-
char *ptr = (char *)(mem->device_ptrs[global_mem_id].mem_ptr);
911-
ptr += arg->offset;
912-
return (void *)ptr;
913-
}
914-
915894
#ifdef HAVE_LIBXSMM
916895

917896
static cl_bool

lib/CL/devices/common_utils.h

-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ POCL_EXPORT
128128
void pocl_free_kernel_arg_array_with_locals (void **arguments, void **arguments2,
129129
kernel_run_command *k);
130130

131-
void *pocl_cpu_get_ptr (struct pocl_argument *arg, unsigned global_mem_id);
132-
133131
POCL_EXPORT
134132
void pocl_cpu_save_rm_and_ftz (unsigned *rm, unsigned *ftz);
135133

lib/CL/devices/cpu_dbk/CMakeLists.txt

+4-5
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ list(APPEND POCL_DEVICES_SOURCES
1616
)
1717

1818
if(HAVE_OPENCV)
19-
add_library(pocl_dbk_khr_dnn_utils OBJECT
20-
pocl_dbk_khr_dnn_utils.cpp
21-
pocl_dbk_khr_dnn_utils.hh)
22-
target_link_libraries(pocl_dbk_khr_dnn_utils PRIVATE opencv_dnn)
19+
list(APPEND POCL_DEVICES_SOURCES
20+
${CMAKE_CURRENT_SOURCE_DIR}/pocl_dbk_khr_dnn_utils.cpp
21+
${CMAKE_CURRENT_SOURCE_DIR}/pocl_dbk_khr_dnn_utils.hh)
2322

24-
list(APPEND POCL_DEVICES_LINK_LIST pocl_dbk_khr_dnn_utils)
23+
list(APPEND POCL_DEVICES_LINK_LIST opencv_dnn)
2524

2625
endif ()
2726

lib/CL/devices/cpu_dbk/pocl_dbk_khr_dnn_utils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323

2424
#include "pocl_dbk_khr_dnn_utils.hh"
25-
#include "common_utils.h"
25+
#include "pocl_mem_management.h"
2626
#include <opencv2/dnn.hpp>
2727
#include <string>
2828

lib/CL/devices/cpu_dbk/pocl_dbk_khr_img_cpu.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323

2424
#include "pocl_dbk_khr_img_cpu.h"
25-
#include "common_utils.h"
25+
#include "pocl_mem_management.h"
2626

2727
int
2828
pocl_cpu_execute_dbk_exp_img_yuv2rgb (cl_program program,

lib/CL/devices/cpu_dbk/pocl_dbk_khr_jpeg_cpu.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424

2525
#include "pocl_dbk_khr_jpeg_cpu.h"
26-
#include "common_utils.h"
26+
#include "pocl_mem_management.h"
2727

2828
#ifdef HAVE_LIBJPEG_TURBO
2929

lib/CL/pocl_mem_management.c

+21
Original file line numberDiff line numberDiff line change
@@ -1090,3 +1090,24 @@ pocl_find_raw_ptr_with_dev_ptr (cl_context context, const void *dev_ptr)
10901090
POCL_UNLOCK_OBJ (context);
10911091
return item;
10921092
}
1093+
1094+
/**
1095+
* Get the device memory pointer of the supplied pocl argument.
1096+
*
1097+
* \param global_mem_id [in] This is needed to get the device specific pointer.
1098+
* \return NULL if arg->value is NULL and otherwise the requested pointer.
1099+
*/
1100+
void *
1101+
pocl_cpu_get_ptr (struct pocl_argument *arg, unsigned global_mem_id)
1102+
{
1103+
if (arg->value == NULL)
1104+
return NULL;
1105+
1106+
if (arg->is_raw_ptr)
1107+
return *(void **)arg->value;
1108+
1109+
cl_mem mem = *(cl_mem *)(arg->value);
1110+
char *ptr = (char *)(mem->device_ptrs[global_mem_id].mem_ptr);
1111+
ptr += arg->offset;
1112+
return (void *)ptr;
1113+
}

lib/CL/pocl_mem_management.h

+12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
#include "pocl_cl.h"
2626
#include "utlist.h"
2727

28+
#ifdef __cplusplus
29+
extern "C"
30+
{
31+
#endif
32+
2833
#ifdef __GNUC__
2934
#pragma GCC visibility push(hidden)
3035
#endif
@@ -111,6 +116,13 @@ pocl_convert_to_subbuffer_migrations (pocl_buffer_migration_info *buffer_usage,
111116

112117
#endif
113118

119+
POCL_EXPORT
120+
void *pocl_cpu_get_ptr (struct pocl_argument *arg, unsigned global_mem_id);
121+
114122
#ifdef __GNUC__
115123
#pragma GCC visibility pop
116124
#endif
125+
126+
#ifdef __cplusplus
127+
}
128+
#endif

0 commit comments

Comments
 (0)