Skip to content

Commit

Permalink
(#17704) xsimd: add version 11.1.0, update xtl, minor improvement
Browse files Browse the repository at this point in the history
* xsimd: add version 11.1.0, minor improvement

* use C++14 when xtl_complex is True
  • Loading branch information
toge authored May 26, 2023
1 parent e359fab commit 76f86b4
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 35 deletions.
3 changes: 3 additions & 0 deletions recipes/xsimd/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"11.1.0":
url: "https://github.com/xtensor-stack/xsimd/archive/11.1.0.tar.gz"
sha256: "aa54dba8daade472656eba0d27154f072fec06ee3831aefcac69a5f6c7dbbae7"
"11.0.0":
url: "https://github.com/xtensor-stack/xsimd/archive/11.0.0.tar.gz"
sha256: "50c31c319c8b36c8946eb954c7cca2e2ece86bf8a66a7ebf321b24cd273e7c47"
Expand Down
38 changes: 30 additions & 8 deletions recipes/xsimd/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from conan.tools.layout import basic_layout
from conan.tools.scm import Version
from conan.tools.apple import is_apple_os
from conan.tools.build import check_min_cppstd
import os
import textwrap

Expand All @@ -12,11 +13,11 @@

class XsimdConan(ConanFile):
name = "xsimd"
description = "C++ wrappers for SIMD intrinsics and parallelized, optimized mathematical functions (SSE, AVX, NEON, AVX512)"
license = "BSD-3-Clause"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/xtensor-stack/xsimd"
description = "C++ wrappers for SIMD intrinsics and parallelized, optimized mathematical functions (SSE, AVX, NEON, AVX512)"
topics = ("simd-intrinsics", "vectorization", "simd")
topics = ("simd-intrinsics", "vectorization", "simd", "header-only")
package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
options = {
Expand All @@ -25,20 +26,43 @@ class XsimdConan(ConanFile):
default_options = {
"xtl_complex": False,
}

no_copy_source = True

@property
def _min_cppstd(self):
return 14 if self.options.xtl_complex else 11

@property
def _compilers_minimum_version(self):
return {
"14": {
"gcc": "6",
"clang": "5",
"apple-clang": "10",
"Visual Studio": "15",
"msvc": "191",
},
}.get(self._min_cppstd, {})

def requirements(self):
if self.options.xtl_complex:
self.requires("xtl/0.7.4")
self.requires("xtl/0.7.5")

def package_id(self):
self.info.clear()

def validate(self):
# TODO: check supported version (probably >= 8.0.0)
if Version(self.version) < "8.0.0" and self.settings.os == "Macos" and self.settings.arch in ["armv8", "armv8_32", "armv8.3"]:
raise ConanInvalidConfiguration(f"{self.name} doesn't support macOS M1")
if Version(self.version) < "8.0.0" and is_apple_os(self) and self.settings.arch in ["armv8", "armv8_32", "armv8.3"]:
raise ConanInvalidConfiguration(f"{self.ref} doesn't support macOS M1")

if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)

def layout(self):
basic_layout(self, src_folder="src")
Expand Down Expand Up @@ -79,9 +103,7 @@ def package_info(self):
if self.options.xtl_complex:
self.cpp_info.defines = ["XSIMD_ENABLE_XTL_COMPLEX=1"]
self.cpp_info.bindirs = []
self.cpp_info.frameworkdirs = []
self.cpp_info.libdirs = []
self.cpp_info.resdirs = []

## TODO: workaround for arm compilation issue : https://github.com/xtensor-stack/xsimd/issues/735
if Version(self.version) >= "9.0.0" and \
Expand Down
7 changes: 6 additions & 1 deletion recipes/xsimd/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ find_package(xsimd REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE xsimd)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)

if (XSIMD_WITH_XTL)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
else()
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
foreach(flag "/arch:AVX")
Expand Down
16 changes: 13 additions & 3 deletions recipes/xsimd/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.cmake import CMakeDeps, CMakeToolchain
from conan.tools.env import VirtualBuildEnv
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["XSIMD_WITH_XTL"] = self.dependencies["xsimd"].options.xtl_complex
tc.generate()
tc = CMakeDeps(self)
tc.generate()
tc = VirtualBuildEnv(self)
tc.generate(scope="build")

def build(self):
cmake = CMake(self)
Expand Down
25 changes: 2 additions & 23 deletions recipes/xsimd/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

include(CheckCXXCompilerFlag)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(xsimd REQUIRED CONFIG)

add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE xsimd)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
foreach(flag "/arch:AVX")
CHECK_CXX_COMPILER_FLAG(${flag} COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
target_compile_options(${PROJECT_NAME} PRIVATE ${flag})
endif()
endforeach()
elseif ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
foreach(flag "-march=native" "-mtune=native")
CHECK_CXX_COMPILER_FLAG(${flag} COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
target_compile_options(${PROJECT_NAME} PRIVATE ${flag})
endif()
endforeach()
endif()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)
1 change: 1 addition & 0 deletions recipes/xsimd/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class TestPackageConan(ConanFile):

def build(self):
cmake = CMake(self)
cmake.definitions["XSIMD_WITH_XTL"] = self.options["xsimd"].xtl_complex
cmake.configure()
cmake.build()

Expand Down
2 changes: 2 additions & 0 deletions recipes/xsimd/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"11.1.0":
folder: all
"11.0.0":
folder: all
"10.0.0":
Expand Down

0 comments on commit 76f86b4

Please sign in to comment.