simplify cc_cblas test

This commit is contained in:
Radovan Bast
2015-09-17 00:35:45 +02:00
parent d33cab4a43
commit a7de2e62e9
5 changed files with 46 additions and 38 deletions

View 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

View 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()

View 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;
}