diff options
author | Tor Lillqvist <tml@collabora.com> | 2014-10-29 14:45:48 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2014-10-29 15:29:22 +0200 |
commit | 28561633d82df4f7909b6d8211d4bff2912f1bd6 (patch) | |
tree | 48f5b2c6d1597447e6124418bda1452a16906190 /sc | |
parent | 20860044c4a8c990a0b734c5a8eb63de4ab03260 (diff) |
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
Diffstat (limited to 'sc')
-rw-r--r-- | sc/CppunitTest_sc_opencl_test.mk | 1 | ||||
-rw-r--r-- | sc/Library_sc.mk | 33 | ||||
-rw-r--r-- | sc/Library_scopencl.mk | 67 | ||||
-rw-r--r-- | sc/Module_sc.mk | 6 | ||||
-rw-r--r-- | sc/inc/pch/precompiled_sc.hxx | 4 | ||||
-rw-r--r-- | sc/inc/pch/precompiled_scopencl.cxx | 12 | ||||
-rw-r--r-- | sc/inc/pch/precompiled_scopencl.hxx | 41 | ||||
-rw-r--r-- | sc/source/core/opencl/clcc/clew.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/opencl/opencl_device.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/opencl/openclwrapper.cxx | 5 | ||||
-rw-r--r-- | sc/source/core/tool/formulagroup.cxx | 123 |
12 files changed, 55 insertions, 253 deletions
diff --git a/sc/CppunitTest_sc_opencl_test.mk b/sc/CppunitTest_sc_opencl_test.mk index 4fc6ecbada0d..16ebd5e32bd0 100644 --- a/sc/CppunitTest_sc_opencl_test.mk +++ b/sc/CppunitTest_sc_opencl_test.mk @@ -36,7 +36,6 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_opencl_test, \ salhelper \ sax \ sc \ - $(if $(ENABLE_OPENCL),scopencl) \ scqahelper \ sfx \ sot \ diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index 5a7c03b96313..364872083a0f 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -655,6 +655,39 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ 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_set_include,sc/sdi/scslots,\ diff --git a/sc/Library_scopencl.mk b/sc/Library_scopencl.mk deleted file mode 100644 index 5f60a3736a26..000000000000 --- a/sc/Library_scopencl.mk +++ /dev/null @@ -1,67 +0,0 @@ -# -*- 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: diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index 0cb59e30ead6..56f02da58681 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -22,12 +22,6 @@ $(eval $(call gb_Module_add_l10n_targets,sc,\ UIConfig_scalc \ )) -ifneq (,$(ENABLE_OPENCL)) -$(eval $(call gb_Module_add_targets,sc,\ - Library_scopencl \ -)) -endif - ifneq (,$(filter DESKTOP,$(BUILD_TYPE))) $(eval $(call gb_Module_add_targets,sc,\ Library_scqahelper \ diff --git a/sc/inc/pch/precompiled_sc.hxx b/sc/inc/pch/precompiled_sc.hxx index 5e4dada012d9..e46f17c5ca6b 100644 --- a/sc/inc/pch/precompiled_sc.hxx +++ b/sc/inc/pch/precompiled_sc.hxx @@ -57,6 +57,7 @@ #include <boost/unordered_set.hpp> #include <cassert> #include <climits> +#include <cmath> #include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <com/sun/star/accessibility/AccessibleEventObject.hpp> #include <com/sun/star/accessibility/AccessibleRelationType.hpp> @@ -430,6 +431,7 @@ #include <comphelper/types.hxx> #include <comphelper/uno3.hxx> #include <config_features.h> +#include <config_folders.h> #include <config_mpl.h> #include <config_options.h> #include <config_orcus.h> @@ -561,6 +563,7 @@ #include <rsc/rscsfx.hxx> #include <rtl/bootstrap.hxx> #include <rtl/crc.h> +#include <rtl/digest.h> #include <rtl/instance.hxx> #include <rtl/math.hxx> #include <rtl/ref.hxx> @@ -627,6 +630,7 @@ #include <sot/filelist.hxx> #include <sot/formats.hxx> #include <sot/storage.hxx> +#include <sstream> #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/sc/inc/pch/precompiled_scopencl.cxx b/sc/inc/pch/precompiled_scopencl.cxx deleted file mode 100644 index 85d15b40e4a5..000000000000 --- a/sc/inc/pch/precompiled_scopencl.cxx +++ /dev/null @@ -1,12 +0,0 @@ -/* -*- 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: */ diff --git a/sc/inc/pch/precompiled_scopencl.hxx b/sc/inc/pch/precompiled_scopencl.hxx deleted file mode 100644 index 82714668d2fa..000000000000 --- a/sc/inc/pch/precompiled_scopencl.hxx +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- 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: */ diff --git a/sc/source/core/opencl/clcc/clew.cxx b/sc/source/core/opencl/clcc/clew.cxx index 485cd926a7dc..636c8e2623bb 100644 --- a/sc/source/core/opencl/clcc/clew.cxx +++ b/sc/source/core/opencl/clcc/clew.cxx @@ -13,7 +13,8 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #define VC_EXTRALEAN - #include <windows.h> + #include <prewin.h> + #include <postwin.h> typedef HMODULE CLCC_DYNLIB_HANDLE; diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index c8dbcced560b..42860509dbe0 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -3732,18 +3732,18 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, extern "C" { -SAL_DLLPUBLIC_EXPORT sc::FormulaGroupInterpreter* SAL_CALL +sc::FormulaGroupInterpreter* createFormulaGroupOpenCLInterpreter() { return new sc::opencl::FormulaGroupInterpreterOpenCL(); } -SAL_DLLPUBLIC_EXPORT size_t getOpenCLPlatformCount() +size_t getOpenCLPlatformCount() { return sc::opencl::getOpenCLPlatformCount(); } -SAL_DLLPUBLIC_EXPORT void SAL_CALL fillOpenCLInfo( +void fillOpenCLInfo( sc::OpenCLPlatformInfo* pInfos, size_t nInfoSize ) { const std::vector<sc::OpenCLPlatformInfo>& rPlatforms = @@ -3753,14 +3753,14 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL fillOpenCLInfo( pInfos[i] = rPlatforms[i]; } -SAL_DLLPUBLIC_EXPORT bool SAL_CALL switchOpenCLDevice( +bool switchOpenCLDevice( const OUString* pDeviceId, bool bAutoSelect, bool 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); } diff --git a/sc/source/core/opencl/opencl_device.cxx b/sc/source/core/opencl/opencl_device.cxx index 917fd24de48a..bcb3c3f59f1c 100644 --- a/sc/source/core/opencl/opencl_device.cxx +++ b/sc/source/core/opencl/opencl_device.cxx @@ -8,7 +8,8 @@ */ #ifdef _WIN32 -#include <windows.h> +#include <prewin.h> +#include <postwin.h> #elif defined __MACH__ #include <mach/mach_time.h> #else diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx index baf3bcc6de82..0f462c07d7a3 100644 --- a/sc/source/core/opencl/openclwrapper.cxx +++ b/sc/source/core/opencl/openclwrapper.cxx @@ -26,8 +26,9 @@ #include <string.h> #include <cmath> -#ifdef WIN32 -#include <windows.h> +#ifdef _WIN32 +#include <prewin.h> +#include <postwin.h> #define OPENCL_DLL_NAME "OpenCL.dll" #elif defined(MACOSX) #define OPENCL_DLL_NAME NULL diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index 1445dd312624..376b22d88438 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -30,7 +30,6 @@ #include <cstdio> #if HAVE_FEATURE_OPENCL -#ifdef DISABLE_DYNLOADING extern "C" size_t getOpenCLPlatformCount(void); extern "C" void fillOpenCLInfo(sc::OpenCLPlatformInfo*, size_t); @@ -39,7 +38,6 @@ extern "C" sc::FormulaGroupInterpreter* createFormulaGroupOpenCLInterpreter(); extern "C" void getOpenCLDeviceInfo(size_t*, size_t*); #endif -#endif namespace sc { @@ -511,53 +509,8 @@ public: #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; -#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 FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic() { @@ -590,28 +543,7 @@ void FormulaGroupInterpreter::fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rP #if !HAVE_FEATURE_OPENCL (void) rPlatforms; #else -#ifndef DISABLE_DYNLOADING - 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(); + size_t nPlatforms = ::getOpenCLPlatformCount(); if (!nPlatforms) return; @@ -619,7 +551,6 @@ void FormulaGroupInterpreter::fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rP ::fillOpenCLInfo(&aPlatforms[0], aPlatforms.size()); rPlatforms.swap(aPlatforms); #endif -#endif } bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect, bool bForceEvaluation) @@ -640,24 +571,10 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool return true; } #if HAVE_FEATURE_OPENCL -#ifndef DISABLE_DYNLOADING - 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); + bool bSuccess = ::switchOpenCLDevice(&rDeviceId, bAutoSelect, bForceEvaluation); if(!bSuccess) return false; #else - bool bSuccess = switchOpenCLDevice(&rDeviceId, bAutoSelect, bForceEvaluation); - if(!bSuccess) - return false; -#endif -#else (void) bAutoSelect; #endif @@ -667,24 +584,8 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool #if HAVE_FEATURE_OPENCL if ( ScInterpreter::GetGlobalConfig().mbOpenCLEnabled ) { -#ifdef DISABLE_DYNLOADING - msInstance = createFormulaGroupOpenCLInterpreter(); + msInstance = ::createFormulaGroupOpenCLInterpreter(); 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 (void) bForceEvaluation; @@ -705,21 +606,9 @@ void FormulaGroupInterpreter::getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int3 size_t aDeviceId = static_cast<size_t>(-1); size_t aPlatformId = static_cast<size_t>(-1); -#ifndef DISABLE_DYNLOADING - osl::Module* pModule = getOpenCLModule(); - if (!pModule) - return; - - oslGenericFunction fn = pModule->getFunctionSymbol("getOpenCLDeviceInfo"); - if (!fn) - return; - - reinterpret_cast<__getOpenCLDeviceInfo>(fn)(&aDeviceId, &aPlatformId); -#else - getOpenCLDeviceInfo(&aDeviceId, &aPlatformId); -#endif - rDeviceId = aDeviceId; - rPlatformId = aPlatformId; + ::getOpenCLDeviceInfo(&aDeviceId, &aPlatformId); + rDeviceId = aDeviceId; + rPlatformId = aPlatformId; #endif } |