LibreOffice Module opencl (master) 1
openclwrapper.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef INCLUDED_SC_SOURCE_CORE_OPENCL_OPENCLWRAPPER_HXX
11#define INCLUDED_SC_SOURCE_CORE_OPENCL_OPENCLWRAPPER_HXX
12
13#include <vector>
14
15#include <clew/clew.h>
16
17#include <opencl/opencldllapi.h>
18#include <rtl/ustring.hxx>
19
20#define MAX_CLFILE_NUM 50
21#define OPENCL_CMDQUEUE_SIZE 1 // number of command queues per OpenCL device.
22
23#include <cstdio>
24
26
27namespace openclwrapper
28{
29
31{
32 cl_context mpkContext;
33 cl_command_queue mpkCmdQueue;
34 cl_program mpkProgram;
35};
36
38{
39 //share vb in all modules in hb library
40 cl_platform_id mpPlatformID;
41 cl_context mpContext;
42 cl_device_id mpDevID;
43 cl_command_queue mpCmdQueue[OPENCL_CMDQUEUE_SIZE];
45 cl_program mpArryPrograms[MAX_CLFILE_NUM]; //one program object maps one kernel source file
46 int mnIsUserCreated; // 1: created , 0:no create and needed to create by opencl wrapper
51
52 static bool isOpenCLEnabled();
53};
54
56extern OPENCL_DLLPUBLIC sal_uInt64 kernelFailures;
57
59
60OPENCL_DLLPUBLIC bool generatBinFromKernelSource( cl_program program, const char * clFileName );
61OPENCL_DLLPUBLIC bool buildProgramFromBinary(const char* buildOption, GPUEnv* gpuEnv, const char* filename, int idx);
63OPENCL_DLLPUBLIC const std::vector<OpenCLPlatformInfo>& fillOpenCLInfo();
64
74OPENCL_DLLPUBLIC bool switchOpenCLDevice(std::u16string_view aDevice, bool bAutoSelect,
75 bool bForceEvaluation,
76 OUString& rOutSelectedDeviceVersionIDString);
77
78OPENCL_DLLPUBLIC void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId);
79
80OPENCL_DLLPUBLIC void getOpenCLDeviceName(OUString& rDeviceName, OUString& rPlatformName);
81
87
92OPENCL_DLLPUBLIC const char* errorString(cl_int nError);
93
94}
95
96#endif
97
98/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool switchOpenCLDevice(std::u16string_view aDevice, bool bAutoSelect, bool bForceEvaluation, OUString &rOutSelectedDeviceVersionIDString)
Used to set or switch between OpenCL devices.
const char * errorString(cl_int nError)
Return a textual representation of an OpenCL error code.
const std::vector< OpenCLPlatformInfo > & fillOpenCLInfo()
void setOpenCLCmdQueuePosition(int nPos)
Set the current command queue position in case of multiple command queues for a given device.
void getOpenCLDeviceName(OUString &rDeviceName, OUString &rPlatformName)
bool buildProgramFromBinary(const char *buildOption, GPUEnv *gpuInfo, const char *filename, int idx)
void setKernelEnv(KernelEnv *envInfo)
sal_uInt64 kernelFailures
bool generatBinFromKernelSource(cl_program program, const char *clFileName)
void getOpenCLDeviceInfo(size_t &rDeviceId, size_t &rPlatformId)
#define OPENCL_DLLPUBLIC
Definition: opencldllapi.h:28
#define MAX_CLFILE_NUM
#define OPENCL_CMDQUEUE_SIZE
cl_platform_id mpPlatformID
cl_command_queue mpkCmdQueue