Skip to content

Commit

Permalink
re-insertion of Altivec code
Browse files Browse the repository at this point in the history
[empty commit message]
  • Loading branch information
stevengj committed Jun 21, 2011
1 parent 931617e commit 32dcba1
Show file tree
Hide file tree
Showing 11 changed files with 439 additions and 14 deletions.
7 changes: 6 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ AVX_LIBS = dft/simd/avx/libdft_avx_codelets.la \
rdft/simd/avx/librdft_avx_codelets.la
endif

if HAVE_ALTIVEC
ALTIVEC_LIBS = dft/simd/altivec/libdft_altivec_codelets.la \
rdft/simd/altivec/librdft_altivec_codelets.la
endif

if SMP
if COMBINED_THREADS
COMBINED_THREADLIBS=threads/libfftw3@PREC_SUFFIX@_threads.la
Expand All @@ -51,7 +56,7 @@ libfftw3@PREC_SUFFIX@_la_LIBADD = \
rdft/scalar/r2r/librdft_scalar_r2r.la \
reodft/libreodft.la \
api/libapi.la \
$(SIMD_LIBS) $(SSE2_LIBS) $(AVX_LIBS) \
$(SIMD_LIBS) $(SSE2_LIBS) $(AVX_LIBS) $(ALTIVEC_LIBS) \
$(COMBINED_THREADLIBS)

if QUAD
Expand Down
21 changes: 13 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,17 @@ if test "${ax_cv_c_compiler_vendor}" = "gnu"; then
[AC_MSG_ERROR([Need a version of gcc with -mavx])])
fi

if test "$have_altivec" = "yes" -a "x$ALTIVEC_CFLAGS" = x; then
# -DFAKE__VEC__ is a workaround because gcc-3.3 does not
# #define __VEC__ with -maltivec.
AX_CHECK_COMPILER_FLAGS(-faltivec, [ALTIVEC_CFLAGS="-faltivec"],
[AX_CHECK_COMPILER_FLAGS(-maltivec -mabi=altivec,
[ALTIVEC_CFLAGS="-maltivec -mabi=altivec -DFAKE__VEC__"],
[AX_CHECK_COMPILER_FLAGS(-fvec, [ALTIVEC_CFLAGS="-fvec"],
[AC_MSG_ERROR([Need a version of gcc with -maltivec])])])])
fi

dnl FIXME:
dnl elif test "$have_altivec" = "yes"; then
dnl # -DFAKE__VEC__ is a workaround because gcc-3.3 does not
dnl # #define __VEC__ with -maltivec.
dnl AX_CHECK_COMPILER_FLAGS(-faltivec, [SIMD_CFLAGS="-faltivec"],
dnl [AX_CHECK_COMPILER_FLAGS(-maltivec -mabi=altivec,
dnl [SIMD_CFLAGS="-maltivec -mabi=altivec -DFAKE__VEC__"],
dnl [AX_CHECK_COMPILER_FLAGS(-fvec, [SIMD_CFLAGS="-fvec"],
dnl [AC_MSG_ERROR([Need a version of gcc with -maltivec])])])])
dnl elif test "$have_mips_ps" = "yes"; then
dnl # Just punt here and use only new 4.2 compiler :(
dnl # Should add section for older compilers...
Expand All @@ -256,6 +258,7 @@ fi

AC_SUBST(SSE2_CFLAGS)
AC_SUBST(AVX_CFLAGS)
AC_SUBST(ALTIVEC_CFLAGS)

