Skip to content

Commit

Permalink
Make sse2 support a configure option
Browse files Browse the repository at this point in the history
  • Loading branch information
vaeth committed Sep 11, 2020
1 parent b175a0e commit eaa44b9
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 15 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ChangeLog for eix - Ebuild IndeX for portage

*eix-0.34.9
Jan Ziak <0xe2.0x9a.0x9b at gmail.com>:
- Use sse2 for speedup of eix-update.

*eix-0.34.8
Martin Väth <martin at mvath.de>:
- Fix regression of 0.34.6 (and 0.34.5): Fix override_by_map. Thanks to
Expand Down
3 changes: 3 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS

/* Define if support for sse2 is wanted */
#undef SUPPORT_SSE2

/* Define if __attribute__ ((const)) can be used for const virtuals */
#undef USE_PURE_FOR_CONST_VIRTUALS

Expand Down
31 changes: 29 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dnl each item is listed in a separate line with indent level increased;
dnl in such a case the opening/closing braces are isolated.
dnl 2. The AC_INIT macro must be in one line since it is parsed by
dnl primitive scripts.
AC_INIT([eix], [0.34.8], [https://github.com/vaeth/eix/issues/], [eix], [https://github.com/vaeth/eix/])
AC_INIT([eix], [0.34.9], [https://github.com/vaeth/eix/issues/], [eix], [https://github.com/vaeth/eix/])
AC_PREREQ([2.64])

m4_ifdef([AC_CONFIG_MACRO_DIR],
Expand Down Expand Up @@ -919,6 +919,8 @@ AC_ARG_WITH([extra-doc],
[AS_VAR_SET([extra_doc], [false])])
AM_CONDITIONAL([EXTRA_DOC], [$extra_doc])



# Use paranoic asserts?
AC_MSG_CHECKING([whether paranoic asserts are used])
AS_IF([$paranoicassert],
Expand Down Expand Up @@ -1620,7 +1622,7 @@ AC_MSG_CHECKING([whether emplace can be used])
MV_RUN_IFELSE_LINK([AC_LANG_PROGRAM([[
#include <set>
#include <utility>
]], [[
]], [[
typedef std::pair<int, int> mypair;
std::set<mypair> a;
a.insert(mypair(4, 4));
Expand All @@ -1632,6 +1634,31 @@ return (a.size() == 2) ? 0 : 1;
[Define if STL has emplace])],
[MV_MSG_RESULT([no])])

# Check if sse2 can be used
AC_MSG_CHECKING([whether sse2 should be used])
AS_VAR_SET([support_sse2], [false])
AC_ARG_WITH([sse2],
[AS_HELP_STRING([--with-sse2],
[Use sse2 instruction set])],
[AS_CASE(["$withval"],
[no], [MV_MSG_RESULT([no], [on request])],
[MV_MSG_RESULT([yes], [on request])
AS_VAR_SET([support_sse2], [:])])],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <emmintrin.h>
]], [[
#ifndef __SSE2__
#error "SSE2 not available"
#endif
]])],
[MV_MSG_RESULT([yes], [autodetected])
AS_VAR_SET([support_sse2], [:])],
[MV_MSG_RESULT([no], [autodetected])])])
AS_IF([$support_sse2],
[AC_DEFINE([SUPPORT_SSE2],
[1],
[Define if support for sse2 is wanted])])

# reset the CXXFLAGS, LDFLAGS for the normal tests
AS_VAR_COPY([CXXFLAGS], [my_cxxflags])
AS_VAR_COPY([LDFLAGS], [my_ldflags])
Expand Down
22 changes: 20 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('eix', 'cpp',
version : '0.34.8',
version : '0.34.9',
license : 'GPLv2',
default_options : [
'prefix=/usr',
Expand Down Expand Up @@ -1370,6 +1370,24 @@ message('emplace: ' + have_emplace.to_string())
conf.set('HAVE_EMPLACE', have_emplace,
description : 'Define if STL has emplace')

sse2 = get_option('sse2')
support_sse2 = false
sse2_msg = ''
if sse2 == 'auto'
sse2_msg = ' (auto)'
support_sse2 = cxx.compiles('''
#include <emmintrin.h>
#ifndef __SSE2__
#error "SSE2 not available"
#endif
''', args : flags_dialect)
elif sse2 == 'true'
support_sse2 = true
endif
message('sse2: ' + support_sse2.to_string() + sse2_msg)
conf.set('SUPPORT_SSE2', support_sse2,
description : 'Define if support for sse2 is wanted')

sqlite_dep = []
with_sqlite = false
want_sqlite = get_option('sqlite')
Expand All @@ -1383,7 +1401,7 @@ if want_sqlite != 'false'
sqlite_dep = [sqlite_only_dep]
with_sqlite = true
want_sqlite = 'true'
elif want_sqlite == true
elif want_sqlite == 'true'
error('sqlite required by option but not found')
else
want_sqlite = 'false'
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ option('swap-remote', type : 'boolean', value : false,
description : 'swap the remote paths')
option('extra-doc', type : 'boolean', value : false,
description : 'install developer documentation. Might need rst2html.py from docutils')
option('sse2', type : 'combo', choices : [ 'auto', 'true', 'false' ],
description : 'Compile in support for sse2')
option('sqlite', type : 'combo', choices : [ 'auto', 'true', 'false' ],
description : 'Compile in support for cache method sqlite')
option('protobuf', type : 'combo', choices : [ 'auto', 'true', 'false' ],
Expand Down
2 changes: 1 addition & 1 deletion src/eixTk/stringlist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ void StringList::push_back(std::string&& s) {
ptr->usage = 1;
#endif
}
ptr->push_back(std::move(s));
ptr->push_back(MOVE(s));
}
#endif
4 changes: 1 addition & 3 deletions src/eixTk/stringlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
#include "eixTk/attribute.h"
#ifdef STRINGLIST_FREE
#include "eixTk/inttypes.h"
#ifdef HAVE_MOVE
#include "eixTk/dialect.h"
#endif
#endif
#include "eixTk/diagnostics.h"
#include "eixTk/null.h"
#include "eixTk/stringtypes.h"
Expand Down Expand Up @@ -65,7 +63,7 @@ class StringListContent {

#ifdef HAVE_MOVE
void push_back(std::string&& s) {
m_list.PUSH_BACK(std::move(s));
m_list.PUSH_BACK(MOVE(s));
}
#endif

Expand Down
9 changes: 5 additions & 4 deletions src/eixTk/stringutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

#include <fnmatch.h>

#ifdef SUPPORT_SSE2
#include <emmintrin.h>
#endif

#include <locale>

#include <cstdlib>
Expand All @@ -30,9 +34,6 @@
#include "eixTk/null.h"
#include "eixTk/stringtypes.h"

#ifdef __SSE2__
#include <emmintrin.h>
#endif

using std::string;
using std::vector;
Expand Down Expand Up @@ -292,7 +293,7 @@ static void erase_escapes(string *s, const char *at) {
}

static string::size_type find_first_of(const string& str, const char *at, string::size_type pos, size_t at_len) {
#ifdef __SSE2__
#ifdef SUPPORT_SSE2
const char *s = str.c_str();
const string::size_type str_size = str.size();

Expand Down
6 changes: 3 additions & 3 deletions src/eixTk/stringutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ template<typename T> inline static void push_back(std::vector<T> *v, const T& e)
}
#ifdef HAVE_MOVE
template<typename T> inline static void push_back(std::vector<T> *v, T&& e) {
v->PUSH_BACK(std::move(e));
v->PUSH_BACK(MOVE(e));
}
#endif

Expand All @@ -496,7 +496,7 @@ template<typename T> inline static void push_back(std::set<T> *s, const T& e) {
}
#ifdef HAVE_MOVE
template<typename T> inline static void push_back(std::set<T> *s, T&& e) {
s->INSERT(std::move(e));
s->INSERT(MOVE(e));
}
#endif

Expand All @@ -509,7 +509,7 @@ template<typename T> inline static void push_back(UNORDERED_SET<T> *s, const T&
}
#ifdef HAVE_MOVE
template<typename T> inline static void push_back(UNORDERED_SET<T> *s, T&& e) {
s->INSERT(std::move(e));
s->INSERT(MOVE(e));
}
#endif
#endif // HAVE_UNORDERED_SET
Expand Down

0 comments on commit eaa44b9

Please sign in to comment.