- Check for packaged streflop and use it before using embedded copy

This commit is contained in:
SoftCoder
2017-02-05 16:48:50 -08:00
parent b9a0a31127
commit 8195121fca
9 changed files with 247 additions and 41 deletions

View File

@@ -1,15 +1,50 @@
AUX_SOURCE_DIRECTORY(libm/flt-32 libm_flt32_source)
find_package(PkgConfig REQUIRED)
IF(FORCE_STREFLOP_SOFTWRAPPER)
pkg_search_module(STREFLOP streflop-soft)
ELSE()
IF(HAS_SSE_EXTENSIONS AND NOT ${FORCE_MAX_SSE_LEVEL} MATCHES "0")
pkg_search_module(STREFLOP streflop-sse)
ELSE()
IF(HAS_X87_SUPPORT)
pkg_search_module(STREFLOP streflop-x87)
ELSE()
pkg_search_module(STREFLOP streflop-soft)
ENDIF()
ENDIF()
ENDIF()
IF(NOT STREFLOP_FOUND)
pkg_search_module(STREFLOP streflop)
ENDIF()
MESSAGE(STATUS "Search for Library STREFLOP result = ${STREFLOP_FOUND} libs: ${STREFLOP_LIBRARIES} include dirs: ${STREFLOP_INCLUDE_DIRS}")
SET(cxxflags "-w -O3 -I${CMAKE_CURRENT_SOURCE_DIR}/libm/headers")
if (NOT $ENV{CXX} MATCHES "icpc")
SET(cxxflags "${cxxflags} -mfpmath=sse -msse")
endif (NOT $ENV{CXX} MATCHES "icpc")
SET_SOURCE_FILES_PROPERTIES(${libm_flt32_source} PROPERTIES COMPILE_FLAGS "-DLIBM_COMPILING_FLT32 ${cxxflags}")
IF(FORCE_EMBEDDED_LIBS)
SET(STREFLOP_FOUND OFF)
MESSAGE(STATUS "FORCING USE of EMBEDDED Libraries...")
ENDIF()
ADD_LIBRARY(streflop STATIC EXCLUDE_FROM_ALL
SMath.cpp
Random.cpp
streflopC.cpp
${libm_flt32_source}
)
set_target_properties(streflop PROPERTIES COMPILE_FLAGS "${PIC_FLAG}")
IF(WANT_USE_STREFLOP)
IF(STREFLOP_FOUND)
INCLUDE_DIRECTORIES(${STREFLOP_INCLUDE_DIRS} ${STREFLOP_INCLUDE_DIRS}/streflop)
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${STREFLOP_LIBRARIES})
ADD_DEFINITIONS("-DUSE_STREFLOP_PKG")
ENDIF()
ENDIF()
IF(NOT STREFLOP_FOUND)
AUX_SOURCE_DIRECTORY(libm/flt-32 libm_flt32_source)
SET(cxxflags "-w -O3 -I${CMAKE_CURRENT_SOURCE_DIR}/libm/headers")
if (NOT $ENV{CXX} MATCHES "icpc")
SET(cxxflags "${cxxflags} -mfpmath=sse -msse")
endif (NOT $ENV{CXX} MATCHES "icpc")
SET_SOURCE_FILES_PROPERTIES(${libm_flt32_source} PROPERTIES COMPILE_FLAGS "-DLIBM_COMPILING_FLT32 ${cxxflags}")
ADD_LIBRARY(streflop STATIC EXCLUDE_FROM_ALL
SMath.cpp
Random.cpp
streflopC.cpp
${libm_flt32_source}
)
set_target_properties(streflop PROPERTIES COMPILE_FLAGS "${PIC_FLAG}")
ENDIF()

View File

@@ -15,7 +15,7 @@
//#include "LogOutput.h"
#include "util.h"
#include "streflop_cond.h"
#include "../../include/platform/common/streflop_cond.h"
/**
@brief checks FPU control registers.

View File

@@ -1,73 +0,0 @@
/* Copyright (C) 2008 Tobi Vollebregt
2010 Mark Vejvoda
You can redistribute this code 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
==============================================================
*/
/* Conditionally include streflop depending on STREFLOP_* #defines:
If one of those is present, #include "streflop.h", otherwise #include <math.h>
When faced with ambiguous call errors with e.g. fabs, use math::function.
Add it to math namespace if it doesn't exist there yet. */
#ifndef STREFLOP_COND_H
#define STREFLOP_COND_H
#if defined(STREFLOP_X87) || defined(STREFLOP_SSE) || defined(STREFLOP_SOFT)
#include "streflop.h"
using namespace streflop;
namespace math {
using namespace streflop;
}
#else
#include <cmath>
namespace math {
using std::fabs;
// using std::sqrt;
using std::sin;
using std::cos;
using std::sinh;
using std::cosh;
using std::tan;
using std::tanh;
using std::asin;
using std::acos;
using std::atan;
using std::atan2;
using std::ceil;
using std::floor;
using std::fmod;
using std::pow;
using std::log;
using std::log10;
using std::exp;
using std::frexp;
using std::ldexp;
// the following are C99 functions -> not supported by VS C
#if !defined(_MSC_VER) || _MSC_VER < 1500
using std::isnan;
using std::isinf;
using std::isfinite;
#elif __cplusplus
template<typename T> inline bool isnan(T value) {
return value != value;
}
// requires include <limits>
template<typename T> inline bool isinf(T value) {
return std::numeric_limits<T>::has_infinity && value == std::numeric_limits<T>::infinity();
}
// requires include <limits>
template<typename T> inline bool isfinite(T value) {
return !isinf<T>(value);
}
#endif
}
#endif
#endif // STREFLOP_COND_H