simplify cc_cblas test
This commit is contained in:
18
test/cxx_cblas/cmake/autocmake.cfg
Normal file
18
test/cxx_cblas/cmake/autocmake.cfg
Normal file
@ -0,0 +1,18 @@
|
||||
[project]
|
||||
name: example
|
||||
min_cmake_version: 2.8
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
||||
[static]
|
||||
source: ../../../modules/static_linking.cmake
|
||||
|
||||
[cblas]
|
||||
source: ../../../modules/cblas.cmake
|
||||
|
||||
[default_build_paths]
|
||||
source: ../../../modules/default_build_paths.cmake
|
||||
|
||||
[src]
|
||||
source: ../../../modules/src.cmake
|
7
test/cxx_cblas/src/CMakeLists.txt
Normal file
7
test/cxx_cblas/src/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
if(CBLAS_FOUND)
|
||||
include_directories(${CBLAS_INCLUDE_DIR})
|
||||
add_executable(example example.cxx)
|
||||
target_link_libraries(example ${CBLAS_LIBRARIES})
|
||||
else()
|
||||
message(FATAL_ERROR "CBLAS library not found")
|
||||
endif()
|
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;
|
||||
}
|
Reference in New Issue
Block a user