Bump version to 6.4-15
[LibreOffice.git] / include / opencl / openclwrapper.hxx
blob81138ced24e8868b324bcf550d00b9a1651fa0b4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #ifndef INCLUDED_SC_SOURCE_CORE_OPENCL_OPENCLWRAPPER_HXX
11 #define INCLUDED_SC_SOURCE_CORE_OPENCL_OPENCLWRAPPER_HXX
13 #include <vector>
15 #include <clew/clew.h>
17 #include <opencl/opencldllapi.h>
18 #include <rtl/ustring.hxx>
20 #define MAX_CLFILE_NUM 50
21 #define OPENCL_CMDQUEUE_SIZE 1 // number of command queues per OpenCL device.
23 #include <cstdio>
25 struct OpenCLPlatformInfo;
27 namespace openclwrapper
30 struct KernelEnv
32 cl_context mpkContext;
33 cl_command_queue mpkCmdQueue;
34 cl_program mpkProgram;
37 struct OPENCL_DLLPUBLIC GPUEnv
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];
44 bool mbCommandQueueInitialized;
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
47 int mnCmdQueuePos;
48 bool mnKhrFp64Flag;
49 bool mnAmdFp64Flag;
50 bool mbNeedsTDRAvoidance;
52 static bool isOpenCLEnabled();
55 extern OPENCL_DLLPUBLIC GPUEnv gpuEnv;
56 extern OPENCL_DLLPUBLIC sal_uInt64 kernelFailures;
58 OPENCL_DLLPUBLIC bool canUseOpenCL();
60 OPENCL_DLLPUBLIC bool generatBinFromKernelSource( cl_program program, const char * clFileName );
61 OPENCL_DLLPUBLIC bool buildProgramFromBinary(const char* buildOption, GPUEnv* gpuEnv, const char* filename, int idx);
62 OPENCL_DLLPUBLIC void setKernelEnv( KernelEnv *envInfo );
63 OPENCL_DLLPUBLIC const std::vector<OpenCLPlatformInfo>& fillOpenCLInfo();
65 /**
66 * Used to set or switch between OpenCL devices.
68 * @param pDeviceId the id of the opencl device of type cl_device_id, NULL means use software calculation
69 * @param bAutoSelect use the algorithm to select the best OpenCL device
70 * @param rOutSelectedDeviceVersionIDString returns the selected device's version string.
72 * @return returns true if there is a valid opencl device that has been set up
74 OPENCL_DLLPUBLIC bool switchOpenCLDevice(const OUString* pDeviceId, bool bAutoSelect,
75 bool bForceEvaluation,
76 OUString& rOutSelectedDeviceVersionIDString);
78 OPENCL_DLLPUBLIC void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId);
80 OPENCL_DLLPUBLIC void getOpenCLDeviceName(OUString& rDeviceName, OUString& rPlatformName);
82 /**
83 * Set the current command queue position in case of multiple command queues
84 * for a given device.
86 OPENCL_DLLPUBLIC void setOpenCLCmdQueuePosition( int nPos );
88 /**
89 * Return a textual representation of an OpenCL error code.
90 * (Currently the symbolic name sans the CL_ prefix.)
92 OPENCL_DLLPUBLIC const char* errorString(cl_int nError);
96 #endif
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */