Merge pull request #99 from miroi/cblas_test

new test cc_cblas (closes #95)
This commit is contained in:
Radovan Bast 2015-08-31 21:04:41 +02:00
commit b95993aa26
6 changed files with 71 additions and 2 deletions

View File

@ -52,7 +52,7 @@ build_script:
- 7z x OpenBLAS-v0.2.14-Win64-int32.zip > NUL
# add both OpenBLAS dynamic (libopenblas.dll) and static (libopenblas.a) library files dir to path
- set path=%path%;C:\software\OpenBLAS-v0.2.14-Win64-int32\bin;C:\software\OpenBLAS-v0.2.14-Win64-int32\lib
- set path=%path%;C:\software\OpenBLAS-v0.2.14-Win64-int32\bin;C:\software\OpenBLAS-v0.2.14-Win64-int32\lib;C:\software\OpenBLAS-v0.2.14-Win64-int32\include
# download and upgrade pip

View File

@ -128,6 +128,7 @@ set(OPENBLAS_BLAS_INCLUDE_PATH_SUFFIXES)
set(OPENBLAS_LAPACK_INCLUDE_PATH_SUFFIXES)
set(OPENBLAS_BLAS_HEADERS cblas_openblas.h openblas_config.h cblas.h f77blas.h)
set(OPENBLAS_LAPACK_HEADERS lapacke.h lapacke_config.h lapacke_mangling.h lapacke_utils.h)
set(OPENBLAS_BLAS_LIBRARY_PATH_SUFFIXES openblas openblas-base)
set(OPENBLAS_LAPACK_LIBRARY_PATH_SUFFIXES openblas openblas-base)
@ -309,6 +310,7 @@ macro(cache_math_result _service MATH_TYPE)
mark_as_advanced(${_SERVICE}_TYPE)
add_definitions(-DHAVE_${MATH_TYPE}_${_SERVICE})
message(STATUS "Setting -DHAVE_${MATH_TYPE}_${_SERVICE}")
set(HAVE_${_SERVICE} ON CACHE INTERNAL
"Defined if ${_SERVICE} is available"
)
@ -502,7 +504,8 @@ if (ENABLE_STATIC_LINKING)
BLAS_TYPE MATCHES ATLAS OR
BLAS_TYPE MATCHES SYSTEM_NATIVE OR
BLAS_TYPE MATCHES OPENBLAS)
set(MATH_LIBS ${MATH_LIBS} -Wl,--whole-archive -lpthread -Wl,--no-whole-archive)
#cc_blas_static with ATLAS on travis-ci needs -lm
set(MATH_LIBS ${MATH_LIBS} -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lm)
endif()
if (LAPACK_TYPE MATCHES MKL OR
BLAS_TYPE MATCHES MKL)

View File

@ -0,0 +1,17 @@
[project]
name: example
[cc]
source: ../../../modules/cc.cmake
[static]
source: ../../../modules/static_linking.cmake
[math_libs]
source: ../../../modules/math_libs.cmake
[default_build_paths]
source: ../../../modules/default_build_paths.cmake
[src]
source: ../../../modules/src.cmake

View File

@ -0,0 +1,10 @@
if(BLAS_FOUND)
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
#windows does not find cblas.h of openblas by default
include_directories($ENV{PATH})
endif()
add_executable(example example.c)
target_link_libraries(example ${MATH_LIBS})
else()
message(FATAL_ERROR "BLAS library not found for the test cc_cblas!")
endif()

View File

@ -0,0 +1,31 @@
#include <stdio.h>
#include <stdlib.h>
/* cblas */
#if defined HAVE_MKL_BLAS
#include "mkl_cblas.h"
#pragma message "Using Intel MKL <mkl_cblas.h> interface"
#else
#include "cblas.h"
#pragma message "Using GNU <cblas.h> interface"
#endif
void main(void)
{
int i,j,n=10;
double *a,*b,*c;
unsigned char test_ok=1;
a = (double*)malloc(n * n * sizeof(a[0]));
b = (double*)malloc(n * n * sizeof(b[0]));
c = (double*)malloc(n * n * sizeof(c[0]));
for (i = 0; i < n*n; i++) { a[i] = 1.0; b[i] = 2.0; c[i] = 0.0; }
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, n, n, n, 1.00, a, n, b, n, 0.00, c, n);
for (i = 0; i < n*n; i++) {
if (abs(c[i]) - 20.00 > 0.0) { printf ("\n ERROR: element %i is %lf",i,c[i]); test_ok = 0;}
}
if ( test_ok == 1 ) {printf("PASSED");}
free(a);free(b);free(c);
}

View File

@ -187,6 +187,14 @@ def test_fc_blas():
def test_fc_blas_static():
configure_build_and_exe('fc_blas', 'python setup.py --fc=gfortran --static --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"')
def test_cc_cblas():
configure_build_and_exe('cc_cblas', 'python setup.py --cc=gcc --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"')
def test_cc_cblas_static():
configure_build_and_exe('cc_cblas', 'python setup.py --cc=gcc --static --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"')
# ------------------------------------------------------------------------------