You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 3.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. include_directories(${PROJECT_SOURCE_DIR})
  2. include_directories(${PROJECT_BINARY_DIR})
  3. enable_language(Fortran)
  4. if (CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
  5. set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-tree-vectorize")
  6. endif()
  7. if (CMAKE_Fortran_COMPILER_ID STREQUAL Flang)
  8. set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O2")
  9. endif()
  10. if (BUILD_SINGLE)
  11. list( APPEND OpenBLAS_Tests sblat1 sblat2 sblat3)
  12. endif()
  13. if (BUILD_DOUBLE)
  14. list (APPEND OpenBLAS_Tests dblat1 dblat2 dblat3)
  15. endif()
  16. if (BUILD_COMPLEX)
  17. list (APPEND OpenBLAS_Tests cblat1 cblat2 cblat3)
  18. endif()
  19. if (BUILD_COMPLEX16)
  20. list (APPEND OpenBLAS_Tests zblat1 zblat2 zblat3)
  21. endif()
  22. set (USE_GEMM3M 0)
  23. if (${ARCH} MATCHES x86|x86_64|ia64|mips)
  24. set(USE_GEMM3M 1)
  25. if (BUILD_COMPLEX)
  26. list (APPEND OpenBLAS_Tests cblat3_3m)
  27. endif ()
  28. if (BUILD_COMPLEX16)
  29. list (APPEND OpenBLAS_Tests zblat3_3m)
  30. endif ()
  31. endif ()
  32. foreach(test_bin ${OpenBLAS_Tests})
  33. add_executable(${test_bin} ${test_bin}.f)
  34. target_link_libraries(${test_bin} ${OpenBLAS_LIBNAME})
  35. if (USE_OPENMP AND (${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) AND (${CMAKE_C_COMPILER_ID} STREQUAL Clang))
  36. string(REGEX REPLACE "-fopenmp" "" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
  37. target_link_libraries(${test_bin} omp pthread)
  38. endif()
  39. endforeach()
  40. # $1 exec, $2 input, $3 output_result
  41. if(WIN32)
  42. FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_helper.ps1
  43. "[Console]::InputEncoding = New-Object Text.UTF8Encoding $false\n"
  44. "if (Test-Path $args[2]) { Remove-Item -Force $args[2] } \n"
  45. "$ErrorActionPreference = \"Stop\"\n"
  46. "Get-Content $args[1] | & $args[0]\n"
  47. "If ((Get-Content $args[2] | %{$_ -match \"FATAL\"}) -contains $true) {\n"
  48. "echo Error\n"
  49. "exit 1\n"
  50. "} else {\n"
  51. "exit 0\n"
  52. "}\n"
  53. )
  54. set(helper_prefix powershell -ExecutionPolicy Bypass "${CMAKE_CURRENT_BINARY_DIR}/test_helper.ps1")
  55. else()
  56. FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_helper.sh
  57. "rm -f $3\n"
  58. "$1 < $2\n"
  59. "grep -q FATAL $3\n"
  60. "if [ $? -eq 0 ]; then\n"
  61. "echo Error\n"
  62. "exit 1\n"
  63. "else\n"
  64. "exit 0\n"
  65. "fi\n"
  66. )
  67. set(helper_prefix sh "${CMAKE_CURRENT_BINARY_DIR}/test_helper.sh")
  68. endif()
  69. #set(float_types s d c z)
  70. if (BUILD_SINGLE)
  71. list (APPEND float_types s)
  72. endif()
  73. if (BUILD_DOUBLE)
  74. list (APPEND float_types d)
  75. endif()
  76. if (BUILD_COMPLEX)
  77. list (APPEND float_types c)
  78. endif()
  79. if (BUILD_COMPLEX16)
  80. list (APPEND float_types z)
  81. endif()
  82. foreach(float_type ${float_types})
  83. string(TOUPPER ${float_type} float_type_upper)
  84. add_test(NAME "${float_type}blas1"
  85. COMMAND $<TARGET_FILE:${float_type}blat1>)
  86. add_test(NAME "${float_type}blas2"
  87. COMMAND ${helper_prefix} $<TARGET_FILE:${float_type}blat2> "${PROJECT_SOURCE_DIR}/test/${float_type}blat2.dat" ${float_type_upper}BLAT2.SUMM)
  88. add_test(NAME "${float_type}blas3"
  89. COMMAND ${helper_prefix} $<TARGET_FILE:${float_type}blat3> "${PROJECT_SOURCE_DIR}/test/${float_type}blat3.dat" ${float_type_upper}BLAT3.SUMM)
  90. if (USE_GEMM3M)
  91. if ((${float_type} STREQUAL "c") OR (${float_type} STREQUAL "z"))
  92. add_test(NAME "${float_type}blas3_3m"
  93. COMMAND ${helper_prefix} $<TARGET_FILE:${float_type}blat3_3m> "${PROJECT_SOURCE_DIR}/test/${float_type}blat3_3m.dat" ${float_type_upper}BLAT3_3M.SUMM)
  94. endif()
  95. endif()
  96. endforeach()