diff --git a/BLAS/CMakeLists.txt b/BLAS/CMakeLists.txt index 45e68e9..7d72098 100644 --- a/BLAS/CMakeLists.txt +++ b/BLAS/CMakeLists.txt @@ -3,7 +3,3 @@ if(BUILD_TESTING) add_subdirectory(TESTING) endif(BUILD_TESTING) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/blas.pc.in ${CMAKE_CURRENT_BINARY_DIR}/blas.pc) -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/blas.pc - DESTINATION ${PKG_CONFIG_DIR} - ) diff --git a/BLAS/SRC/CMakeLists.txt b/BLAS/SRC/CMakeLists.txt index 63ff224..7890f5a 100644 --- a/BLAS/SRC/CMakeLists.txt +++ b/BLAS/SRC/CMakeLists.txt @@ -135,17 +135,27 @@ if(BLAS_COMPLEX16) ${ALLBLAS} ${ZBLAS2} ${ZBLAS3}) endif() -set(XERBLA xerbla.f) - -add_library(ogxerbla SHARED ${XERBLA}) -set_target_properties(ogxerbla PROPERTIES SOVERSION ${LAPACK_VERSION_MAJOR} VERSION ${LAPACK_VERSION}) -lapack_install_library(ogxerbla) - -add_library(ogblas SHARED ${ALLOBJ}) -set_target_properties(ogblas PROPERTIES SOVERSION ${LAPACK_VERSION_MAJOR} VERSION ${LAPACK_VERSION}) -target_link_libraries(ogblas ogxerbla) +set(XERBLA xerbla.f) + +add_multitarget_library(ogxerbla + VERSION ${LAPACK_VERSION} + SOVERSION ${LAPACK_VERSION_MAJOR} + SOURCES ${XERBLA} + TARGETS ${TARGET_TYPES} + ) + +set(LINK_MULTILIBRARIES ogblas ogxerbla) if(UNIX) - target_link_libraries(ogblas m) + set(LINK_LIBRARIES m) +else() + set(LINK_LIBRARIES "") endif() -target_link_libraries(ogblas) -lapack_install_library(ogblas) + +add_multitarget_library(ogblas + VERSION ${LAPACK_VERSION} + SOVERSION ${LAPACK_VERSION_MAJOR} + SOURCES ${ALLOBJ} + TARGETS ${TARGET_TYPES} + LINK_MULTILIBRARIES ${LINK_MULTILIBRARIES} + LINK_LIBRARIES ${LINK_LIBRARIES} + ) diff --git a/CMAKE/CheckCPUID.cmake b/CMAKE/CheckCPUID.cmake new file mode 100644 index 0000000..b79334c --- /dev/null +++ b/CMAKE/CheckCPUID.cmake @@ -0,0 +1,50 @@ +# +# Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies +# +# Please see distribution for license. +# + +# Inclusion of this module sets the targets supported by the machine on which +# CMake is running. SUPPORT_${TARGET} is set to TRUE or FALSE for each target in +# dbg, std, sse41, sse42, avx1 and avx2. std and sbg require no special CPU +# support and are always set. + +# this module caches the fact it has run by setting CPUID_CACHED = TRUE + +macro( CheckCPUID ) + if(NOT DEFINED CPUID_CACHED) + set(CPUID_CACHED TRUE CACHE INTERNAL "Whether CPUID has run") + try_run(CPUID_FLAG CPUID_COMPILE_RESULT + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/CMAKE/cmcpuid.c) + + set(SUPPORT_dbg TRUE CACHE INTERNAL "Support for debug build") + set(SUPPORT_std TRUE CACHE INTERNAL "Support for standard build") + + # NOTE: These flags must match the numbers in cmcpuid.c + if(${CPUID_FLAG} GREATER 1) + set(SUPPORT_sse41 TRUE CACHE INTERNAL "Local CPU support for SSE4.1") + message(STATUS "CPU supports SSE4.1") + else() + message(STATUS "CPU does not support SSE4.1") + endif() + if(${CPUID_FLAG} GREATER 2) + set(SUPPORT_sse42 TRUE CACHE INTERNAL "Local CPU support for SSE4.2") + message(STATUS "CPU supports SSE4.2") + else() + message(STATUS "CPU does not support SSE4.2") + endif() + if(${CPUID_FLAG} GREATER 3) + set(SUPPORT_avx1 TRUE CACHE INTERNAL "Local CPU support for AVX1") + message(STATUS "CPU supports AVX1") + else() + message(STATUS "CPU does not support AVX1") + endif() + if(${CPUID_FLAG} GREATER 4) + set(SUPPORT_avx2 TRUE CACHE INTERNAL "Local CPU support for AVX2") + message(STATUS "CPU supports AVX2") + else() + message(STATUS "CPU does not support AVX2") + endif() + endif() +endmacro() diff --git a/CMAKE/MultiInstructionTarget.cmake b/CMAKE/MultiInstructionTarget.cmake new file mode 100644 index 0000000..d06bb6d --- /dev/null +++ b/CMAKE/MultiInstructionTarget.cmake @@ -0,0 +1,75 @@ +# +# Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies +# +# Please see distribution for license. +# + +include(CMakeParseArguments) + +include( CheckCPUID ) +CheckCPUID() + +# Create a library for multiple target instruction sets. Note that this is +# specialised to its use in Nyqwk2 and does not fully provide all of the +# functionality that can be provided by add_library and set_target_properties. +# One instance of the library is created for each of the TARGETS. + +function(add_multitarget_library _TARGET_NAME) + cmake_parse_arguments(MTLIB + "" + "VERSION;SOVERSION" + "SOURCES;TARGETS;LINK_MULTILIBRARIES;LINK_LIBRARIES;COMPILE_DEFINITIONS;MULTI_DEPENDS" + ${ARGN}) + foreach(TARGET ${MTLIB_TARGETS}) + set(LIBNAME ${_TARGET_NAME}_${TARGET}) + add_library(${LIBNAME} SHARED ${MTLIB_SOURCES}) + set_target_properties(${LIBNAME} PROPERTIES + VERSION ${MTLIB_VERSION} + SOVERSION ${MTLIB_SOVERSION} + COMPILE_FLAGS ${OPT_FLAGS_${TARGET}}) + foreach(LINK_LIB ${MTLIB_LINK_MULTILIBRARIES}) + target_link_libraries(${LIBNAME} ${LINK_LIB}_${TARGET}) + endforeach() + foreach(LINK_LIB ${MTLIB_LINK_LIBRARIES}) + target_link_libraries(${LIBNAME} ${LINK_LIB}) + endforeach() + foreach(COMPILE_DEFINITION ${MTLIB_COMPILE_DEFINITIONS}) + set_target_properties(${LIBNAME} PROPERTIES COMPILE_DEFINITIONS ${COMPILE_DEFINITION}) + endforeach() + foreach(DEPENDENCY ${MTLIB_MULTI_DEPENDS}) + add_dependencies(${LIBNAME} ${DEPENDENCY}_${TARGET}) + endforeach() + endforeach() +endfunction() + +# Create a binary for multiple target instruction sets. Note that this is +# specialised to its use in Nyqwk2 and does not fully provide all of the +# functionality that can be provided by add_library and set_target_properties. +# One instance of the library is created for each of the TARGETS. + +function(add_multitarget_binary _TARGET_NAME) + cmake_parse_arguments(MTBIN + "" + "VERSION;SOVERSION" + "SOURCES;TARGETS;LINK_MULTILIBRARIES;LINK_LIBRARIES;COMPILE_DEFINITIONS;MULTI_DEPENDS" + ${ARGN}) + foreach(TARGET ${MTBIN_TARGETS}) + set(BINNAME ${_TARGET_NAME}_${TARGET}) + add_executable(${BINNAME} ${MTBIN_SOURCES}) + set_target_properties(${BINNAME} PROPERTIES + COMPILE_FLAGS ${OPT_FLAGS_${TARGET}}) + foreach(LINK_LIB ${MTBIN_LINK_MULTILIBRARIES}) + target_link_libraries(${BINNAME} ${LINK_LIB}_${TARGET}) + endforeach() + foreach(LINK_LIB ${MTBIN_LINK_LIBRARIES}) + target_link_libraries(${BINNAME} ${LINK_LIB}) + endforeach() + foreach(COMPILE_DEFINITION ${MTBIN_COMPILE_DEFINITIONS}) + set_target_properties(${BINNAME} PROPERTIES COMPILE_DEFINITIONS ${COMPILE_DEFINITION}) + endforeach() + foreach(DEPENDENCY ${MTBIN_MULTI_DEPENDS}) + add_dependencies(${BINNAME} ${DEPENDENCY}_${TARGET}) + endforeach() + endforeach() +endfunction() + diff --git a/CMAKE/cmcpuid.c b/CMAKE/cmcpuid.c new file mode 100644 index 0000000..14d27d7 --- /dev/null +++ b/CMAKE/cmcpuid.c @@ -0,0 +1,113 @@ +/** + * Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies + * + * Please see distribution for license. + */ + +#include +#include +#include +#include + + +/** + * The supported instruction set on this machine for use in other functions. + * + * These must match up with the numbers used in MultiLib.cmake. + */ +typedef enum instructions_available_e +{ + supports_STANDARD = 1, + supports_SSE41 = 2, + supports_SSE42 = 3, + supports_AVX1 = 4, + supports_AVX2 = 5 +} instructions_available; + + +instructions_available getSupportedInstructionSet() { + + // probes of cpuid with %eax=0000_0001h + enum instructions_available_eax0000_0001h_e + { + probe01_SSE_3 = 1<<0, + probe01_SSE_4_1 = 1<<19, + probe01_SSE_4_2 = 1<<20, + probe01_AVX1 = 1<<28 + }; + + // probes of cpuid with %eax=0000_0007h + enum instructions_available_eax0000_0007h_e + { + probe07_AVX2 = 1<<5 + }; + + // the eax register + int32_t EAX; + // contends of the returned register + int32_t supported; + + // Call cpuid with eax=0x00000001 and get ecx + EAX = 0x00000001; + __asm__("cpuid" + :"=c"(supported) // %ecx contains large feature flag set + :"0"(EAX) // call with 0x1 + :"%eax","%ebx","%edx"); // clobbered + + if(supported & probe01_AVX1) // we have at least AVX1 + { + EAX = 0x00000007; + __asm__("cpuid" + :"=b"(supported) // %ebx contains feature flag AVX2 + :"0"(EAX) // call with 0x7 + :"%eax","%ecx","%edx"); // clobbered + + if(supported & probe07_AVX2) // we have at least AVX2 + { + printf("AVX2 SUPPORTED\n"); + return supports_AVX2; + } + printf("AVX1 SUPPORTED\n"); + return supports_AVX1; + } + else if(supported & probe01_SSE_4_1) // we have at least SSE4.1 + { + printf("SSE4.2 SUPPORTED\n"); + return supports_SSE42; + } + else // we have nothing specifically useful! + { + printf("STANDARD SUPPORTED\n"); + return supports_STANDARD; + } +} + + +int main(void) +{ + instructions_available ia; + ia = getSupportedInstructionSet(); + + switch(ia) + { + case supports_AVX2: + printf("AVX2\n"); + break; + case supports_AVX1: + printf("AVX1\n"); + break; + case supports_SSE42: + printf("SSE42\n"); + break; + case supports_SSE41: + printf("SSE41\n"); + break; + case supports_STANDARD: + printf("STANDARD\n"); + break; + default: + printf("Failed to find supported instruction set, this is an error!\n"); + exit(-1); + } + return ia; +} diff --git a/CMakeLists.txt b/CMakeLists.txt index dec634e..01f11e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,37 +1,43 @@ -cmake_minimum_required(VERSION 2.8) -project(LAPACK Fortran) +# +# Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies +# +# Please see distribution for license. +# -enable_language(C) +cmake_minimum_required (VERSION 2.8.6) -if(APPLE) - set(CMAKE_Fortran_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") - set(CMAKE_Fortran_OSX_CURRENT_VERSION_FLAG "-current_version ") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wl,-flat_namespace") -endif(APPLE) +include(CMakeForceCompiler) + +if(APPLE OR WIN32) + # On Apple, we don't want to use Clang. + # On Windows, we don't want to end up building with Visual Studio. + CMAKE_FORCE_C_COMPILER(gcc GNU) +endif(APPLE OR WIN32) + +project (LAPACK) set(LAPACK_VERSION_MAJOR 3) set(LAPACK_VERSION_MINOR 4) set(LAPACK_VERSION_PATCH 2) set(LAPACK_VERSION ${LAPACK_VERSION_MAJOR}.${LAPACK_VERSION_MINOR}.${LAPACK_VERSION_PATCH}) -# Add the CMake directory for custon CMake modules -set(CMAKE_MODULE_PATH "${LAPACK_SOURCE_DIR}/CMAKE" ${CMAKE_MODULE_PATH}) - -if (UNIX) - if ( "${CMAKE_Fortran_COMPILER}" MATCHES "ifort" ) - set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fltconsistency -fp_port" ) - endif () - if ( "${CMAKE_Fortran_COMPILER}" MATCHES "xlf" ) - set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qnosave -qstrict=none" ) - endif () -# Delete libmtsk in linking sequence for Sun/Oracle Fortran Compiler. -# This library is not present in the Sun package SolarisStudio12.3-linux-x86-bin - STRING(REPLACE \;mtsk\; \; CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}") -endif () +# Append local module folder to module path +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMAKE ${CMAKE_MODULE_PATH}) -if(CMAKE_SYSTEM_NAME MATCHES "Linux") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--rpath -Wl,\$ORIGIN") -endif() +# fix for fortran support to get version correct +if(APPLE) + set(CMAKE_Fortran_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") + set(CMAKE_Fortran_OSX_CURRENT_VERSION_FLAG "-current_version ") +endif(APPLE) + +# languages +enable_language(Fortran) +enable_language(C) + +# use flat namespace +if(APPLE) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wl,-flat_namespace") +endif(APPLE) # Get Python find_package(PythonInterp) @@ -39,77 +45,59 @@ message(STATUS "Looking for Python found - ${PYTHONINTERP_FOUND}") if (PYTHONINTERP_FOUND) message(STATUS "Using Python version ${PYTHON_VERSION_STRING}") endif() -# -------------------------------------------------- - -# Configure the warning and code coverage suppression file -configure_file( - "${LAPACK_SOURCE_DIR}/CTestCustom.cmake.in" - "${LAPACK_BINARY_DIR}/CTestCustom.cmake" - @ONLY -) - -# On Windows-GNU builds try to provide MS import libraries too. -include(GNUtoMS) - -if(GNUtoMS) - set(LAPACK_GNUtoMS_IMPORT ${LAPACK_SOURCE_DIR}/CMAKE/lapack-GNUtoMS.cmake) - set(LAPACK_GNUtoMS_INSTALL "include(\${_SELF_DIR}/lapack-GNUtoMS.cmake)") - set(LAPACK_GNUtoMS_BUILD "include(\"${LAPACK_GNUtoMS_IMPORT}\")") + +if(WIN32) + set(CMAKE_THREAD_LIBS_INIT -mthreads) +else() + # we force -pthread in preference to -lpthread because it sets -D_REENTRANT + set(THREADS_HAVE_PTHREAD_ARG "THREADS_HAVE_PTHREAD_ARG") + find_package(Threads) endif() -macro(lapack_install_library lib) - install(TARGETS ${lib} EXPORT lapack-targets - ARCHIVE DESTINATION lib${LIB_SUFFIX} - LIBRARY DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - ) - if(GNUtoMS) - install(FILES ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/lib${lib}.lib DESTINATION lib) - endif() -endmacro() +# Add thread libs +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_THREAD_LIBS_INIT}") +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${CMAKE_THREAD_LIBS_INIT}") -# -------------------------------------------------- -# Testing +# Use the native assembler on Apple in order to be able to generate AVX instructions. +if(APPLE) + set(CMAKE_C_FLAGS "-Wa,-q ${CMAKE_C_FLAGS}") + set(CMAKE_Fortran_FLAGS "${CMAKE_C_FLAGS}") +endif() -enable_testing() -include(CTest) -enable_testing() -# -------------------------------------------------- +# fix rpath +if(CMAKE_SYSTEM_NAME MATCHES "Linux") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--rpath -Wl,\$ORIGIN") +endif() -# Organize output files. On Windows this also keeps .dll files next -# to the .exe files that need them, making tests easy to run. + +# Place executables and libraries in bin on Windows so that its linker can find them. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR}/bin) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR}/lib) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LAPACK_BINARY_DIR}/lib) -# -------------------------------------------------- +enable_testing() + # Check for any necessary platform specific compiler flags +# this is from the original LAPACK cmake build, in our case makes sure +# FPE traps aren't on by accident or intent! include( CheckLAPACKCompilerFlags ) CheckLAPACKCompilerFlags() -# -------------------------------------------------- -# Check second function +# Multi-targets need to be built +include(MultiInstructionTarget) +set(TARGET_TYPES dbg std sse41 avx1) -include(CheckTimeFunction) -set(TIME_FUNC NONE ${TIME_FUNC}) -CHECK_TIME_FUNCTION(NONE TIME_FUNC) -CHECK_TIME_FUNCTION(INT_CPU_TIME TIME_FUNC) -CHECK_TIME_FUNCTION(EXT_ETIME TIME_FUNC) -CHECK_TIME_FUNCTION(EXT_ETIME_ TIME_FUNC) -CHECK_TIME_FUNCTION(INT_ETIME TIME_FUNC) -message(STATUS "--> Will use second_${TIME_FUNC}.f and dsecnd_${TIME_FUNC}.f as timing function.") -set(SECOND_SRC ${LAPACK_SOURCE_DIR}/INSTALL/second_${TIME_FUNC}.f) -set(DSECOND_SRC ${LAPACK_SOURCE_DIR}/INSTALL/dsecnd_${TIME_FUNC}.f) -set(prefix ${CMAKE_INSTALL_PREFIX}) -set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) -set(PKG_CONFIG_DIR lib/pkgconfig) +set(OPT_FLAGS_dbg "-DDEBUG ${CMAKE_C_FLAGS_DEBUG}") +set(OPT_FLAGS_std "-O2 -funroll-loops -DNDEBUG") +set(OPT_FLAGS_sse41 "${OPT_FLAGS_std} -march=core2 -msse4.1") +set(OPT_FLAGS_avx1 "${OPT_FLAGS_std} -march=corei7-avx -mavx256-split-unaligned-load -mavx256-split-unaligned-store") -message(STATUS "Using supplied NETLIB BLAS implementation") +# make calls to existing cmake to pickup BLAS +message(STATUS "Using NETLIB BLAS implementation") add_subdirectory(BLAS) set( BLAS_LIBRARIES ogblas ) -message(STATUS "Using supplied NETLIB LAPACK implementation") +# make calls to existing cmake to pick build support config +message(STATUS "Using NETLIB LAPACK implementation") set( LAPACK_LIBRARIES oglapack ) set(BUILD_SINGLE TRUE) set(BUILD_DOUBLE TRUE) @@ -117,60 +105,30 @@ set(BUILD_COMPLEX TRUE) set(BUILD_COMPLEX16 TRUE) add_subdirectory(SRC) + +# Check second function +include(CheckTimeFunction) +set(TIME_FUNC NONE ${TIME_FUNC}) +CHECK_TIME_FUNCTION(NONE TIME_FUNC) +CHECK_TIME_FUNCTION(INT_CPU_TIME TIME_FUNC) +CHECK_TIME_FUNCTION(EXT_ETIME TIME_FUNC) +CHECK_TIME_FUNCTION(EXT_ETIME_ TIME_FUNC) +CHECK_TIME_FUNCTION(INT_ETIME TIME_FUNC) +message(STATUS "--> Will use second_${TIME_FUNC}.f and dsecnd_${TIME_FUNC}.f as timing function.") + +set(SECOND_SRC ${LAPACK_SOURCE_DIR}/INSTALL/second_${TIME_FUNC}.f) +set(DSECOND_SRC ${LAPACK_SOURCE_DIR}/INSTALL/dsecnd_${TIME_FUNC}.f) + add_subdirectory(TESTING) -# -------------------------------------------------- -# CPACK Packaging - -SET(CPACK_GENERATOR "TGZ" "DEB" "RPM" "NSIS" "PackageMaker") -SET(CPACK_PACKAGE_NAME "OG-Lapack") -SET(CPACK_PACKAGE_VENDOR "OpenGamma") -SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LAPACK - Linear Algebra Package") -set(CPACK_PACKAGE_VERSION_MAJOR ${LAPACK_VERSION_MAJOR}) -set(CPACK_PACKAGE_VERSION_MINOR ${LAPACK_VERSION_MINOR}) -set(CPACK_PACKAGE_VERSION_PATCH ${LAPACK_VERSION_PATCH}) -set(CPACK_PACKAGE_CONTACT "Graham Markall ") - -set(CPACK_DEBIAN_PACKAGE_NAME "og-lapack") -set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3)") - -set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") - -# There is a bug in NSI that does not handle full unix paths properly. Make -# sure there is at least one set of four (4) backlasshes. -SET(CPACK_NSIS_CONTACT "lapack@eecs.utk.edu") -SET(CPACK_NSIS_MODIFY_PATH ON) -SET(CPACK_NSIS_DISPLAY_NAME "LAPACK-${LAPACK_VERSION}") - -INCLUDE(CPack) - -set(ALL_TARGETS ${ALL_TARGETS} ogblas) -set(ALL_TARGETS ${ALL_TARGETS} oglapack) -set(ALL_TARGETS ${ALL_TARGETS} ogxerbla) -set(ALL_TARGETS ${ALL_TARGETS} ogtmglib) -export(TARGETS ${ALL_TARGETS} FILE lapack-targets.cmake) - -configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-version.cmake.in - ${LAPACK_BINARY_DIR}/lapack-config-version.cmake @ONLY) -configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-build.cmake.in - ${LAPACK_BINARY_DIR}/lapack-config.cmake @ONLY) - - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lapack.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc) - install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc - DESTINATION ${PKG_CONFIG_DIR} - ) - -configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-install.cmake.in - ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake @ONLY) -install(FILES - ${LAPACK_GNUtoMS_IMPORT} - ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake - ${LAPACK_BINARY_DIR}/lapack-config-version.cmake - DESTINATION lib/cmake/lapack-${LAPACK_VERSION} - ) - -install(EXPORT lapack-targets - DESTINATION lib/cmake/lapack-${LAPACK_VERSION}) +# done +message(" + Package " ${CMAKE_PROJECT_NAME} " version " ${LAPACK_VERSION} " + Prefix.....................: " ${CMAKE_INSTALL_PREFIX} " + C Compiler.................: " ${CMAKE_C_COMPILER} " + C Flags....................: " ${CMAKE_C_FLAGS} " + Fortran Compiler...........: " ${CMAKE_Fortran_COMPILER} " + Fortran Compiler...........: " ${CMAKE_Fortran_FLAGS} " + Threads flag..............:: " ${CMAKE_THREAD_LIBS_INIT} " + Python executable..........: " ${PYTHON_EXECUTABLE} " + ") \ No newline at end of file diff --git a/SRC/CMakeLists.txt b/SRC/CMakeLists.txt index fb03958..d23c7ce 100644 --- a/SRC/CMakeLists.txt +++ b/SRC/CMakeLists.txt @@ -386,7 +386,6 @@ set(ZXLASRC zgesvxx.f zgerfsx.f zla_gerfsx_extended.f zla_geamv.f zla_lin_berr.f zlarscl2.f zlascl2.f zla_wwaddw.f) - if( USE_XBLAS) set(ALLXOBJ ${SXLASRC} ${DXLASRC} ${CXLASRC} ${ZXLASRC} ${ALLXAUX}) endif() @@ -415,8 +414,11 @@ endif() list(REMOVE_DUPLICATES ALLOBJ) -add_library(oglapack SHARED ${ALLOBJ} ${ALLXOBJ}) -set_target_properties(oglapack PROPERTIES SOVERSION ${LAPACK_VERSION_MAJOR} VERSION ${LAPACK_VERSION}) -target_link_libraries(oglapack ogxerbla ${BLAS_LIBRARIES} ${XBLAS_LIBRARY}) -lapack_install_library(oglapack) +add_multitarget_library(oglapack + VERSION ${LAPACK_VERSION} + SOVERSION ${LAPACK_VERSION_MAJOR} + SOURCES ${ALLOBJ} ${ALLXOBJ} + TARGETS ${TARGET_TYPES} + LINK_MULTILIBRARIES ${BLAS_LIBRARIES} ${XBLAS_LIBRARY} ogxerbla + LINK_LIBRARIES "") diff --git a/TESTING/CMakeLists.txt b/TESTING/CMakeLists.txt index fe0cdfa..f5a5ced 100644 --- a/TESTING/CMakeLists.txt +++ b/TESTING/CMakeLists.txt @@ -7,20 +7,29 @@ endif() add_subdirectory(MATGEN) add_subdirectory(LIN) add_subdirectory(EIG) + macro(add_lapack_test output input target) - set(TEST_INPUT "${LAPACK_SOURCE_DIR}/TESTING/${input}") - set(TEST_OUTPUT "${LAPACK_BINARY_DIR}/TESTING/${output}") - get_target_property(TEST_LOC ${target} LOCATION) - string(REPLACE "." "_" input_name ${input}) - set(testName "${target}_${input_name}") - if(EXISTS "${TEST_INPUT}") - add_test(LAPACK-${testName} "${CMAKE_COMMAND}" - -DTEST=${TEST_LOC} - -DINPUT=${TEST_INPUT} - -DOUTPUT=${TEST_OUTPUT} - -DINTDIR=${CMAKE_CFG_INTDIR} - -P "${LAPACK_SOURCE_DIR}/TESTING/runtest.cmake") - endif() + foreach(TARGET ${TARGET_TYPES}) + if(SUPPORT_${TARGET}) + set(TEST_INPUT_BASENAME "${LAPACK_SOURCE_DIR}/TESTING/${input}") + set(TEST_INPUT_BASENAME_TARGETTED "${CMAKE_BINARY_DIR}/TESTING/${input}_${TARGET}") + set(TEST_OUTPUT_BASENAME_TARGETTED "${CMAKE_BINARY_DIR}/TESTING/${output}_${TARGET}") + configure_file(${TEST_INPUT_BASENAME} ${TEST_INPUT_BASENAME_TARGETTED} COPYONLY) + set(TEST_INPUT ${TEST_INPUT_BASENAME_TARGETTED}) + set(TEST_OUTPUT ${TEST_OUTPUT_BASENAME_TARGETTED}) + get_target_property(TEST_LOC ${target}_${TARGET} LOCATION) + string(REPLACE "." "_" input_name ${input}) + set(testName "${target}_${input_name}") + if(EXISTS "${TEST_INPUT}") + add_test(LAPACK-${testName}-${TARGET} "${CMAKE_COMMAND}" + -DTEST=${TEST_LOC} + -DINPUT=${TEST_INPUT} + -DOUTPUT=${TEST_OUTPUT} + -DINTDIR=${CMAKE_CFG_INTDIR} + -P "${LAPACK_SOURCE_DIR}/TESTING/runtest.cmake") + endif() + endif() + endforeach() endmacro(add_lapack_test) if (BUILD_SINGLE) @@ -310,11 +319,12 @@ endif() # ============================================================================== execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${LAPACK_SOURCE_DIR}/lapack_testing.py ${LAPACK_BINARY_DIR}) - add_test( - NAME LAPACK_Test_Summary - WORKING_DIRECTORY ${LAPACK_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "lapack_testing.py" - ) - -add_definitions(-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}) -add_executable(testing_summary testing_summary.c) +foreach(TARGET ${TARGET_TYPES}) + if(SUPPORT_${TARGET}) + add_test( + NAME LAPACK_Test_Summary_for_${TARGET} + WORKING_DIRECTORY ${LAPACK_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} "lapack_testing.py" "-i" "${TARGET}" + ) + endif() +endforeach() \ No newline at end of file diff --git a/TESTING/EIG/CMakeLists.txt b/TESTING/EIG/CMakeLists.txt index f92e778..cd129b9 100644 --- a/TESTING/EIG/CMakeLists.txt +++ b/TESTING/EIG/CMakeLists.txt @@ -118,8 +118,13 @@ set(ZEIGTST zchkee.f zstt21.f zstt22.f zunt01.f zunt03.f) macro(add_eig_executable name ) - add_executable(${name} ${ARGN}) - target_link_libraries(${name} ogblas oglapack ogtmglib ${LAPACK_LIBRARIES}) + add_multitarget_binary(${name} + VERSION ${LAPACK_VERSION} + SOVERSION ${LAPACK_VERSION_MAJOR} + SOURCES ${ARGN} + TARGETS ${TARGET_TYPES} + LINK_MULTILIBRARIES ogblas oglapack ogtmglib + LINK_LIBRARIES "") endmacro(add_eig_executable) if (BUILD_SINGLE) diff --git a/TESTING/LIN/CMakeLists.txt b/TESTING/LIN/CMakeLists.txt index ca43f74..6e8a0b0 100644 --- a/TESTING/LIN/CMakeLists.txt +++ b/TESTING/LIN/CMakeLists.txt @@ -192,8 +192,13 @@ set(ZLINTSTRFP zchkrfp.f zdrvrfp.f zdrvrf1.f zdrvrf2.f zdrvrf3.f zdrvrf4.f zerr chkxer.f xerbla.f alaerh.f aladhd.f alahd.f alasvm.f ) macro(add_lin_executable name ) - add_executable(${name} ${ARGN}) - target_link_libraries(${name} ogblas oglapack ogtmglib ${LAPACK_LIBRARIES}) + add_multitarget_binary(${name} + VERSION ${LAPACK_VERSION} + SOVERSION ${LAPACK_VERSION_MAJOR} + SOURCES ${ARGN} + TARGETS ${TARGET_TYPES} + LINK_MULTILIBRARIES ogblas oglapack ogtmglib + LINK_LIBRARIES "") endmacro(add_lin_executable) IF(BUILD_SINGLE) diff --git a/TESTING/MATGEN/CMakeLists.txt b/TESTING/MATGEN/CMakeLists.txt index 80a5a33..4c39de9 100644 --- a/TESTING/MATGEN/CMakeLists.txt +++ b/TESTING/MATGEN/CMakeLists.txt @@ -70,7 +70,11 @@ set(ALLOBJ ${SMATGEN} ${CMATGEN} ${SCATGEN} ${DMATGEN} ${ZMATGEN} else() list(REMOVE_DUPLICATES ALLOBJ) endif() -add_library(ogtmglib SHARED ${ALLOBJ} ) -set_target_properties(ogtmglib PROPERTIES SOVERSION ${LAPACK_VERSION_MAJOR} VERSION ${LAPACK_VERSION}) -target_link_libraries(ogtmglib ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}) -lapack_install_library(ogtmglib) + +add_multitarget_library(ogtmglib + VERSION ${LAPACK_VERSION} + SOVERSION ${LAPACK_VERSION_MAJOR} + SOURCES ${ALLOBJ} + TARGETS ${TARGET_TYPES} + LINK_MULTILIBRARIES ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} + LINK_LIBRARIES "") diff --git a/lapack_testing.py b/lapack_testing.py index 3bd9462..20335b3 100755 --- a/lapack_testing.py +++ b/lapack_testing.py @@ -10,10 +10,12 @@ from subprocess import Popen, STDOUT, PIPE import os, sys, math import getopt +import platform +import re # Arguments try: - opts, args = getopt.getopt(sys.argv[1:], "hd:srep:t:n", - ["help", "dir", "short", "run", "error","prec=","test=","number"]) + opts, args = getopt.getopt(sys.argv[1:], "hd:srep:t:ni:", + ["help", "dir", "short", "run", "error","prec=","test=","number","instructionSet"]) except getopt.error, msg: print msg @@ -26,13 +28,14 @@ prec='x' test='all' only_numbers=0 +instr_set="" dir="TESTING" for o, a in opts: if o in ("-h", "--help"): - print sys.argv[0]+" [-h|--help] [-d dir |--dir dir] [-s |--short] [-r |--run] [-e |--error] [-p p |--prec p] [-t test |--test test] [-n | --number]" + print sys.argv[0]+" [-h|--help] [-d dir |--dir dir] [-s |--short] [-r |--run] [-e |--error] [-p p |--prec p] [-t test |--test test] [-n | --number] [-i instructionSet | --instructionSet=]" print " - h is to print this message" - print " - r is to use to run the LAPACK tests then analyse the output (.out files). By default, the script will not run all the LAPACK tests" - print " - d [dir] is to indicate where is the LAPACK testing directory (.out files). By default, the script will use ." + print " - r is to use to run the LAPACK tests then analyse the output (.out_ files). By default, the script will not run all the LAPACK tests" + print " - d [dir] is to indicate where is the LAPACK testing directory (.out_ files). By default, the script will use ." print " LEVEL OF OUTPUT" print " - x is to print a detailed summary" print " - e is to print only the error summary" @@ -53,6 +56,7 @@ print " mixed=mixed-precision" print " rfp=rfp format" print " all=all tests [DEFAULT]" + print " - i [dbg/std/sse41/avx1] the instruction set to use." print " EXAMPLES:" print " ./lapack_testing.py -n" print " Will return the numbers of failed tests by analyzing the LAPACK output" @@ -78,11 +82,15 @@ if o in ( '-n', '--number' ): only_numbers = 1 short_summary = 1 + if o in ( "-i" , "--instructionSet" ): + instr_set = a + +print "instruction set is: " + instr_set # process options os.chdir(dir) execution=1 -summary="\n\t\t\t--> LAPACK TESTING SUMMARY <--\n"; +summary="\n\t\t\t--> LAPACK TESTING SUMMARY FOR INSTRUCTION SET "+instr_set+" <--\n"; if with_file: summary+= "\t\tProcessing LAPACK Testing output found in the "+dir+" direcory\n"; summary+="SUMMARY \tnb test run \tnumerical error \tother error \n"; summary+="================ \t===========\t=================\t================ \n"; @@ -245,20 +253,20 @@ def run_summary_test( f, cmdline, short_summary): if dtest==16 and (letter=="s" or letter=="c"): continue if (with_file==1): - cmdbase=dtests[2][dtest]+".out" + cmdbase=dtests[2][dtest]+".out_"+instr_set else: if dtest==15: # LIN TESTS - cmdbase="xlintst"+letter+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out" + cmdbase="xlintst"+letter+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out_"+instr_set elif dtest==16: # PROTO LIN TESTS - cmdbase="xlintst"+letter+dtypes[0][dtype-1]+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out" + cmdbase="xlintst"+letter+dtypes[0][dtype-1]+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out_"+instr_set elif dtest==17: # PROTO LIN TESTS - cmdbase="xlintstrf"+letter+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out" + cmdbase="xlintstrf"+letter+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out_"+instr_set else: # EIG TESTS - cmdbase="xeigtst"+letter+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out" + cmdbase="xeigtst"+letter+" < "+dtests[0][dtest]+".in > "+dtests[2][dtest]+".out_"+instr_set if (not just_errors and not short_summary): print "--> Testing "+name+" "+dtests[1][dtest]+" [ "+cmdbase+" ]" # Run the process: either to read the file or run the LAPACK testing @@ -316,3 +324,26 @@ def run_summary_test( f, cmdline, short_summary): # This may close the sys.stdout stream, so make it the last statement f.close() + +# check number of tests run and make sure it wasn't zero +if(list_results[0][4]==0): + print "No tests ran, failing as a result." + exit(1) + +# mangle results for windows and mac, this is down to a test based local xerbla being called but +# these OSs use the originally linked symbol instead so the tests unduly fail. See issue [MAT-289]. +linuxexpr = re.compile('linux',re.I); +if not linuxexpr.match(platform.system()): + list_results[2][4]-=61; # 61 fails due to bad xerblas + +# check summary and fail if tests failed +if(list_results[1][4]>0): + print "Failing as "+instr_set+". "+str(list_results[1][4])+" tests failed on numerical error." + exit(1) +if(list_results[2][4]>0): + print "Failing as "+instr_set+". "+str(list_results[2][4])+" tests failed on other error." + exit(1) + +# all tests that ran passed +print "Pass for "+instr_set+". "+str(list_results[0][4])+" tests passed." +exit(0) \ No newline at end of file