aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/btl
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2014-03-07 23:11:38 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2014-03-07 23:11:38 +0100
commit33ca9b4ee690ed12bd072273ea0d24c5eaae77fd (patch)
treeda594d569232820e15e4a9f3f9f1bd2d85df291f /bench/btl
parentce41b72eb8b0657957893275e4936b0961bae80b (diff)
Add support for OSX in BTL and fix a few warnings
Diffstat (limited to 'bench/btl')
-rw-r--r--bench/btl/CMakeLists.txt8
-rw-r--r--bench/btl/generic_bench/bench.hh4
-rw-r--r--bench/btl/generic_bench/btl.hh2
-rw-r--r--bench/btl/generic_bench/init/init_matrix.hh10
-rw-r--r--bench/btl/generic_bench/init/init_vector.hh2
-rw-r--r--bench/btl/generic_bench/timers/portable_perf_analyzer.hh2
-rwxr-xr-xbench/btl/generic_bench/timers/portable_timer.hh46
-rw-r--r--bench/btl/libs/eigen3/eigen3_interface.hh8
8 files changed, 65 insertions, 17 deletions
diff --git a/bench/btl/CMakeLists.txt b/bench/btl/CMakeLists.txt
index 119b470d9..0ac5c15fc 100644
--- a/bench/btl/CMakeLists.txt
+++ b/bench/btl/CMakeLists.txt
@@ -48,6 +48,12 @@ include_directories(
# set(DEFAULT_LIBRARIES ${MKL_LIBRARIES})
# endif (MKL_FOUND)
+find_library(EIGEN_BTL_RT_LIBRARY rt)
+# if we cannot find it easily, then we don't need it!
+if(NOT EIGEN_BTL_RT_LIBRARY)
+ set(EIGEN_BTL_RT_LIBRARY "")
+endif()
+
MACRO(BTL_ADD_BENCH targetname)
foreach(_current_var ${ARGN})
@@ -70,7 +76,7 @@ MACRO(BTL_ADD_BENCH targetname)
IF(BUILD_${targetname})
ADD_EXECUTABLE(${targetname} ${_sources})
ADD_TEST(${targetname} "${targetname}")
- target_link_libraries(${targetname} ${DEFAULT_LIBRARIES} rt)
+ target_link_libraries(${targetname} ${DEFAULT_LIBRARIES} ${EIGEN_BTL_RT_LIBRARY})
ENDIF(BUILD_${targetname})
ENDMACRO(BTL_ADD_BENCH)
diff --git a/bench/btl/generic_bench/bench.hh b/bench/btl/generic_bench/bench.hh
index 005c36395..7b7b951b5 100644
--- a/bench/btl/generic_bench/bench.hh
+++ b/bench/btl/generic_bench/bench.hh
@@ -102,8 +102,8 @@ BTL_DONT_INLINE void bench( int size_min, int size_max, int nb_point )
// merge the two data
std::vector<int> newSizes;
std::vector<double> newFlops;
- int i=0;
- int j=0;
+ unsigned int i=0;
+ unsigned int j=0;
while (i<tab_sizes.size() && j<oldSizes.size())
{
if (tab_sizes[i] == oldSizes[j])
diff --git a/bench/btl/generic_bench/btl.hh b/bench/btl/generic_bench/btl.hh
index f1a88ff74..4670f5113 100644
--- a/bench/btl/generic_bench/btl.hh
+++ b/bench/btl/generic_bench/btl.hh
@@ -46,7 +46,7 @@
#if (defined __GNUC__) && (!defined __INTEL_COMPILER) && !defined(__arm__) && !defined(__powerpc__)
#define BTL_DISABLE_SSE_EXCEPTIONS() { \
- int aux; \
+ int aux = 0; \
asm( \
"stmxcsr %[aux] \n\t" \
"orl $32832, %[aux] \n\t" \
diff --git a/bench/btl/generic_bench/init/init_matrix.hh b/bench/btl/generic_bench/init/init_matrix.hh
index 67cbd2073..6382d30c8 100644
--- a/bench/btl/generic_bench/init/init_matrix.hh
+++ b/bench/btl/generic_bench/init/init_matrix.hh
@@ -29,7 +29,7 @@ BTL_DONT_INLINE void init_row(Vector & X, int size, int row){
X.resize(size);
- for (int j=0;j<X.size();j++){
+ for (unsigned int j=0;j<X.size();j++){
X[j]=typename Vector::value_type(init_function(row,j));
}
}
@@ -42,7 +42,7 @@ BTL_DONT_INLINE void init_row(Vector & X, int size, int row){
template<double init_function(int,int),class Vector>
BTL_DONT_INLINE void init_matrix(Vector & A, int size){
A.resize(size);
- for (int row=0; row<A.size() ; row++){
+ for (unsigned int row=0; row<A.size() ; row++){
init_row<init_function>(A[row],size,row);
}
}
@@ -50,11 +50,11 @@ BTL_DONT_INLINE void init_matrix(Vector & A, int size){
template<double init_function(int,int),class Matrix>
BTL_DONT_INLINE void init_matrix_symm(Matrix& A, int size){
A.resize(size);
- for (int row=0; row<A.size() ; row++)
+ for (unsigned int row=0; row<A.size() ; row++)
A[row].resize(size);
- for (int row=0; row<A.size() ; row++){
+ for (unsigned int row=0; row<A.size() ; row++){
A[row][row] = init_function(row,row);
- for (int col=0; col<row ; col++){
+ for (unsigned int col=0; col<row ; col++){
double x = init_function(row,col);
A[row][col] = A[col][row] = x;
}
diff --git a/bench/btl/generic_bench/init/init_vector.hh b/bench/btl/generic_bench/init/init_vector.hh
index efaf0c92e..518e87dbe 100644
--- a/bench/btl/generic_bench/init/init_vector.hh
+++ b/bench/btl/generic_bench/init/init_vector.hh
@@ -29,7 +29,7 @@ void init_vector(Vector & X, int size){
X.resize(size);
- for (int i=0;i<X.size();i++){
+ for (unsigned int i=0;i<X.size();i++){
X[i]=typename Vector::value_type(init_function(i));
}
}
diff --git a/bench/btl/generic_bench/timers/portable_perf_analyzer.hh b/bench/btl/generic_bench/timers/portable_perf_analyzer.hh
index fc0f3168d..5e579fb49 100644
--- a/bench/btl/generic_bench/timers/portable_perf_analyzer.hh
+++ b/bench/btl/generic_bench/timers/portable_perf_analyzer.hh
@@ -78,7 +78,7 @@ public:
// time measurement
action.calculate();
_chronos.start();
- for (int ii=0;ii<_nb_calc;ii++)
+ for (unsigned int ii=0;ii<_nb_calc;ii++)
{
action.calculate();
}
diff --git a/bench/btl/generic_bench/timers/portable_timer.hh b/bench/btl/generic_bench/timers/portable_timer.hh
index e6ad309fe..c199811b6 100755
--- a/bench/btl/generic_bench/timers/portable_timer.hh
+++ b/bench/btl/generic_bench/timers/portable_timer.hh
@@ -34,7 +34,7 @@
// timer -------------------------------------------------------------------//
// A timer object measures CPU time.
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
#define NOMINMAX
#include <windows.h>
@@ -87,6 +87,48 @@
}; // Portable_Timer
+#elif defined(__APPLE__)
+#include <CoreServices/CoreServices.h>
+#include <mach/mach_time.h>
+
+
+class Portable_Timer
+{
+ public:
+
+ Portable_Timer()
+ {
+ }
+
+ void start()
+ {
+ m_start_time = double(mach_absolute_time())*1e-9;;
+
+ }
+
+ void stop()
+ {
+ m_stop_time = double(mach_absolute_time())*1e-9;;
+
+ }
+
+ double elapsed()
+ {
+ return user_time();
+ }
+
+ double user_time()
+ {
+ return m_stop_time - m_start_time;
+ }
+
+
+private:
+
+ double m_stop_time, m_start_time;
+
+}; // Portable_Timer (Apple)
+
#else
#include <sys/time.h>
@@ -138,7 +180,7 @@ private:
int m_clkid;
double m_stop_time, m_start_time;
-}; // Portable_Timer
+}; // Portable_Timer (Linux)
#endif
diff --git a/bench/btl/libs/eigen3/eigen3_interface.hh b/bench/btl/libs/eigen3/eigen3_interface.hh
index 31bcc1f93..0c8aa74da 100644
--- a/bench/btl/libs/eigen3/eigen3_interface.hh
+++ b/bench/btl/libs/eigen3/eigen3_interface.hh
@@ -52,8 +52,8 @@ public :
static BTL_DONT_INLINE void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){
A.resize(A_stl[0].size(), A_stl.size());
- for (int j=0; j<A_stl.size() ; j++){
- for (int i=0; i<A_stl[j].size() ; i++){
+ for (unsigned int j=0; j<A_stl.size() ; j++){
+ for (unsigned int i=0; i<A_stl[j].size() ; i++){
A.coeffRef(i,j) = A_stl[j][i];
}
}
@@ -62,13 +62,13 @@ public :
static BTL_DONT_INLINE void vector_from_stl(gene_vector & B, stl_vector & B_stl){
B.resize(B_stl.size(),1);
- for (int i=0; i<B_stl.size() ; i++){
+ for (unsigned int i=0; i<B_stl.size() ; i++){
B.coeffRef(i) = B_stl[i];
}
}
static BTL_DONT_INLINE void vector_to_stl(gene_vector & B, stl_vector & B_stl){
- for (int i=0; i<B_stl.size() ; i++){
+ for (unsigned int i=0; i<B_stl.size() ; i++){
B_stl[i] = B.coeff(i);
}
}