Skip to content

Commit

Permalink
Merge pull request #16 from JohanMabille/refactor
Browse files Browse the repository at this point in the history
refactoring
  • Loading branch information
JohanMabille committed May 19, 2017
2 parents a1bf9ac + 157f93b commit c91dcca
Show file tree
Hide file tree
Showing 16 changed files with 599 additions and 576 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ matrix:
packages:
- clang-3.8
env: COMPILER=clang CLANG=3.8
- os: osx
osx_image: xcode8
compiler: clang
env:
global:
- MINCONDA_VERSION="latest"
Expand Down
31 changes: 13 additions & 18 deletions include/xsimd/config/xsimd_align.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

#include "xsimd_instruction_set.hpp"

/**************************************************
* Platform checks for aligned malloc functions
**************************************************/
/************************************************
* Platform checks for aligned malloc functions *
************************************************/

#if ((defined __QNXNTO__) || (defined _GNU_SOURCE) || ((defined _XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600))) \
&& (defined _POSIX_ADVISORY_INFO) && (_POSIX_ADVISORY_INFO > 0)
Expand All @@ -28,9 +28,9 @@
#define XSIMD_HAS_MM_MALLOC 0
#endif

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

#ifndef XSIMD_ALLOCA
#if defined(__linux__)
Expand All @@ -40,19 +40,14 @@
#endif
#endif

/***********
* headers *
***********/
/*********************
* Default alignment *
*********************/

#if defined(_MSC_VER) || defined(__MINGW64__) || defined(__MINGW32__)
#include <malloc.h>
#elif defined(__GNUC__)
#include <mm_malloc.h>
#if defined(XSIMD_ALLOCA)
#include <alloca.h>
#endif
#else
#include <stdlib.h>
#if XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION
#define XSIMD_DEFAULT_ALIGNMENT 32
#elif XSIMD_X86_INSTR_SET >= XSIMD_X86_SSE2_VERSION
#define XSIMD_DEFAULT_ALIGNMENT 16
#endif

#endif
Expand Down
9 changes: 1 addition & 8 deletions include/xsimd/config/xsimd_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,14 @@
#ifndef XSIMD_CONFIG_HPP
#define XSIMD_CONFIG_HPP

#include "xsimd_instruction_set.hpp"
#include "xsimd_align.hpp"

#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 XSIMD_DEFAULT_ALIGNMENT 16
#endif

#ifndef XSIMD_DEFAULT_ALLOCATOR
#ifdef XSIMD_USE_SSE_OR_AVX
#if XSIMD_X86_INSTR_SET_AVAILABLE
#define XSIMD_DEFAULT_ALLOCATOR(T) xsimd::aligned_allocator<T, XSIMD_DEFAULT_ALIGNMENT>
#else
#define XSIMD_DEFAULT_ALLOCATOR(T) std::allocator<T>
Expand Down
16 changes: 8 additions & 8 deletions include/xsimd/config/xsimd_instruction_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@
#define XSIMD_INSTR_SET_AVAILABLE
#endif

// Temporary backward compatibility
#if ((XSIMD_X86_INSTR_SET >= XSIMD_X86_AVX_VERSION) && !defined(XSIMD_FORBID_AVX))
#define XSIMD_USE_AVX
#elif (defined(XSIMD_X86_INSTR_SET_AVAILABLE) && !defined(XSIMD_FORBID_SSE))
#define XSIMD_USE_SSE
#endif
/**********************
* USER CONFIGURATION *
**********************/

#if defined(XSIMD_USE_SSE) || defined(XSIMD_USE_AVX)
#define XSIMD_USE_SSE_OR_AVX
#ifdef XSIMD_FORCE_X86_INSTR_SET
#define XSIMD_X86_INSTR_SET XSIMD_FORCE_X86_INSTR_SET
#define XSIMD_X86_INSTR_SET_AVAILABLE
#define XSIMD_INSTR_SET XSIMD_X86_INSTR_SET
#define XSIMD_INSTR_SET_AVAILABLE
#endif

#endif
Expand Down
22 changes: 16 additions & 6 deletions include/xsimd/memory/xsimd_aligned_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
#include <algorithm>
#include "../config/xsimd_align.hpp"

#if defined(_MSC_VER) || defined(__MINGW64__) || defined(__MINGW32__)
#include <malloc.h>
#elif defined(__GNUC__)
#include <mm_malloc.h>
#if defined(XSIMD_ALLOCA)
#include <alloca.h>
#endif
#else
#include <stdlib.h>
#endif

namespace xsimd
{
Expand Down Expand Up @@ -78,9 +88,9 @@ namespace xsimd
size_t get_alignment_offset(const T* p, size_t size, size_t block_size);


/**************************************
* aligned_allocator implementation
**************************************/
/************************************
* aligned_allocator implementation *
************************************/

template <class T, size_t A>
inline aligned_allocator<T, A>::aligned_allocator() noexcept
Expand Down Expand Up @@ -170,9 +180,9 @@ namespace xsimd
}


/******************************************
* aligned malloc / free implementation
******************************************/
/****************************************
* aligned malloc / free implementation *
****************************************/

namespace detail
{
Expand Down
6 changes: 3 additions & 3 deletions include/xsimd/memory/xsimd_aligned_stack_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ namespace xsimd
};


/*****************************************
* aligned_stack_buffer implementation
*****************************************/
/***************************************
* aligned_stack_buffer implementation *
***************************************/

namespace detail
{
Expand Down

0 comments on commit c91dcca

Please sign in to comment.