Commit 93e3ae0c authored by Dmitry Kazakov's avatar Dmitry Kazakov

Added a PACKAGERS_BUILD option for code generation for many architectures

This option is disabled by default.

By default we build the whole Calligra optimized for the host architecture.
When the option is on, the hottest parts of calligra will compile optimized
for several most popular architectures. The rest of the code will not use
any brand-new instructions for not breaking binary compatibility among cpus.

Short manual:
1) If you build Calligra for yourself and are not going to copy Krita binary
   to another CPU, disable this option.
2) If you build a Calligra package and are going to distribute it among users,
   then enable the option.
parent ab38362c
......@@ -41,6 +41,7 @@ option(NEPOMUK "support NEPOMUK Tagging" ON)
option(TINY "compile a tiny Calligra" OFF)
option(CREATIVEONLY "compile only Karbon and Krita" OFF)
option(QT3SUPPORT "Build the parts of Calligra that still depend on Qt3" ON)
option(PACKAGERS_BUILD "Build support of multiple CPU architectures in one binary. Should be used by packagers only." OFF)
IF (TINY)
set(SHOULD_BUILD_WORDS TRUE)
......@@ -315,6 +316,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
macro_optional_find_package(Vc)
macro_log_feature(Vc_FOUND "Vc" "Portable, zero-overhead SIMD library for C++" "http://code.compeng.uni-frankfurt.de/projects/vc" FALSE "" "Required by the Krita for vectorization")
macro_bool_to_01(Vc_FOUND HAVE_VC)
macro_bool_to_01(PACKAGERS_BUILD DO_PACKAGERS_BUILD)
if(NOT MSVC)
macro_bool_to_01(Vc_FOUND HAVE_SANE_VC)
endif(NOT MSVC)
......@@ -324,8 +327,11 @@ if(HAVE_VC)
message(STATUS "Vc found!")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${Vc_CMAKE_MODULES_DIR}")
# include (OptimizeForArchitecture)
# OptimizeForArchitecture()
if (NOT PACKAGERS_BUILD)
# Optimize the whole Calligra for current architecture
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Vc_DEFINITIONS}")
endif (NOT PACKAGERS_BUILD)
endif(HAVE_VC)
set(CMAKE_MODULE_PATH ${OLD_CMAKE_MODULE_PATH} )
......
......@@ -3,5 +3,6 @@
/* Define if you have Vc, the vectorization library */
#cmakedefine HAVE_VC 1
#cmakedefine HAVE_SANE_VC 1
#cmakedefine DO_PACKAGERS_BUILD 1
......@@ -18,6 +18,8 @@ if(HAVE_SANE_VC)
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)
......@@ -59,10 +61,16 @@ macro(ca_compile_for_all_implementations _objs _src)
endif()
endmacro()
ca_compile_for_all_implementations(__per_arch_factory_objs compositeops/KoOptimizedCompositeOpFactoryPerArch.cpp "-fPIC")
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)
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})
......
......@@ -22,6 +22,8 @@
#include <Vc/Vc>
#include <Vc/common/support.h>
#ifdef DO_PACKAGERS_BUILD
template<template<Vc::Implementation _impl> class FactoryType, class ReturnType>
ReturnType* createOptimizedFactoryNoScalar()
{
......@@ -71,4 +73,31 @@ template<template<Vc::Implementation _impl> class FactoryType, class ReturnType>
DECLARE_FOR_ALL_ARCHS_NO_SCALAR(_DECL); \
_DECL(Vc::ScalarImpl);
#else /* DO_PACKAGERS_BUILD */
/**
* When doing not a packager's build we have one architecture only,
* so the factory methods are simplified
*/
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>();
}
#define DECLARE_FOR_ALL_ARCHS_NO_SCALAR(_DECL) \
_DECL(VC_IMPL);
#define DECLARE_FOR_ALL_ARCHS(_DECL) \
DECLARE_FOR_ALL_ARCHS_NO_SCALAR(_DECL);
#endif /* DO_PACKAGERS_BUILD */
#endif /* __KOVCMULTIARCHBUILDSUPPORT_H */
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