Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanMabille committed Aug 24, 2021
1 parent 8bf4845 commit c5e9d93
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 61 deletions.
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,39 @@ http://xsimd.readthedocs.io/

## Usage

### Explicit use of an instruction set extension
The version 8 of the library is a complete rewrite and there are some slight differences with 7.x versions.
A migration guide will be available soon. In the meanwhile, the following examples show how to use both versions
7 and 8 of the library?

### Explicit use of an instruction set extension (8.x)

Here is an example that computes the mean of two sets of 4 double floating point values, assuming AVX extension is supported:
```cpp
#include <iostream>
#include "xsimd/xsimd.hpp"

namespace xs = xsimd;

int main(int argc, char* argv[])
{
xs::batch<double, xs::avx2> a(1.5, 2.5, 3.5, 4.5);
xs::batch<double, xs::avx2> b(2.5, 3.5, 4.5, 5.5);
auto mean = (a + b) / 2;
std::cout << mean << std::endl;
return 0;
}
```

Do not forget to enable AVX extension when building the example. With gcc or clang, this is done with the `-march=native` flag,
on MSVC you have to pass the `/arch:AVX` option.

This example outputs:

```cpp
(2.0, 3.0, 4.0, 5.0)
```

### Explicit use of an instruction set extension (7.x and 8.x)

Here is an example that computes the mean of two sets of 4 double floating point values, assuming AVX extension is supported:
```cpp
Expand Down Expand Up @@ -100,7 +132,7 @@ This example outputs:
(2.0, 3.0, 4.0, 5.0)
```

### Auto detection of the instruction set extension to be used
### Auto detection of the instruction set extension to be used (7.x)

The same computation operating on vectors and using the most performant instruction set available:

Expand Down
59 changes: 0 additions & 59 deletions include/xsimd/types/xsimd_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,43 +81,6 @@ namespace xsimd
template <class T>
using revert_simd_type = typename revert_simd_traits<T>::type;


// TODO: we have a problem here since the specialization for
// batch<xtl::xcomplex<T, T, i3ec>> does not exit anymore
/*#ifdef XSIMD_ENABLE_XTL_COMPLEX
template <bool i3ec>
struct simd_traits<xtl::xcomplex<float, float, i3ec>>
{
using type = batch<xtl::xcomplex<float, float, i3ec>, XSIMD_BATCH_FLOAT_SIZE>;
using bool_type = typename simd_batch_traits<type>::batch_bool_type;
static constexpr size_t size = type::size;
};
template <bool i3ec>
struct revert_simd_traits<batch<xtl::xcomplex<float, float, i3ec>, XSIMD_BATCH_FLOAT_SIZE>>
{
using type = xtl::xcomplex<float, float, i3ec>;
static constexpr size_t size = simd_traits<type>::size;
};
#endif // XSIMD_ENABLE_XTL_COMPLEX
*/
/*#ifdef XSIMD_ENABLE_XTL_COMPLEX
template <bool i3ec>
struct simd_traits<xtl::xcomplex<double, double, i3ec>>
{
using type = batch<xtl::xcomplex<double, double, i3ec>, XSIMD_BATCH_DOUBLE_SIZE>;
using bool_type = typename simd_batch_traits<type>::batch_bool_type;
static constexpr size_t size = type::size;
};
template <bool i3ec>
struct revert_simd_traits<batch<xtl::xcomplex<double, double, i3ec>, XSIMD_BATCH_DOUBLE_SIZE>>
{
using type = xtl::xcomplex<double, double, i3ec>;
static constexpr size_t size = simd_traits<type>::size;
};
#endif // XSIMD_ENABLE_XTL_COMPLEX*/

/********************
* simd_return_type *
********************/
Expand Down Expand Up @@ -174,20 +137,6 @@ namespace xsimd
: std::enable_if<simd_condition<T1, T2>::value, batch<std::complex<T2>, A>>
{
};

/*#ifdef XSIMD_ENABLE_XTL_COMPLEX
template <class T1, bool i3ec, class T2, std::size_t N>
struct simd_return_type_impl<xtl::xcomplex<T1, T1, i3ec>, T2, N>
: std::enable_if<simd_condition<T1, T2>::value, batch<xtl::xcomplex<T2, T2, i3ec>, N>>
{
};
template <class T1, class T2, bool i3ec, std::size_t N>
struct simd_return_type_impl<xtl::xcomplex<T1, T1, i3ec>, xtl::xcomplex<T2, T2, i3ec>, N>
: std::enable_if<simd_condition<T1, T2>::value, batch<xtl::xcomplex<T2, T2, i3ec>, N>>
{
};
#endif // XSIMD_ENABLE_XTL_COMPLEX*/
}

template <class T1, class T2, class A = default_arch>
Expand Down Expand Up @@ -234,14 +183,6 @@ namespace xsimd
struct is_batch_complex<batch<std::complex<T>, A>> : std::true_type
{
};
/*
#ifdef XSIMD_ENABLE_XTL_COMPLEX
template <class T, bool i3ec, std::size_t N>
struct is_batch_complex<batch<xtl::xcomplex<T, T, i3ec>, N>> : std::true_type
{
};
#endif //XSIMD_ENABLE_XTL_COMPLEX*/

}

#endif

0 comments on commit c5e9d93

Please sign in to comment.