From 8d4c4775a0a686e93fbaaf02057f8ab8ef4896c3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 26 Jan 2019 14:46:38 +0100 Subject: Cleanup: fix compiler warnings. --- intern/cycles/bvh/bvh2.h | 4 ++-- intern/cycles/bvh/bvh4.h | 4 ++-- intern/cycles/bvh/bvh8.h | 4 ++-- source/blender/imbuf/intern/oiio/openimageio_api.cpp | 1 - 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/intern/cycles/bvh/bvh2.h b/intern/cycles/bvh/bvh2.h index f38cdf5aca9..6afa6c21796 100644 --- a/intern/cycles/bvh/bvh2.h +++ b/intern/cycles/bvh/bvh2.h @@ -52,7 +52,7 @@ protected: virtual BVHNode *widen_children_nodes(const BVHNode *root) override; /* pack */ - void pack_nodes(const BVHNode *root); + void pack_nodes(const BVHNode *root) override; void pack_leaf(const BVHStackEntry& e, const LeafNode *leaf); @@ -81,7 +81,7 @@ protected: uint visibility0, uint visibility1); /* refit */ - void refit_nodes(); + void refit_nodes() override; void refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility); }; diff --git a/intern/cycles/bvh/bvh4.h b/intern/cycles/bvh/bvh4.h index 2a2a466c767..caa0e2c8182 100644 --- a/intern/cycles/bvh/bvh4.h +++ b/intern/cycles/bvh/bvh4.h @@ -52,7 +52,7 @@ protected: virtual BVHNode *widen_children_nodes(const BVHNode *root) override; /* pack */ - void pack_nodes(const BVHNode *root); + void pack_nodes(const BVHNode *root) override; void pack_leaf(const BVHStackEntry& e, const LeafNode *leaf); void pack_inner(const BVHStackEntry& e, const BVHStackEntry *en, int num); @@ -81,7 +81,7 @@ protected: const int num); /* refit */ - void refit_nodes(); + void refit_nodes() override; void refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility); }; diff --git a/intern/cycles/bvh/bvh8.h b/intern/cycles/bvh/bvh8.h index 84f82538c0f..277e2f2d653 100644 --- a/intern/cycles/bvh/bvh8.h +++ b/intern/cycles/bvh/bvh8.h @@ -63,7 +63,7 @@ protected: virtual BVHNode *widen_children_nodes(const BVHNode *root) override; /* pack */ - void pack_nodes(const BVHNode *root); + void pack_nodes(const BVHNode *root) override; void pack_leaf(const BVHStackEntry& e, const LeafNode *leaf); void pack_inner(const BVHStackEntry& e, const BVHStackEntry *en, int num); @@ -92,7 +92,7 @@ protected: const int num); /* refit */ - void refit_nodes(); + void refit_nodes() override; void refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility); }; diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp index 34d5cccac84..7c64fdfc9df 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp +++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp @@ -203,7 +203,6 @@ struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspac struct ImBuf *ibuf = NULL; int width, height, components; bool is_float, is_alpha; - TypeDesc typedesc; int basesize; char file_colorspace[IM_MAX_SPACE]; -- cgit v1.2.3 From b7a9e980a11a085a3bc7ef8e267b967197f47447 Mon Sep 17 00:00:00 2001 From: Arto Kitula Date: Sat, 26 Jan 2019 14:14:51 +0100 Subject: macOS: add support for OpenMP, making smoke/fluid/cloth simulations faster. This bring macOS on par with Windows and Linux. It uses the OpenMP library added to our precompiled libraries. Custom flags are set because FindOpenMP from CMake below 3.12 does not support AppleClang, and more recent versions do not work with our custom directory location either. Differential Revision: https://developer.blender.org/D4257 --- CMakeLists.txt | 5 ++++- build_files/build_environment/cmake/harvest.cmake | 4 ++++ build_files/build_environment/cmake/openmp.cmake | 3 ++- build_files/cmake/platform/platform_apple.cmake | 21 +++++++++++++++------ source/creator/CMakeLists.txt | 7 +++++++ 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2341a535603..a71677c0308 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1177,7 +1177,10 @@ endif() #----------------------------------------------------------------------------- # Configure OpenMP. if(WITH_OPENMP) - find_package(OpenMP) + if(NOT OPENMP_CUSTOM) + find_package(OpenMP) + endif() + if(OPENMP_FOUND) if(NOT WITH_OPENMP_STATIC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake index d79d91f2b90..a281eb900e3 100644 --- a/build_files/build_environment/cmake/harvest.cmake +++ b/build_files/build_environment/cmake/harvest.cmake @@ -131,6 +131,10 @@ harvest(lame/lib ffmpeg/lib "*.a") harvest(clang/bin llvm/bin "clang-format") harvest(llvm/bin llvm/bin "llvm-config") harvest(llvm/lib llvm/lib "libLLVM*.a") +if(APPLE) + harvest(openmp/lib openmp/lib "*") + harvest(openmp/include openmp/include "*.h") +endif() harvest(ogg/lib ffmpeg/lib "*.a") harvest(openal/include openal/include "*.h") if(UNIX AND NOT APPLE) diff --git a/build_files/build_environment/cmake/openmp.cmake b/build_files/build_environment/cmake/openmp.cmake index ba8e6248126..d8224020ecf 100644 --- a/build_files/build_environment/cmake/openmp.cmake +++ b/build_files/build_environment/cmake/openmp.cmake @@ -23,7 +23,8 @@ ExternalProject_Add(external_openmp URL_HASH MD5=${OPENMP_HASH} PREFIX ${BUILD_DIR}/openmp CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openmp ${DEFAULT_CMAKE_FLAGS} - INSTALL_DIR ${LIBDIR}/clang + INSTALL_COMMAND cd ${BUILD_DIR}/openmp/src/external_openmp-build && install_name_tool -id '@executable_path/../Resources/lib/libomp.dylib' runtime/src/libomp.dylib && make install + INSTALL_PATH ${LIBDIR}/openmp ) add_dependencies( diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 4e78737fd9e..1b3b844642e 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -383,13 +383,22 @@ if(WITH_CYCLES_EMBREE) set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Xlinker -stack_size -Xlinker 0x100000") endif() +# CMake FindOpenMP doesn't know about AppleClang before 3.12, so provide custom flags. if(WITH_OPENMP) - execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE COMPILER_VENDOR) - string(SUBSTRING "${COMPILER_VENDOR}" 0 5 VENDOR_NAME) # truncate output - if(${VENDOR_NAME} MATCHES "Apple") # Apple does not support OpenMP reliable with gcc and not with clang - set(WITH_OPENMP OFF) - else() # vanilla gcc or clang_omp support OpenMP - message(STATUS "Using special OpenMP enabled compiler !") # letting find_package(OpenMP) module work for gcc + if(CMAKE_C_COMPILER_ID MATCHES "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0") + # Use OpenMP from our precompiled libraries. + message(STATUS "Using ${LIBDIR}/openmp for OpenMP") + set(OPENMP_CUSTOM ON) + set(OPENMP_FOUND ON) + set(OpenMP_C_FLAGS "-Xclang -fopenmp -I${LIBDIR}/openmp/include") + set(OpenMP_CXX_FLAGS "-Xclang -fopenmp -I${LIBDIR}/openmp/include") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${LIBDIR}/openmp/lib -lomp") + + # Copy libomp.dylib to allow executables like datatoc to work. + execute_process( + COMMAND mkdir -p ${CMAKE_BINARY_DIR}/Resources/lib + COMMAND cp -p ${LIBDIR}/openmp/lib/libomp.dylib ${CMAKE_BINARY_DIR}/Resources/lib/libomp.dylib + ) endif() endif() diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index a553b8a569b..d2255bbd894 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -914,6 +914,13 @@ elseif(APPLE) blender.app/Contents/ ) + if(WITH_OPENMP AND OPENMP_CUSTOM) + install( + FILES ${LIBDIR}/openmp/lib/libomp.dylib + DESTINATION blender.app/Contents/Resources/lib + ) + endif() + if(WITH_LLVM AND NOT LLVM_STATIC) install( FILES ${LIBDIR}/llvm/lib/libLLVM-3.4.dylib -- cgit v1.2.3