ELSE()
ADD_COMPILE_OPTIONS(-DHAVE_CBLAS_H)
ENDIF()
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/sgemm.c" "
+#include <stddef.h>
+enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102 };
+enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112 };
+extern void cblas_sgemm(const enum CBLAS_ORDER Order,
+ const enum CBLAS_TRANSPOSE TA,
+ const enum CBLAS_TRANSPOSE TB,
+ const int M, const int N, const int K,
+ const float alpha, const float *A, const int lda,
+ const float *B, const int ldb, const float beta,
+ float *C, const int ldc);
+int main(int argc, char **argv)
+{
+ cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 0, 0, 0, 0, NULL, 0,
+ NULL, 0, 0, NULL, 0);
+ return 0;
+}
+")
+ try_compile(HAVE_CBLAS_SGEMM
+ ${CMAKE_CURRENT_BINARY_DIR}
+ "${CMAKE_CURRENT_BINARY_DIR}/sgemm.c"
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ LINK_LIBRARIES ${BLAS_REQUIRED_LIBRARIES}
+ OUTPUT_VARIABLE SGEMM_ERR)
+
+ # Cmake is just brain damaged
+ #CHECK_LIBRARY_EXISTS(${BLAS_REQUIRED_LIBRARIES} cblas_sgemm "" HAVE_CBLAS_SGEMM)
+ if(HAVE_CBLAS_SGEMM)
+ MESSAGE(STATUS "Blas has CBLAS sgemm")
+ ADD_COMPILE_OPTIONS(-DHAVE_CBLAS_SGEMM)
+ else()
+ MESSAGE(STATUS "Blas has -NOT- CBLAS sgemm, use internal workaround: ${SGEMM_ERR}")
+ endif()
ADD_COMPILE_OPTIONS(-DHAVE_CBLAS)
ENDIF(WITH_BLAS)
\ No newline at end of file
void kad_saxpy(int n, float a, const float *x, float *y) { kad_saxpy_inlined(n, a, x, y); }
+/* This is actually lapack not cblas, but this definition is used */
#ifdef HAVE_CBLAS
#ifndef __APPLE__
/* As gfortran mangles names */
#define ssyev ssyev_
#endif
extern void ssyev(const char* jobz, const char* uplo, int* n, float* a, int* lda, float* w, float* work, int* lwork, int* info);
+#endif
+
+#ifdef HAVE_CBLAS_SGEMM
+
#ifdef HAVE_CBLAS_H
#include "cblas.h"
#else
-/* Poor man approach */
+/* Poor man approach, thanks for that Apple */
enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102 };
enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112 };
extern void cblas_sgemm(const enum CBLAS_ORDER Order,
const float *B, const int ldb, const float beta,
float *C, const int ldc);
#endif
+
void kad_sgemm_simple(int trans_A, int trans_B, int M, int N, int K, const float *A, const float *B, float *C)
{
cblas_sgemm(CblasRowMajor, trans_A? CblasTrans : CblasNoTrans, trans_B? CblasTrans : CblasNoTrans, M, N, K, 1.0f, A, trans_A? M : K, B, trans_B? K : N, 1.0f, C, N);