Skip to content

Commit

Permalink
Merge pull request #13 from JohanMabille/cmake
Browse files Browse the repository at this point in the history
Cmake
  • Loading branch information
JohanMabille committed May 11, 2017
2 parents 6f6833a + d176533 commit 70032e8
Show file tree
Hide file tree
Showing 19 changed files with 100 additions and 128 deletions.
37 changes: 10 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set(XSIMD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
# Versionning
# ===========

file(STRINGS "${XSIMD_INCLUDE_DIR}/xsimd/xsimd_config.hpp" xsimd_version_defines
file(STRINGS "${XSIMD_INCLUDE_DIR}/xsimd/config/xsimd_config.hpp" xsimd_version_defines
REGEX "#define XSIMD_VERSION_(MAJOR|MINOR|PATCH)")
foreach(ver ${xsimd_version_defines})
if(ver MATCHES "#define XSIMD_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$")
Expand All @@ -33,25 +33,15 @@ OPTION(BUILD_TESTS "xsimd test suite" ON)

set(XSIMD_HEADERS
${XSIMD_INCLUDE_DIR}/xsimd/xsimd.hpp
${XSIMD_INCLUDE_DIR}/xsimd/xsimd_config.hpp
)

set(XSIMD_CONFIG_HEADERS
${XSIMD_INCLUDE_DIR}/xsimd/config/xplatform_config.hpp
${XSIMD_INCLUDE_DIR}/xsimd/config/xsimd_platform_config.hpp
${XSIMD_INCLUDE_DIR}/xsimd/config/xsimd_include.hpp
${XSIMD_INCLUDE_DIR}/xsimd/config/xsimd_config.hpp
)

set(XSIMD_MEMORY_HEADERS
${XSIMD_INCLUDE_DIR}/xsimd/memory/xaligned_allocator.hpp
${XSIMD_INCLUDE_DIR}/xsimd/memory/xaligned_stack_buffer.hpp
)

set(XSIMD_TYPES_HEADERS
${XSIMD_INCLUDE_DIR}/xsimd/types/xavx_double.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xavx_float.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsse_double.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsse_float.hpp
${XSIMD_INCLUDE_DIR}/xsimd/memory/xsimd_aligned_allocator.hpp
${XSIMD_INCLUDE_DIR}/xsimd/memory/xsimd_aligned_stack_buffer.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_avx_double.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_avx_float.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_sse_double.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_sse_float.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_base.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_traits.hpp
)
Expand All @@ -66,15 +56,8 @@ endif()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

install(FILES ${XSIMD_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xsimd)
install(FILES ${XSIMD_CONFIG_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xsimd/config)
install(FILES ${XSIMD_MEMORY_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xsimd/memory)
install(FILES ${XSIMD_TYPES_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xsimd/types)

install(DIRECTORY ${XSIMD_INCLUDE_DIR}/xsimd
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# GNUInstallDirs "DATADIR" wrong here; CMake search path wants "share".
set(XSIMD_CMAKECONFIG_INSTALL_DIR "share/cmake/${PROJECT_NAME}" CACHE STRING "install path for xsimdConfig.cmake")
Expand Down
24 changes: 14 additions & 10 deletions include/xsimd/config/xsimd_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,28 @@
#ifndef XSIMD_CONFIG_HPP
#define XSIMD_CONFIG_HPP

#include "xplatform_config.hpp"
#include "xsimd_platform_config.hpp"

#ifdef XUSE_AVX
#define XDEFAULT_ALIGNMENT 32
#define XSIMD_VERSION_MAJOR 3
#define XSIMD_VERSION_MINOR 0
#define XSIMD_VERSION_PATCH 0

#ifdef XSIMD_USE_AVX
#define XSIMD_DEFAULT_ALIGNMENT 32
#else
#define XDEFAULT_ALIGNMENT 16
#define XSIMD_DEFAULT_ALIGNMENT 16
#endif

#ifndef XDEFAULT_ALLOCATOR
#ifdef XUSE_SSE_OR_AVX
#define XDEFAULT_ALLOCATOR(T) nxsimd::aligned_allocator<T, XDEFAULT_ALIGNMENT>
#ifndef XSIMD_DEFAULT_ALLOCATOR
#ifdef XSIMD_USE_SSE_OR_AVX
#define XSIMD_DEFAULT_ALLOCATOR(T) xsimd::aligned_allocator<T, XSIMD_DEFAULT_ALIGNMENT>
#else
#define XDEFAULT_ALLOCATOR(T) std::allocator<T>
#define XSIMD_DEFAULT_ALLOCATOR(T) std::allocator<T>
#endif
#endif

#ifndef XSTACK_ALLOCATION_LIMIT
#define XSTACK_ALLOCATION_LIMIT 20000
#ifndef XSIMD_STACK_ALLOCATION_LIMIT
#define XSIMD_STACK_ALLOCATION_LIMIT 20000
#endif

#endif
Expand Down
2 changes: 1 addition & 1 deletion include/xsimd/config/xsimd_include.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef XSIMD_INCLUDE_HPP
#define XSIMD_INCLUDE_HPP

#include "xplatform_config.hpp"
#include "xsimd_platform_config.hpp"

// Include the appropriate header file for intrinsic functions
#if SSE_INSTR_SET > 7 // AVX2 and later
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XPLATFORM_CONFIG_HPP
#define XPLATFORM_CONFIG_HPP
#ifndef XSIMD_PLATFORM_CONFIG_HPP
#define XSIMD_PLATFORM_CONFIG_HPP

/*************************
* SSE instruction set
Expand Down Expand Up @@ -59,9 +59,9 @@
// PowerPC or SPARC)
#if defined(__GLIBC__) && ((__GLIBC__>=2 && __GLIBC_MINOR__ >= 8) || __GLIBC__>2) \
&& defined(__LP64__)
#define XGLIBC_MALLOC_ALREADY_16ALIGNED 1
#define XSIMD_GLIBC_MALLOC_ALREADY_16ALIGNED 1
#else
#define XGLIBC_MALLOC_ALREADY_16ALIGNED 0
#define XSIMD_GLIBC_MALLOC_ALREADY_16ALIGNED 0
#endif

// FreeBSD world
Expand All @@ -71,66 +71,66 @@
// FreeBSD 7 seems to have 16-byte aligned malloc except on ARM and MIPS architectures
// See http://svn.freebsd.org/viewvc/base/stable/7/lib/libc/stdlib/malloc.c?view=markup
#if defined(__FreeBSD__) && !defined(__arm__) && !defined(__mips__)
#define XFREEBSD_MALLOC_ALREADY_16ALIGNED 1
#define XSIMD_FREEBSD_MALLOC_ALREADY_16ALIGNED 1
#else
#define XFREEBSD_MALLOC_ALREADY_16ALIGNED 0
#define XSIMD_FREEBSD_MALLOC_ALREADY_16ALIGNED 0
#endif

#if (defined(__APPLE__) \
|| defined(_WIN64) \
|| XGLIBC_MALLOC_ALREADY_16ALIGNED \
|| XFREEBSD_MALLOC_ALREADY_16ALIGNED)
#define XMALLOC_ALREADY_16ALIGNED 1
|| XSIMD_GLIBC_MALLOC_ALREADY_16ALIGNED \
|| XSIMD_FREEBSD_MALLOC_ALREADY_16ALIGNED)
#define XSIMD_MALLOC_ALREADY_16ALIGNED 1
#else
#define XMALLOC_ALREADY_16ALIGNED 0
#define XSIMD_MALLOC_ALREADY_16ALIGNED 0
#endif

#if ((defined __QNXNTO__) || (defined _GNU_SOURCE) || ((defined _XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600))) \
&& (defined _POSIX_ADVISORY_INFO) && (_POSIX_ADVISORY_INFO > 0)
#define XHAS_POSIX_MEMALIGN 1
#define XSIMD_HAS_POSIX_MEMALIGN 1
#else
#define XHAS_POSIX_MEMALIGN 0
#define XSIMD_HAS_POSIX_MEMALIGN 0
#endif

#if SSE_INSTR_SET > 0
#define XHAS_MM_MALLOC 1
#define XSIMD_HAS_MM_MALLOC 1
#else
#define XHAS_MM_MALLOC 0
#define XSIMD_HAS_MM_MALLOC 0
#endif

#if ((SSE_INSTR_SET > 6) && !defined(FORBID_AVX))
#define XUSE_AVX
#elif ((SSE_INSTR_SET > 0) && !defined(FORBID_SSE))
#define XUSE_SSE
#if ((SSE_INSTR_SET > 6) && !defined(XSIMD_FORBID_AVX))
#define XSIMD_USE_AVX
#elif ((SSE_INSTR_SET > 0) && !defined(XSIMD_FORBID_SSE))
#define XSIMD_USE_SSE
#endif

#ifdef XUSE_SSE
#define XMALLOC_ALREADY_ALIGNED XMALLOC_ALREADY_16ALIGNED
#ifdef XSIMD_USE_SSE
#define XSIMD_MALLOC_ALREADY_ALIGNED XSIMD_MALLOC_ALREADY_16ALIGNED
#else
#define XMALLOC_ALREADY_ALIGNED 0
#define XSIMD_MALLOC_ALREADY_ALIGNED 0
#endif

#if defined(XUSE_SSE) || defined(XUSE_AVX)
#define XUSE_SSE_OR_AVX
#if defined(XSIMD_USE_SSE) || defined(XSIMD_USE_AVX)
#define XSIMD_USE_SSE_OR_AVX
#endif


/************************************
* Stack allocation and alignment
************************************/

#ifndef XALLOCA
#ifndef XSIMD_ALLOCA
#if defined(__linux__)
#define XALLOCA alloca
#define XSIMD_ALLOCA alloca
#elif defined(_MSC_VER)
#define XALLOCA _alloca
#define XSIMD_ALLOCA _alloca
#endif
#endif

#if (defined __GNUC__)
#define XSTACK_ALIGN(N) __attribute__((aligned(N)))
#define XSIMD_STACK_ALIGN(N) __attribute__((aligned(N)))
#elif (defined _MSC_VER)
#define XSTACK_ALIGN(N) __declspec(align(N))
#define XSIMD_STACK_ALIGN(N) __declspec(align(N))
#else
#error Equivalent of __attribute__((aligned(N))) unknown
#endif
Expand All @@ -141,9 +141,9 @@
****************************************/

#ifdef __x86_64__
#define XNB_FP_REGISTERS 16
#define XSIMD_NB_FP_REGISTERS 16
#else
#define XNB_FP_REGISTERS 8
#define XSIMD_NB_FP_REGISTERS 8

#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XALIGNED_ALLOCATOR_HPP
#define XALIGNED_ALLOCATOR_HPP
#ifndef XSIMD_ALIGNED_ALLOCATOR_HPP
#define XSIMD_ALIGNED_ALLOCATOR_HPP

#include <cstddef>
#include "../config/xplatform_config.hpp"
#include <algorithm>
#include "../config/xsimd_platform_config.hpp"

#if defined(_MSC_VER) || defined(__MINGW64__) || defined(__MINGW32__)
#include <malloc.h>
#elif defined(__GNUC__)
#include <mm_malloc.h>
#if defined(XALLOCA)
#if defined(XSIMD_ALLOCA)
#include <alloca.h>
#endif
#else
Expand Down Expand Up @@ -209,11 +209,11 @@ namespace xsimd

inline void* aligned_malloc(size_t size, size_t alignment)
{
#if XMALLOC_ALREADY_ALIGNED
#if XSIMD_MALLOC_ALREADY_ALIGNED
return malloc(size);
#elif XHAS_MM_MALLOC
#elif XSIMD_HAS_MM_MALLOC
return _mm_malloc(size, alignment);
#elif XHAS_POSIX_MEMALIGN
#elif XSIMD_HAS_POSIX_MEMALIGN
void* res;
const int failed = posix_memalign(&res, size, alignment);
if (failed)
Expand All @@ -228,11 +228,11 @@ namespace xsimd

inline void aligned_free(void* ptr)
{
#if XMALLOC_ALREADY_ALIGNED
#if XSIMD_MALLOC_ALREADY_ALIGNED
free(ptr);
#elif XHAS_MM_MALLOC
#elif XSIMD_HAS_MM_MALLOC
_mm_free(ptr);
#elif XHAS_POSIX_MEMALIGN
#elif XSIMD_HAS_POSIX_MEMALIGN
free(ptr);
#elif defined(_MSC_VER)
_aligned_free(ptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XALIGNED_STACK_BUFFER_HPP
#define XALIGNED_STACK_BUFFER_HPP
#ifndef XSIMD_ALIGNED_STACK_BUFFER_HPP
#define XSIMD_ALIGNED_STACK_BUFFER_HPP

#include <type_traits>
#include "xaligned_allocator.hpp"
#include "xsimd_aligned_allocator.hpp"

namespace xsimd
{
Expand Down Expand Up @@ -64,7 +64,7 @@ namespace xsimd
inline void* aligned_alloc_stack(size_t size, size_t alignment)
{
return reinterpret_cast<void*>(
reinterpret_cast<size_t>(XALLOCA(size + alignment)) &
reinterpret_cast<size_t>(XSIMD_ALLOCA(size + alignment)) &
~(size_t(alignment - 1))) + alignment;
}
}
Expand All @@ -73,11 +73,11 @@ namespace xsimd
inline aligned_stack_buffer<T, A>::aligned_stack_buffer(size_type n)
: m_size(n)
{
#ifdef XALLOCA
if(sizeof(T) * n <= XSTACK_ALLOCATION_LIMIT)
#ifdef XSIMD_ALLOCA
if(sizeof(T) * n <= XSIMD_STACK_ALLOCATION_LIMIT)
{
m_ptr = reinterpret_cast<pointer>(
(reinterpret_cast<size_t>(XALLOCA(n + A)) &
(reinterpret_cast<size_t>(XSIMD_ALLOCA(n + A)) &
~(size_t(A - 1))) + A);
m_heap_allocation = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XAVX_DOUBLE_HPP
#define XAVX_DOUBLE_HPP
#ifndef XSIMD_AVX_DOUBLE_HPP
#define XSIMD_AVX_DOUBLE_HPP

#include "xsimd_base.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XAVX_FLOAT_HPP
#define XAVX_FLOAT_HPP
#ifndef XSIMD_AVX_FLOAT_HPP
#define XSIMD_AVX_FLOAT_HPP

#include "xsimd_base.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XSSE_DOUBLE_HPP
#define XSSE_DOUBLE_HPP
#ifndef XSIMD_SSE_DOUBLE_HPP
#define XSIMD_SSE_DOUBLE_HPP

#include "xsimd_base.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XSSE_FLOAT_HPP
#define XSSE_FLOAT_HPP
#ifndef XSIMD_SSE_FLOAT_HPP
#define XSIMD_SSE_FLOAT_HPP

#include "xsimd_base.hpp"

Expand Down

0 comments on commit 70032e8

Please sign in to comment.