simplify cc_cblas test
This commit is contained in:
@ -1,31 +0,0 @@
|
|||||||
#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);
|
|
||||||
}
|
|
@ -2,8 +2,8 @@
|
|||||||
name: example
|
name: example
|
||||||
min_cmake_version: 2.8
|
min_cmake_version: 2.8
|
||||||
|
|
||||||
[cc]
|
[cxx]
|
||||||
source: ../../../modules/cc.cmake
|
source: ../../../modules/cxx.cmake
|
||||||
|
|
||||||
[static]
|
[static]
|
||||||
source: ../../../modules/static_linking.cmake
|
source: ../../../modules/static_linking.cmake
|
@ -1,6 +1,6 @@
|
|||||||
if(CBLAS_FOUND)
|
if(CBLAS_FOUND)
|
||||||
include_directories(${CBLAS_INCLUDE_DIR})
|
include_directories(${CBLAS_INCLUDE_DIR})
|
||||||
add_executable(example example.c)
|
add_executable(example example.cxx)
|
||||||
target_link_libraries(example ${CBLAS_LIBRARIES})
|
target_link_libraries(example ${CBLAS_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "CBLAS library not found")
|
message(FATAL_ERROR "CBLAS library not found")
|
39
test/cxx_cblas/src/example.cxx
Normal file
39
test/cxx_cblas/src/example.cxx
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#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
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
const int n = 10;
|
||||||
|
|
||||||
|
double a[n*n];
|
||||||
|
double b[n*n];
|
||||||
|
double c[n*n];
|
||||||
|
|
||||||
|
for (int 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.0, a, n, b, n, 0.0, c, n);
|
||||||
|
|
||||||
|
bool passed = true;
|
||||||
|
for (int i = 0; i < n*n; i++)
|
||||||
|
{
|
||||||
|
if (abs(c[i]) - 20.00 > 0.0) passed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (passed) printf("PASSED");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -170,13 +170,13 @@ def test_fc_blas_static():
|
|||||||
|
|
||||||
|
|
||||||
@skip_on_osx
|
@skip_on_osx
|
||||||
def test_cc_cblas():
|
def test_cxx_cblas():
|
||||||
configure_build_and_exe('cc_cblas', 'python setup.py --cc=gcc --cblas')
|
configure_build_and_exe('cxx_cblas', 'python setup.py --cxx=g++ --cblas')
|
||||||
|
|
||||||
|
|
||||||
@skip_on_osx
|
@skip_on_osx
|
||||||
def test_cc_cblas_static():
|
def test_cxx_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\'"')
|
configure_build_and_exe('cxx_cblas', 'python setup.py --cxx=g++ --static --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"')
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user