feat: add OpenCL kernel support for division operations and update includes

This commit is contained in:
chraac 2026-01-15 11:57:37 +08:00
parent e6db6313a9
commit 5fbff1aa3a
4 changed files with 33 additions and 25 deletions

View File

@ -22,6 +22,8 @@ if (GGML_OPENCL_USE_ADRENO_KERNELS)
add_compile_definitions(GGML_OPENCL_USE_ADRENO_KERNELS)
endif ()
target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/kernels")
if (GGML_OPENCL_EMBED_KERNELS)
add_compile_definitions(GGML_OPENCL_EMBED_KERNELS)

View File

@ -29,6 +29,10 @@
#include <charconv>
#include <mutex>
namespace ocl_kernel_prototypes {
#include "div.h"
}
#undef MIN
#undef MAX
#define MIN(a, b) ((a) < (b) ? (a) : (b))

View File

@ -4,28 +4,28 @@
#include "ocl_defs.h"
kernel void kernel_div(global char * src0,
ulong offset0,
global char * src1,
ulong offset1,
global char * dst,
ulong offsetd,
ulong nb00,
ulong nb01,
ulong nb02,
ulong nb03,
int ne10,
int ne11,
int ne12,
int ne13,
ulong nb10,
ulong nb11,
ulong nb12,
ulong nb13,
int ne0,
ulong nb0,
ulong nb1,
ulong nb2,
ulong nb3);
OCL_KERNEL void kernel_div(OCL_GLOBAL char * src0,
ulong offset0,
OCL_GLOBAL char * src1,
ulong offset1,
OCL_GLOBAL char * dst,
ulong offsetd,
ulong nb00,
ulong nb01,
ulong nb02,
ulong nb03,
int ne10,
int ne11,
int ne12,
int ne13,
ulong nb10,
ulong nb11,
ulong nb12,
ulong nb13,
int ne0,
ulong nb0,
ulong nb1,
ulong nb2,
ulong nb3);
#endif // __KERNELS_DIV_H__

View File

@ -4,10 +4,12 @@
#ifdef __OPENCL_C_VERSION__
// Device (OpenCL) Definitions
# define OCL_KERNEL kernel
# define OCL_GLOBAL global
#else
// Host (C++) Definitions
# define kernel
# define global
# define OCL_KERNEL
# define OCL_GLOBAL
# define __kernel
# define __global
# define ulong cl_ulong