Commit ce37b73f authored by Eric J Korpela's avatar Eric J Korpela

Fixed avx detection on GCC windows compiles

More windows library detection added to configure.ac
Additional cross compile fixes for libboinc and client.
parent 77dbcfd9
......@@ -126,16 +126,16 @@ switcher_LDADD = $(LIBBOINC)
## since we are using libtool we need some magic to get boinc and boinc_client
## to both be installed properly. The next two rules do that...
all-local: boinc
all-local: boinc$(EXEEXT)
boinc: boinc_client
rm -f boinc .libs/boinc
$(LN) boinc_client boinc
if test -f .libs/boinc_client ; then $(LN) .libs/boinc_client .libs/boinc ; fi
boinc$(EXEEXT): boinc_client$(EXEEXT)
rm -f boinc$(EXEEXT) .libs/boinc$(EXEEXT)
$(LN) boinc_client$(EXEEXT) boinc$(EXEEXT)
if test -f .libs/boinc_client$(EXEEXT) ; then $(LN) .libs/boinc_client$(EXEEXT) .libs/boinc$(EXEEXT) ; fi
install-exec-hook:
rm -f $(DESTDIR)$(exec_prefix)/bin/boinc
$(LN) $(DESTDIR)$(exec_prefix)/bin/boinc_client $(DESTDIR)$(exec_prefix)/bin/boinc
rm -f $(DESTDIR)$(exec_prefix)/bin/boinc$(EXEEXT)
$(LN) $(DESTDIR)$(exec_prefix)/bin/boinc_client$(EXEEXT) $(DESTDIR)$(exec_prefix)/bin/boinc$(EXEEXT)
## these source files need to be specified because no rule uses them.
......
......@@ -23,7 +23,7 @@
#define snprintf _snprintf
#endif
#ifndef __CYGWIN__
#ifdef HAVE_INTRIN_H
#include <intrin.h>
#endif
......@@ -140,17 +140,94 @@
#define PRODUCT_CLOUD_STORAGE_SERVER 0x0000006E
#endif
/* HAVE_DECL__XGETBV should be set by autoconf or in boinc_win.h */
#if !defined(HAVE_DECL__XGETBV) || !HAVE_DECL__XGETBV
#if HAVE_DECL_XGETBV
#define _xgetbv(x) xgetbv(x)
#elif HAVE_DECL___XGETBV
#define _xgetbv(x) __xgetbv(x)
#else
static unsigned long long _xgetbv(unsigned int index){
unsigned int A=0, D=0;
#ifdef __GNUC__
#ifdef ASM_SUPPORTS_XGETBV
__asm__ __volatile__("xgetbv" : "=a"(A), "=d"(D) : "c"(index));
#else
__asm__ __volatile__(".byte 0x0f, 0x01, 0xd0": "=a"(A), "=d"(D) : "c"(index));
#endif
#elif defined(_MSC_VER)
#ifdef _M_IX86
__asm {
mov ecx,index
__emit 00fh
__emit 001h
__emit 0d0h
mov D,edx
mov A,eax
}
#elif defined(_M_AMD64)
// damn Microsoft for not having inline assembler in 64-bit code
// so this is in an NASM compiled library
return asm_xgetbv(index);
#endif
#endif
return ((unsigned long long)D << 32) | A;
}
#endif
#endif
/* HAVE_DECL___CPUID should be set by autoconf or in boinc_win.h */
#if !defined(HAVE_DECL___CPUID) || !HAVE_DECL___CPUID
#if HAVE_DECL_CPUID
#define __cpuid(x,y) cpuid(x,y)
#elif HAVE_DECL__CPUID
#define __cpuid(x,y) _cpuid(x,y)
#else
static void __cpuid(unsigned int cpuinfo[4], unsigned int type) {
#ifdef __GNUC__
#ifdef ASM_SUPPORTS_CPUID
__asm__ __volatile__("cpuid"
: "=a" (cpuinfo[0]), "=b" (cpuinfo[1]),
"=c" (cpuinfo[2]), "=d" (cpuinfo[3])
: "a" (type));
#else
__asm__ __volatile__(".byte 0x0f, 0xa2"
: "=a" (cpuinfo[0]), "=b" (cpuinfo[1]),
"=c" (cpuinfo[2]), "=d" (cpuinfo[3])
: "a" (type));
#endif
#elif defined(_MSC_VER)
#ifdef _M_IX86
__asm {
mov eax,type
__emit 00fh
__emit 0a2h
mov cpuinfo[0],eax
mov cpuinfo[1],ebx
mov cpuinfo[2],ecx
mov cpuinfo[3],edx
}
#elif defined(_M_AMD64)
// damn Microsoft for not having inline assembler in 64-bit code
// so this is in an NASM compiled library
asm_cpuid(cpuinfo,type);
#endif
#endif
}
#endif
#endif
// Returns the number of seconds difference from UTC
//
int get_timezone(int& timezone) {
int get_timezone(int& tz) {
TIME_ZONE_INFORMATION tzi;
memset(&tzi, 0, sizeof(TIME_ZONE_INFORMATION));
DWORD result = GetTimeZoneInformation(&tzi);
if (result == TIME_ZONE_ID_DAYLIGHT) {
timezone = -(tzi.Bias + tzi.DaylightBias) * 60;
tz = -(tzi.Bias + tzi.DaylightBias) * 60;
} else {
timezone = -(tzi.Bias + tzi.StandardBias) * 60;
tz = -(tzi.Bias + tzi.StandardBias) * 60;
}
return 0;
}
......@@ -648,13 +725,12 @@ int get_os_information(
//
int get_cpuid(unsigned int info_type, unsigned int& a, unsigned int& b, unsigned int& c, unsigned int& d) {
#ifdef _MSC_VER
// Microsoft compiler - use intrinsic
int retval = 1;
int CPUInfo[4] = {0,0,0,0};
unsigned int CPUInfo[4] = {0,0,0,0};
#ifdef _MSC_VER
__try {
#endif
__cpuid(CPUInfo, info_type);
a = CPUInfo[0];
......@@ -663,19 +739,11 @@ int get_cpuid(unsigned int info_type, unsigned int& a, unsigned int& b, unsigned
d = CPUInfo[3];
retval = 0;
#ifdef _MSC_VER
}
__except (EXCEPTION_EXECUTE_HANDLER) {}
return retval;
#elif defined(__GNUC__)
// GCC compiler
__asm__ __volatile__ ("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (info_type));
return 0;
#else
return 1;
#endif
return retval;
}
......@@ -785,7 +853,9 @@ int get_processor_cache(int& cache) {
return 0;
}
#ifndef _XCR_XFEATURE_ENABLED_MASK
#define _XCR_XFEATURE_ENABLED_MASK 0
#endif
// Returns true if the AVX instruction set is supported with the current
// combination of OS and CPU.
// see: http://insufficientlycomplicated.wordpress.com/2011/11/07/detecting-intel-advanced-vector-extensions-avx-in-visual-studio/
......@@ -794,9 +864,7 @@ bool is_avx_supported() {
bool supported = false;
// If Visual Studio 2010 SP1 or later
#if (_MSC_FULL_VER >= 160040219)
// Checking for AVX requires 3 things:
// Checking for AVX on Windows requires 3 things:
// 1) CPUID indicates that the OS uses XSAVE and XRSTORE
// instructions (allowing saving YMM registers on context
// switch)
......@@ -806,11 +874,11 @@ bool is_avx_supported() {
//
// Note that XGETBV is only available on 686 or later CPUs, so
// the instruction needs to be conditionally run.
int cpuInfo[4];
__cpuid(cpuInfo, 1);
unsigned int a,b,c,d;
get_cpuid(1, a, b, c, d);
bool osUsesXSAVE_XRSTORE = cpuInfo[2] & (1 << 27) || false;
bool cpuAVXSuport = cpuInfo[2] & (1 << 28) || false;
bool osUsesXSAVE_XRSTORE = c & (1 << 27) || false;
bool cpuAVXSuport = c & (1 << 28) || false;
if (osUsesXSAVE_XRSTORE && cpuAVXSuport)
{
......@@ -818,7 +886,6 @@ bool is_avx_supported() {
unsigned long long xcrFeatureMask = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);
supported = (xcrFeatureMask & 0x6) || false;
}
#endif
return supported;
}
......
......@@ -52,7 +52,7 @@
#define CONNECTED_STATE_UNKNOWN 2
#ifndef SIM
#ifdef _WIN32
#if defined(_WIN32) && ( !defined(__MINGW32__) || defined(HAVE_LIBSENSAPI) )
#include <sensapi.h>
int get_connected_state() {
......
This diff is collapsed.
......@@ -35,7 +35,7 @@
#include "app_ipc.h"
#ifdef _MSC_VER
#if !defined(HAVE_STRDUP) && defined(HAVE__STRDUP)
#define strdup _strdup
#endif
......
......@@ -41,7 +41,6 @@
#define HAVE_STD_TRANSFORM 1
#endif
#ifndef HAVE_ALLOCA
#define HAVE_ALLOCA 1
#endif
......@@ -66,10 +65,26 @@
#define HAVE_WINHTTP_H 1
#define HAVE_WINTERNL_H 1
#define HAVE_DELAYIMP_H 1
#define HAVE_INTRIN_H 1
#define HAVE_FCNTL_H 1
#define HAVE_CRTDBG_H 1
#define HAVE_DECL_FPRESET 1
#define HAVE_DECL__FPRESET 1
#define HAVE_DECL___CPUID 1
#define HAVE_MSVCRT 1
#undef HAVE_STRDUP
#define HAVE__STRDUP 1
#undef NO_PER_THREAD_LOCALE
#define HAVE_DECL__CONFIGTHREADLOCALE 1
#define HAVE__CONFIGTHREADLOCALE 1
#define HAVE_DECL___CPUID 1
#if ( _MSC_FULL_VER >= 160040219 )
#define HAVE_DECL__XGETBV 1
#else
#define HAVE_DECL__XGETBV 0
#endif
#else
// Under any system that can run configure we need to include config.h first.
......@@ -120,6 +135,7 @@
/* If we're not running under CYGWIN use windows networking */
#undef USE_WINSOCK
#define USE_WINSOCK 1
/* wxWidgets doesn't do winsock 2, so ignore it for now */
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#elif defined(HAVE_WINSOCK_H)
......
......@@ -8,14 +8,16 @@ case $1 in
export TARGET_HOST=$1
;;
esac
echo -n Checking for cross compiling environment ...
for target_host in ${TARGET_HOST} i686-w64-mingw32 i686-pc-mingw32 x86_64-w64-mingw32 x86_64-pc-mingw32 none ; do
if test ${target_host} = none ; then
echo ${target_host}
echo Cross compiling environment not found in /usr
exit 1
fi
echo Checking for cross compiling environment in /usr/${target_host}
if test -d /usr/${target_host}; then
export TARGET_HOST=${target_host}
echo /usr/${target_host}
break
fi
done
......@@ -28,7 +30,7 @@ case $TARGET_HOST in
esac
build_manager=no
build_client=no
build_client=yes
build_libs=yes
build_server=no
......@@ -123,36 +125,76 @@ if test $build_client != no -o $build_manager != no ; then
fi
fi
if test $build_manager != no ; then
if ! test -f ${XCOMPILE_ROOT}/lib/libwxbase30u.a ; then
z7=`which 7z`
if test "x${z7}" = x ; then
echo you must install 7z in the path in order to install wxwidgets
exit 1
if test $build_client != no ; then
thisdir=`pwd`
if ! test -f ${XCOMPILE_ROOT}/include/nvapi.h ; then
rsync -va ../coprocs/NVIDIA/include/* ${XCOMPILE_ROOT}/include
fi
nvdir=
if ! test -f ${XCOMPILE_ROOT}/lib/libnvapi.a ; then
mkdir NVIDIA
case $target_host in
i[56]86-*) nvdir=../coprocs/NVIDIA/mswin/Win32/Release/lib
;;
x86*|x64*) nvdir=../coprocs/NVIDIA/mswin/x64/Release/lib
;;
esac
if test x$nvdir != x ; then
rsync -va $nvdir/* NVIDIA
cd NVIDIA
obj=`ar t nvapi.lib | head -1`
objdir=`dirname $obj`
mkdir -p $objdir
ar x nvapi.lib
cd $objdir
ar cr libnvapi.a *.obj
mv *.a ${XCOMPILE_ROOT}/lib
fi
fi
cd $thisdir
rm -rf NVIDIA
fi
if test $build_manager != no ; then
if ! test -f ${XCOMPILE_ROOT}/lib/libwx_baseu_net-3.0-i686-w64-mingw32.dll.a ; then
wxver=3.0.0
gccver=481
filename=wxMSW-${wxver}_gcc${gccver}TDM_Dev.7z
mkdir wxdist
cd wxdist
wget http://sourceforge.net/projects/wxwindows/files/3.0.0/binaries/$filename/download
mv download $filename
7z x $filename
rm $filename
rsync lib/gcc${gccver}TDM_dll/*.a ${XCOMPILE_ROOT}/lib
rsync lib/gcc${gccver}TDM_dll/*.dll ${XCOMPILE_ROOT}/bin
filename=wxWidgets-${wxver}_headers.7z
filename=wxWidgets-${wxver}.tar.bz2
wget http://sourceforge.net/projects/wxwindows/files/3.0.0/$filename/download
mv download $filename
7z x $filename
rm $filename
rsync -va include/wx ${XCOMPILE_ROOT}/include
rsync -va lib/gcc${gccver}TDM_dll/mswu/wx ${XCOMPILE_ROOT}/include
tar jxf $filename
# rm -f $filename
cd wxWidgets-${wxver}
enables="--with-msw --with-libpng --with-libjpeg --with-libtiff --with-opengl --with-zlib --enable-toolbar --enable-statusbar --enable-statbmp --enable-intl --enable-accessibility --enable-catch_segvs --enable-std_containers --enable-std_iostreams --enable-std_string --enable-std_string_conv_in_wxstring --enable-permissive --enable-xlocale --enable-config --enable-protocols --enable-ftp --enable-http --enable-fileproto --enable-sockets --enable-ole --enable-dataobj --enable-ipc --enable-baseevtloop --enable-selectloop --enable-any --enable-base64 --enable-dialupman --enable-uxtheme "
./configure -C --host=$TARGET_HOST --build=$BUILD_HOST ${enables} --with-libcurl=${XCOMPILE_ROOT} --with-ssl=${XCOMPILE_ROOT} --with-winsock --prefix=${XCOMPILE_ROOT}
make all
make install
/bin/cp lib/*.a ${XCOMPILE_ROOT}/lib
/bin/cp lib/*.dll ${XCOMPILE_ROOT}/bin
/bin/mv -f ${XCOMPILE_ROOT}/lib/wx*.dll ${XCOMPILE_ROOT}/bin
cd ..
rm -rf wxdist
rm -rf wxWidgets-${wxver}
fi
fi
if test $build_manager != no ; then
if ! test -f ${XCOMPILE_ROOT}/lib/libsqlite3.a ; then
sqlite_year=2014
sqlite_ver=3080403
filename=sqlite-autoconf-${sqlite_ver}.tar.gz
wget http://www.sqlite.org/${sqlite_year}/$filename
tar zxf $filename
cd sqlite-autoconf-${sqlite_ver}
./configure -C --host=$TARGET_HOST --build=$BUILD_HOST --prefix=${XCOMPILE_ROOT} --with-sysroot=${XCOMPILE_ROOT}
make all
make install
cd ..
/bin/rm -f $filename
/bin/rm -rf sqlite-autoconf-${sqlite_ver}
fi
fi
if test $build_manager != no -o $build_libs != no ; then
if ! test -f ${XCOMPILE_ROOT}/include/GL/glut.h -a -f ${XCOMPILE_ROOT}/lib/libfreeglut_static.a ; then
svn co http://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut freeglut
......@@ -197,4 +239,4 @@ fi
../configure -C --host=$TARGET_HOST --build=$BUILD_HOST ${enables} --with-libcurl=${XCOMPILE_ROOT} --with-ssl=${XCOMPILE_ROOT} --with-winsock --prefix=${XCOMPILE_ROOT}
make -j 4 all
exit 0
#exit 0
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