Skip to content

Commit f74ff6d

Browse files
committed
Merge branch 'cmake' into develop
2 parents 5a29160 + 2feef49 commit f74ff6d

80 files changed

Lines changed: 6104 additions & 143 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,5 @@ test/sblat3
6666
test/zblat1
6767
test/zblat2
6868
test/zblat3
69+
build
70+
build.*

CMakeLists.txt

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
##
2+
## Author: Hank Anderson <hank@statease.com>
3+
##
4+
5+
cmake_minimum_required(VERSION 2.8.4)
6+
project(OpenBLAS)
7+
set(OpenBLAS_MAJOR_VERSION 0)
8+
set(OpenBLAS_MINOR_VERSION 2)
9+
set(OpenBLAS_PATCH_VERSION 14)
10+
set(OpenBLAS_VERSION "${OpenBLAS_MAJOR_VERSION}.${OpenBLAS_MINOR_VERSION}.${OpenBLAS_PATCH_VERSION}")
11+
12+
enable_language(ASM)
13+
enable_language(C)
14+
15+
if(MSVC)
16+
set(OpenBLAS_LIBNAME libopenblas)
17+
else()
18+
set(OpenBLAS_LIBNAME openblas)
19+
endif()
20+
21+
#######
22+
if(MSVC)
23+
option(BUILD_WITHOUT_LAPACK "Without LAPACK and LAPACKE (Only BLAS or CBLAS)" ON)
24+
endif()
25+
option(BUILD_WITHOUT_CBLAS "Without CBLAS" OFF)
26+
option(BUILD_DEBUG "Build Debug Version" OFF)
27+
#######
28+
if(BUILD_WITHOUT_LAPACK)
29+
set(NO_LAPACK 1)
30+
set(NO_LAPACKE 1)
31+
endif()
32+
33+
if(BUILD_DEBUG)
34+
set(CMAKE_BUILD_TYPE Debug)
35+
else()
36+
set(CMAKE_BUILD_TYPE Release)
37+
endif()
38+
39+
if(BUILD_WITHOUT_CBLAS)
40+
set(NO_CBLAS 1)
41+
endif()
42+
43+
#######
44+
45+
46+
message(WARNING "CMake support is experimental. This will not produce the same Makefiles that OpenBLAS ships with. Only x86 support is currently available.")
47+
48+
include("${CMAKE_SOURCE_DIR}/cmake/utils.cmake")
49+
include("${CMAKE_SOURCE_DIR}/cmake/system.cmake")
50+
51+
set(BLASDIRS interface driver/level2 driver/level3 driver/others)
52+
53+
if (NOT DYNAMIC_ARCH)
54+
list(APPEND BLASDIRS kernel)
55+
endif ()
56+
57+
if (DEFINED UTEST_CHECK)
58+
set(SANITY_CHECK 1)
59+
endif ()
60+
61+
if (DEFINED SANITY_CHECK)
62+
list(APPEND BLASDIRS reference)
63+
endif ()
64+
65+
set(SUBDIRS ${BLASDIRS})
66+
if (NOT NO_LAPACK)
67+
list(APPEND SUBDIRS lapack)
68+
endif ()
69+
70+
# set which float types we want to build for
71+
if (NOT DEFINED BUILD_SINGLE AND NOT DEFINED BUILD_DOUBLE AND NOT DEFINED BUILD_COMPLEX AND NOT DEFINED BUILD_COMPLEX16)
72+
# if none are defined, build for all
73+
set(BUILD_SINGLE true)
74+
set(BUILD_DOUBLE true)
75+
set(BUILD_COMPLEX true)
76+
set(BUILD_COMPLEX16 true)
77+
endif ()
78+
79+
set(FLOAT_TYPES "")
80+
if (BUILD_SINGLE)
81+
message(STATUS "Building Single Precision")
82+
list(APPEND FLOAT_TYPES "SINGLE") # defines nothing
83+
endif ()
84+
85+
if (BUILD_DOUBLE)
86+
message(STATUS "Building Double Precision")
87+
list(APPEND FLOAT_TYPES "DOUBLE") # defines DOUBLE
88+
endif ()
89+
90+
if (BUILD_COMPLEX)
91+
message(STATUS "Building Complex Precision")
92+
list(APPEND FLOAT_TYPES "COMPLEX") # defines COMPLEX
93+
endif ()
94+
95+
if (BUILD_COMPLEX16)
96+
message(STATUS "Building Double Complex Precision")
97+
list(APPEND FLOAT_TYPES "ZCOMPLEX") # defines COMPLEX and DOUBLE
98+
endif ()
99+
100+
set(SUBDIRS_ALL ${SUBDIRS} test ctest utest exports benchmark ../laswp ../bench)
101+
102+
# all :: libs netlib tests shared
103+
104+
# libs :
105+
if (NOT DEFINED CORE OR "${CORE}" STREQUAL "UNKNOWN")
106+
message(FATAL_ERROR "Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for details.")
107+
endif ()
108+
109+
if (${NO_STATIC} AND ${NO_SHARED})
110+
message(FATAL_ERROR "Neither static nor shared are enabled.")
111+
endif ()
112+
113+
# get obj vars into format that add_library likes: $<TARGET_OBJS:objlib> (see http://www.cmake.org/cmake/help/v3.0/command/add_library.html)
114+
set(TARGET_OBJS "")
115+
foreach (SUBDIR ${SUBDIRS})
116+
add_subdirectory(${SUBDIR})
117+
string(REPLACE "/" "_" subdir_obj ${SUBDIR})
118+
list(APPEND TARGET_OBJS "$<TARGET_OBJECTS:${subdir_obj}>")
119+
endforeach ()
120+
121+
# netlib:
122+
123+
# Can't just use lapack-netlib's CMake files, since they are set up to search for BLAS, build and install a binary. We just want to build a couple of lib files out of lapack and lapacke.
124+
# Not using add_subdirectory here because lapack-netlib already has its own CMakeLists.txt. Instead include a cmake script with the sources we want.
125+
if (NOT NOFORTRAN AND NOT NO_LAPACK)
126+
include("${CMAKE_SOURCE_DIR}/cmake/lapack.cmake")
127+
if (NOT NO_LAPACKE)
128+
include("${CMAKE_SOURCE_DIR}/cmake/lapacke.cmake")
129+
endif ()
130+
endif ()
131+
132+
#Only generate .def for dll on MSVC
133+
if(MSVC)
134+
set(OpenBLAS_DEF_FILE "${PROJECT_BINARY_DIR}/openblas.def")
135+
endif()
136+
137+
# add objects to the openblas lib
138+
add_library(${OpenBLAS_LIBNAME} SHARED ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS} ${OpenBLAS_DEF_FILE})
139+
140+
include("${CMAKE_SOURCE_DIR}/cmake/export.cmake")
141+
142+
143+
if(NOT MSVC)
144+
#only build shared library for MSVC
145+
add_library(${OpenBLAS_LIBNAME}_static STATIC ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS})
146+
set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES OUTPUT_NAME ${OpenBLAS_LIBNAME})
147+
set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
148+
149+
if(SMP)
150+
target_link_libraries(${OpenBLAS_LIBNAME} pthread)
151+
target_link_libraries(${OpenBLAS_LIBNAME}_static pthread)
152+
endif()
153+
154+
#build test and ctest
155+
enable_testing()
156+
add_subdirectory(test)
157+
if(NOT NO_CBLAS)
158+
add_subdirectory(ctest)
159+
endif()
160+
endif()
161+
162+
set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES
163+
VERSION ${OpenBLAS_MAJOR_VERSION}.${OpenBLAS_MINOR_VERSION}
164+
SOVERSION ${OpenBLAS_MAJOR_VERSION}
165+
)
166+
167+
168+
# TODO: Why is the config saved here? Is this necessary with CMake?
169+
#Save the config files for installation
170+
# @cp Makefile.conf Makefile.conf_last
171+
# @cp config.h config_last.h
172+
#ifdef QUAD_PRECISION
173+
# @echo "#define QUAD_PRECISION">> config_last.h
174+
#endif
175+
#ifeq ($(EXPRECISION), 1)
176+
# @echo "#define EXPRECISION">> config_last.h
177+
#endif
178+
###
179+
#ifeq ($(DYNAMIC_ARCH), 1)
180+
# @$(MAKE) -C kernel commonlibs || exit 1
181+
# @for d in $(DYNAMIC_CORE) ; \
182+
# do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\
183+
# done
184+
# @echo DYNAMIC_ARCH=1 >> Makefile.conf_last
185+
#endif
186+
#ifdef USE_THREAD
187+
# @echo USE_THREAD=$(USE_THREAD) >> Makefile.conf_last
188+
#endif
189+
# @touch lib.grd
190+

