2013-06-16 17:18:23 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2014-04-18 19:10:04 +02:00
|
|
|
#ifndef INCLUDED_SC_SOURCE_CORE_OPENCL_OPENCLWRAPPER_HXX
|
|
|
|
#define INCLUDED_SC_SOURCE_CORE_OPENCL_OPENCLWRAPPER_HXX
|
2013-06-16 17:18:23 +01:00
|
|
|
|
2013-06-26 14:04:25 +01:00
|
|
|
#include <config_features.h>
|
2014-11-27 15:13:12 +02:00
|
|
|
|
|
|
|
#include <cassert>
|
2013-09-17 23:04:54 +02:00
|
|
|
#include <vector>
|
2014-11-27 15:13:12 +02:00
|
|
|
|
2013-09-17 23:04:54 +02:00
|
|
|
#include <boost/shared_ptr.hpp>
|
2014-12-08 09:29:28 +02:00
|
|
|
#include <clew/clew.h>
|
2013-09-11 14:22:48 -04:00
|
|
|
|
2014-11-27 15:13:12 +02:00
|
|
|
#include <sal/detail/log.h>
|
|
|
|
#include <opencl/opencldllapi.h>
|
|
|
|
#include <opencl/platforminfo.hxx>
|
|
|
|
#include <osl/file.hxx>
|
2013-09-17 04:24:36 +02:00
|
|
|
#include <rtl/string.hxx>
|
|
|
|
|
2013-09-16 18:29:37 -04:00
|
|
|
#define MAX_CLFILE_NUM 50
|
2015-01-07 16:24:06 -05:00
|
|
|
#define OPENCL_CMDQUEUE_SIZE 1 // number of command queues per OpenCL device.
|
2013-09-10 17:01:15 -04:00
|
|
|
|
2013-08-05 10:21:36 -04:00
|
|
|
#include <cstdio>
|
|
|
|
|
2014-11-27 18:03:35 +02:00
|
|
|
namespace opencl {
|
|
|
|
|
2014-10-28 13:32:16 +02:00
|
|
|
struct KernelEnv
|
2013-07-24 15:16:55 -04:00
|
|
|
{
|
2013-07-08 10:49:05 +01:00
|
|
|
cl_context mpkContext;
|
|
|
|
cl_command_queue mpkCmdQueue;
|
|
|
|
cl_program mpkProgram;
|
2014-10-28 13:32:16 +02:00
|
|
|
};
|
2013-06-16 17:18:23 +01:00
|
|
|
|
2013-09-16 15:35:31 -04:00
|
|
|
struct GPUEnv
|
2013-07-24 15:16:55 -04:00
|
|
|
{
|
2013-06-16 17:18:23 +01:00
|
|
|
//share vb in all modules in hb library
|
2013-07-08 10:49:05 +01:00
|
|
|
cl_platform_id mpPlatformID;
|
|
|
|
cl_device_type mDevType;
|
|
|
|
cl_context mpContext;
|
|
|
|
cl_device_id *mpArryDevsID;
|
|
|
|
cl_device_id mpDevID;
|
2015-01-07 16:24:06 -05:00
|
|
|
cl_command_queue mpCmdQueue[OPENCL_CMDQUEUE_SIZE];
|
2013-07-08 10:49:05 +01:00
|
|
|
cl_program mpArryPrograms[MAX_CLFILE_NUM]; //one program object maps one kernel source file
|
2013-09-16 16:32:25 -04:00
|
|
|
int mnIsUserCreated; // 1: created , 0:no create and needed to create by opencl wrapper
|
2015-01-07 16:24:06 -05:00
|
|
|
int mnCmdQueuePos;
|
2014-01-17 11:49:26 +01:00
|
|
|
bool mnKhrFp64Flag;
|
|
|
|
bool mnAmdFp64Flag;
|
2013-09-16 15:35:31 -04:00
|
|
|
};
|
2013-06-16 17:18:23 +01:00
|
|
|
|
2014-11-27 17:43:55 +02:00
|
|
|
extern OPENCL_DLLPUBLIC GPUEnv gpuEnv;
|
|
|
|
OPENCL_DLLPUBLIC bool generatBinFromKernelSource( cl_program program, const char * clFileName );
|
|
|
|
OPENCL_DLLPUBLIC bool buildProgramFromBinary(const char* buildOption, GPUEnv* gpuEnv, const char* filename, int idx);
|
|
|
|
OPENCL_DLLPUBLIC void setKernelEnv( KernelEnv *envInfo );
|
2014-11-27 15:13:12 +02:00
|
|
|
OPENCL_DLLPUBLIC const std::vector<OpenCLPlatformInfo>& fillOpenCLInfo();
|
2013-09-14 01:22:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to set or switch between OpenCL devices.
|
|
|
|
*
|
|
|
|
* @param pDeviceId the id of the opencl device of type cl_device_id, NULL means use software calculation
|
|
|
|
* @param bAutoSelect use the algorithm to select the best OpenCL device
|
2013-09-14 16:07:42 +02:00
|
|
|
*
|
|
|
|
* @return returns true if there is a valid opencl device that has been set up
|
2013-09-14 01:22:41 +02:00
|
|
|
*/
|
2014-11-27 15:13:12 +02:00
|
|
|
OPENCL_DLLPUBLIC bool switchOpenCLDevice(const OUString* pDeviceId, bool bAutoSelect,
|
|
|
|
bool bForceEvaluation);
|
2013-09-13 14:11:43 +02:00
|
|
|
|
2014-11-27 15:13:12 +02:00
|
|
|
OPENCL_DLLPUBLIC void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId);
|
2013-11-22 20:27:48 +01:00
|
|
|
|
2015-01-07 16:24:06 -05:00
|
|
|
/**
|
|
|
|
* Set the current command queue position in case of multiple command queues
|
|
|
|
* for a given device.
|
|
|
|
*/
|
|
|
|
OPENCL_DLLPUBLIC void setOpenCLCmdQueuePosition( int nPos );
|
|
|
|
|
2015-02-05 23:42:30 +02:00
|
|
|
/**
|
|
|
|
* Return a textual representation of an OpenCL error code.
|
|
|
|
* (Currently the symbolic name sans the CL_ prefix.)
|
|
|
|
*/
|
|
|
|
OPENCL_DLLPUBLIC const char* errorString(cl_int nError);
|
|
|
|
|
2014-11-27 15:13:12 +02:00
|
|
|
}
|
2013-09-10 17:01:15 -04:00
|
|
|
|
2013-06-26 12:19:51 +01:00
|
|
|
#endif
|
2013-09-10 17:01:15 -04:00
|
|
|
|
2013-06-26 12:19:51 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|