dnl Checks for header files.
AC_HEADER_STDC
Expand Down Expand Up @@ -498,6 +501,7 @@ AC_CONFIG_FILES([
dft/simd/common/Makefile
dft/simd/sse2/Makefile
dft/simd/avx/Makefile
dft/simd/altivec/Makefile
rdft/Makefile
rdft/scalar/Makefile
Expand All @@ -508,6 +512,7 @@ AC_CONFIG_FILES([
rdft/simd/common/Makefile
rdft/simd/sse2/Makefile
rdft/simd/avx/Makefile
rdft/simd/altivec/Makefile
reodft/Makefile
Expand Down
2 changes: 1 addition & 1 deletion dft/simd/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SUBDIRS = common sse2 avx
SUBDIRS = common sse2 avx altivec
EXTRA_DIST = n1b.h n1f.h n2b.h n2f.h n2s.h q1b.h q1f.h t1b.h t1bu.h \
t1f.h t1fu.h t2b.h t2f.h t3b.h t3f.h ts.h codlist.mk simd.mk
14 changes: 14 additions & 0 deletions dft/simd/altivec/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
AM_CFLAGS = $(ALTIVEC_CFLAGS)
noinst_LTLIBRARIES = libdft_altivec_codelets.la
SIMD_HEADER=simd-altivec.h

include $(top_srcdir)/dft/simd/codlist.mk
include $(top_srcdir)/dft/simd/simd.mk

if HAVE_ALTIVEC
BUILT_SOURCES = $(EXTRA_DIST)
endif

libdft_altivec_codelets_la_SOURCES = $(BUILT_SOURCES)


11 changes: 9 additions & 2 deletions kernel/ifftw.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,15 @@ typedef struct scanner_s scanner;
/*-----------------------------------------------------------------------*/
/* alloca: */
#if HAVE_SIMD
#define MIN_ALIGNMENT 32 /* best alignment for AVX, conservative for
* everything else */
# ifdef HAVE_AVX
# define MIN_ALIGNMENT 32 /* best alignment for AVX, conservative for
* everything else */
# else
/* Note that we cannot use 32-byte alignment for all SIMD. For
example, MacOS X malloc is 16-byte aligned, but there was no
posix_memalign in MacOS X until version 10.6. */
# define MIN_ALIGNMENT 16
# endif
#endif

#if defined(HAVE_ALLOCA) && defined(FFTW_ENABLE_ALLOCA)
Expand Down
2 changes: 1 addition & 1 deletion rdft/simd/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SUBDIRS = common sse2 avx
SUBDIRS = common sse2 avx altivec
EXTRA_DIST = hc2cbv.h hc2cfv.h codlist.mk simd.mk
14 changes: 14 additions & 0 deletions rdft/simd/altivec/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
AM_CFLAGS = $(ALTIVEC_CFLAGS)
noinst_LTLIBRARIES = librdft_altivec_codelets.la
SIMD_HEADER=simd-altivec.h

include $(top_srcdir)/rdft/simd/codlist.mk
include $(top_srcdir)/rdft/simd/simd.mk

if HAVE_ALTIVEC
BUILT_SOURCES = $(EXTRA_DIST)
endif

librdft_altivec_codelets_la_SOURCES = $(BUILT_SOURCES)


2 changes: 1 addition & 1 deletion simd-support/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/kernel
noinst_LTLIBRARIES = libsimd_support.la libsimd_sse2_nonportable.la

libsimd_support_la_SOURCES = taint.c simd-common.h simd-sse2.h sse2.c \
x86-cpuid.h amd64-cpuid.h avx.c simd-avx.h
x86-cpuid.h amd64-cpuid.h avx.c simd-avx.h altivec.c simd-altivec.h

# sse2-nonportable.c needs SSE2_CFLAGS, but Automake does not support
# per-object CFLAGS. Thus we build a separate library.
Expand Down
80 changes: 80 additions & 0 deletions simd-support/altivec.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2003, 2007-8 Matteo Frigo
* Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/


#include "ifftw.h"

#if HAVE_ALTIVEC

#if HAVE_SYS_SYSCTL_H
# include <sys/sysctl.h>
#endif

#if HAVE_SYS_SYSCTL_H && HAVE_SYSCTL && defined(CTL_HW) && defined(HW_VECTORUNIT)
/* code for darwin */
static int really_have_altivec(void)
{
int mib[2], altivecp;
size_t len;
mib[0] = CTL_HW;
mib[1] = HW_VECTORUNIT;
len = sizeof(altivecp);
sysctl(mib, 2, &altivecp, &len, NULL, 0);
return altivecp;
}
#else /* GNU/Linux and other non-Darwin systems (!HAVE_SYS_SYSCTL_H etc.) */

#include <signal.h>
#include <setjmp.h>

static jmp_buf jb;

static void sighandler(int x)
{
longjmp(jb, 1);
}

static int really_have_altivec(void)
{
void (*oldsig)(int);
oldsig = signal(SIGILL, sighandler);
if (setjmp(jb)) {
signal(SIGILL, oldsig);
return 0;
} else {
__asm__ __volatile__ (".long 0x10000484"); /* vor 0,0,0 */
signal(SIGILL, oldsig);
return 1;
}
return 0;
}
#endif

int X(have_simd_altivec)(void)
{
static int init = 0, res;
if (!init) {
res = really_have_altivec();
init = 1;
}
return res;
}

#endif
Loading

0 comments on commit 32dcba1

Please sign in to comment.