Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#138 from gangliao/master
Browse files Browse the repository at this point in the history
Add Mac OS X port
  • Loading branch information
gangliao authored Sep 29, 2016
2 parents 1fc4352 + efea5c8 commit 2920b6b
Show file tree
Hide file tree
Showing 59 changed files with 969 additions and 265 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
*.DS_Store
build/
*.user

.vscode
.idea
6 changes: 4 additions & 2 deletions cmake/cblas.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ set(OPENBLAS_ROOT $ENV{OPENBLAS_ROOT} CACHE PATH "Folder contains Openblas")
set(OPENBLAS_INCLUDE_SEARCH_PATHS
${OPENBLAS_ROOT}/include
/usr/include
/usr/include/openblas)
/usr/include/openblas
/usr/local/opt/openblas/include)
set(OPENBLAS_LIB_SEARCH_PATHS
${OPENBLAS_ROOT}/lib
/usr/lib
/usr/lib/blas/openblas
/usr/lib/openblas)
/usr/lib/openblas
/usr/local/opt/openblas/lib)

find_path(OPENBLAS_INC_DIR NAMES cblas.h
PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS})
Expand Down
2 changes: 1 addition & 1 deletion cmake/cudnn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ list(APPEND CUDNN_CHECK_LIBRARY_DIRS
$ENV{CUDNN_ROOT}/lib64
$ENV{CUDNN_ROOT}/lib
/usr/lib)
find_library(CUDNN_LIBRARY NAMES libcudnn.so # libcudnn_static.a
find_library(CUDNN_LIBRARY NAMES libcudnn.so libcudnn.dylib # libcudnn_static.a
PATHS ${CUDNN_CHECK_LIBRARY_DIRS} ${CUDNN_INCLUDE_DIR} ${__libpath_hist}
NO_DEFAULT_PATH
DOC "Path to cuDNN library.")
Expand Down
57 changes: 48 additions & 9 deletions cmake/util.cmake
Original file line number Diff line number Diff line change
@@ -1,16 +1,55 @@
# Some common routine for paddle compile.


# target_circle_link_libraries
# Link libraries to target which has circle dependencies.
#
# First Argument: target name want to be linked with libraries
# Rest Arguments: libraries which link together.
function(target_circle_link_libraries TARGET_NAME)
target_link_libraries(${TARGET_NAME}
-Wl,--start-group
${ARGN}
-Wl,--end-group)
if(APPLE)
set(LIBS)
set(inArchive OFF)
set(libsInArgn)

foreach(arg ${ARGN})
if(${arg} STREQUAL "ARCHIVE_START")
set(inArchive ON)
elseif(${arg} STREQUAL "ARCHIVE_END")
set(inArchive OFF)
else()
if(inArchive)
list(APPEND LIBS "-Wl,-force_load")
endif()
list(APPEND LIBS ${arg})
list(APPEND libsInArgn ${arg})
endif()
endforeach()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
list(APPEND LIBS "-undefined dynamic_lookup")
endif()
list(REVERSE libsInArgn)
target_link_libraries(${TARGET_NAME}
${LIBS}
${libsInArgn})

else() # LINUX
set(LIBS)

foreach(arg ${ARGN})
if(${arg} STREQUAL "ARCHIVE_START")
list(APPEND LIBS "-Wl,--whole-archive")
elseif(${arg} STREQUAL "ARCHIVE_END")
list(APPEND LIBS "-Wl,--no-whole-archive")
else()
list(APPEND LIBS ${arg})
endif()
endforeach()

target_link_libraries(${TARGET_NAME}
"-Wl,--start-group"
${LIBS}
"-Wl,--end-group")
endif()
endfunction()

# compile_cu_as_cpp
Expand Down Expand Up @@ -41,20 +80,20 @@ function(link_paddle_exe TARGET_NAME)
if(PADDLE_WITH_INTERNAL)
set(INTERAL_LIBS paddle_internal_gserver paddle_internal_parameter)
target_circle_link_libraries(${TARGET_NAME}
-Wl,--whole-archive
ARCHIVE_START
paddle_internal_gserver
paddle_internal_owlqn
-Wl,--no-whole-archive
ARCHIVE_END
paddle_internal_parameter)
else()
set(INTERAL_LIBS "")
endif()

target_circle_link_libraries(${TARGET_NAME}
-Wl,--whole-archive
ARCHIVE_START
paddle_gserver
${METRIC_LIBS}
-Wl,--no-whole-archive
ARCHIVE_END
paddle_pserver
paddle_trainer_lib
paddle_network
Expand Down
Loading

0 comments on commit 2920b6b

Please sign in to comment.