| @@ -15,8 +15,10 @@ enable_language(C) | |||||
| set(OpenBLAS_LIBNAME openblas) | set(OpenBLAS_LIBNAME openblas) | ||||
| ####### | ####### | ||||
| if(MSVC) | |||||
| option(BUILD_WITHOUT_LAPACK "Without LAPACK and LAPACKE (Only BLAS or CBLAS)" ON) | 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) | option(BUILD_DEBUG "Build Debug Version" OFF) | ||||
| ####### | ####### | ||||
| if(BUILD_WITHOUT_LAPACK) | if(BUILD_WITHOUT_LAPACK) | ||||
| @@ -129,15 +131,28 @@ set(OpenBLAS_DEF_FILE "${PROJECT_BINARY_DIR}/openblas.def") | |||||
| endif() | endif() | ||||
| # add objects to the openblas lib | # 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") | include("${CMAKE_SOURCE_DIR}/cmake/export.cmake") | ||||
| #only build shared library for MSVC | |||||
| if(NOT MSVC) | if(NOT MSVC) | ||||
| #only build shared library for MSVC | |||||
| add_library(${OpenBLAS_LIBNAME}_static STATIC ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS}) | 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 OUTPUT_NAME ${OpenBLAS_LIBNAME}) | ||||
| set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES CLEAN_DIRECT_OUTPUT 1) | 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() | endif() | ||||
| set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES | set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES | ||||
| @@ -25,9 +25,14 @@ | |||||
| # PTHREAD_CREATE_FUNC | # PTHREAD_CREATE_FUNC | ||||
| # N.B. c_check (and ctest.c) is not cross-platform, so instead try to use CMake variables. | # 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 "_") | set(FU "_") | ||||
| elseif(UNIX) | |||||
| set(FU "") | |||||
| endif() | |||||
| # Convert CMake vars into the format that OpenBLAS expects | # Convert CMake vars into the format that OpenBLAS expects | ||||
| string(TOUPPER ${CMAKE_SYSTEM_NAME} HOST_OS) | string(TOUPPER ${CMAKE_SYSTEM_NAME} HOST_OS) | ||||
| @@ -100,8 +100,8 @@ macro(SetDefaultL1) | |||||
| set(XGEMVNKERNEL zgemv_n.S) | set(XGEMVNKERNEL zgemv_n.S) | ||||
| set(XGEMVTKERNEL zgemv_t.S) | set(XGEMVTKERNEL zgemv_t.S) | ||||
| set(SCABS_KERNEL ../generic/cabs.c) | 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(LSAME_KERNEL ../generic/lsame.c) | ||||
| set(SAXPBYKERNEL ../arm/axpby.c) | set(SAXPBYKERNEL ../arm/axpby.c) | ||||
| set(DAXPBYKERNEL ../arm/axpby.c) | set(DAXPBYKERNEL ../arm/axpby.c) | ||||
| @@ -2058,7 +2058,7 @@ endif () | |||||
| # add lapack-netlib folder to the sources | # add lapack-netlib folder to the sources | ||||
| set(LAPACKE_SOURCES "") | set(LAPACKE_SOURCES "") | ||||
| foreach (LAE_FILE ${LAPACKE_REL_SRC}) | 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 () | endforeach () | ||||
| set(lapacke_include_dir "${NETLIB_LAPACK_DIR}/lapacke/include") | set(lapacke_include_dir "${NETLIB_LAPACK_DIR}/lapacke/include") | ||||
| @@ -460,6 +460,9 @@ typedef char* env_var_t; | |||||
| (__GNUC__ >= 3 && !defined(__cplusplus)) || \ | (__GNUC__ >= 3 && !defined(__cplusplus)) || \ | ||||
| _MSC_VER >= 1800) // Visual Studio 2013 supports complex | _MSC_VER >= 1800) // Visual Studio 2013 supports complex | ||||
| #define OPENBLAS_COMPLEX_C99 | #define OPENBLAS_COMPLEX_C99 | ||||
| #ifndef __cplusplus | |||||
| #include <complex.h> | |||||
| #endif | |||||
| typedef float _Complex openblas_complex_float; | typedef float _Complex openblas_complex_float; | ||||
| typedef double _Complex openblas_complex_double; | typedef double _Complex openblas_complex_double; | ||||
| typedef xdouble _Complex openblas_complex_xdouble; | typedef xdouble _Complex openblas_complex_xdouble; | ||||
| @@ -65,7 +65,11 @@ | |||||
| static void __inline blas_lock(volatile BLASULONG *address){ | static void __inline blas_lock(volatile BLASULONG *address){ | ||||
| #ifndef C_MSVC | |||||
| int ret; | |||||
| #else | |||||
| BLASULONG ret; | BLASULONG ret; | ||||
| #endif | |||||
| do { | do { | ||||
| while (*address) {YIELDING;}; | while (*address) {YIELDING;}; | ||||
| @@ -0,0 +1,6 @@ | |||||
| include_directories(${CMAKE_SOURCE_DIR}) | |||||
| #foreach(test_bin ${OpenBLAS_Tests}) | |||||
| #endforeach() | |||||
| @@ -154,13 +154,13 @@ foreach (float_type ${FLOAT_TYPES}) | |||||
| GenerateNamedObjects("syr_thread.c" "HER" "her_thread_U" false "" "" false ${float_type}) | 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" "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}) | foreach (nu_smp_src ${NU_SMP_SOURCES}) | ||||
| string(REGEX MATCH "[a-z]+_[a-z]+" op_name ${nu_smp_src}) | string(REGEX MATCH "[a-z]+_[a-z]+" op_name ${nu_smp_src}) | ||||
| @@ -0,0 +1,31 @@ | |||||
| 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() | |||||