Skip to content

Commit

Permalink
Properly fallback in non-x86 architectures.
Browse files Browse the repository at this point in the history
  • Loading branch information
ttsiodras committed Jul 11, 2022
1 parent 149a716 commit ef5449b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 18 deletions.
1 change: 0 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ Finally, come back to this source folder, and compile the XaoS
version:

$ ./configure --host=x86_64-w64-mingw32 \
--disable-sse --disable-sse2 --disable-ssse3 \
--with-sdl-prefix=/usr/local/packages/SDL-1.2.15-win32 \
--disable-sdltest
$ make
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ Finally, come back to this source folder, and compile the XaoS
version:

$ ./configure --host=x86_64-w64-mingw32 \
--disable-sse --disable-sse2 --disable-ssse3 \
--with-sdl-prefix=/usr/local/packages/SDL-1.2.15-win32 \
--disable-sdltest
$ make
Expand Down
20 changes: 10 additions & 10 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.71 for mandelSSE 2.6.
# Generated by GNU Autoconf 2.71 for mandelSSE 2.7.
#
# Report bugs to <[email protected]>.
#
Expand Down Expand Up @@ -611,8 +611,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='mandelSSE'
PACKAGE_TARNAME='mandelsse'
PACKAGE_VERSION='2.6'
PACKAGE_STRING='mandelSSE 2.6'
PACKAGE_VERSION='2.7'
PACKAGE_STRING='mandelSSE 2.7'
PACKAGE_BUGREPORT='[email protected]'
PACKAGE_URL=''

Expand Down Expand Up @@ -1345,7 +1345,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures mandelSSE 2.6 to adapt to many kinds of systems.
\`configure' configures mandelSSE 2.7 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
Expand Down Expand Up @@ -1417,7 +1417,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of mandelSSE 2.6:";;
short | recursive ) echo "Configuration of mandelSSE 2.7:";;
esac
cat <<\_ACEOF
Expand Down Expand Up @@ -1527,7 +1527,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
mandelSSE configure 2.6
mandelSSE configure 2.7
generated by GNU Autoconf 2.71
Copyright (C) 2021 Free Software Foundation, Inc.
Expand Down Expand Up @@ -1827,7 +1827,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by mandelSSE $as_me 2.6, which was
It was created by mandelSSE $as_me 2.7, which was
generated by GNU Autoconf 2.71. Invocation command line was
$ $0$ac_configure_args_raw
Expand Down Expand Up @@ -3510,7 +3510,7 @@ fi

# Define the identity of the package.
PACKAGE='mandelsse'
VERSION='2.6'
VERSION='2.7'


printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
Expand Down Expand Up @@ -7276,7 +7276,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by mandelSSE $as_me 2.6, which was
This file was extended by mandelSSE $as_me 2.7, which was
generated by GNU Autoconf 2.71. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -7344,7 +7344,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
mandelSSE config.status 2.6
mandelSSE config.status 2.7
configured by $0, generated by GNU Autoconf 2.71,
with options \\"\$ac_cs_config\\"
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([mandelSSE], [2.6], [[email protected]])
AC_INIT([mandelSSE], [2.7], [[email protected]])

AC_LANG(C++)
AC_CONFIG_HEADERS([src/config.h])
Expand Down
9 changes: 7 additions & 2 deletions src/mandel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ int main(int argc, char *argv[])
puts("[-] FPS Limit: unlimited");
else
printf("[-] FPS Limit: %d frames/sec\n", fps);
CoreLoopDouble = (__builtin_cpu_supports("avx")) ? CoreLoopDoubleAVX : CoreLoopDoubleDefault;
printf("[-] Mode: %s\n", (__builtin_cpu_supports("avx")) ? "AVX" : "non-AVX");
#ifdef __x86_64__
CoreLoopDouble = __builtin_cpu_supports("avx") ? CoreLoopDoubleAVX : CoreLoopDoubleDefault;
printf("[-] Mode: %s\n", __builtin_cpu_supports("avx") ? "AVX" : "non-AVX");
#else
CoreLoopDouble = CoreLoopDoubleDefault;
printf("[-] Mode: %s\n", "non-AVX");
#endif

init256();

Expand Down
3 changes: 3 additions & 0 deletions src/sse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ void CoreLoopDoubleDefault(double xcur, double ycur, double xstep, unsigned char
*(*p)++ = k1[3];
}

#ifdef __x86_64__

void CoreLoopDoubleAVX(double xcur, double ycur, double xstep, unsigned char **p)
{
DECLARE_ALIGNED(32,double,re[4]);
Expand Down Expand Up @@ -179,3 +181,4 @@ void CoreLoopDoubleAVX(double xcur, double ycur, double xstep, unsigned char **p
*(*p)++ = outputs[2];
*(*p)++ = outputs[3];
}
#endif
12 changes: 9 additions & 3 deletions src/xaos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ int compare_points(const void *p1, const void *p2)
0;
}

__attribute__((target_clones("default","avx")))
#if defined(__x86_64__) && !defined(__WIN64__)
#define AUTO_DISPATCH __attribute__((target_clones("default","avx")))
#else
#define AUTO_DISPATCH
#endif

AUTO_DISPATCH
void mandel(
double xld, double yld, double xru, double yru,
double percentageOfPixelsToRedraw)
Expand Down Expand Up @@ -233,7 +239,7 @@ void mandel(
SDL_UpdateRect(surface, 0, 0, MAXX, MAXY);
}

__attribute__((target_clones("default","avx")))
AUTO_DISPATCH
double autopilot()
{
static double interesting_points[][2] = {
Expand Down Expand Up @@ -296,7 +302,7 @@ double autopilot()
return ((double)frames)*1000.0/ticks;
}

__attribute__((target_clones("default","avx")))
AUTO_DISPATCH
double mousedriven()
{
int x,y;
Expand Down

0 comments on commit ef5449b

Please sign in to comment.