Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r1890 - in trunk: . CMake Core/Math Core/Util Model/Groups StandAlone
- Date: Fri, 30 Nov 2007 12:50:33 -0700 (MST)
Author: bigler
Date: Fri Nov 30 12:50:31 2007
New Revision: 1890
Added:
trunk/CMake/sseTest.cc
Modified:
trunk/CMake/CheckSSE.cmake
trunk/CMake/CompilerInfo.cmake
trunk/CMake/ConfigCompilerFlags.cmake
trunk/CMake/FindLibXML2.cmake
trunk/CMakeLists.txt
trunk/Core/Math/CubicSolver.h
trunk/Core/Math/Expon.h
trunk/Core/Math/SSEDefs.h
trunk/Core/Util/Preprocessor.h
trunk/Model/Groups/DynBVH.cc
trunk/Model/Groups/GriddedGroup.cc
trunk/Model/Groups/KDTree.cc
trunk/Model/Groups/Mesh.cc
trunk/StandAlone/manta.cc
Log:
CMake/CheckSSE.cmake
Use TRY_COMPILE instead of hard coded one that isn't friendly to
non-unix systems.
CMake/CompilerInfo.cmake
First stab at the VS compiler detection.
CMake/ConfigCompilerFlags.cmake
Turn off the deprecated printf function warnings and double -> float
warnings for windows. It may not actually stick, but it's in here
for reference.
CMake/FindLibXML2.cmake
Look also for libxml2. The windows version of the library
prepends lib to like in unix, but the windows version of
FIND_LIBRARY doesn't look for it like that automatically like on
unix based systems.
CMake/sseTest.cc
File used to test SSE capabilities.
CMakeLists.txt
Enforce a minimum cmake version to 2.4.5. :)
Turn on CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS. This allows one to do
this:
IF( CONDITION )
ENDIF()
IF( CONDITION )
ELSEIF( CONDITION_2 )
ENDIF()
FOREACH( var ${list} )
ENDFOREACH()
MACRO(MY_MACRO)
ENDMACRO()
This is useful for when you have a large and complicated CONDITION.
Or a short block. For larger blocks of code, please name the
closing ().
Core/Math/CubicSolver.h
Use the builtin versions of Cos, Acos, Sqrt, and Cbrt. These will
select the correct type (float -vs- double).
Core/Math/Expon.h
sqrtl, powl, and cbrtl don't exist in cygwin land.
Core/Math/SSEDefs.h
We should be using unions for reinterpret casts for the cast
functions.
We should probably make a test for these functions since they don't
seem to be supported by all sorts of compilers.
Core/Util/Preprocessor.h
Use __FUNCTION__ for MANTA_FUNC for VS.
Model/Groups/DynBVH.cc
Model/Groups/KDTree.cc
Include <algorithm> for std::sort.
Model/Groups/GriddedGroup.cc
Use Cbrt instead of cbrt for compilers that don't support it.
Model/Groups/Mesh.cc
Use MANTA_FUNC instead of __func__.
StandAlone/manta.cc
Include <string> instead of <strings.h>
Modified: trunk/CMake/CheckSSE.cmake
==============================================================================
--- trunk/CMake/CheckSSE.cmake (original)
+++ trunk/CMake/CheckSSE.cmake Fri Nov 30 12:50:31 2007
@@ -6,24 +6,27 @@
SET(NOT_MANTA_SSE 1)
# First try.
-FILE(WRITE ${CMAKE_BINARY_DIR}/test/test.c "#include <emmintrin.h>\nstatic
__m128 foo;\n\n")
-EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
- ARGS -c ${CMAKE_CXX_FLAGS} -o /dev/null ${CMAKE_BINARY_DIR}/test/test.c
- OUTPUT_VARIABLE OUTPUT
- RETURN_VALUE NOT_MANTA_SSE )
+SET(SSE_TEST_FILE ${CMAKE_SOURCE_DIR}/CMake/sseTest.cc)
+TRY_COMPILE(NOT_MANTA_SSE ${CMAKE_BINARY_DIR}/testSSE ${SSE_TEST_FILE}
+ CMAKE_FLAGS ${CMAKE_CXX_FLAGS}
+ OUTPUT_VARIABLE SSE_TEST_BUILD_OUTPUT
+ )
# If not, Try adding -msse flags and see if that makes it work.
IF (NOT_MANTA_SSE)
SET(BACKUP ${CMAKE_CXX_FLAGS})
- SET(CMAKE_CXX_FLAGS "-msse -msse2 ${BACKUP}")
+ IF (USING_WINDOWS_CL)
+ SET(CMAKE_CXX_FLAGS "/arch:SSE /arch:SSE2 ${BACKUP}")
+ ELSE()
+ SET(CMAKE_CXX_FLAGS "-msse -msse2 ${BACKUP}")
+ ENDIF()
# Test again.
- FILE(WRITE ${CMAKE_BINARY_DIR}/test/test.c "#include <emmintrin.h>\nstatic
__m128 foo;\n\n")
- EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
- ARGS -c ${CMAKE_CXX_FLAGS} -o /dev/null ${CMAKE_BINARY_DIR}/test/test.c
- OUTPUT_VARIABLE OUTPUT
- RETURN_VALUE NOT_MANTA_SSE )
+ TRY_COMPILE(NOT_MANTA_SSE ${CMAKE_BINARY_DIR}/testSSE ${SSE_TEST_FILE}
+ CMAKE_FLAGS ${CMAKE_CXX_FLAGS}
+ OUTPUT_VARIABLE SSE_TEST_BUILD_OUTPUT
+ )
# Reset the flags if they didn't help
IF(NOT_MANTA_SSE)
@@ -42,11 +45,11 @@
SET(MANTA_SSE TRUE CACHE BOOL "Compile SSE code.")
# Check to see if the system is using gcc sse intrinsics.
- FILE(WRITE ${CMAKE_BINARY_DIR}/test/test.c "#include <emmintrin.h>\nstatic
__m128i foo = _mm_set1_epi64x( (long long)1 );\n\n")
- EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
- ARGS -c ${CMAKE_CXX_FLAGS} -o /dev/null ${CMAKE_BINARY_DIR}/test/test.c
- OUTPUT_VARIABLE OUTPUT
- RETURN_VALUE NOT_MANTA_SSE_GCC )
+ TRY_COMPILE(NOT_MANTA_SSE_GCC ${CMAKE_BINARY_DIR}/testSSE ${SSE_TEST_FILE}
+ CMAKE_FLAGS ${CMAKE_CXX_FLAGS}
+ COMPILE_DEFINITIONS -DMANTA_TEST_GCC
+ OUTPUT_VARIABLE SSE_TEST_BUILD_OUTPUT
+ )
IF(NOT NOT_MANTA_SSE_GCC)
SET(MANTA_SSE_GCC TRUE CACHE BOOL "Found *epi64x intrinsics")
Modified: trunk/CMake/CompilerInfo.cmake
==============================================================================
--- trunk/CMake/CompilerInfo.cmake (original)
+++ trunk/CMake/CompilerInfo.cmake Fri Nov 30 12:50:31 2007
@@ -7,6 +7,10 @@
# Have to set this variable outside of the top level IF statement,
# since CMake will break if you use it in an IF statement.
+
+#MESSAGE("CMAKE_C_COMPILER = ${CMAKE_C_COMPILER}")
+#MESSAGE("CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}")
+
SET(MANTA_COMPILER_NAME_REGEXPR "icc.*$")
IF(NOT CMAKE_COMPILER_IS_GNUCC)
@@ -37,6 +41,13 @@
SET(USING_GPP TRUE)
ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
+SET(MANTA_COMPILER_NAME_REGEXPR "cl*$")
+IF(CMAKE_C_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR}
+ AND CMAKE_CXX_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR})
+ SET(USING_WINDOWS_CL TRUE)
+ # We should set this macro as well to get our nice trig functions
+ ADD_DEFINITIONS(-D_USE_MATH_DEFINES)
+ENDIF()
# Do some error checking
# Mixing compilers
@@ -53,13 +64,13 @@
ENDIF(USING_ICC AND USING_GPP)
# Using unknown compilers
-IF (NOT USING_ICC AND NOT USING_GCC)
+IF (NOT USING_ICC AND NOT USING_GCC AND NOT USING_WINDOWS_CL)
FIRST_TIME_MESSAGE("Specified C compiler ${CMAKE_C_COMPILER} is not
recognized (gcc, icc). Using CMake defaults.")
-ENDIF(NOT USING_ICC AND NOT USING_GCC)
+ENDIF()
-IF (NOT USING_ICPC AND NOT USING_GPP)
+IF (NOT USING_ICPC AND NOT USING_GPP AND NOT USING_WINDOWS_CL)
FIRST_TIME_MESSAGE("Specified CXX compiler ${CMAKE_CXX_COMPILER} is not
recognized (g++, icpc). Using CMake defaults.")
-ENDIF(NOT USING_ICPC AND NOT USING_GPP)
+ENDIF()
# Warn if the compiler is not icc on SGI_LINUX systems
IF (CMAKE_SYSTEM_PROCESSOR MATCHES "ia64")
Modified: trunk/CMake/ConfigCompilerFlags.cmake
==============================================================================
--- trunk/CMake/ConfigCompilerFlags.cmake (original)
+++ trunk/CMake/ConfigCompilerFlags.cmake Fri Nov 30 12:50:31 2007
@@ -53,6 +53,7 @@
SET(INTEL_OPT " ")
SET(GCC_OPT " ")
+SET(CL_OPT " ")
# Set the default warning levels for each compiler
@@ -99,6 +100,11 @@
APPEND_TO_STRING(CXX_FLAGS_RELEASE ${RELEASE_FLAGS})
ENDIF(USING_GPP)
+SET(WARNING_FLAGS "/wd4305 /wd4996")
+IF (USING_WINDOWS_CL)
+ APPEND_TO_STRING(C_FLAGS ${WARNING_FLAGS})
+ APPEND_TO_STRING(CXX_FLAGS ${WARNING_FLAGS})
+ENDIF()
##############################################################
## IA64
Modified: trunk/CMake/FindLibXML2.cmake
==============================================================================
--- trunk/CMake/FindLibXML2.cmake (original)
+++ trunk/CMake/FindLibXML2.cmake Fri Nov 30 12:50:31 2007
@@ -5,7 +5,7 @@
# Look for library here before you look in Thirdparty path
SET(LIBXML2_INSTALL_PATH "" CACHE PATH "Default search path for libxml2
install")
-FIND_LIBRARY( LIBXML2_LIBRARY NAMES xml2
+FIND_LIBRARY( LIBXML2_LIBRARY NAMES xml2 libxml2
PATHS ${LIBXML2_INSTALL_PATH}/lib ${THIRD_PARTY_LIBRARY_PATH}
/usr/lib /usr/local/lib /usr/lib
DOC "libxml2 library (This is a path.)" )
FIND_PATH ( LIBXML2_INCLUDE libxml/tree.h ${LIBXML2_INSTALL_PATH}/include
${THIRD_PARTY_INCLUDE_PATH} /usr/include/libxml2 /usr/include
/usr/local/include /usr/include
Added: trunk/CMake/sseTest.cc
==============================================================================
--- (empty file)
+++ trunk/CMake/sseTest.cc Fri Nov 30 12:50:31 2007
@@ -0,0 +1,6 @@
+#include <emmintrin.h>
+static __m128 float_sse_var;
+#ifdef MANTA_TEST_GCC
+static __m128i int_sse_var = _mm_set1_epi64x( (long long)1 );
+#endif
+
Modified: trunk/CMakeLists.txt
==============================================================================
--- trunk/CMakeLists.txt (original)
+++ trunk/CMakeLists.txt Fri Nov 30 12:50:31 2007
@@ -12,6 +12,8 @@
PROJECT (Manta)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5 FATAL_ERROR)
+
INCLUDE(CTest)
IF(BUILD_TESTING)
ENABLE_TESTING()
@@ -34,6 +36,8 @@
# make VERBOSE=1
SET(CMAKE_VERBOSE_MAKEFILE OFF)
+
+SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
############################################################
# Set default search directory prefixes for third party libraries.
Modified: trunk/Core/Math/CubicSolver.h
==============================================================================
--- trunk/Core/Math/CubicSolver.h (original)
+++ trunk/Core/Math/CubicSolver.h Fri Nov 30 12:50:31 2007
@@ -31,6 +31,8 @@
#include <math.h>
#include <stdio.h>
+#include <Core/Math/Trig.h>
+#include <Core/Math/Expon.h>
namespace Manta
{
@@ -63,7 +65,7 @@
double disc = B*B - 4*A*C;
if (disc < 0) return 0;
- disc = sqrt(disc);
+ disc = Sqrt(disc);
s[0] = (-B - disc) / (2*A);
s[1] = (-B + disc) / (2*A);
return 2;
@@ -107,7 +109,7 @@
}
else /* one single and one double solution */
{
- double u = cbrt(-q);
+ double u = Cbrt(-q);
s[ 0 ] = 2 * u;
s[ 1 ] = - u;
num = 2;
@@ -115,19 +117,19 @@
}
else if (D < 0) /* Casus irreducibilis: three real solutions */
{
- double phi = 1.0/3 * acos(-q / sqrt(-cb_p));
- double t = 2 * sqrt(-p);
+ double phi = 1.0/3 * Acos(-q / Sqrt(-cb_p));
+ double t = 2 * Sqrt(-p);
- s[ 0 ] = t * cosf(phi);
- s[ 1 ] = - t * cosf(phi + M_PI / 3);
- s[ 2 ] = - t * cosf(phi - M_PI / 3);
+ s[ 0 ] = t * Cos(phi);
+ s[ 1 ] = - t * Cos(phi + M_PI / 3);
+ s[ 2 ] = - t * Cos(phi - M_PI / 3);
num = 3;
}
else /* one real solution */
{
- double sqrt_D = sqrt(D);
- double u = cbrt(sqrt_D - q);
- double v = - cbrt(sqrt_D + q);
+ double sqrt_D = Sqrt(D);
+ double u = Cbrt(sqrt_D - q);
+ double v = - Cbrt(sqrt_D + q);
s[ 0 ] = u + v;
num = 1;
Modified: trunk/Core/Math/Expon.h
==============================================================================
--- trunk/Core/Math/Expon.h (original)
+++ trunk/Core/Math/Expon.h Fri Nov 30 12:50:31 2007
@@ -134,10 +134,12 @@
return (int)sqrt((double)i);
}
+#if !defined(__CYGWIN__)
inline long double Sqrt(long double d)
{
return sqrtl(d);
}
+#endif
inline double Sqrt(double d)
{
@@ -155,20 +157,24 @@
return pow(d, 1./3.);
}
+# if !defined(__CYGWIN__)
inline long double Cbrt(long double d)
{
return powl(d, 1./3.);
}
+# endif
#else
inline double Cbrt(double d)
{
return cbrt(d);
}
+# if !defined(__CYGWIN__)
inline long double Cbrt(long double d)
{
return cbrtl(d);
}
+# endif
#endif
inline double Sqr(double x)
Modified: trunk/Core/Math/SSEDefs.h
==============================================================================
--- trunk/Core/Math/SSEDefs.h (original)
+++ trunk/Core/Math/SSEDefs.h Fri Nov 30 12:50:31 2007
@@ -8,6 +8,7 @@
#ifdef MANTA_SSE
#include <xmmintrin.h>
+#include <emmintrin.h>
#include <Core/Util/Align.h>
#include <Core/Geometry/vecdefs.h>
#include <Core/Geometry/Vector.h>
@@ -100,12 +101,12 @@
#endif
//#ifdef __CYGWIN__
-#if __GNUC__ < 4 && !defined(__INTEL_COMPILER)
+#if (defined(__GNUC__) && __GNUC__ < 4 && !defined(__INTEL_COMPILER)) ||
defined(_MSC_VER)
// Intel casting intrinsics.
- static inline __m128i _mm_castps_si128(__m128 val) { return (__m128i)val;
}
- static inline __m128 _mm_castsi128_ps(__m128i val) { return (__m128) val;
}
- static inline __m128d _mm_castps_pd (__m128 val) { return (__m128d)val;
}
- static inline __m128 _mm_castpd_ps (__m128d val) { return (__m128) val;
}
+ static inline __m128i _mm_castps_si128(__m128 val) { union { __m128 f;
__m128i i;} c; c.f = val; return c.i; }
+ static inline __m128 _mm_castsi128_ps(__m128i val) { union { __m128 f;
__m128i i;} c; c.i = val; return c.f; }
+ static inline __m128d _mm_castps_pd (__m128 val) { union { __m128 f;
__m128d d;} c; c.f = val; return c.d; }
+ static inline __m128 _mm_castpd_ps (__m128d val) { union { __m128 f;
__m128d d;} c; c.d = val; return c.f; }
#endif
static const MANTA_ALIGN(16) sse_t _mm_eps = _mm_set_ps1(1e-5);
@@ -122,8 +123,8 @@
static const MANTA_ALIGN(16) sse_t _mm_two = _mm_set_ps1(2.f);
static const MANTA_ALIGN(16) sse_t _mm_256 = _mm_set_ps1(256);
static const MANTA_ALIGN(16) sse_t _mm_255 = _mm_set_ps1(255);
- static const MANTA_ALIGN(16) sse_t _mm_infty = _mm_set_ps1(9.9e9999f);
- static const MANTA_ALIGN(16) sse_t _mm_minus_infty =
_mm_set_ps1(-9.9e9999f);
+ static const MANTA_ALIGN(16) sse_t _mm_infty =
_mm_set_ps1(static_cast<float>(1e308));
+ static const MANTA_ALIGN(16) sse_t _mm_minus_infty =
_mm_set_ps1(static_cast<float>(-1e308));
static const int _mm_intabsmask = 0x7fffffff;
static const int _mm_intsignbit = 0x80000000;
static const int _mm_inttruemask = 0xffffffff;
Modified: trunk/Core/Util/Preprocessor.h
==============================================================================
--- trunk/Core/Util/Preprocessor.h (original)
+++ trunk/Core/Util/Preprocessor.h Fri Nov 30 12:50:31 2007
@@ -3,6 +3,8 @@
#if defined(__GNUC__)
#define MANTA_FUNC __PRETTY_FUNCTION__
+#elif defined(_MSC_VER)
+#define MANTA_FUNC __FUNCTION__ // or perhaps __FUNCDNAME__ + __FUNCSIG__
#else
#define MANTA_FUNC __func__
#endif
Modified: trunk/Model/Groups/DynBVH.cc
==============================================================================
--- trunk/Model/Groups/DynBVH.cc (original)
+++ trunk/Model/Groups/DynBVH.cc Fri Nov 30 12:50:31 2007
@@ -7,6 +7,7 @@
#include <float.h>
#include <limits>
#include <iostream>
+#include <algorithm>
#include <Core/Thread/Time.h>
#include <Interface/Context.h>
#include <Interface/Task.h>
Modified: trunk/Model/Groups/GriddedGroup.cc
==============================================================================
--- trunk/Model/Groups/GriddedGroup.cc (original)
+++ trunk/Model/Groups/GriddedGroup.cc Fri Nov 30 12:50:31 2007
@@ -81,7 +81,7 @@
Real vol3 = Cbrt(volume);
int numObjects = objs.size();
int target_numcells = static_cast<int>(numObjects*cellfactor);
- Real avgside = cbrt(static_cast<Real>(target_numcells));
+ Real avgside = Cbrt(static_cast<Real>(target_numcells));
int nx = static_cast<int>(diag.x()/vol3 * avgside + 0.8);
int ny = static_cast<int>(diag.y()/vol3 * avgside + 0.8);
int nz = static_cast<int>(diag.z()/vol3 * avgside + 0.8);
Modified: trunk/Model/Groups/KDTree.cc
==============================================================================
--- trunk/Model/Groups/KDTree.cc (original)
+++ trunk/Model/Groups/KDTree.cc Fri Nov 30 12:50:31 2007
@@ -9,6 +9,7 @@
#include <fstream>
#include <iostream>
#include <limits>
+#include <algorithm>
#define DBG(a)
@@ -187,7 +188,7 @@
BBox rBounds = bounds;
DBG(cout << "sorting " << k << " " << event[k].size() << endl);
- sort(event[k].begin(),event[k].end());
+ std::sort(event[k].begin(),event[k].end());
int Nl = 0;
int Nr = primitiveID.size();
Modified: trunk/Model/Groups/Mesh.cc
==============================================================================
--- trunk/Model/Groups/Mesh.cc (original)
+++ trunk/Model/Groups/Mesh.cc Fri Nov 30 12:50:31 2007
@@ -131,13 +131,13 @@
void Mesh::add(Object* obj)
{
//I don't think this should be allowed.
- throw InternalError(string("Illegal call to ") + __func__);
+ throw InternalError(string("Illegal call to ") + MANTA_FUNC);
}
void Mesh::set( int i, Object *obj )
{
//I don't think this should be allowed.
- throw InternalError(string("Illegal call to ") + __func__);
+ throw InternalError(string("Illegal call to ") + MANTA_FUNC);
}
MeshTriangle* Mesh::get( size_t i ) {
Modified: trunk/StandAlone/manta.cc
==============================================================================
--- trunk/StandAlone/manta.cc (original)
+++ trunk/StandAlone/manta.cc Fri Nov 30 12:50:31 2007
@@ -65,7 +65,7 @@
#include <Model/Primitives/Sphere.h>
#include <Model/TexCoordMappers/UniformMapper.h>
#include <Core/Thread/Thread.h>
-#include <strings.h>
+#include <string>
#include <iostream>
using namespace std;
- [Manta] r1890 - in trunk: . CMake Core/Math Core/Util Model/Groups StandAlone, bigler, 11/30/2007
Archive powered by MHonArc 2.6.16.