[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/vector_compositioning_kazakov] /: Made the per-arch compilation code reusable
From: Dmitry Kazakov <dimula73 () gmail ! com>
Date: 2012-12-06 9:52:49
Message-ID: 20121206095249.3D9F9A6091 () git ! kde ! org
[Download RAW message or body]
Git commit 262aae7d86923a8514168bf7020cf507cdcd1c42 by Dmitry Kazakov.
Committed on 04/12/2012 at 11:15.
Pushed by dkazakov into branch 'vector_compositioning_kazakov'.
Made the per-arch compilation code reusable
Now I can start making the same thing for KisAutoBrush
M +51 -0 CMakeLists.txt
M +3 -59 libs/pigment/CMakeLists.txt
M +10 -25 libs/pigment/compositeops/KoOptimizedCompositeOpFactory.cpp
M +2 -6 libs/pigment/compositeops/KoOptimizedCompositeOpFactoryPerArch.h
R +12 -3 libs/pigment/compositeops/KoOptimizedCompositeOpFactoryPerArch_Scalar.cpp \
[from: libs/pigment/compositeops/KoOptimizedCompositeOpFactory_p.cpp - 069% \
similarity] D +0 -41 \
libs/pigment/compositeops/KoOptimizedCompositeOpFactory_p.h M +28 -26 \
libs/pigment/compositeops/KoVcMultiArchBuildSupport.h
http://commits.kde.org/calligra/262aae7d86923a8514168bf7020cf507cdcd1c42
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51d867f..025510b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -327,6 +327,57 @@ if(HAVE_VC)
message(STATUS "Vc found!")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${Vc_CMAKE_MODULES_DIR}")
+ include (VcMacros)
+
+ # This is a copy-paste from VcMacros.cmake
+ # we need a version *without* Scalar implementation
+ macro(ko_compile_for_all_implementations_no_scalar_impl _objs _src)
+ set(${_objs})
+
+ # remove all -march, -msse, etc. flags from the flags we want to pass
+ string(REPLACE "${Vc_ARCHITECTURE_FLAGS}" "" _flags "${Vc_DEFINITIONS}")
+ string(REPLACE "-DVC_IMPL=[^ ]*" "" _flags "${_flags}")
+
+ # capture the -march= switch as -mtune; if there is none skip it
+ if(Vc_ARCHITECTURE_FLAGS MATCHES "-march=")
+ string(REGEX REPLACE "^.*-march=([^ ]*).*$" "-mtune=\\1" _tmp \
"${Vc_ARCHITECTURE_FLAGS}") + set(_flags "${_flags} ${_tmp}")
+ endif()
+
+ # make a semicolon separated list of all flags
+ string(TOUPPER "${CMAKE_BUILD_TYPE}" _tmp)
+ set(_tmp "CMAKE_CXX_FLAGS_${_tmp}")
+ string(REPLACE " " ";" _flags "${CMAKE_CXX_FLAGS} ${${_tmp}} ${_flags} \
${ARGN}") + get_directory_property(_inc INCLUDE_DIRECTORIES)
+ foreach(_i ${_inc})
+ list(APPEND _flags "-I${_i}")
+ endforeach()
+
+ set(_vc_compile_src "${_src}")
+
+ ##! commented out intentionally, the only difference with original
+ # _vc_compile_one_implementation(${_objs} Scalar NO_FLAG)
+ ##!
+ if(NOT Vc_SSE_INTRINSICS_BROKEN)
+ _vc_compile_one_implementation(${_objs} SSE2 "-msse2" "-xSSE2" \
"/arch:SSE2") + _vc_compile_one_implementation(${_objs} SSE3 "-msse3" \
"-xSSE3" "/arch:SSE2") + _vc_compile_one_implementation(${_objs} SSSE3 \
"-mssse3" "-xSSSE3" "/arch:SSE2") + _vc_compile_one_implementation(${_objs} \
SSE4_1 "-msse4.1" "-xSSE4.1" "/arch:SSE2") + \
_vc_compile_one_implementation(${_objs} SSE4_2 "-msse4.2" "-xSSE4.2" "/arch:SSE2") + \
_vc_compile_one_implementation(${_objs} SSE4a "-msse4a" "-xSSSE3" "/arch:SSE2") + \
endif() + if(NOT Vc_AVX_INTRINSICS_BROKEN)
+ _vc_compile_one_implementation(${_objs} AVX "-mavx" "-xAVX" \
"/arch:AVX") + endif()
+ endmacro()
+
+ macro(ko_compile_for_all_implementations_no_scalar _objs _src _opts)
+ if(PACKAGERS_BUILD)
+ ko_compile_for_all_implementations_no_scalar_impl(${_objs} ${_src} ${_opts})
+ else(PACKAGERS_BUILD)
+ set(${_objs} ${_src})
+ endif(PACKAGERS_BUILD)
+ endmacro()
if (NOT PACKAGERS_BUILD)
# Optimize the whole Calligra for current architecture
diff --git a/libs/pigment/CMakeLists.txt b/libs/pigment/CMakeLists.txt
index be440e0..a765959 100644
--- a/libs/pigment/CMakeLists.txt
+++ b/libs/pigment/CMakeLists.txt
@@ -13,67 +13,11 @@ endif(OPENEXR_FOUND)
set(LINK_VC_LIB)
if(HAVE_SANE_VC)
include_directories(${Vc_INCLUDE_DIR})
-
- set(OLD_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} )
- SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${Vc_CMAKE_MODULES_DIR}")
- include (VcMacros)
-
-if(PACKAGERS_BUILD)
-
-# This is a copy-paste from VcMacros.cmake
-# we need a version *without* Scalar implementation
-macro(ca_compile_for_all_implementations _objs _src)
- set(${_objs})
-
- # remove all -march, -msse, etc. flags from the flags we want to pass
- string(REPLACE "${Vc_ARCHITECTURE_FLAGS}" "" _flags "${Vc_DEFINITIONS}")
- string(REPLACE "-DVC_IMPL=[^ ]*" "" _flags "${_flags}")
-
- # capture the -march= switch as -mtune; if there is none skip it
- if(Vc_ARCHITECTURE_FLAGS MATCHES "-march=")
- string(REGEX REPLACE "^.*-march=([^ ]*).*$" "-mtune=\\1" _tmp \
"${Vc_ARCHITECTURE_FLAGS}")
- set(_flags "${_flags} ${_tmp}")
- endif()
-
- # make a semicolon separated list of all flags
- string(TOUPPER "${CMAKE_BUILD_TYPE}" _tmp)
- set(_tmp "CMAKE_CXX_FLAGS_${_tmp}")
- string(REPLACE " " ";" _flags "${CMAKE_CXX_FLAGS} ${${_tmp}} ${_flags} ${ARGN}")
- get_directory_property(_inc INCLUDE_DIRECTORIES)
- foreach(_i ${_inc})
- list(APPEND _flags "-I${_i}")
- endforeach()
-
- set(_vc_compile_src "${_src}")
-
-# commented out intentionally
-# _vc_compile_one_implementation(${_objs} Scalar NO_FLAG)
- if(NOT Vc_SSE_INTRINSICS_BROKEN)
- _vc_compile_one_implementation(${_objs} SSE2 "-msse2" "-xSSE2" \
"/arch:SSE2")
- _vc_compile_one_implementation(${_objs} SSE3 "-msse3" "-xSSE3" \
"/arch:SSE2")
- _vc_compile_one_implementation(${_objs} SSSE3 "-mssse3" "-xSSSE3" \
"/arch:SSE2")
- _vc_compile_one_implementation(${_objs} SSE4_1 "-msse4.1" "-xSSE4.1" \
"/arch:SSE2")
- _vc_compile_one_implementation(${_objs} SSE4_2 "-msse4.2" "-xSSE4.2" \
"/arch:SSE2")
- _vc_compile_one_implementation(${_objs} SSE4a "-msse4a" "-xSSSE3" \
"/arch:SSE2")
- endif()
- if(NOT Vc_AVX_INTRINSICS_BROKEN)
- _vc_compile_one_implementation(${_objs} AVX "-mavx" "-xAVX" \
"/arch:AVX")
- endif()
-endmacro()
-
- ca_compile_for_all_implementations(__per_arch_factory_objs \
compositeops/KoOptimizedCompositeOpFactoryPerArch.cpp "-fPIC")
-
-else(PACKAGERS_BUILD)
- set(__per_arch_factory_objs compositeops/KoOptimizedCompositeOpFactoryPerArch.cpp)
-endif(PACKAGERS_BUILD)
+ set(LINK_VC_LIB ${Vc_LIBRARIES})
+ ko_compile_for_all_implementations_no_scalar(__per_arch_factory_objs \
compositeops/KoOptimizedCompositeOpFactoryPerArch.cpp "-fPIC")
message("Following objects are generated from the per-arch lib")
message(${__per_arch_factory_objs})
-
-
- set(CMAKE_MODULE_PATH ${OLD_CMAKE_MODULE_PATH} )
-
- set(LINK_VC_LIB ${Vc_LIBRARIES})
endif(HAVE_SANE_VC)
add_subdirectory(tests)
@@ -111,7 +55,7 @@ set(pigmentcms_SRCS
colorspaces/KoRgbU8ColorSpace.cpp
colorspaces/KoSimpleColorSpaceEngine.cpp
compositeops/KoOptimizedCompositeOpFactory.cpp
- compositeops/KoOptimizedCompositeOpFactory_p.cpp
+ compositeops/KoOptimizedCompositeOpFactoryPerArch_Scalar.cpp
${__per_arch_factory_objs}
colorprofiles/KoDummyColorProfile.cpp
resources/KoAbstractGradient.cpp
diff --git a/libs/pigment/compositeops/KoOptimizedCompositeOpFactory.cpp \
b/libs/pigment/compositeops/KoOptimizedCompositeOpFactory.cpp index 0f37ccc..04b9ed4 \
100644
--- a/libs/pigment/compositeops/KoOptimizedCompositeOpFactory.cpp
+++ b/libs/pigment/compositeops/KoOptimizedCompositeOpFactory.cpp
@@ -17,55 +17,40 @@
*/
#include "KoOptimizedCompositeOpFactory.h"
-#include "KoOptimizedCompositeOpFactory_p.h"
#include "config-vc.h"
#ifdef HAVE_SANE_VC
#include <Vc/global.h>
#include <Vc/common/support.h>
-#include "KoOptimizedCompositeOpFactoryPerArch.h"
+#endif
+#include "KoOptimizedCompositeOpFactoryPerArch.h"
static struct ArchReporter {
ArchReporter() {
KoOptimizedCompositeOpFactoryPerArchBase *factory =
createOptimizedCompositeOpFactory();
- if (factory) {
- factory->printArchInfo();
- delete factory;
- }
+ factory->printArchInfo();
+ delete factory;
}
} StaticReporter;
-#endif
-
KoCompositeOp* KoOptimizedCompositeOpFactory::createAlphaDarkenOp32(const \
KoColorSpace *cs) {
-#if defined HAVE_SANE_VC
KoOptimizedCompositeOpFactoryPerArchBase *factory =
createOptimizedCompositeOpFactory();
- if (factory) {
- KoCompositeOp *op = factory->createAlphaDarkenOp32(cs);
- delete factory;
- return op;
- }
-#endif
- return KoOptimizedCompositeOpFactoryPrivate::createLegacyAlphaDarkenOp32(cs);
+ KoCompositeOp *op = factory->createAlphaDarkenOp32(cs);
+ delete factory;
+ return op;
}
KoCompositeOp* KoOptimizedCompositeOpFactory::createOverOp32(const KoColorSpace *cs)
{
-#if defined HAVE_SANE_VC
KoOptimizedCompositeOpFactoryPerArchBase *factory =
createOptimizedCompositeOpFactory();
- if (factory) {
- KoCompositeOp *op = factory->createOverOp32(cs);
- delete factory;
- return op;
- }
-#endif
-
- return KoOptimizedCompositeOpFactoryPrivate::createLegacyOverOp32(cs);
+ KoCompositeOp *op = factory->createOverOp32(cs);
+ delete factory;
+ return op;
}
diff --git a/libs/pigment/compositeops/KoOptimizedCompositeOpFactoryPerArch.h \
b/libs/pigment/compositeops/KoOptimizedCompositeOpFactoryPerArch.h index \
3418a49..e0d16b1 100644
--- a/libs/pigment/compositeops/KoOptimizedCompositeOpFactoryPerArch.h
+++ b/libs/pigment/compositeops/KoOptimizedCompositeOpFactoryPerArch.h
@@ -19,10 +19,6 @@
#ifndef KOOPTIMIZEDCOMPOSITEOPFACTORYPERARCH_H
#define KOOPTIMIZEDCOMPOSITEOPFACTORYPERARCH_H
-#include "config-vc.h"
-#ifndef HAVE_SANE_VC
-#error "BUG: There is no reason in including this file when Vc is not present"
-#endif
#include "KoVcMultiArchBuildSupport.h"
@@ -51,8 +47,8 @@ struct KoOptimizedCompositeOpFactoryPerArch : public \
KoOptimizedCompositeOpFacto
template<> KoCompositeOp* \
KoOptimizedCompositeOpFactoryPerArch<__arch>::createOverOp32(const KoColorSpace *cs); \
\
template<> void KoOptimizedCompositeOpFactoryPerArch<__arch>::printArchInfo();
-DECLARE_FOR_ALL_ARCHS_NO_SCALAR(DECLARE_FOR_ARCH);
-#define createOptimizedCompositeOpFactory \
createOptimizedFactoryNoScalar<KoOptimizedCompositeOpFactoryPerArch, \
KoOptimizedCompositeOpFactoryPerArchBase> +DECLARE_FOR_ALL_ARCHS(DECLARE_FOR_ARCH);
+#define createOptimizedCompositeOpFactory \
createOptimizedFactory<KoOptimizedCompositeOpFactoryPerArch, \
KoOptimizedCompositeOpFactoryPerArchBase>
#endif /* KOOPTIMIZEDCOMPOSITEOPFACTORYPERARCH_H */
diff --git a/libs/pigment/compositeops/KoOptimizedCompositeOpFactory_p.cpp \
b/libs/pigment/compositeops/KoOptimizedCompositeOpFactoryPerArch_Scalar.cpp \
similarity index 69% rename from \
libs/pigment/compositeops/KoOptimizedCompositeOpFactory_p.cpp rename to \
libs/pigment/compositeops/KoOptimizedCompositeOpFactoryPerArch_Scalar.cpp index \
d944a08..b2fa117 100644
--- a/libs/pigment/compositeops/KoOptimizedCompositeOpFactory_p.cpp
+++ b/libs/pigment/compositeops/KoOptimizedCompositeOpFactoryPerArch_Scalar.cpp
@@ -16,19 +16,28 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#include "KoOptimizedCompositeOpFactory_p.h"
+#include "KoOptimizedCompositeOpFactoryPerArch.h"
#include "KoColorSpaceTraits.h"
#include "KoCompositeOpAlphaDarken.h"
#include "KoCompositeOpOver.h"
-KoCompositeOp* KoOptimizedCompositeOpFactoryPrivate::createLegacyAlphaDarkenOp32(const \
KoColorSpace *cs) +template<>
+KoCompositeOp* KoOptimizedCompositeOpFactoryPerArch<Vc::ScalarImpl>::createAlphaDarkenOp32(const \
KoColorSpace *cs) {
return new KoCompositeOpAlphaDarken<KoBgrU8Traits>(cs);
}
-KoCompositeOp* KoOptimizedCompositeOpFactoryPrivate::createLegacyOverOp32(const \
KoColorSpace *cs) +template<>
+KoCompositeOp* KoOptimizedCompositeOpFactoryPerArch<Vc::ScalarImpl>::createOverOp32(const \
KoColorSpace *cs) {
return new KoCompositeOpOver<KoBgrU8Traits>(cs);
}
+
+template<>
+void KoOptimizedCompositeOpFactoryPerArch<Vc::ScalarImpl>::printArchInfo()
+{
+ qDebug() << "Legacy integer arithmetics implementation";
+
+}
diff --git a/libs/pigment/compositeops/KoOptimizedCompositeOpFactory_p.h \
b/libs/pigment/compositeops/KoOptimizedCompositeOpFactory_p.h deleted file mode \
100644 index 9c5420f..0000000
--- a/libs/pigment/compositeops/KoOptimizedCompositeOpFactory_p.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2012 Dmitry Kazakov <dimula73@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef KOOPTIMIZEDCOMPOSITEOPFACTORY_P_H
-#define KOOPTIMIZEDCOMPOSITEOPFACTORY_P_H
-
-#include "pigment_export.h"
-
-class KoCompositeOp;
-class KoColorSpace;
-
-/**
- * The creation of the legacy composite ops is moved to a separate
- * object file. Putting all the implementations together makes the
- * system run 1.4 times slower. I do not know the reason of it,
- * looks like some layout/code locality problem (DK)
- */
-
-class PIGMENTCMS_EXPORT KoOptimizedCompositeOpFactoryPrivate
-{
-public:
- static KoCompositeOp* createLegacyAlphaDarkenOp32(const KoColorSpace *cs);
- static KoCompositeOp* createLegacyOverOp32(const KoColorSpace *cs);
-};
-
-#endif /* KOOPTIMIZEDCOMPOSITEOPFACTORY_P_H */
diff --git a/libs/pigment/compositeops/KoVcMultiArchBuildSupport.h \
b/libs/pigment/compositeops/KoVcMultiArchBuildSupport.h index 166dfb2..db43dcf 100644
--- a/libs/pigment/compositeops/KoVcMultiArchBuildSupport.h
+++ b/libs/pigment/compositeops/KoVcMultiArchBuildSupport.h
@@ -19,13 +19,33 @@
#ifndef __KOVCMULTIARCHBUILDSUPPORT_H
#define __KOVCMULTIARCHBUILDSUPPORT_H
+#include "config-vc.h"
+
+#ifdef HAVE_SANE_VC
+
#include <Vc/Vc>
#include <Vc/common/support.h>
+#else /* HAVE_SANE_VC */
+
+namespace Vc {
+ typedef enum {ScalarImpl} Implementation;
+}
+
+#define VC_IMPL ::Vc::ScalarImpl
+
+#ifdef DO_PACKAGERS_BUILD
+#warning "Packagers build is not available without the presence of Vc library. \
Disabling." +#undef DO_PACKAGERS_BUILD
+#endif
+
+#endif /* HAVE_SANE_VC */
+
+
#ifdef DO_PACKAGERS_BUILD
template<template<Vc::Implementation _impl> class FactoryType, class ReturnType>
- ReturnType* createOptimizedFactoryNoScalar()
+ ReturnType* createOptimizedFactory()
{
/*if (Vc::isImplementationSupported(Vc::Fma4Impl)) {
return new FactoryType<Vc::Fma4Impl>();
@@ -46,19 +66,13 @@ template<template<Vc::Implementation _impl> class FactoryType, \
class ReturnType> return new FactoryType<Vc::SSE3Impl>();
} else if (Vc::isImplementationSupported(Vc::SSE2Impl)) {
return new FactoryType<Vc::SSE2Impl>();
+ } else {
+ return new FactoryType<Vc::ScalarImpl>();
}
-
- return 0;
}
-template<template<Vc::Implementation _impl> class FactoryType, class ReturnType>
- ReturnType* createOptimizedFactory()
-{
- ReturnType *f = createOptimizedFactoryNoScalar<FactoryType, ReturnType>();
- return f ? f : new FactoryType<Vc::ScalarImpl>();
-}
-
-#define DECLARE_FOR_ALL_ARCHS_NO_SCALAR(_DECL) \
+#define DECLARE_FOR_ALL_ARCHS(_DECL) \
+ _DECL(Vc::ScalarImpl); \
_DECL(Vc::SSE2Impl); \
_DECL(Vc::SSE3Impl); \
_DECL(Vc::SSSE3Impl); \
@@ -69,10 +83,6 @@ template<template<Vc::Implementation _impl> class FactoryType, \
class ReturnType> _DECL(Vc::XopImpl); \
_DECL(Vc::Fma4Impl);*/
-#define DECLARE_FOR_ALL_ARCHS(_DECL) \
- DECLARE_FOR_ALL_ARCHS_NO_SCALAR(_DECL); \
- _DECL(Vc::ScalarImpl);
-
#else /* DO_PACKAGERS_BUILD */
/**
@@ -81,22 +91,14 @@ template<template<Vc::Implementation _impl> class FactoryType, \
class ReturnType>
*/
template<template<Vc::Implementation _impl> class FactoryType, class ReturnType>
- ReturnType* createOptimizedFactoryNoScalar()
-{
- return new FactoryType<VC_IMPL>();
-}
-
-template<template<Vc::Implementation _impl> class FactoryType, class ReturnType>
ReturnType* createOptimizedFactory()
{
- return createOptimizedFactoryNoScalar<FactoryType, ReturnType>();
+ return new FactoryType<VC_IMPL>();
}
-#define DECLARE_FOR_ALL_ARCHS_NO_SCALAR(_DECL) \
- _DECL(VC_IMPL);
-
#define DECLARE_FOR_ALL_ARCHS(_DECL) \
- DECLARE_FOR_ALL_ARCHS_NO_SCALAR(_DECL);
+ _DECL(Vc::ScalarImpl); \
+ _DECL(VC_IMPL);
#endif /* DO_PACKAGERS_BUILD */
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic