Skip to content

Commit

Permalink
Sync with 666ff73
Browse files Browse the repository at this point in the history
  • Loading branch information
HasKha committed Nov 1, 2022
1 parent 3e856f1 commit 882c442
Show file tree
Hide file tree
Showing 107 changed files with 5,817 additions and 1,348 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
# Python cache
__pycache__

# Python folders
*.egg-info

# Executables
*.exe
*.out
Expand Down
18 changes: 13 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ if(LAGRANGE_WITH_CCACHE AND CCACHE_PROGRAM)
endforeach()
endif()

# Set default macOS deployment target
if(LAGRANGE_TOPLEVEL_PROJECT)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version")
endif()

################################################################################
file(READ "VERSION" lagrange_version)
string(STRIP ${lagrange_version} lagrange_version)
Expand Down Expand Up @@ -125,9 +130,10 @@ set(LAGRANGE_WEBSITE_REPO "" CACHE FILEPATH "Path to the website repository for

# Set default minimum C++ standard
if(LAGRANGE_TOPLEVEL_PROJECT)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version")
endif()

if(LAGRANGE_EXTERNAL_ONLY)
Expand All @@ -153,12 +159,11 @@ else()
endif()
set(LAGRANGE_IDE_PREFIX ${LAGRANGE_IDE_PREFIX_DEFAULT} CACHE STRING "Folder prefix for Lagrange targets in MSVC/Xcode")

# When building anorigami module, additionally defaults to MKL-dynamic and TBB-dynamic
# When building anorigami module, defaults to pre-built Arpack and dynamic MKL/TBB
if(LAGRANGE_MODULE_ANORIGAMI OR (LAGRANGE_ALL AND NOT LAGRANGE_NO_INTERNAL))
set(MKL_LINKING "dynamic" CACHE STRING "Linking strategy to use with MKL (static, dynamic or sdl)")
option(TBB_PREFER_STATIC "Build with static TBB" OFF)
option(TBB_BUILD_TBBMALLOC "Build TBB malloc library" ON)
include(mkl)
endif()

# On Linux & Windows we use MKL to provide BLAS/LAPACK. Since it comes precompiled with /MD on Windows,
Expand All @@ -184,10 +189,11 @@ include(lagrange_add_python_binding)
include(lagrange_add_test)
include(lagrange_download_data)
include(lagrange_global_flags)
include(lagrange_has_onetbb)
include(lagrange_include_modules)
include(lagrange_install)
include(lagrange_warnings)
include(lagrange_limit_parallelism)
include(lagrange_warnings)
include(sanitizers)
include(code-coverage)

Expand All @@ -202,9 +208,11 @@ endif()
find_package(Threads REQUIRED)

# Include OneTBB early to provide TBB::tbb target
if(LAGRANGE_WITH_ONETBB AND NOT (LAGRANGE_ALL OR LAGRANGE_MODULE_LANTERN))
if(LAGRANGE_WITH_ONETBB)
set(MKL_VERSION 2021.3.0 CACHE STRING "MKL version to use (2020.4 or 2021.3.0)")
include(onetbb)
else()
set(MKL_VERSION 2020.4 CACHE STRING "MKL version to use (2020.4 or 2021.3.0)")
endif()

# Enable unit testing at the root level
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.5.0
6.6.0
1 change: 1 addition & 0 deletions cmake/lagrange/lagrange_add_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function(lagrange_add_test)

# Register tests
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/reports")

if(LAGRANGE_TOPLEVEL_PROJECT AND NOT EMSCRIPTEN)
catch_discover_tests(${test_target}
REPORTER junit
Expand Down
47 changes: 47 additions & 0 deletions cmake/lagrange/lagrange_has_onetbb.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Copyright 2020 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
function(lagrange_has_onetbb)
if(NOT TARGET TBB::tbb)
message(FATAL_ERROR "CMake target TBB::tbb must be defined.")
endif()

# This is a very ad-hoc system. Ideally we would use check_cxx_source_compiles() to check the
# major version macro TBB_INTERFACE_VERSION_MAJOR, but this is a very limited CMake function
# that does not understand CMake targets not generator expression, making it difficult to test
# it against the real target TBB::tbb.
get_target_property(TBB_SOURCES TBB::tbb SOURCES)
if("arena_slot.cpp" IN_LIST TBB_SOURCES)
message(STATUS "Lagrange detected OneTBB 2021 or higher")
set(LAGRANGE_HAS_ONETBB ON CACHE INTERNAL "TBB version used in Lagrange" FORCE)
else()
message(STATUS "Lagrange detected TBB 2020 or lower")
set(LAGRANGE_HAS_ONETBB OFF CACHE INTERNAL "TBB version used in Lagrange" FORCE)
endif()

# The code below should be preferred to check the TBB version from the provided target. We keep
# it commented for reference, but CMake limitations prevent this from being fully functional.
#
# include(CMakePushCheckState)
# include(CheckCXXSourceCompiles)
# cmake_push_check_state(RESET)
# check_cxx_source_compiles( [[
# #include <tbb/task.h>
# #if TBB_INTERFACE_VERSION_MAJOR >= 12
# #message("OneTBB 2021 or higher")
# #else
# #error("TBB 2020 or lower")
# #endif
# ]]
# LAGRANGE_HAS_ONETBB
# )
# cmake_pop_check_state()
endfunction()
3 changes: 2 additions & 1 deletion cmake/lagrange/lagrange_include_modules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ function(lagrange_include_modules)
add_subdirectory(${lagrange_source_dir}/modules/${name} ${lagrange_binary_dir}/modules/lagrange_${name})
endif()

if(NOT TARGET lagrange::${name})
# deformers or lantern modules can be skipped on certain platforms due to lack of support
if(NOT name MATCHES "(deformers|lantern)" AND NOT TARGET lagrange::${name})
message(FATAL_ERROR "Failed to create lagrange module: ${name}")
endif()
endforeach()
Expand Down
15 changes: 15 additions & 0 deletions cmake/recipes/external/blas.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if(TARGET BLAS::BLAS)
return()
endif()

message(STATUS "Third-party (external): creating target 'BLAS::BLAS'")

if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm64" OR "${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm64")
# Use Accelerate on macOS M1
set(BLA_VENDOR Apple)
find_package(BLAS REQUIRED)
else()
# Use MKL on other platforms
include(mkl)
add_library(BLAS::BLAS ALIAS mkl::mkl)
endif()
9 changes: 1 addition & 8 deletions cmake/recipes/external/gklib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include(FetchContent)
FetchContent_Declare(
gklib
GIT_REPOSITORY https://github.com/KarypisLab/GKlib.git
GIT_TAG a7f8172703cf6e999dd0710eb279bba513da4fec
GIT_TAG 67c6e4322bb326a04727995775c3eafc47d7a252
)

FetchContent_GetProperties(gklib)
Expand Down Expand Up @@ -47,13 +47,6 @@ target_include_directories(GKlib SYSTEM PUBLIC
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)

# Until [1] is merged, workaround this by making a copying the missing header so it can be found
# during compilation.
# [1]: https://github.com/KarypisLab/GKlib/pull/19
file(MAKE_DIRECTORY "${gklib_BINARY_DIR}/include/gklib")
configure_file("${gklib_SOURCE_DIR}/gk_ms_stdint.h" "${gklib_BINARY_DIR}/include/gklib/ms_stdint.h" COPYONLY)
target_include_directories(GKlib SYSTEM PUBLIC "$<BUILD_INTERFACE:${gklib_BINARY_DIR}/include/gklib>")

set_target_properties(GKlib PROPERTIES FOLDER third_party)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR
Expand Down
15 changes: 15 additions & 0 deletions cmake/recipes/external/lapack.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if(TARGET LAPACK::LAPACK)
return()
endif()

message(STATUS "Third-party (external): creating target 'LAPACK::LAPACK'")

if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm64" OR "${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm64")
# Use Accelerate on macOS M1
set(BLA_VENDOR Apple)
find_package(LAPACK REQUIRED)
else()
# Use MKL on other platforms
include(mkl)
add_library(LAPACK::LAPACK ALIAS mkl::mkl)
endif()
26 changes: 26 additions & 0 deletions cmake/recipes/external/mikktspace.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright 2022 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
if(TARGET mikktspace::mikktspace)
return()
endif()

include(FetchContent)
FetchContent_Declare(
mikktspace
GIT_REPOSITORY https://github.com/mmikk/MikkTSpace.git
GIT_TAG 3e895b49d05ea07e4c2133156cfa94369e19e409
)
FetchContent_MakeAvailable(mikktspace)

add_library(mikktspace ${mikktspace_SOURCE_DIR}/mikktspace.c)
add_library(mikktspace::mikktspace ALIAS mikktspace)
target_include_directories(mikktspace PUBLIC ${mikktspace_SOURCE_DIR})
2 changes: 1 addition & 1 deletion cmake/recipes/external/mkl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ set_property(CACHE MKL_LINKING PROPERTY STRINGS ${MKL_LINKINK_CHOICES})
message(STATUS "MKL linking strategy: ${MKL_LINKING}")

# MKL version
set(MKL_VERSION "2020.4" CACHE STRING "MKL version to use (2020.4 or 2021.3.0)")
set(MKL_VERSION "2021.3.0" CACHE STRING "MKL version to use (2020.4 or 2021.3.0)")
set(MKL_VERSION_CHOICES 2020.4 2021.3.0)
set_property(CACHE MKL_VERSION PROPERTY STRINGS ${MKL_VERSION_CHOICES})
message(STATUS "MKL version: ${MKL_VERSION}")
Expand Down
2 changes: 1 addition & 1 deletion cmake/recipes/external/mshio.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include(FetchContent)
FetchContent_Declare(
mshio
GIT_REPOSITORY https://github.com/qnzhou/MshIO.git
GIT_TAG 0e1e8c1f688085c482ffbfd2c44d787c6a447624
GIT_TAG 2a897f96ee76497d90dd8560325c232278aaea9d
)
FetchContent_MakeAvailable(mshio)

Expand Down
2 changes: 1 addition & 1 deletion cmake/recipes/external/nanobind.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include(FetchContent)
FetchContent_Declare(
nanobind
GIT_REPOSITORY https://github.com/wjakob/nanobind.git
GIT_TAG 526e2c798547185e37f66f77e3876311157eca95
GIT_TAG 42db2fdb3292c6851d68d4a56f48e2031666173f
)

include(python)
Expand Down
15 changes: 9 additions & 6 deletions cmake/recipes/external/nasoq.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ endif()
# nasoq::eigen_interface depends on nasoq::nasoq.
# nasoq::nasoq does NOT include nasoq::eigen_interface.


include(blas)
include(eigen)
include(metis)

option(NASOQ_WITH_EIGEN "Build NASOQ Eigen interface" ON)

# Note: For now, Nasoq's CMake code to find OpenBLAS is broken on Linux, so we default to MKL.
set(NASOQ_BLAS_BACKEND "MKL" CACHE STRING "BLAS implementation for NASOQ to use")
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm64" OR "${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm64")
# apple M1
set(NASOQ_BLAS_BACKEND "OpenBLAS" CACHE STRING "BLAS implementation for NASOQ to use")
else()
# windows, linux, apple intel
set(NASOQ_BLAS_BACKEND "MKL" CACHE STRING "BLAS implementation for NASOQ to use")
endif()

if(NASOQ_BLAS_BACKEND STREQUAL "MKL")
include(mkl)
Expand All @@ -45,10 +51,7 @@ FetchContent_Declare(
set(CMAKE_DISABLE_FIND_PACKAGE_OpenMP TRUE)
FetchContent_MakeAvailable(nasoq)

if(NASOQ_BLAS_BACKEND STREQUAL "MKL")
# Really should be handled by Nasoq's CMake...
target_link_libraries(nasoq PUBLIC mkl::mkl)
endif()
target_link_libraries(nasoq PUBLIC BLAS::BLAS)

set_target_properties(nasoq PROPERTIES FOLDER third_party)
if(TARGET clapack)
Expand Down
2 changes: 1 addition & 1 deletion cmake/recipes/external/onetbb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ include(FetchContent)
FetchContent_Declare(
tbb
GIT_REPOSITORY https://github.com/oneapi-src/oneTBB.git
GIT_TAG v2021.6.0
GIT_TAG v2021.7.0
GIT_SHALLOW TRUE
)

Expand Down
6 changes: 3 additions & 3 deletions cmake/recipes/external/openvdb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include(FetchContent)
FetchContent_Declare(
openvdb
GIT_REPOSITORY https://github.com/AcademySoftwareFoundation/openvdb.git
GIT_TAG 05b32911c2699b2cfe4b364da071cca9fcc420f2
GIT_TAG v10.0.0
)

option(OPENVDB_CORE_SHARED "" OFF)
Expand Down Expand Up @@ -111,8 +111,8 @@ function(openvdb_import_target)
include(tbb)
include(boost)
include(ilmbase)
set(Tbb_VERSION 2019.0 CACHE STRING "" FORCE)
set(Boost_LIB_VERSION 1.70 CACHE STRING "" FORCE)
set(Tbb_VERSION 2021.0 CACHE STRING "" FORCE)
set(Boost_LIB_VERSION 1.76 CACHE STRING "" FORCE)
set(IlmBase_VERSION 2.4 CACHE STRING "" FORCE)

# Ready to include openvdb CMake
Expand Down
10 changes: 9 additions & 1 deletion modules/core/include/lagrange/Attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,15 @@ class Attribute : public AttributeBase
/// @param[in] values Values to be inserted. The span size must be a multiple of number of
/// channels for the attribute.
///
void insert_elements(lagrange::span<const ValueType> values);
void insert_elements(span<const ValueType> values);

///
/// Inserts values for new elements.
///
/// @param[in] values Values to be inserted. The span size must be a multiple of number of
/// channels for the attribute.
///
void insert_elements(std::initializer_list<const ValueType> values);

///
/// Inserts new elements. Use set_default_value to use a non-zero default value to initialize
Expand Down
4 changes: 3 additions & 1 deletion modules/core/include/lagrange/AttributeFwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ enum AttributeElement : int {
enum class AttributeUsage {
Vector, ///< Mesh attribute can have any number of channels (including 1 channel).
Scalar, ///< Mesh attribute must have exactly 1 channel.
Normal, ///< Mesh attribute can have 2, 3 or 4 channels.
Normal, ///< Mesh attribute can have dim or dim + 1 channels.
Tangent, ///< Mesh attribute can have dim or dim + 1 channels.
Bitangent, ///< Mesh attribute can have dim or dim + 1 channels.
Color, ///< Mesh attribute can have 1, 2, 3 or 4 channels.
UV, ///< Mesh attribute must have exactly 2 channels.
VertexIndex, ///< Single channel integer attribute indexing a mesh vertex.
Expand Down
Loading

0 comments on commit 882c442

Please sign in to comment.