<<: *setup_ci_environment
- run:
name: Test
- no_output_timeout: "90m"
+ no_output_timeout: "1h"
command: |
set -e
export COMMIT_DOCKER_IMAGE=${DOCKER_IMAGE}-${CIRCLE_SHA1}
# symbolize=1: Gives us much better errors when things go wrong
export ASAN_OPTIONS=detect_leaks=0:symbolize=1
-# FIXME: Remove the hardcoded "-pthread" option.
-# With asan build, the cmake thread CMAKE_HAVE_LIBC_CREATE[1] checking will
-# succeed because "pthread_create" is in libasan.so. However, libasan doesn't
-# have the full pthread implementation. Other advanced pthread functions doesn't
-# exist in libasan.so[2]. If we need some pthread advanced functions, we still
-# need to link the pthread library.
-# [1] https://github.com/Kitware/CMake/blob/8cabaaf054a16ea9c8332ce8e9291bd026b38c62/Modules/FindThreads.cmake#L135
-# [2] https://wiki.gentoo.org/wiki/AddressSanitizer/Problems
-#
# TODO: Make the ASAN flags a more unified env var
CC="clang" CXX="clang++" LDSHARED="clang --shared" \
- CFLAGS="-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -shared-libasan -pthread" \
- CXX_FLAGS="-pthread" \
+ CFLAGS="-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -shared-libasan" \
NO_CUDA=1 USE_MKLDNN=0 \
python setup.py install
else()
target_link_libraries(caffe2 PUBLIC protobuf::libprotobuf)
endif()
-
- #cmake only check for separate OpenMP library on AppleClang 7+
- #https://github.com/Kitware/CMake/blob/42212f7539040139ecec092547b7d58ef12a4d72/Modules/FindOpenMP.cmake#L252
- if (WITH_OPENMP AND CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
- if (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "7.0" OR
- CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.0")
- target_link_libraries(caffe2 PRIVATE ${OpenMP_libomp_LIBRARY})
- endif()
- endif()
endif()
+
target_link_libraries(caffe2 PUBLIC c10)
target_link_libraries(caffe2 PUBLIC ${Caffe2_PUBLIC_DEPENDENCY_LIBS})
target_link_libraries(caffe2 PRIVATE ${Caffe2_DEPENDENCY_LIBS})
# ---[ OpenMP
if(USE_OPENMP)
- set(WITH_OPENMP ON CACHE BOOL "OpenMP support if available?")
- if(APPLE AND CMAKE_COMPILER_IS_GNUCC)
- exec_program(uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION)
- string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
- message(STATUS "MAC OS Darwin Version: ${DARWIN_VERSION}")
- if(DARWIN_VERSION GREATER 9)
- set(APPLE_OPENMP_SUCKS 1)
- endif(DARWIN_VERSION GREATER 9)
- execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
- OUTPUT_VARIABLE GCC_VERSION)
- if(APPLE_OPENMP_SUCKS AND GCC_VERSION VERSION_LESS 4.6.2)
- message(STATUS "Warning: Disabling OpenMP (unstable with this version of GCC)")
- message(STATUS " Install GCC >= 4.6.2 or change your OS to enable OpenMP")
- add_compile_options(-Wno-unknown-pragmas)
- set(WITH_OPENMP OFF CACHE BOOL "OpenMP support if available?" FORCE)
- endif()
- endif()
-
- if(WITH_OPENMP AND NOT CHECKED_OPENMP)
- find_package(OpenMP)
- set(CHECKED_OPENMP ON CACHE BOOL "already checked for OpenMP")
-
- # OPENMP_FOUND is not cached in FindOpenMP.cmake (all other variables are cached)
- # see https://github.com/Kitware/CMake/blob/master/Modules/FindOpenMP.cmake
- set(OPENMP_FOUND ${OPENMP_FOUND} CACHE BOOL "OpenMP Support found")
- endif()
-
+ find_package(OpenMP)
if(OPENMP_FOUND)
message(STATUS "Adding " ${OpenMP_CXX_FLAGS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
else()
message(WARNING "Not compiling with OpenMP. Suppress this warning with -DUSE_OPENMP=OFF")
caffe2_update_option(USE_OPENMP OFF)
STRING(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_DEBUG "" ${CMAKE_CXX_FLAGS_DEBUG})
STRING(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELEASE "" ${CMAKE_CXX_FLAGS_RELEASE})
ENDIF()
+
+ # OpenMP support?
+ SET(WITH_OPENMP ON CACHE BOOL "OpenMP support if available?")
+ IF (APPLE AND CMAKE_COMPILER_IS_GNUCC)
+ EXEC_PROGRAM (uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION)
+ STRING (REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
+ MESSAGE (STATUS "MAC OS Darwin Version: ${DARWIN_VERSION}")
+ IF (DARWIN_VERSION GREATER 9)
+ SET(APPLE_OPENMP_SUCKS 1)
+ ENDIF (DARWIN_VERSION GREATER 9)
+ EXECUTE_PROCESS (COMMAND ${CMAKE_C_COMPILER} -dumpversion
+ OUTPUT_VARIABLE GCC_VERSION)
+ IF (APPLE_OPENMP_SUCKS AND GCC_VERSION VERSION_LESS 4.6.2)
+ MESSAGE(STATUS "Warning: Disabling OpenMP (unstable with this version of GCC)")
+ MESSAGE(STATUS " Install GCC >= 4.6.2 or change your OS to enable OpenMP")
+ add_compile_options(-Wno-unknown-pragmas)
+ SET(WITH_OPENMP OFF CACHE BOOL "OpenMP support if available?" FORCE)
+ ENDIF()
+ ENDIF()
+
+ IF (WITH_OPENMP AND NOT CHECKED_OPENMP)
+ FIND_PACKAGE(OpenMP)
+ SET(CHECKED_OPENMP ON CACHE BOOL "already checked for OpenMP")
+
+ # OPENMP_FOUND is not cached in FindOpenMP.cmake (all other variables are cached)
+ # see https://github.com/Kitware/CMake/blob/master/Modules/FindOpenMP.cmake
+ SET(OPENMP_FOUND ${OPENMP_FOUND} CACHE BOOL "OpenMP Support found")
+ ENDIF()
+
+ IF (OPENMP_FOUND)
+ MESSAGE(STATUS "Compiling with OpenMP support")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+ ENDIF()
+
+
SET(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE OFF)
FIND_PACKAGE(MAGMA)
file(GLOB Detectron_GPU_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cu)
if (BUILD_CAFFE2_OPS)
- #cmake only check for separate OpenMP library on AppleClang 7+
- #https://github.com/Kitware/CMake/blob/42212f7539040139ecec092547b7d58ef12a4d72/Modules/FindOpenMP.cmake#L252
- if (WITH_OPENMP AND CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
- if (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "7.0" OR
- CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.0")
- Set(OpenMP_link ${OpenMP_libomp_LIBRARY})
- endif()
- endif()
-
# Note(ilijar): Since Detectron ops currently have no
# CPU implementation, we only build GPU ops for now.
if (USE_CUDA)
${Detectron_CPU_SRCS}
${Detectron_GPU_SRCS})
- target_link_libraries(caffe2_detectron_ops_gpu caffe2_gpu ${OpenMP_link})
+ target_link_libraries(caffe2_detectron_ops_gpu caffe2_gpu)
install(TARGETS caffe2_detectron_ops_gpu DESTINATION lib)
elseif(NOT IOS_PLATFORM)
add_library(caffe2_detectron_ops SHARED ${Detectron_CPU_SRCS})
- target_link_libraries(caffe2_detectron_ops caffe2 ${OpenMP_link})
+ target_link_libraries(caffe2_detectron_ops caffe2)
install(TARGETS caffe2_detectron_ops DESTINATION lib)
endif()
endif()
return()
endif()
else()
- cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
+ cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(torch CXX C)
find_package(Caffe2 REQUIRED)
option(USE_CUDA "Use CUDA" ON)
if (VERBOSE)
message(STATUS "Compiling with OpenMP")
endif()
- target_compile_options(torch INTERFACE ${OpenMP_CXX_FLAGS})
+ target_compile_options(torch INTERFACE -fopenmp)
target_link_libraries(torch -fopenmp)
- #cmake only check for separate OpenMP library on AppleClang 7+
- #https://github.com/Kitware/CMake/blob/42212f7539040139ecec092547b7d58ef12a4d72/Modules/FindOpenMP.cmake#L252
- if (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
- if (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "7.0" OR
- CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.0")
- target_link_libraries(torch ${OpenMP_libomp_LIBRARY})
- endif()
- endif()
endif()
if (NOT NO_API)