cmake/arch.cmake

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
##
2+
## Author: Hank Anderson <hank@statease.com>
3+
## Description: Ported from portion of OpenBLAS/Makefile.system
4+
## Sets various variables based on architecture.
5+
6+
if (${ARCH} STREQUAL "x86" OR ${ARCH} STREQUAL "x86_64")
7+
8+
if (${ARCH} STREQUAL "x86")
9+
if (NOT BINARY)
10+
set(NO_BINARY_MODE 1)
11+
endif ()
12+
endif ()
13+
14+
if (NOT NO_EXPRECISION)
15+
if (${F_COMPILER} MATCHES "GFORTRAN")
16+
# N.B. I'm not sure if CMake differentiates between GCC and LSB -hpa
17+
if (${CMAKE_C_COMPILER} STREQUAL "GNU" OR ${CMAKE_C_COMPILER} STREQUAL "LSB")
18+
set(EXPRECISION 1)
19+
set(CCOMMON_OPT "${CCOMMON_OPT} -DEXPRECISION -m128bit-long-double")
20+
set(FCOMMON_OPT "${FCOMMON_OPT} -m128bit-long-double")
21+
endif ()
22+
if (${CMAKE_C_COMPILER} STREQUAL "Clang")
23+
set(EXPRECISION 1)
24+
set(CCOMMON_OPT "${CCOMMON_OPT} -DEXPRECISION")
25+
set(FCOMMON_OPT "${FCOMMON_OPT} -m128bit-long-double")
26+
endif ()
27+
endif ()
28+
endif ()
29+
endif ()
30+
31+
if (${CMAKE_C_COMPILER} STREQUAL "Intel")
32+
set(CCOMMON_OPT "${CCOMMON_OPT} -wd981")
33+
endif ()
34+
35+
if (USE_OPENMP)
36+
37+
if (${CMAKE_C_COMPILER} STREQUAL "GNU" OR ${CMAKE_C_COMPILER} STREQUAL "LSB")
38+
set(CCOMMON_OPT "${CCOMMON_OPT} -fopenmp")
39+
endif ()
40+
41+
if (${CMAKE_C_COMPILER} STREQUAL "Clang")
42+
message(WARNING "Clang doesn't support OpenMP yet.")
43+
set(CCOMMON_OPT "${CCOMMON_OPT} -fopenmp")
44+
endif ()
45+
46+
if (${CMAKE_C_COMPILER} STREQUAL "Intel")
47+
set(CCOMMON_OPT "${CCOMMON_OPT} -openmp")
48+
endif ()
49+
50+
if (${CMAKE_C_COMPILER} STREQUAL "PGI")
51+
set(CCOMMON_OPT "${CCOMMON_OPT} -mp")
52+
endif ()
53+
54+
if (${CMAKE_C_COMPILER} STREQUAL "OPEN64")
55+
set(CCOMMON_OPT "${CCOMMON_OPT} -mp")
56+
set(CEXTRALIB "${CEXTRALIB} -lstdc++")
57+
endif ()
58+
59+
if (${CMAKE_C_COMPILER} STREQUAL "PATHSCALE")
60+
set(CCOMMON_OPT "${CCOMMON_OPT} -mp")
61+
endif ()
62+
endif ()
63+
64+
65+
if (DYNAMIC_ARCH)
66+
if (${ARCH} STREQUAL "x86")
67+
set(DYNAMIC_CORE "KATMAI COPPERMINE NORTHWOOD PRESCOTT BANIAS CORE2 PENRYN DUNNINGTON NEHALEM ATHLON OPTERON OPTERON_SSE3 BARCELONA BOBCAT ATOM NANO")
68+
endif ()
69+
70+
if (${ARCH} STREQUAL "x86_64")
71+
set(DYNAMIC_CORE "PRESCOTT CORE2 PENRYN DUNNINGTON NEHALEM OPTERON OPTERON_SSE3 BARCELONA BOBCAT ATOM NANO")
72+
if (NOT NO_AVX)
73+
set(DYNAMIC_CORE "${DYNAMIC_CORE} SANDYBRIDGE BULLDOZER PILEDRIVER STEAMROLLER")
74+
endif ()
75+
if (NOT NO_AVX2)
76+
set(DYNAMIC_CORE "${DYNAMIC_CORE} HASWELL")
77+
endif ()
78+
endif ()
79+
80+
if (NOT DYNAMIC_CORE)
81+
unset(DYNAMIC_ARCH)
82+
endif ()
83+
endif ()
84+
85+
if (${ARCH} STREQUAL "ia64")
86+
set(NO_BINARY_MODE 1)
87+
set(BINARY_DEFINED 1)
88+
89+
if (${F_COMPILER} MATCHES "GFORTRAN")
90+
if (${CMAKE_C_COMPILER} STREQUAL "GNU")
91+
# EXPRECISION = 1
92+
# CCOMMON_OPT += -DEXPRECISION
93+
endif ()
94+
endif ()
95+
endif ()
96+
97+
if (${ARCH} STREQUAL "mips64")
98+
set(NO_BINARY_MODE 1)
99+
endif ()
100+
101+
if (${ARCH} STREQUAL "alpha")
102+
set(NO_BINARY_MODE 1)
103+
set(BINARY_DEFINED 1)
104+
endif ()
105+
106+
if (${ARCH} STREQUAL "arm")
107+
set(NO_BINARY_MODE 1)
108+
set(BINARY_DEFINED 1)
109+
endif ()
110+
111+
if (${ARCH} STREQUAL "arm64")
112+
set(NO_BINARY_MODE 1)
113+
set(BINARY_DEFINED 1)
114+
endif ()
115+

0 commit comments

Comments
 (0)