Kaydet (Commit) 28561633 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Don't bother with a separate dynamically loaded scopencl library

Just link that code into the sc library. We use clew anyway to handle
optoinal presence of OpenCL at run-time.

This is a straightforward change for now. Could be cleaner; we could
get rid of the fairly pointless wrappers in
sc/source/core/opencl/formulagroupcl.cxx for instance.

Change-Id: I23215c6516ef04698f6891e2a7fc6611dc83b37a
üst 20860044
...@@ -226,7 +226,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,calc, \ ...@@ -226,7 +226,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,calc, \
scfilt \ scfilt \
scui \ scui \
wpftcalc \ wpftcalc \
$(if $(ENABLE_OPENCL),scopencl) \
$(if $(ENABLE_COINMP)$(ENABLE_LPSOLVE),solver) \ $(if $(ENABLE_COINMP)$(ENABLE_LPSOLVE),solver) \
$(call gb_Helper_optional,SCRIPTING,vbaobj) \ $(call gb_Helper_optional,SCRIPTING,vbaobj) \
)) ))
......
...@@ -183,7 +183,6 @@ endef ...@@ -183,7 +183,6 @@ endef
ifeq (,$(filter-out all build check unitcheck slowcheck subsequentcheck,$(MAKECMDGOALS))) ifeq (,$(filter-out all build check unitcheck slowcheck subsequentcheck,$(MAKECMDGOALS)))
$(eval $(call repositorymodule_serialize,\ $(eval $(call repositorymodule_serialize,\
scfilt \ scfilt \
$(if $(ENABLE_OPENCL),scopencl) \
$(call gb_Helper_optional,SCRIPTING,vbaobj) \ $(call gb_Helper_optional,SCRIPTING,vbaobj) \
sc msword \ sc msword \
$(call gb_Helper_optional,DESKTOP,swui) \ $(call gb_Helper_optional,DESKTOP,swui) \
......
...@@ -36,7 +36,6 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_opencl_test, \ ...@@ -36,7 +36,6 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_opencl_test, \
salhelper \ salhelper \
sax \ sax \
sc \ sc \
$(if $(ENABLE_OPENCL),scopencl) \
scqahelper \ scqahelper \
sfx \ sfx \
sot \ sot \
......
...@@ -655,6 +655,39 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ ...@@ -655,6 +655,39 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/xmlsource/xmlsourcedlg \ sc/source/ui/xmlsource/xmlsourcedlg \
)) ))
ifneq (,$(ENABLE_OPENCL))
$(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/opencl/formulagroupcl \
sc/source/core/opencl/openclwrapper \
sc/source/core/opencl/opencl_device \
sc/source/core/opencl/opbase \
sc/source/core/opencl/op_financial \
sc/source/core/opencl/op_database \
sc/source/core/opencl/op_math \
sc/source/core/opencl/op_addin \
sc/source/core/opencl/op_statistical \
sc/source/core/opencl/op_array \
sc/source/core/opencl/op_logical \
sc/source/core/opencl/op_spreadsheet \
sc/source/core/opencl/clcc/clew \
))
ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,sc,\
-ldl \
-lrt \
))
endif
ifeq ($(OS),MACOSX)
$(eval $(call gb_Library_add_libs,sc,\
-framework OpenCL \
))
endif
endif
$(eval $(call gb_SdiTarget_SdiTarget,sc/sdi/scslots,sc/sdi/scalc)) $(eval $(call gb_SdiTarget_SdiTarget,sc/sdi/scslots,sc/sdi/scalc))
$(eval $(call gb_SdiTarget_set_include,sc/sdi/scslots,\ $(eval $(call gb_SdiTarget_set_include,sc/sdi/scslots,\
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# 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/.
#
$(eval $(call gb_Library_Library,scopencl))
$(eval $(call gb_Library_set_include,scopencl,\
-I$(SRCDIR)/sc/source/core/inc \
-I$(SRCDIR)/sc/inc \
$$(INCLUDE) \
))
$(eval $(call gb_Library_set_precompiled_header,scopencl,$(SRCDIR)/sc/inc/pch/precompiled_scopencl))
$(eval $(call gb_Library_use_sdk_api,scopencl))
$(eval $(call gb_Library_use_externals,scopencl,\
boost_headers \
))
$(eval $(call gb_Library_use_libraries,scopencl,\
comphelper \
cppu \
cppuhelper \
for \
sal \
svl \
sc \
tl \
$(gb_UWINAPI) \
))
$(eval $(call gb_Library_add_exception_objects,scopencl,\
sc/source/core/opencl/formulagroupcl \
sc/source/core/opencl/openclwrapper \
sc/source/core/opencl/opencl_device \
sc/source/core/opencl/opbase \
sc/source/core/opencl/op_financial \
sc/source/core/opencl/op_database \
sc/source/core/opencl/op_math \
sc/source/core/opencl/op_addin \
sc/source/core/opencl/op_statistical \
sc/source/core/opencl/op_array \
sc/source/core/opencl/op_logical \
sc/source/core/opencl/op_spreadsheet \
sc/source/core/opencl/clcc/clew \
))
ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,scopencl,\
-ldl \
-lrt \
))
endif
ifeq ($(OS),MACOSX)
$(eval $(call gb_Library_add_libs,scopencl,\
-framework OpenCL \
))
endif
# vim: set noet sw=4 ts=4:
...@@ -22,12 +22,6 @@ $(eval $(call gb_Module_add_l10n_targets,sc,\ ...@@ -22,12 +22,6 @@ $(eval $(call gb_Module_add_l10n_targets,sc,\
UIConfig_scalc \ UIConfig_scalc \
)) ))
ifneq (,$(ENABLE_OPENCL))
$(eval $(call gb_Module_add_targets,sc,\
Library_scopencl \
))
endif
ifneq (,$(filter DESKTOP,$(BUILD_TYPE))) ifneq (,$(filter DESKTOP,$(BUILD_TYPE)))
$(eval $(call gb_Module_add_targets,sc,\ $(eval $(call gb_Module_add_targets,sc,\
Library_scqahelper \ Library_scqahelper \
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
#include <boost/unordered_set.hpp> #include <boost/unordered_set.hpp>
#include <cassert> #include <cassert>
#include <climits> #include <climits>
#include <cmath>
#include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/accessibility/AccessibleEventObject.hpp> #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
#include <com/sun/star/accessibility/AccessibleRelationType.hpp> #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
...@@ -430,6 +431,7 @@ ...@@ -430,6 +431,7 @@
#include <comphelper/types.hxx> #include <comphelper/types.hxx>
#include <comphelper/uno3.hxx> #include <comphelper/uno3.hxx>
#include <config_features.h> #include <config_features.h>
#include <config_folders.h>
#include <config_mpl.h> #include <config_mpl.h>
#include <config_options.h> #include <config_options.h>
#include <config_orcus.h> #include <config_orcus.h>
...@@ -561,6 +563,7 @@ ...@@ -561,6 +563,7 @@
#include <rsc/rscsfx.hxx> #include <rsc/rscsfx.hxx>
#include <rtl/bootstrap.hxx> #include <rtl/bootstrap.hxx>
#include <rtl/crc.h> #include <rtl/crc.h>
#include <rtl/digest.h>
#include <rtl/instance.hxx> #include <rtl/instance.hxx>
#include <rtl/math.hxx> #include <rtl/math.hxx>
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
...@@ -627,6 +630,7 @@ ...@@ -627,6 +630,7 @@
#include <sot/filelist.hxx> #include <sot/filelist.hxx>
#include <sot/formats.hxx> #include <sot/formats.hxx>
#include <sot/storage.hxx> #include <sot/storage.hxx>
#include <sstream>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
......
/* -*- 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/.
*/
#include "precompiled_scopencl.hxx"
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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/.
*/
/*
This file has been autogenerated by update_pch.sh . It is possible to edit it
manually (such as when an include file has been moved/renamed/removed. All such
manual changes will be rewritten by the next run of update_pch.sh (which presumably
also fixes all possible problems, so it's usually better to use it).
*/
#include <algorithm>
#include <boost/scoped_array.hpp>
#include <boost/scoped_ptr.hpp>
#include <cmath>
#include <config_folders.h>
#include <float.h>
#include <formula/vectortoken.hxx>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <osl/file.hxx>
#include <rtl/bootstrap.hxx>
#include <rtl/digest.h>
#include <rtl/strbuf.hxx>
#include <rtl/ustring.hxx>
#include <sal/config.h>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <vector>
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#ifdef _WIN32 #ifdef _WIN32
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define VC_EXTRALEAN #define VC_EXTRALEAN
#include <windows.h> #include <prewin.h>
#include <postwin.h>
typedef HMODULE CLCC_DYNLIB_HANDLE; typedef HMODULE CLCC_DYNLIB_HANDLE;
......
...@@ -3732,18 +3732,18 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, ...@@ -3732,18 +3732,18 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
extern "C" { extern "C" {
SAL_DLLPUBLIC_EXPORT sc::FormulaGroupInterpreter* SAL_CALL sc::FormulaGroupInterpreter*
createFormulaGroupOpenCLInterpreter() createFormulaGroupOpenCLInterpreter()
{ {
return new sc::opencl::FormulaGroupInterpreterOpenCL(); return new sc::opencl::FormulaGroupInterpreterOpenCL();
} }
SAL_DLLPUBLIC_EXPORT size_t getOpenCLPlatformCount() size_t getOpenCLPlatformCount()
{ {
return sc::opencl::getOpenCLPlatformCount(); return sc::opencl::getOpenCLPlatformCount();
} }
SAL_DLLPUBLIC_EXPORT void SAL_CALL fillOpenCLInfo( void fillOpenCLInfo(
sc::OpenCLPlatformInfo* pInfos, size_t nInfoSize ) sc::OpenCLPlatformInfo* pInfos, size_t nInfoSize )
{ {
const std::vector<sc::OpenCLPlatformInfo>& rPlatforms = const std::vector<sc::OpenCLPlatformInfo>& rPlatforms =
...@@ -3753,14 +3753,14 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL fillOpenCLInfo( ...@@ -3753,14 +3753,14 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL fillOpenCLInfo(
pInfos[i] = rPlatforms[i]; pInfos[i] = rPlatforms[i];
} }
SAL_DLLPUBLIC_EXPORT bool SAL_CALL switchOpenCLDevice( bool switchOpenCLDevice(
const OUString* pDeviceId, bool bAutoSelect, const OUString* pDeviceId, bool bAutoSelect,
bool bForceEvaluation ) bool bForceEvaluation )
{ {
return sc::opencl::switchOpenCLDevice(pDeviceId, bAutoSelect, bForceEvaluation); return sc::opencl::switchOpenCLDevice(pDeviceId, bAutoSelect, bForceEvaluation);
} }
SAL_DLLPUBLIC_EXPORT void SAL_CALL getOpenCLDeviceInfo( size_t* pDeviceId, size_t* pPlatformId ) void getOpenCLDeviceInfo( size_t* pDeviceId, size_t* pPlatformId )
{ {
sc::opencl::getOpenCLDeviceInfo(*pDeviceId, *pPlatformId); sc::opencl::getOpenCLDeviceInfo(*pDeviceId, *pPlatformId);
} }
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
*/ */
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <prewin.h>
#include <postwin.h>
#elif defined __MACH__ #elif defined __MACH__
#include <mach/mach_time.h> #include <mach/mach_time.h>
#else #else
......
...@@ -26,8 +26,9 @@ ...@@ -26,8 +26,9 @@
#include <string.h> #include <string.h>
#include <cmath> #include <cmath>
#ifdef WIN32 #ifdef _WIN32
#include <windows.h> #include <prewin.h>
#include <postwin.h>
#define OPENCL_DLL_NAME "OpenCL.dll" #define OPENCL_DLL_NAME "OpenCL.dll"
#elif defined(MACOSX) #elif defined(MACOSX)
#define OPENCL_DLL_NAME NULL #define OPENCL_DLL_NAME NULL
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <cstdio> #include <cstdio>
#if HAVE_FEATURE_OPENCL #if HAVE_FEATURE_OPENCL
#ifdef DISABLE_DYNLOADING
extern "C" size_t getOpenCLPlatformCount(void); extern "C" size_t getOpenCLPlatformCount(void);
extern "C" void fillOpenCLInfo(sc::OpenCLPlatformInfo*, size_t); extern "C" void fillOpenCLInfo(sc::OpenCLPlatformInfo*, size_t);
...@@ -38,7 +37,6 @@ extern "C" bool switchOpenCLDevice(const OUString*, bool, bool); ...@@ -38,7 +37,6 @@ extern "C" bool switchOpenCLDevice(const OUString*, bool, bool);
extern "C" sc::FormulaGroupInterpreter* createFormulaGroupOpenCLInterpreter(); extern "C" sc::FormulaGroupInterpreter* createFormulaGroupOpenCLInterpreter();
extern "C" void getOpenCLDeviceInfo(size_t*, size_t*); extern "C" void getOpenCLDeviceInfo(size_t*, size_t*);
#endif
#endif #endif
namespace sc { namespace sc {
...@@ -511,53 +509,8 @@ public: ...@@ -511,53 +509,8 @@ public:
#endif #endif
#if HAVE_FEATURE_OPENCL
#ifndef DISABLE_DYNLOADING
class FormulaGroupInterpreterOpenCLMissing : public FormulaGroupInterpreter
{
public:
FormulaGroupInterpreterOpenCLMissing() : FormulaGroupInterpreter() {}
virtual ~FormulaGroupInterpreterOpenCLMissing() {}
virtual ScMatrixRef inverseMatrix(const ScMatrix&) SAL_OVERRIDE { return ScMatrixRef(); }
virtual CompiledFormula* createCompiledFormula(ScDocument&, const ScAddress&, ScFormulaCellGroup&, ScTokenArray&) SAL_OVERRIDE { return NULL; }
virtual bool interpret(ScDocument&, const ScAddress&, ScFormulaCellGroupRef&, ScTokenArray&) SAL_OVERRIDE { return false; }
};
static void SAL_CALL thisModule() {}
typedef FormulaGroupInterpreter* (*__createFormulaGroupOpenCLInterpreter)(void);
typedef size_t (*__getOpenCLPlatformCount)(void);
typedef void (*__fillOpenCLInfo)(OpenCLPlatformInfo*, size_t);
typedef bool (*__switchOpenCLDevice)(const OUString*, bool, bool);
typedef void (*__getOpenCLDeviceInfo)(size_t*, size_t*);
#endif
#endif
FormulaGroupInterpreter *FormulaGroupInterpreter::msInstance = NULL; FormulaGroupInterpreter *FormulaGroupInterpreter::msInstance = NULL;
#if HAVE_FEATURE_OPENCL
#ifndef DISABLE_DYNLOADING
osl::Module* getOpenCLModule()
{
static osl::Module aModule;
if (aModule.is())
// Already loaded.
return &aModule;
OUString aLibName(SVLIBRARY("scopencl"));
bool bLoaded = aModule.loadRelative(&thisModule, aLibName);
if (!bLoaded)
bLoaded = aModule.load(aLibName);
return bLoaded ? &aModule : NULL;
}
#endif
#endif
/// load and/or configure the correct formula group interpreter /// load and/or configure the correct formula group interpreter
FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic() FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic()
{ {
...@@ -590,28 +543,7 @@ void FormulaGroupInterpreter::fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rP ...@@ -590,28 +543,7 @@ void FormulaGroupInterpreter::fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rP
#if !HAVE_FEATURE_OPENCL #if !HAVE_FEATURE_OPENCL
(void) rPlatforms; (void) rPlatforms;
#else #else
#ifndef DISABLE_DYNLOADING size_t nPlatforms = ::getOpenCLPlatformCount();
osl::Module* pModule = getOpenCLModule();
if (!pModule)
return;
oslGenericFunction fn = pModule->getFunctionSymbol("getOpenCLPlatformCount");
if (!fn)
return;
size_t nPlatforms = reinterpret_cast<__getOpenCLPlatformCount>(fn)();
if (!nPlatforms)
return;
fn = pModule->getFunctionSymbol("fillOpenCLInfo");
if (!fn)
return;
std::vector<OpenCLPlatformInfo> aPlatforms(nPlatforms);
reinterpret_cast<__fillOpenCLInfo>(fn)(&aPlatforms[0], aPlatforms.size());
rPlatforms.swap(aPlatforms);
#else
size_t nPlatforms = getOpenCLPlatformCount();
if (!nPlatforms) if (!nPlatforms)
return; return;
...@@ -619,7 +551,6 @@ void FormulaGroupInterpreter::fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rP ...@@ -619,7 +551,6 @@ void FormulaGroupInterpreter::fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rP
::fillOpenCLInfo(&aPlatforms[0], aPlatforms.size()); ::fillOpenCLInfo(&aPlatforms[0], aPlatforms.size());
rPlatforms.swap(aPlatforms); rPlatforms.swap(aPlatforms);
#endif #endif
#endif
} }
bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect, bool bForceEvaluation) bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect, bool bForceEvaluation)
...@@ -640,23 +571,9 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool ...@@ -640,23 +571,9 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool
return true; return true;
} }
#if HAVE_FEATURE_OPENCL #if HAVE_FEATURE_OPENCL
#ifndef DISABLE_DYNLOADING bool bSuccess = ::switchOpenCLDevice(&rDeviceId, bAutoSelect, bForceEvaluation);
osl::Module* pModule = getOpenCLModule();
if (!pModule)
return false;
oslGenericFunction fn = pModule->getFunctionSymbol("switchOpenCLDevice");
if (!fn)
return false;
bool bSuccess = reinterpret_cast<__switchOpenCLDevice>(fn)(&rDeviceId, bAutoSelect, bForceEvaluation);
if(!bSuccess) if(!bSuccess)
return false; return false;
#else
bool bSuccess = switchOpenCLDevice(&rDeviceId, bAutoSelect, bForceEvaluation);
if(!bSuccess)
return false;
#endif
#else #else
(void) bAutoSelect; (void) bAutoSelect;
#endif #endif
...@@ -667,24 +584,8 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool ...@@ -667,24 +584,8 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool
#if HAVE_FEATURE_OPENCL #if HAVE_FEATURE_OPENCL
if ( ScInterpreter::GetGlobalConfig().mbOpenCLEnabled ) if ( ScInterpreter::GetGlobalConfig().mbOpenCLEnabled )
{ {
#ifdef DISABLE_DYNLOADING msInstance = ::createFormulaGroupOpenCLInterpreter();
msInstance = createFormulaGroupOpenCLInterpreter();
return msInstance != NULL; return msInstance != NULL;
#else
// Dynamically load scopencl shared object, and instantiate the opencl interpreter.
bSuccess = false;
fn = pModule->getFunctionSymbol("createFormulaGroupOpenCLInterpreter");
if (fn)
{
msInstance = reinterpret_cast<__createFormulaGroupOpenCLInterpreter>(fn)();
bSuccess = msInstance != NULL;
}
if (!msInstance)
msInstance = new sc::FormulaGroupInterpreterOpenCLMissing();
return bSuccess;
#endif
} }
#else #else
(void) bForceEvaluation; (void) bForceEvaluation;
...@@ -705,21 +606,9 @@ void FormulaGroupInterpreter::getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int3 ...@@ -705,21 +606,9 @@ void FormulaGroupInterpreter::getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int3
size_t aDeviceId = static_cast<size_t>(-1); size_t aDeviceId = static_cast<size_t>(-1);
size_t aPlatformId = static_cast<size_t>(-1); size_t aPlatformId = static_cast<size_t>(-1);
#ifndef DISABLE_DYNLOADING ::getOpenCLDeviceInfo(&aDeviceId, &aPlatformId);
osl::Module* pModule = getOpenCLModule(); rDeviceId = aDeviceId;
if (!pModule) rPlatformId = aPlatformId;
return;
oslGenericFunction fn = pModule->getFunctionSymbol("getOpenCLDeviceInfo");
if (!fn)
return;
reinterpret_cast<__getOpenCLDeviceInfo>(fn)(&aDeviceId, &aPlatformId);
#else
getOpenCLDeviceInfo(&aDeviceId, &aPlatformId);
#endif
rDeviceId = aDeviceId;
rPlatformId = aPlatformId;
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment