set(OpenBLAS_LIBNAME openblas)
#######
+if(MSVC)
option(BUILD_WITHOUT_LAPACK "Without LAPACK and LAPACKE (Only BLAS or CBLAS)" ON)
-option(BUILD_WITHOUT_CBLAS "Without CBLAS" ON)
+endif()
+option(BUILD_WITHOUT_CBLAS "Without CBLAS" OFF)
option(BUILD_DEBUG "Build Debug Version" OFF)
#######
if(BUILD_WITHOUT_LAPACK)
endif()
# add objects to the openblas lib
-add_library(${OpenBLAS_LIBNAME} SHARED ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS} ${PROJECT_BINARY_DIR}/openblas.def)
+add_library(${OpenBLAS_LIBNAME} SHARED ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS} ${OpenBLAS_DEF_FILE})
include("${CMAKE_SOURCE_DIR}/cmake/export.cmake")
-#only build shared library for MSVC
+
if(NOT MSVC)
+#only build shared library for MSVC
add_library(${OpenBLAS_LIBNAME}_static STATIC ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS})
set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES OUTPUT_NAME ${OpenBLAS_LIBNAME})
set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+
+if(SMP)
+target_link_libraries(${OpenBLAS_LIBNAME} pthread)
+target_link_libraries(${OpenBLAS_LIBNAME}_static pthread)
+endif()
+
+#build test and ctest
+enable_testing()
+add_subdirectory(test)
+if(NOT NO_CBLAS)
+add_subdirectory(ctest)
+endif()
endif()
set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES
# PTHREAD_CREATE_FUNC
# N.B. c_check (and ctest.c) is not cross-platform, so instead try to use CMake variables.
-
-# TODO: detect FU (front underscore) by compiling ctest1.c
+set(FU "")
+if(APPLE)
+set(FU "_")
+elseif(MSVC)
set(FU "_")
+elseif(UNIX)
+set(FU "")
+endif()
# Convert CMake vars into the format that OpenBLAS expects
string(TOUPPER ${CMAKE_SYSTEM_NAME} HOST_OS)
set(XGEMVNKERNEL zgemv_n.S)
set(XGEMVTKERNEL zgemv_t.S)
set(SCABS_KERNEL ../generic/cabs.c)
- set(DCABS_KERNEL ../generic/cabs.S)
- set(QCABS_KERNEL ../generic/cabs.S)
+ set(DCABS_KERNEL ../generic/cabs.c)
+ set(QCABS_KERNEL ../generic/cabs.c)
set(LSAME_KERNEL ../generic/lsame.c)
set(SAXPBYKERNEL ../arm/axpby.c)
set(DAXPBYKERNEL ../arm/axpby.c)
# add lapack-netlib folder to the sources
set(LAPACKE_SOURCES "")
foreach (LAE_FILE ${LAPACKE_REL_SRC})
- list(APPEND LAPACKE_SOURCES "${NETLIB_LAPACK_DIR}/lapacke/SRC/${LAE_FILE}")
+ list(APPEND LAPACKE_SOURCES "${NETLIB_LAPACK_DIR}/lapacke/src/${LAE_FILE}")
endforeach ()
set(lapacke_include_dir "${NETLIB_LAPACK_DIR}/lapacke/include")
(__GNUC__ >= 3 && !defined(__cplusplus)) || \
_MSC_VER >= 1800) // Visual Studio 2013 supports complex
#define OPENBLAS_COMPLEX_C99
+#ifndef __cplusplus
+ #include <complex.h>
+#endif
typedef float _Complex openblas_complex_float;
typedef double _Complex openblas_complex_double;
typedef xdouble _Complex openblas_complex_xdouble;
static void __inline blas_lock(volatile BLASULONG *address){
+#ifndef C_MSVC
+ int ret;
+#else
BLASULONG ret;
+#endif
do {
while (*address) {YIELDING;};
--- /dev/null
+include_directories(${CMAKE_SOURCE_DIR})
+
+
+#foreach(test_bin ${OpenBLAS_Tests})
+
+#endforeach()
\ No newline at end of file
GenerateNamedObjects("syr_thread.c" "HER" "her_thread_U" false "" "" false ${float_type})
GenerateNamedObjects("syr_thread.c" "HER;LOWER" "her_thread_L" false "" "" false ${float_type})
- GenerateNamedObjects("syr_thread.c" "HEMVREV" "her_thread_V" false "" "" false ${float_type})
- GenerateNamedObjects("syr_thread.c" "LOWER;HEMVREV" "her_thread_M" false "" "" false ${float_type})
+ GenerateNamedObjects("syr_thread.c" "HERREV" "her_thread_V" false "" "" false ${float_type})
+ GenerateNamedObjects("syr_thread.c" "LOWER;HERREV" "her_thread_M" false "" "" false ${float_type})
- GenerateNamedObjects("syr2_thread.c" "HER2" "her2_thread_U" false "" "" false ${float_type})
- GenerateNamedObjects("syr2_thread.c" "HER2;LOWER" "her2_thread_L" false "" "" false ${float_type})
- GenerateNamedObjects("syr2_thread.c" "HEMVREV" "her2_thread_V" false "" "" false ${float_type})
- GenerateNamedObjects("syr2_thread.c" "LOWER;HEMVREV" "her2_thread_M" false "" "" false ${float_type})
+ GenerateNamedObjects("syr2_thread.c" "HER" "her2_thread_U" false "" "" false ${float_type})
+ GenerateNamedObjects("syr2_thread.c" "HER;LOWER" "her2_thread_L" false "" "" false ${float_type})
+ GenerateNamedObjects("syr2_thread.c" "HERREV" "her2_thread_V" false "" "" false ${float_type})
+ GenerateNamedObjects("syr2_thread.c" "LOWER;HERREV" "her2_thread_M" false "" "" false ${float_type})
foreach (nu_smp_src ${NU_SMP_SOURCES})
string(REGEX MATCH "[a-z]+_[a-z]+" op_name ${nu_smp_src})
--- /dev/null
+include_directories(${CMAKE_SOURCE_DIR})
+
+enable_language(Fortran)
+
+set(OpenBLAS_Tests
+ sblat1 sblat2 sblat3
+ dblat1 dblat2 dblat3
+ cblat1 cblat2 cblat3
+ zblat1 zblat2 zblat3)
+
+foreach(test_bin ${OpenBLAS_Tests})
+add_executable(${test_bin} ${test_bin}.f)
+target_link_libraries(${test_bin} ${OpenBLAS_LIBNAME}_static)
+endforeach()
+
+# $1 exec, $2 input, $3 output_result
+FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_helper.sh
+"rm -f $3\n"
+"$1 < $2"
+)
+
+set(float_types s d c z)
+foreach(float_type ${float_types})
+string(TOUPPER ${float_type} float_type_upper)
+add_test(NAME "${float_type}blas1"
+ COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${float_type}blat1")
+add_test(NAME "${float_type}blas2"
+ COMMAND sh "${CMAKE_CURRENT_BINARY_DIR}/test_helper.sh" "${CMAKE_CURRENT_BINARY_DIR}/${float_type}blat2" "${PROJECT_SOURCE_DIR}/test/${float_type}blat2.dat" ${float_type_upper}BLAT2.SUMM)
+add_test(NAME "${float_type}blas3"
+ COMMAND sh "${CMAKE_CURRENT_BINARY_DIR}/test_helper.sh" "${CMAKE_CURRENT_BINARY_DIR}/${float_type}blat3" "${PROJECT_SOURCE_DIR}/test/${float_type}blat3.dat" ${float_type_upper}BLAT3.SUMM)
+endforeach()
\ No newline at end of file