BTL: - patch from Victor (add ACML support)

- fix overflow issues
This commit is contained in:
Gael Guennebaud 2009-03-05 08:11:47 +00:00
parent 6a26506341
commit a72ff5abc1
8 changed files with 102 additions and 15 deletions

View File

@ -55,7 +55,7 @@ public :
_cost = 0;
for (int j=0; j<_size; ++j)
{
int r = std::max(_size - j -1,0);
double r = std::max(_size - j -1,0);
_cost += 2*(r*j+r+j);
}
}
@ -126,7 +126,7 @@ private :
typename Interface::gene_matrix C;
int _size;
int _cost;
double _cost;
};
#endif

View File

@ -52,8 +52,8 @@ public :
_cost = 0;
for (int j=0; j<_size-2; ++j)
{
int r = std::max(0,_size-j-1);
int b = std::max(0,_size-j-2);
double r = std::max(0,_size-j-1);
double b = std::max(0,_size-j-2);
_cost += 6 + 3*b + r*r*4 + r*_size*4;
}
}

View File

@ -118,7 +118,7 @@ private :
typename Interface::gene_matrix C;
int _size;
int _cost;
double _cost;
};
#endif

View File

@ -130,7 +130,7 @@ private :
typename Interface::gene_vector B;
int _size;
int _cost;
double _cost;
};
#endif

View File

@ -0,0 +1,60 @@
# include(FindLibraryWithDebug)
if (ACML_INCLUDES AND ACML_LIBRARIES)
set(ACML_FIND_QUIETLY TRUE)
endif (ACML_INCLUDES AND ACML_LIBRARIES)
find_path(ACML_INCLUDES
NAMES
acml.h
PATHS
$ENV{ACMLDIR}/include
$ENV{ACML_DIR}/include
${INCLUDE_INSTALL_DIR}
)
find_library(ACML_LIBRARIES
NAMES
acml_mp acml_mv
PATHS
$ENV{ACMLDIR}/lib
$ENV{ACML_DIR}/lib
${LIB_INSTALL_DIR}
)
find_file(ACML_LIBRARIES
NAMES
libacml_mp.so
PATHS
/usr/lib
$ENV{ACMLDIR}/lib
${LIB_INSTALL_DIR}
)
if(NOT ACML_LIBRARIES)
message(STATUS "Multi-threaded library not found, looking for single-threaded")
find_library(ACML_LIBRARIES
NAMES
acml acml_mv
PATHS
$ENV{ACMLDIR}/lib
$ENV{ACML_DIR}/lib
${LIB_INSTALL_DIR}
)
find_file(ACML_LIBRARIES
libacml.so libacml_mv.so
PATHS
/usr/lib
$ENV{ACMLDIR}/lib
${LIB_INSTALL_DIR}
)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ACML DEFAULT_MSG
ACML_INCLUDES ACML_LIBRARIES)
mark_as_advanced(ACML_INCLUDES ACML_LIBRARIES)

View File

@ -28,3 +28,14 @@ if (GOTO_FOUND)
set_target_properties(btl_goto PROPERTIES COMPILE_FLAGS "-DCBLASNAME=GOTO -DPUREBLAS")
endif(BUILD_btl_goto)
endif (GOTO_FOUND)
find_package(ACML)
if (ACML_FOUND)
include_directories(${ACML_INCLUDES} ${PROJECT_SOURCE_DIR}/libs/f77)
btl_add_bench(btl_acml main.cpp)
if(BUILD_btl_acml)
target_link_libraries(btl_acml ${ACML_LIBRARIES} )
set_target_properties(btl_acml PROPERTIES COMPILE_FLAGS "-DCBLASNAME=ACML -DHAS_LAPACK=1 -DPUREBLAS")
endif(BUILD_btl_acml)
endif (ACML_FOUND)

View File

@ -248,7 +248,15 @@ public :
}
static inline void hessenberg(const gene_matrix & X, gene_matrix & C, int N){
#ifdef PUREBLAS
{
int N2 = N*N;
int inc = 1;
scopy_(&N2, X, &inc, C, &inc);
}
#else
cblas_scopy(N*N, X, 1, C, 1);
#endif
int info = 0;
int ilo = 1;
int ihi = N;
@ -260,7 +268,15 @@ public :
}
static inline void tridiagonalization(const gene_matrix & X, gene_matrix & C, int N){
#ifdef PUREBLAS
{
int N2 = N*N;
int inc = 1;
scopy_(&N2, X, &inc, C, &inc);
}
#else
cblas_scopy(N*N, X, 1, C, 1);
#endif
char uplo = 'U';
int info = 0;
int ilo = 1;