diff --git a/CMakeLists.txt b/CMakeLists.txt index 610cc9c90..e10df13a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,8 +15,10 @@ enable_language(C) 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) @@ -129,15 +131,28 @@ set(OpenBLAS_DEF_FILE "${PROJECT_BINARY_DIR}/openblas.def") 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 diff --git a/cmake/c_check.cmake b/cmake/c_check.cmake index e32c18a43..89ec31446 100644 --- a/cmake/c_check.cmake +++ b/cmake/c_check.cmake @@ -25,9 +25,14 @@ # 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) diff --git a/cmake/kernel.cmake b/cmake/kernel.cmake index c2ee62545..fad84de51 100644 --- a/cmake/kernel.cmake +++ b/cmake/kernel.cmake @@ -100,8 +100,8 @@ macro(SetDefaultL1) 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) diff --git a/cmake/lapacke.cmake b/cmake/lapacke.cmake index ce7f781dd..39ade0577 100644 --- a/cmake/lapacke.cmake +++ b/cmake/lapacke.cmake @@ -2058,7 +2058,7 @@ endif () # 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") diff --git a/common.h b/common.h index 1fb2c7eaf..c87ed6652 100644 --- a/common.h +++ b/common.h @@ -460,6 +460,9 @@ typedef char* env_var_t; (__GNUC__ >= 3 && !defined(__cplusplus)) || \ _MSC_VER >= 1800) // Visual Studio 2013 supports complex #define OPENBLAS_COMPLEX_C99 +#ifndef __cplusplus + #include +#endif typedef float _Complex openblas_complex_float; typedef double _Complex openblas_complex_double; typedef xdouble _Complex openblas_complex_xdouble; diff --git a/common_x86_64.h b/common_x86_64.h index 8bb87c7c0..54377695c 100644 --- a/common_x86_64.h +++ b/common_x86_64.h @@ -65,7 +65,11 @@ static void __inline blas_lock(volatile BLASULONG *address){ +#ifndef C_MSVC + int ret; +#else BLASULONG ret; +#endif do { while (*address) {YIELDING;}; diff --git a/ctest/CMakeLists.txt b/ctest/CMakeLists.txt new file mode 100644 index 000000000..d3e15870b --- /dev/null +++ b/ctest/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories(${CMAKE_SOURCE_DIR}) + + +#foreach(test_bin ${OpenBLAS_Tests}) + +#endforeach() \ No newline at end of file diff --git a/driver/level2/CMakeLists.txt b/driver/level2/CMakeLists.txt index 5db4fb5ee..3f40aa47d 100644 --- a/driver/level2/CMakeLists.txt +++ b/driver/level2/CMakeLists.txt @@ -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;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}) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 000000000..446fb8a44 --- /dev/null +++ b/test/CMakeLists.txt @@ -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() \ No newline at end of file