simplify cc_cblas test
This commit is contained in:
parent
d33cab4a43
commit
a7de2e62e9
@ -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
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cc]
|
||||
source: ../../../modules/cc.cmake
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
||||
[static]
|
||||
source: ../../../modules/static_linking.cmake
|
@ -1,6 +1,6 @@
|
||||
if(CBLAS_FOUND)
|
||||
include_directories(${CBLAS_INCLUDE_DIR})
|
||||
add_executable(example example.c)
|
||||
add_executable(example example.cxx)
|
||||
target_link_libraries(example ${CBLAS_LIBRARIES})
|
||||
else()
|
||||
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
|
||||
def test_cc_cblas():
|
||||
configure_build_and_exe('cc_cblas', 'python setup.py --cc=gcc --cblas')
|
||||
def test_cxx_cblas():
|
||||
configure_build_and_exe('cxx_cblas', 'python setup.py --cxx=g++ --cblas')
|
||||
|
||||
|
||||
@skip_on_osx
|
||||
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\'"')
|
||||
def test_cxx_cblas_static():
|
||||
configure_build_and_exe('cxx_cblas', 'python setup.py --cxx=g++ --static --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"')
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user