├── .clang-format ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md └── workflows │ └── ci.yaml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CTestConfig.cmake ├── CTestCustom.cmake ├── INSTALL ├── LICENSE ├── Makefile ├── README.md ├── Test_all_compilers.sh ├── Test_vc.sh ├── Vc ├── Allocator ├── IO ├── Memory ├── SimdArray ├── Utils ├── Vc ├── algorithm ├── array ├── avx │ ├── README │ ├── casts.h │ ├── const.h │ ├── const_data.h │ ├── debug.h │ ├── deinterleave.tcc │ ├── detail.h │ ├── helperimpl.h │ ├── intrinsics.h │ ├── limits.h │ ├── macros.h │ ├── mask.h │ ├── mask.tcc │ ├── math.h │ ├── shuffle.h │ ├── simd_cast.h │ ├── simd_cast_caller.tcc │ ├── types.h │ ├── vector.h │ ├── vector.tcc │ └── vectorhelper.h ├── common │ ├── algorithms.h │ ├── aliasingentryhelper.h │ ├── alignedbase.h │ ├── bitscanintrinsics.h │ ├── const.h │ ├── data.h │ ├── deinterleave.h │ ├── detail.h │ ├── elementreference.h │ ├── exponential.h │ ├── fix_clang_emmintrin.h │ ├── gatherimplementation.h │ ├── gatherinterface.h │ ├── gatherinterface_deprecated.h │ ├── generalinterface.h │ ├── iif.h │ ├── indexsequence.h │ ├── interleave.h │ ├── interleavedmemory.h │ ├── iterators.h │ ├── loadinterface.h │ ├── loadstoreflags.h │ ├── logarithm.h │ ├── macros.h │ ├── makeContainer.h │ ├── make_unique.h │ ├── malloc.h │ ├── mask.h │ ├── maskbool.h │ ├── math.h │ ├── memory.h │ ├── memorybase.h │ ├── memoryfwd.h │ ├── operators.h │ ├── permutation.h │ ├── scatterimplementation.h │ ├── scatterinterface.h │ ├── scatterinterface_deprecated.h │ ├── set.h │ ├── simd_cast.h │ ├── simd_cast_caller.tcc │ ├── simdarray.h │ ├── simdarrayfwd.h │ ├── simdarrayhelper.h │ ├── simdize.h │ ├── simdmaskarray.h │ ├── span.h │ ├── storage.h │ ├── storeinterface.h │ ├── subscript.h │ ├── support.h │ ├── transpose.h │ ├── trigonometric.h │ ├── types.h │ ├── utility.h │ ├── vector.h │ ├── vector │ │ └── casts.h │ ├── vectorabi.h │ ├── vectortraits.h │ ├── vectortuple.h │ ├── where.h │ ├── writemaskedvector.h │ └── x86_prefetches.h ├── cpuid.h ├── fwddecl.h ├── global.h ├── iterators ├── limits ├── scalar │ ├── detail.h │ ├── helperimpl.h │ ├── limits.h │ ├── macros.h │ ├── mask.h │ ├── math.h │ ├── operators.h │ ├── simd_cast.h │ ├── simd_cast_caller.tcc │ ├── type_traits.h │ ├── types.h │ ├── vector.h │ └── vector.tcc ├── simdize ├── span ├── sse │ ├── casts.h │ ├── const.h │ ├── const_data.h │ ├── debug.h │ ├── deinterleave.tcc │ ├── detail.h │ ├── helperimpl.h │ ├── intrinsics.h │ ├── limits.h │ ├── macros.h │ ├── mask.h │ ├── mask.tcc │ ├── math.h │ ├── prefetches.tcc │ ├── shuffle.h │ ├── simd_cast.h │ ├── simd_cast_caller.tcc │ ├── type_traits.h │ ├── types.h │ ├── vector.h │ ├── vector.tcc │ ├── vectorhelper.h │ └── vectorhelper.tcc ├── support.h ├── traits │ ├── decay.h │ ├── entry_type_of.h │ ├── has_addition_operator.h │ ├── has_contiguous_storage.h │ ├── has_equality_operator.h │ ├── has_multiply_operator.h │ ├── has_no_allocated_data.h │ ├── has_subscript_operator.h │ ├── is_functor_argument_immutable.h │ ├── is_implicit_cast_allowed.h │ ├── is_index_sequence.h │ ├── is_output_iterator.h │ └── type_traits.h ├── type_traits ├── vector ├── vector.h └── version.h ├── changeVersion.sh ├── cmake ├── AddCompilerFlag.cmake ├── AddTargetProperty.cmake ├── CheckCCompilerFlag.cmake ├── CheckCXXCompilerFlag.cmake ├── FindVc.cmake ├── OptimizeForArchitecture.cmake ├── UserWarning.cmake ├── VcConfig.cmake.in ├── VcMacros.cmake ├── toolchain-arm-linux-gnueabi-gcc.cmake └── toolchain-arm-linux.cmake ├── configure-icc.sh ├── doc ├── DoxyInternal ├── Doxyfile ├── DoxygenLayout.xml ├── dox-math.h ├── dox-real-ops.h ├── dox.h ├── examples.h ├── logo.png ├── logo.svg ├── logo_small.png ├── polarcoord-cartesian.png ├── polarcoord-polar.png └── qhelpgenerator-wrapper ├── examples ├── CMakeLists.txt ├── buddhabrot │ ├── CMakeLists.txt │ ├── main.cpp │ └── main.h ├── cpuid │ ├── CMakeLists.txt │ └── main.cpp ├── finitediff │ ├── CMakeLists.txt │ └── main.cpp ├── linear_find │ ├── CMakeLists.txt │ └── main.cpp ├── mandelbrot │ ├── CMakeLists.txt │ ├── main.cpp │ ├── main.h │ ├── mandel.cpp │ └── mandel.h ├── matrix │ ├── CMakeLists.txt │ └── main.cpp ├── polarcoord │ ├── CMakeLists.txt │ └── main.cpp ├── scaling │ ├── CMakeLists.txt │ └── main.cpp ├── simdize │ ├── CMakeLists.txt │ └── main.cpp ├── test_inside │ ├── CMakeLists.txt │ └── main.cpp └── tsc.h ├── godbolt ├── Vc ├── algorithm └── containers ├── makeApidox.sh ├── makeApidoxLoop.sh ├── makeInternalDox.sh ├── makeRelease.sh ├── math ├── cosf.m ├── floattool ├── fold_pi4_single.m ├── generate_sindat.sh ├── hexdouble.m ├── hexfloat.m ├── mycos.m ├── mysin.m ├── print_hexfloat.m ├── round_to_float.m ├── sin_pi4.m ├── sinf.m ├── sinf_fit.gnuplot ├── sinf_fit.m ├── to_double.m └── to_float.m ├── prepare_single_header.sh ├── print_target_architecture.cmake ├── src ├── avx_sorthelper.cpp ├── const.cpp ├── cpuid.cpp ├── sse_sorthelper.cpp ├── support_dummy.cpp ├── support_x86.cpp └── trigonometric.cpp ├── test.cmake └── tests ├── CMakeLists.txt ├── abi.cmake ├── abi.cpp ├── alignedbase.cpp ├── alignmentinheritance.cpp ├── arithmetics.cpp ├── casts.cpp ├── convert-sincos-reference.cpp ├── deinterleave.cpp ├── gather.cpp ├── gatherinterleavedmemory.cpp ├── generators.h ├── gh200.cpp ├── implicit_type_conversion.cpp ├── iterators.cpp ├── linkTest0.cpp ├── linkTest1.cpp ├── linkTestLib0.cpp ├── linkTestLib1.cpp ├── linkTestLib2.cpp ├── linkTestLib3.cpp ├── load.cpp ├── logarithm.cpp ├── mask.cpp ├── math.cpp ├── mathreference.h ├── memory.cpp ├── random.cpp ├── reductions.cpp ├── scalaraccess.cpp ├── scatter.cpp ├── scatterinterleavedmemory.cpp ├── simdarray.cpp ├── simdize.cpp ├── sorted.cpp ├── sse_blend.cpp ├── stlcontainer.cpp ├── store.cpp ├── subscript.cpp ├── supportfunctions.cpp ├── trigonometric.cpp ├── type_traits.cpp ├── typelist.h ├── types.cpp ├── ulp.cpp ├── ulp.h ├── unittest.h ├── utils.cpp └── vectormemoryhelper.h /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Copyright and License 2 | 3 | Vc is licensed with the [3-clause BSD license](http://opensource.org/licenses/BSD-3-Clause). 4 | Your contributions to Vc must be released under the same license. You must add 5 | your copyright information to the files you modified/added. 6 | 7 | ## Code Formatting & Style 8 | 9 | The recommended way is to format the code according to `clang-format` using the 10 | `.clang-format` file in the repository. 11 | 12 | In addition to the `clang-format` style, `if`, `else`, `for`, `while`, and `do` 13 | *must* use braces. 14 | 15 | If, for some reason, you cannot use `clang-format`, here's a quick overview of 16 | the style rules: 17 | * Constrain the code to no more than 90 characters per line. 18 | * Use four spaces for indent. No tabs. 19 | * Opening braces attach to the preceding expression, except for functions, 20 | namespaces, and classes/structs/unions/enums. 21 | * Namespaces introduce no additional indent 22 | * `case` labels are aligned with the `switch` statement 23 | * No more than one empty line. 24 | * No spaces in parentheses, but spaces between keywords and opening paren, i.e. 25 | `if (foo) { bar(); }` 26 | 27 | ### Naming Rules 28 | 29 | * Naming is very important. Take time to choose a name that clearly explains the 30 | intended functionality & usage of the entity. 31 | * Type names typically use `CamelCase`. No underscores. 32 | * Function and variable names use `camelCase`. No underscores. 33 | * Acronyms that appear in camel case names must use lowercase letters for all 34 | characters after the first characters. (e.g. `SimdArray`, `simdFunction`) 35 | * Traits use `lower_case_with_underscores`. 36 | * Macros are prefixed with `Vc_` and use `Vc_ALL_CAPITALS_WITH_UNDERSCORES`. 37 | Macro arguments use a single underscore suffix. 38 | Include guards are prefixed with `VC_` instead. 39 | * File names use `alllowercasewithoutunderscores`. Basically, it is the type name 40 | declared/defined in the file with all letters in lower case. 41 | * There are exceptions and inconsistencies in the code. Don't bother. 42 | 43 | ### Design Guidelines 44 | 45 | * *Avoid out parameters.* Use the return value insted. Use `std::tuple` if you 46 | need to return multiple values. 47 | * *Look for alternatives to in-out parameters.* An obvious exception (and thus 48 | design alternative) is the implicit `this` parameter to non-static member 49 | functions. 50 | * Consequently, *pass function parameters by const-ref or by value.* 51 | Use const-ref for types that (potentially) require more than two CPU 52 | registers. (Consider fundamental types and the fundamental `Vector` types 53 | to require one register, each.) 54 | By value otherwise. 55 | * *Ensure const-correctness.* Member functions use the `const` qualifier if they 56 | do not modify observable state. Use `mutable` members for unobservable state. 57 | * *Avoid macros.* Possible alternatives are constexpr variables and template 58 | code. 59 | 60 | ## Git History 61 | 62 | Git history should be flat, if feasible. Feel free to use merges on your private 63 | branch. However, once you submit a pull request, the history should apply 64 | cleanly on top of master. Use `git rebase [-i]` to straighten the history. 65 | 66 | Use different branches for different issues. 67 | 68 | ## Git Commit Logs 69 | 70 | 1. Write meaningful summaries and strive to use no more than 50 characters 71 | 1. Use imperative mood in the subject line (and possibly in bullet points in the 72 | summary) 73 | 1. Wrap the body at 72 characters 74 | 1. Use the body to explain *what* and *why* (normally it is irrelevant *how* you 75 | did it) 76 | 77 | See also [Chris Beams article](http://chris.beams.io/posts/git-commit/). 78 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | Vc version / revision | Operating System | Compiler & Version | Compiler Flags | Assembler & Version | CPU 9 | ----------------------|------------------|--------------------|----------------|---------------------|---- 10 | | | | | | 11 | 12 | ## Testcase 13 | ```cpp 14 | ``` 15 | 16 | ## Actual Results 17 | 18 | ## Expected Results 19 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | pull_request: 5 | schedule: 6 | - cron: '0 3 * * *' 7 | jobs: 8 | #clang-format: 9 | # runs-on: ubuntu-latest 10 | # steps: 11 | # - uses: actions/checkout@v2 12 | # - uses: DoozyX/clang-format-lint-action@v0.12 13 | # with: 14 | # exclude: './thirdparty' 15 | # clangFormatVersion: 12 16 | 17 | build-ubuntu: 18 | runs-on: ubuntu-latest 19 | env: 20 | dashboard_model: Experimental 21 | build_type: ${{ matrix.build_type }} 22 | NUMBER_OF_PROCESSORS: 2 23 | CXX: ${{ matrix.cxx }} 24 | strategy: 25 | fail-fast: false 26 | matrix: 27 | build_type: [Debug, Release] 28 | cxx: [g++-9, g++-10, g++-11, clang++-10, clang++-11, clang++-12, icpc] 29 | include: 30 | - cxx: g++-11 31 | INSTALL_EXTRA: g++-11 32 | - cxx: clang++-11 33 | INSTALL_EXTRA: clang-11 34 | - cxx: clang++-12 35 | INSTALL_EXTRA: clang-12 36 | - cxx: icpc 37 | INSTALL_ONEAPI: true 38 | exclude: 39 | # icpc in debug mode runs out of memory in CI 40 | - cxx: icpc 41 | build_type: Debug 42 | steps: 43 | - uses: actions/checkout@v2 44 | with: 45 | submodules: true 46 | - name: install OneAPI 47 | if: ${{ matrix.INSTALL_ONEAPI }} 48 | run: | 49 | wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB 50 | sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB 51 | sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" 52 | sudo apt update 53 | sudo apt install intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic 54 | - name: install extras 55 | if: ${{ matrix.INSTALL_EXTRA }} 56 | run: | 57 | sudo apt update 58 | sudo apt install ${{ matrix.INSTALL_EXTRA }} 59 | - name: ctest 60 | run: | 61 | if [ ${{ matrix.INSTALL_ONEAPI }} ] 62 | then 63 | source /opt/intel/oneapi/setvars.sh 64 | export LC_ALL=en_US.utf8 65 | fi 66 | $CXX --version 67 | ctest -VV -S test.cmake 68 | 69 | build-windows: 70 | runs-on: ${{ matrix.os }} 71 | env: 72 | build_type: ${{ matrix.build_type }} 73 | strategy: 74 | fail-fast: false 75 | matrix: 76 | build_type: [Debug, Release] 77 | os: [windows-2019] 78 | steps: 79 | - uses: actions/checkout@v2 80 | with: 81 | submodules: true 82 | - uses: egor-tensin/vs-shell@v2 83 | - name: ctest 84 | run: | 85 | ctest -VV -S test.cmake 86 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | doc/html 2 | doc/latex 3 | doc/man 4 | vc-benchmarks 5 | *.swp 6 | *~ 7 | .makeApidox.stamp 8 | .makeApidox.stamp.new 9 | build-* 10 | .vs 11 | out 12 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tests/testdata"] 2 | path = tests/testdata 3 | url = https://github.com/VcDevel/vc-testdata 4 | [submodule "tests/virtest"] 5 | path = tests/virtest 6 | url = https://github.com/mattkretz/virtest 7 | -------------------------------------------------------------------------------- /CTestConfig.cmake: -------------------------------------------------------------------------------- 1 | set(CTEST_PROJECT_NAME "Vc") 2 | set(CTEST_NIGHTLY_START_TIME "00:00:00 CEST") 3 | 4 | set(CTEST_DROP_METHOD "http") 5 | set(CTEST_DROP_SITE "cdash.cern.ch") 6 | set(CTEST_DROP_LOCATION "/submit.php?project=Vc") 7 | 8 | set(CTEST_DROP_SITE_CDASH TRUE) 9 | 10 | set(CTEST_UPDATE_TYPE "git") 11 | 12 | find_program(GITCOMMAND git) 13 | set(CTEST_UPDATE_COMMAND "${GITCOMMAND}") 14 | 15 | mark_as_advanced(GITCOMMAND) 16 | -------------------------------------------------------------------------------- /CTestCustom.cmake: -------------------------------------------------------------------------------- 1 | set(CTEST_CUSTOM_WARNING_EXCEPTION ${CTEST_CUSTOM_WARNING_EXCEPTION} 2 | " C4723: " # MSVC 2012 can't suppress this warning 3 | " C4756: " # MSVC 2012 can't suppress this warning 4 | "used uninitialized in this function" 5 | "Skipping compilation of tests gatherStruct and gather2dim because of clang bug" # Not a helpful warning for the dashboard 6 | "warning is a GCC extension" 7 | "^-- " # Ignore output from cmake 8 | "AVX disabled per default because of old/broken compiler" # This warning is meant for users not the dashboard 9 | "WARNING non-zero return value in ctest from: make" # Ignore output from ctest 10 | "ipo: warning #11010:" # Ignore warning about incompatible libraries with ICC -m32 on 64-bit system 11 | "include/qt4" # -Wuninitialized in QWeakPointer(X *ptr) 12 | " note: " # Notes are additional lines from errors (or warnings) that we don't want to count as additional warnings 13 | "clang: warning: argument unused during compilation: '-stdlib=libc" 14 | "clang 3.6.x miscompiles AVX code" # a preprocessor warning for users of Vc, irrelevant for the dashboard 15 | ) 16 | 17 | set(CTEST_CUSTOM_ERROR_EXCEPTION ${CTEST_CUSTOM_ERROR_EXCEPTION} 18 | "^ICECC" 19 | "^make\\[[1-9]\\]: " 20 | "^collect2: ld returned . exit status" 21 | "^make: \\*\\*\\* \\[.*\\] Error ") 22 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | See README.md. 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2009-2015 Matthias Kretz 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | * Redistributions of source code must retain the above copyright 6 | notice, this list of conditions and the following disclaimer. 7 | * Redistributions in binary form must reproduce the above copyright 8 | notice, this list of conditions and the following disclaimer in the 9 | documentation and/or other materials provided with the distribution. 10 | * Neither the names of contributing organizations nor the 11 | names of its contributors may be used to endorse or promote products 12 | derived from this software without specific prior written permission. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 18 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CXX ?= c++ 2 | build_dir := $(shell which $(CXX)) 3 | tmp := "case $$(readlink -f $(build_dir)) in *icecc) which $${ICECC_CXX:-g++};; *) echo $(build_dir);; esac" 4 | build_dir := $(shell sh -c $(tmp)) 5 | build_dir := $(realpath $(build_dir)) 6 | build_dir := build-$(subst /,-,$(build_dir:/%=%)$(CXXFLAGS)) 7 | 8 | all: 9 | %:: $(build_dir)/CMakeCache.txt 10 | $(MAKE) --no-print-directory -C "$(build_dir)" $(MAKECMDGOALS) 11 | 12 | $(build_dir)/CMakeCache.txt: 13 | @test -n "$(build_dir)" 14 | @mkdir -p "$(build_dir)" 15 | @test -e "$(build_dir)/CMakeCache.txt" || cmake -H. -B"$(build_dir)" 16 | 17 | print_build_dir: 18 | @echo "$(PWD)/$(build_dir)" 19 | 20 | clean_builddir: 21 | rm -rf "$(build_dir)" 22 | 23 | # the following rule works around %:: grabbing the Makefile rule and thus stops it from running every time 24 | Makefile: 25 | @true 26 | 27 | .PHONY: print_build_dir clean_builddir 28 | -------------------------------------------------------------------------------- /Test_vc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | case "$1" in 4 | Experimental|Nightly|Continuous) 5 | export dashboard_model=$1 6 | case "$2" in 7 | None|Debug|Release|RelWithDebug|RelWithDebInfo|MinSizeRel) 8 | export build_type=$2 9 | ;; 10 | esac 11 | ;; 12 | *) 13 | echo "Usage: $0 []" 14 | echo 15 | echo "Possible arguments for model are Nightly, Continuous, or Experimental." 16 | echo "Build type may be one of: None Debug Release RelWithDebug RelWithDebInfo MinSizeRel." 17 | echo 18 | exit 1 19 | ;; 20 | esac 21 | 22 | ctest -S "`dirname $0`/test.cmake" 23 | -------------------------------------------------------------------------------- /Vc/Memory: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_MEMORY_ 29 | #define VC_MEMORY_ 30 | 31 | #include "vector.h" 32 | #include "common/memory.h" 33 | #include "common/interleavedmemory.h" 34 | 35 | #include "common/make_unique.h" 36 | namespace Vc_VERSIONED_NAMESPACE 37 | { 38 | using Common::make_unique; 39 | } 40 | 41 | #endif // VC_MEMORY_ 42 | 43 | // vim: ft=cpp foldmethod=marker 44 | -------------------------------------------------------------------------------- /Vc/SimdArray: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2013-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_SIMDARRAY_ 29 | #define VC_SIMDARRAY_ 30 | 31 | #include "common/simdarray.h" 32 | 33 | #endif // VC_SIMDARRAY_ 34 | 35 | // vim: ft=cpp foldmethod=marker 36 | -------------------------------------------------------------------------------- /Vc/Utils: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2010-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_UTILS_ 29 | #define VC_UTILS_ 30 | 31 | #include "global.h" 32 | 33 | #ifdef Vc_IMPL_Scalar 34 | # define VECTOR_NAMESPACE Scalar 35 | #else 36 | # define VECTOR_NAMESPACE SSE 37 | #endif 38 | 39 | #include "common/deinterleave.h" 40 | #include "common/makeContainer.h" 41 | 42 | #endif // VC_UTILS_ 43 | 44 | // vim: ft=cpp foldmethod=marker 45 | -------------------------------------------------------------------------------- /Vc/Vc: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_VC_ 29 | #define VC_VC_ 30 | #include "vector.h" 31 | #include "IO" 32 | #include "Memory" 33 | #include "Utils" 34 | #include "Allocator" 35 | #include "algorithm" 36 | #include "iterators" 37 | #include "simdize" 38 | #include "array" 39 | #include "span" 40 | #include "vector" 41 | #endif // VC_VC_ 42 | 43 | // vim: ft=cpp foldmethod=marker 44 | -------------------------------------------------------------------------------- /Vc/algorithm: -------------------------------------------------------------------------------- 1 | #include "common/algorithms.h" 2 | -------------------------------------------------------------------------------- /Vc/avx/README: -------------------------------------------------------------------------------- 1 | ########################################### 2 | ################# AVX ################# 3 | ########################################### 4 | 5 | 6 | 1. Floating Point 7 | =========================================== 8 | Uses full 256bit vectors for all operations. 128bit vectors are never used. 9 | 10 | 11 | 2. Integer 12 | =========================================== 13 | Integer support in AVX is minimal. 14 | The 256bit integer vectors are just intended as a supporting type of float operations. 15 | 16 | Any arithmetic, logical, or comparison operations must be implemented using 128bit operations. 17 | 18 | int_v/uint_v could be implemented either as 128 or 256 types. I.e. either int_v::Size == 4 or 8. 19 | 20 | 21 | 2.1. 256bit int vectors 22 | =========================================== 23 | 24 | 2.1.1. Implementation Details: 25 | This requires the SSE operations to not zero the high bits of the registers. Since the YMM registers 26 | are aliased on the XMM registers you need to use SSE ops that are not using the VEX prefix (IIUC). 27 | Or you have to use two XMM registers most of the time. 28 | Perfect would be the use of 29 | union M256I { 30 | __m256i ymm; 31 | __m128i xmm[2]; 32 | }; 33 | But as far as I know GCC, this will result in lots of unnecessary loads and stores. (It seems this is 34 | due to GCC expecting aliasing, thus making sure the modified values are always up-to-date in memory 35 | - like if it were declared volatile.) 36 | 37 | 2.1.2. Upsides: 38 | int_v::Size == float_v::Size 39 | 40 | 2.1.3. Downsides: 41 | Register pressure is increased. 42 | 43 | 2.2. 128bit int vectors 44 | =========================================== 45 | 46 | 2.2.1. Implementation Details: 47 | 48 | 2.2.2. Upsides: 49 | 50 | 2.2.3. Downsides: 51 | - Use of int_v for float_v operations involving __m256i arguments require an extra type. This will 52 | be hard to generalize 53 | 54 | 55 | 2.3. Mixed approach 56 | =========================================== 57 | int_v/uint_v are implemented as 256bit while short_v/ushort_v are implemented as 128bit. Thus 58 | int_v::Size == short_v::Size (which is the case on LRBni, too). 59 | -------------------------------------------------------------------------------- /Vc/avx/macros.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "../common/macros.h" 29 | 30 | #ifndef VC_AVX_MACROS_H_ 31 | #define VC_AVX_MACROS_H_ 32 | 33 | #endif // VC_AVX_MACROS_H_ 34 | -------------------------------------------------------------------------------- /Vc/avx/simd_cast_caller.tcc: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef Vc_AVX_SIMD_CAST_CALLER_TCC_ 29 | #define Vc_AVX_SIMD_CAST_CALLER_TCC_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | #if Vc_IS_VERSION_1 36 | template 37 | template 38 | Vc_INTRINSIC Vector::Vector(U &&x) 39 | : d(simd_cast(std::forward(x)).data()) 40 | { 41 | } 42 | 43 | template 44 | template 45 | Vc_INTRINSIC Mask::Mask(U &&rhs, 46 | Common::enable_if_mask_converts_explicitly) 47 | : Mask(simd_cast(std::forward(rhs))) 48 | { 49 | } 50 | #endif // Vc_IS_VERSION_1 51 | } 52 | 53 | #endif // Vc_AVX_SIMD_CAST_CALLER_TCC_ 54 | 55 | // vim: foldmethod=marker 56 | -------------------------------------------------------------------------------- /Vc/common/bitscanintrinsics.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2011-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_BITSCANINTRINSICS_H_ 29 | #define VC_COMMON_BITSCANINTRINSICS_H_ 30 | 31 | #if defined(Vc_GCC) || defined(Vc_CLANG) || defined(Vc_APPLECLANG) 32 | #include 33 | # ifndef _bit_scan_forward 34 | # define _bit_scan_forward(x) __builtin_ctz(x) 35 | #include "macros.h" 36 | static Vc_ALWAYS_INLINE Vc_CONST int _Vc_bit_scan_reverse_asm(unsigned int x) { 37 | int r; 38 | __asm__("bsr %1,%0" : "=r"(r) : "X"(x)); 39 | return r; 40 | } 41 | # define _bit_scan_reverse(x) _Vc_bit_scan_reverse_asm(x) 42 | # endif 43 | #elif defined(_WIN32) 44 | #include 45 | static inline __forceinline unsigned long _bit_scan_forward(unsigned long x) { 46 | unsigned long index; 47 | _BitScanForward(&index, x); 48 | return index; 49 | } 50 | static inline __forceinline unsigned long _bit_scan_reverse(unsigned long x) { 51 | unsigned long index; 52 | _BitScanReverse(&index, x); 53 | return index; 54 | } 55 | #elif defined(Vc_ICC) 56 | // for all I know ICC supports the _bit_scan_* intrinsics 57 | #else 58 | // just assume the compiler can do it 59 | #endif 60 | 61 | 62 | #endif // VC_COMMON_BITSCANINTRINSICS_H_ 63 | -------------------------------------------------------------------------------- /Vc/common/data.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2013-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_CONST_DATA_H_ 29 | #define VC_COMMON_CONST_DATA_H_ 30 | 31 | #include "macros.h" 32 | namespace Vc_VERSIONED_NAMESPACE 33 | { 34 | namespace Common 35 | { 36 | 37 | alignas(64) extern unsigned int RandomState[]; 38 | alignas(32) extern const unsigned int AllBitsSet[8]; 39 | 40 | } // namespace Common 41 | } // namespace Vc 42 | 43 | #endif // VC_COMMON_CONST_DATA_H_ 44 | -------------------------------------------------------------------------------- /Vc/common/fix_clang_emmintrin.h: -------------------------------------------------------------------------------- 1 | /*{{{ 2 | Copyright (C) 2013-2015 Matthias Kretz 3 | 4 | Permission to use, copy, modify, and distribute this software 5 | and its documentation for any purpose and without fee is hereby 6 | granted, provided that the above copyright notice appear in all 7 | copies and that both that the copyright notice and this 8 | permission notice and warranty disclaimer appear in supporting 9 | documentation, and that the name of the author not be used in 10 | advertising or publicity pertaining to distribution of the 11 | software without specific, written prior permission. 12 | 13 | The author disclaim all warranties with regard to this 14 | software, including all implied warranties of merchantability 15 | and fitness. In no event shall the author be liable for any 16 | special, indirect or consequential damages or any damages 17 | whatsoever resulting from loss of use, data or profits, whether 18 | in an action of contract, negligence or other tortious action, 19 | arising out of or in connection with the use or performance of 20 | this software. 21 | 22 | }}}*/ 23 | 24 | #ifndef VC_COMMON_FIX_CLANG_EMMINTRIN_H_ 25 | #define VC_COMMON_FIX_CLANG_EMMINTRIN_H_ 26 | 27 | #include "../global.h" 28 | 29 | #if (defined Vc_CLANG && Vc_CLANG < 0x30700) || (defined Vc_APPLECLANG && Vc_APPLECLANG < 0x70000) 30 | 31 | #ifdef _mm_slli_si128 32 | #undef _mm_slli_si128 33 | #define _mm_slli_si128(a, count) __extension__ ({ \ 34 | (__m128i)__builtin_ia32_pslldqi128((__m128i)(a), (count)*8); }) 35 | #endif 36 | 37 | #ifdef _mm_srli_si128 38 | #undef _mm_srli_si128 39 | #define _mm_srli_si128(a, count) __extension__ ({ \ 40 | (__m128i)__builtin_ia32_psrldqi128((__m128i)(a), (count)*8); }) 41 | #endif 42 | 43 | #ifdef _mm_shuffle_epi32 44 | #undef _mm_shuffle_epi32 45 | #define _mm_shuffle_epi32(a, imm) __extension__ ({ \ 46 | (__m128i)__builtin_shufflevector((__v4si)(__m128i)(a), (__v4si) _mm_set1_epi32(0), \ 47 | (imm) & 0x3, ((imm) & 0xc) >> 2, \ 48 | ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6); }) 49 | #endif 50 | 51 | #ifdef _mm_shufflelo_epi16 52 | #undef _mm_shufflelo_epi16 53 | #define _mm_shufflelo_epi16(a, imm) __extension__ ({ \ 54 | (__m128i)__builtin_shufflevector((__v8hi)(__m128i)(a), (__v8hi) _mm_set1_epi16(0), \ 55 | (imm) & 0x3, ((imm) & 0xc) >> 2, \ 56 | ((imm) & 0x30) >> 4, ((imm) & 0xc0) >> 6, \ 57 | 4, 5, 6, 7); }) 58 | #endif 59 | 60 | #ifdef _mm_shufflehi_epi16 61 | #undef _mm_shufflehi_epi16 62 | #define _mm_shufflehi_epi16(a, imm) __extension__ ({ \ 63 | (__m128i)__builtin_shufflevector((__v8hi)(__m128i)(a), (__v8hi) _mm_set1_epi16(0), \ 64 | 0, 1, 2, 3, \ 65 | 4 + (((imm) & 0x03) >> 0), \ 66 | 4 + (((imm) & 0x0c) >> 2), \ 67 | 4 + (((imm) & 0x30) >> 4), \ 68 | 4 + (((imm) & 0xc0) >> 6)); }) 69 | #endif 70 | 71 | #ifdef _mm_shuffle_pd 72 | #undef _mm_shuffle_pd 73 | #define _mm_shuffle_pd(a, b, i) __extension__ ({ \ 74 | __builtin_shufflevector((__m128d)(a), (__m128d)(b), (i) & 1, (((i) & 2) >> 1) + 2); }) 75 | #endif 76 | 77 | #endif // Vc_CLANG || Vc_APPLECLANG 78 | 79 | #endif // VC_COMMON_FIX_CLANG_EMMINTRIN_H_ 80 | -------------------------------------------------------------------------------- /Vc/common/generalinterface.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | public: 29 | /////////////////////////////////////////////////////////////////////////// 30 | // init to zero 31 | Vc_INTRINSIC Vector() = default; 32 | 33 | /////////////////////////////////////////////////////////////////////////// 34 | // types 35 | 36 | /////////////////////////////////////////////////////////////////////////// 37 | // constants 38 | static constexpr std::size_t size() { return Size; } 39 | 40 | /////////////////////////////////////////////////////////////////////////// 41 | // constant Vectors 42 | explicit Vc_INTRINSIC_L Vector(VectorSpecialInitializerZero) Vc_INTRINSIC_R; 43 | explicit Vc_INTRINSIC_L Vector(VectorSpecialInitializerOne) Vc_INTRINSIC_R; 44 | explicit Vc_INTRINSIC_L Vector(VectorSpecialInitializerIndexesFromZero) Vc_INTRINSIC_R; 45 | static Vc_INTRINSIC Vc_CONST Vector Zero() { return Vector(Vc::Zero); } 46 | static Vc_INTRINSIC Vc_CONST Vector One() { return Vector(Vc::One); } 47 | static Vc_INTRINSIC Vc_CONST Vector IndexesFromZero() 48 | { 49 | return Vector(Vc::IndexesFromZero); 50 | } 51 | 52 | /////////////////////////////////////////////////////////////////////////// 53 | // generator ctor 54 | template ()(size_t())), value_type>::value>::type> 57 | explicit Vector(G &&g) : Vector(generate(std::forward(g))) 58 | { 59 | } 60 | 61 | // vim: foldmethod=marker 62 | -------------------------------------------------------------------------------- /Vc/common/indexsequence.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_INDEXSEQUENCE_H_ 29 | #define VC_COMMON_INDEXSEQUENCE_H_ 30 | 31 | #include "../global.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | /** \internal 36 | * Helper class for a sequence of size_t values from 0 to N. This type will be included in 37 | * C++14. 38 | */ 39 | template struct index_sequence 40 | { 41 | static constexpr std::size_t size() noexcept { return sizeof...(I); } 42 | }; 43 | 44 | /** \internal 45 | * This struct builds an index_sequence type from a given upper bound \p N. 46 | * It does so recursively via concatenation of to index sequences of length N/2. 47 | */ 48 | template struct make_index_sequence_impl { 49 | template 50 | static index_sequence join(std::false_type, 51 | index_sequence); 52 | template 53 | static index_sequence join( 54 | std::true_type, index_sequence); 55 | 56 | using is_odd = std::integral_constant; 57 | using half = typename make_index_sequence_impl::type; 58 | using type = decltype(join<(N + 1) / 2>(is_odd(), half())); 59 | }; 60 | template <> struct make_index_sequence_impl<0> { 61 | using type = index_sequence<>; 62 | }; 63 | template <> struct make_index_sequence_impl<1> { 64 | using type = index_sequence<0>; 65 | }; 66 | template <> struct make_index_sequence_impl<2> { 67 | using type = index_sequence<0, 1>; 68 | }; 69 | 70 | /** \internal 71 | * Creates an index_sequence type for the upper bound \p N. 72 | */ 73 | template 74 | using make_index_sequence = typename make_index_sequence_impl::type; 75 | } 76 | 77 | #endif // VC_COMMON_INDEXSEQUENCE_H_ 78 | 79 | // vim: foldmethod=marker 80 | -------------------------------------------------------------------------------- /Vc/common/interleave.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_INTERLEAVE_H_ 29 | #define VC_COMMON_INTERLEAVE_H_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | /** \ingroup Utilities 36 | Interleaves the entries from \p a and \p b into two vectors of the same type. The order 37 | in the returned vector contains the elements `a[0], b[0], a[1], b[1], a[2], b[2], a[3], 38 | b[3], ...`. 39 | 40 | Example: 41 | \code 42 | Vc::SimdArray a = { 1, 2, 3, 4 }; 43 | Vc::SimdArray b = { 9, 8, 7, 6 }; 44 | std::tie(a, b) = Vc::interleave(a, b); 45 | std::cout << a << b; 46 | // prints: 47 | // <1 9 2 8><3 7 4 6> 48 | \endcode 49 | 50 | \param a input vector whose data will appear at even indexes in the output 51 | \param b input vector whose data will appear at odd indexes in the output 52 | \return two vectors with data from \p a and \p b interleaved 53 | */ 54 | template ::value>> 55 | std::pair interleave(const V &a, const V &b) 56 | { 57 | return {a.interleaveLow(b), a.interleaveHigh(b)}; 58 | } 59 | } // namespace Vc 60 | 61 | #endif // VC_COMMON_INTERLEAVE_H_ 62 | 63 | // vim: foldmethod=marker 64 | -------------------------------------------------------------------------------- /Vc/common/make_unique.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2013-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_MAKE_UNIQUE_H_ 29 | #define VC_COMMON_MAKE_UNIQUE_H_ 30 | 31 | #include 32 | #include "malloc.h" 33 | 34 | namespace Vc_VERSIONED_NAMESPACE 35 | { 36 | namespace Common 37 | { 38 | 39 | template struct Deleter 40 | { 41 | Vc_ALWAYS_INLINE void operator()(T *ptr) { 42 | ptr->~T(); 43 | Vc::free(ptr); 44 | } 45 | }; 46 | 47 | template 48 | inline std::unique_ptr> make_unique(Args&&... args) 49 | { 50 | return std::unique_ptr>(new(Vc::malloc(1)) T(std::forward(args)...)); 51 | } 52 | 53 | } // namespace Common 54 | } // namespace Vc 55 | 56 | #endif // VC_COMMON_MAKE_UNIQUE_H_ 57 | -------------------------------------------------------------------------------- /Vc/common/memoryfwd.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2011-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_MEMORYFWD_H_ 29 | #define VC_COMMON_MEMORYFWD_H_ 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | namespace Common 34 | { 35 | template 37 | class Memory; 38 | 39 | template 40 | class MemoryBase; 41 | } // namespace Common 42 | 43 | using Common::Memory; 44 | } // namespace Vc 45 | 46 | #endif // VC_COMMON_MEMORYFWD_H_ 47 | -------------------------------------------------------------------------------- /Vc/common/permutation.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_PERMUTATION_H_ 29 | #define VC_COMMON_PERMUTATION_H_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Permutation 36 | { 37 | struct ReversedTag {}; 38 | constexpr ReversedTag Reversed{}; 39 | } // namespace Permutation 40 | } 41 | 42 | #endif // VC_COMMON_PERMUTATION_H_ 43 | 44 | // vim: foldmethod=marker 45 | -------------------------------------------------------------------------------- /Vc/common/simd_cast.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_SIMD_CAST_H_ 29 | #define VC_COMMON_SIMD_CAST_H_ 30 | 31 | #include 32 | #include "macros.h" 33 | 34 | // declare a bogus simd_cast function template in the global namespace to enable ADL for 35 | // simd_cast 36 | template void simd_cast(); 37 | 38 | namespace Vc_VERSIONED_NAMESPACE 39 | { 40 | /** 41 | * Casts the argument \p x from type \p From to type \p To. 42 | * 43 | * This function implements the trivial case where \p To and \p From are the same type. 44 | * 45 | * \param x The object of type \p From to be converted to type \p To. 46 | * \returns An object of type \p To with all vector components converted according to 47 | * standard conversion behavior as mandated by the C++ standard for the 48 | * underlying arithmetic types. 49 | */ 50 | template 51 | Vc_INTRINSIC Vc_CONST To 52 | simd_cast(From &&x, enable_if>::value> = nullarg) 53 | { 54 | return std::forward(x); 55 | } 56 | 57 | /** 58 | * A cast from nothing results in default-initialization of \p To. 59 | * 60 | * This function can be useful in generic code where a parameter pack expands to nothing. 61 | * 62 | * \returns A zero-initialized object of type \p To. 63 | */ 64 | template Vc_INTRINSIC Vc_CONST To simd_cast() { return To(); } 65 | 66 | } // namespace Vc 67 | 68 | #endif // VC_COMMON_SIMD_CAST_H_ 69 | -------------------------------------------------------------------------------- /Vc/common/simd_cast_caller.tcc: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_SIMD_CAST_CALLER_TCC_ 29 | #define VC_COMMON_SIMD_CAST_CALLER_TCC_ 30 | 31 | #include "macros.h" 32 | namespace Vc_VERSIONED_NAMESPACE { 33 | template 34 | template 35 | Vc_INTRINSIC SimdMaskArray::SimdMaskArray( 36 | const SimdMaskArray &x) 37 | : data(simd_cast(internal_data(x))) 38 | { 39 | } 40 | template 41 | template 42 | Vc_INTRINSIC SimdMaskArray::SimdMaskArray( 43 | const SimdMaskArray &x) 44 | : data(simd_cast(internal_data(internal_data0(x)), 45 | internal_data(internal_data1(x)))) 46 | { 47 | } 48 | template 49 | template 50 | Vc_INTRINSIC SimdMaskArray::SimdMaskArray( 51 | const SimdMaskArray &x) 52 | : data(simd_cast(internal_data(internal_data0(internal_data0(x))), 53 | internal_data(internal_data1(internal_data0(x))), 54 | internal_data(internal_data0(internal_data1(x))), 55 | internal_data(internal_data1(internal_data1(x))))) 56 | { 57 | } 58 | // conversion from any Segment object (could be SimdMaskArray or Mask) 59 | template 60 | template 61 | Vc_INTRINSIC SimdMaskArray::SimdMaskArray( 62 | Common::Segment &&x, 63 | enable_if::value == Size * Pieces>) 64 | : data(simd_cast(x.data)) 65 | { 66 | } 67 | // conversion from Mask 68 | template 69 | template 70 | Vc_INTRINSIC SimdMaskArray::SimdMaskArray(M k) 71 | : data(simd_cast(k)) 72 | { 73 | } 74 | 75 | } // namespace Vc_VERSIONED_NAMESPACE 76 | 77 | #endif // VC_COMMON_SIMD_CAST_CALLER_TCC_ 78 | 79 | // vim: foldmethod=marker 80 | -------------------------------------------------------------------------------- /Vc/common/support.h: -------------------------------------------------------------------------------- 1 | #ifndef VC_DEPRECATED_COMMON_SUPPORT_H_ 2 | #define VC_DEPRECATED_COMMON_SUPPORT_H_ 3 | #ifdef __GNUC__ 4 | #warning "the header is deprecated. Use instead." 5 | #endif 6 | #include 7 | #endif // VC_DEPRECATED_COMMON_SUPPORT_H_ 8 | -------------------------------------------------------------------------------- /Vc/common/transpose.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_TRANSPOSE_H_ 29 | #define VC_COMMON_TRANSPOSE_H_ 30 | 31 | #include "macros.h" 32 | #include 33 | 34 | namespace Vc_VERSIONED_NAMESPACE 35 | { 36 | namespace Common 37 | { 38 | template struct TransposeProxy 39 | { 40 | TransposeProxy(const Inputs &... inputs) : in{inputs...} {} 41 | 42 | std::tuple in; 43 | }; 44 | 45 | template struct TransposeTag { 46 | }; 47 | } // namespace Common 48 | 49 | template Common::TransposeProxy transpose(Vs... vs) 50 | { 51 | return {vs...}; 52 | } 53 | } // namespace Vc 54 | 55 | #endif // VC_COMMON_TRANSPOSE_H_ 56 | 57 | // vim: foldmethod=marker 58 | -------------------------------------------------------------------------------- /Vc/common/utility.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_UTILITY_H_ 29 | #define VC_COMMON_UTILITY_H_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Common 36 | { 37 | /** 38 | * \internal 39 | * Returns the next power of 2 larger than or equal to \p x. 40 | */ 41 | template struct NextPowerOfTwo; 42 | template 43 | struct NextPowerOfTwo : public std::integral_constant { 44 | }; 45 | template 46 | struct NextPowerOfTwo 47 | : public std::integral_constant< 48 | size_t, NextPowerOfTwo<(x | (x >> 1) | (x >> 2) | (x >> 5)) + 1>::value> { 49 | }; 50 | 51 | /** 52 | * \internal 53 | * Enforce an upper bound to an alignment value. This is necessary because some compilers 54 | * implement such an upper bound and emit a warning if it is encountered. 55 | */ 56 | template 57 | struct BoundedAlignment : public std::integral_constant { 72 | }; 73 | 74 | /** 75 | * \internal 76 | * Returns the size of the left/first SimdArray member. 77 | */ 78 | template static constexpr std::size_t left_size() 79 | { 80 | return Common::NextPowerOfTwo<(N + 1) / 2>::value; 81 | } 82 | /** 83 | * \internal 84 | * Returns the size of the right/second SimdArray member. 85 | */ 86 | template static constexpr std::size_t right_size() 87 | { 88 | return N - left_size(); 89 | } 90 | 91 | } // namespace Common 92 | } // namespace Vc 93 | 94 | #endif // VC_COMMON_UTILITY_H_ 95 | 96 | // vim: foldmethod=marker 97 | -------------------------------------------------------------------------------- /Vc/common/vector/casts.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | public: 29 | /////////////////////////////////////////////////////////////////////////////////////////// 30 | // casts - implemented in simd_cast_caller.tcc 31 | 32 | // implict conversion from compatible Vector 33 | template 34 | Vc_INTRINSIC_L Vector( 35 | U &&x, 36 | enable_if>::value && 37 | !std::is_same>::value && 38 | Traits::is_implicit_cast_allowed, T>::value> = 39 | nullarg) Vc_INTRINSIC_R; 40 | 41 | // static_cast from other types 42 | template 43 | Vc_INTRINSIC_L explicit Vector(U &&x, 44 | enable_if::value && 45 | !std::is_same>::value>> 46 | = nullarg) Vc_INTRINSIC_R; 47 | 48 | /////////////////////////////////////////////////////////////////////////////////////////// 49 | // broadcast 50 | Vc_INTRINSIC Vector(EntryType a); 51 | template 52 | Vc_INTRINSIC Vector( 53 | U a, 54 | typename std::enable_if::value && !std::is_same::value, 55 | void *>::type = nullptr) 56 | : Vector(static_cast(a)) 57 | { 58 | } 59 | 60 | /////////////////////////////////////////////////////////////////////////////////////////// 61 | // explicitly forbid construction from initializer_list 62 | explicit Vector(std::initializer_list) 63 | { 64 | static_assert(std::is_same::value, 65 | "A SIMD vector object cannot be initialized from an initializer list " 66 | "because the number of entries in the vector is target-dependent."); 67 | } 68 | 69 | // vim: foldmethod=marker 70 | -------------------------------------------------------------------------------- /Vc/common/vectorabi.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_VECTORABI_H_ 29 | #define VC_COMMON_VECTORABI_H_ 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | namespace VectorAbi 34 | { 35 | template 36 | using Avx1Abi = typename std::conditional::value, VectorAbi::Sse, 37 | VectorAbi::Avx>::type; 38 | 39 | template struct DeduceCompatible { 40 | #ifdef __x86_64__ 41 | using type = Sse; 42 | #else 43 | using type = Scalar; 44 | #endif 45 | }; 46 | 47 | template 48 | struct DeduceBest { 49 | using type = typename std::conditional< 50 | CurrentImplementation::is(ScalarImpl), Scalar, 51 | typename std::conditional< 52 | CurrentImplementation::is_between(SSE2Impl, SSE42Impl), Sse, 53 | typename std::conditional< 54 | CurrentImplementation::is(AVXImpl), Avx1Abi, 55 | typename std::conditional::type>::type>::type>::type; 57 | }; 58 | template using Best = typename DeduceBest::type; 59 | } // namespace VectorAbi 60 | } // namespace Vc_VERSIONED_NAMESPACE 61 | 62 | #include "simdarrayfwd.h" 63 | 64 | namespace Vc_VERSIONED_NAMESPACE 65 | { 66 | namespace detail 67 | { 68 | // is_fixed_size_abi {{{ 69 | template struct is_fixed_size_abi : std::false_type { 70 | }; 71 | template struct is_fixed_size_abi> : std::true_type { 72 | }; 73 | //}}} 74 | 75 | template 76 | using not_fixed_size_abi = typename std::enable_if::value, T>::type; 77 | 78 | } // namespace detail 79 | } // namespace Vc 80 | 81 | #endif // VC_COMMON_VECTORABI_H_ 82 | 83 | // vim: foldmethod=marker 84 | -------------------------------------------------------------------------------- /Vc/common/vectortraits.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_COMMON_VECTORTRAITS_H_ 29 | #define VC_COMMON_VECTORTRAITS_H_ 30 | 31 | #include "vectorabi.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | template struct VectorTraits; 36 | } // namespace Vc 37 | 38 | #endif // VC_COMMON_VECTORTRAITS_H_ 39 | 40 | // vim: foldmethod=marker 41 | -------------------------------------------------------------------------------- /Vc/iterators: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2013-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_INCLUDE_VC_ITERATORS_H_ 29 | #define VC_INCLUDE_VC_ITERATORS_H_ 30 | 31 | #include "common/iterators.h" 32 | namespace Vc_VERSIONED_NAMESPACE 33 | { 34 | using ::Vc::Common::begin; 35 | using ::Vc::Common::end; 36 | using ::Vc::Common::makeIterator; 37 | } 38 | 39 | #endif // VC_INCLUDE_VC_ITERATORS_H_ 40 | 41 | // vim: ft=cpp foldmethod=marker 42 | -------------------------------------------------------------------------------- /Vc/limits: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_LIMITS_ 29 | #define VC_LIMITS_ 30 | 31 | #include 32 | #include "vector.h" 33 | #include "common/macros.h" 34 | #include 35 | 36 | namespace std 37 | { 38 | template struct numeric_limits > : public numeric_limits::EntryType> 39 | { 40 | private: 41 | typedef numeric_limits::EntryType> _Base; 42 | public: 43 | static Vc_INTRINSIC Vc_CONST Vc::Vector max() { return Vc::Vector(_Base::max()); } 44 | static Vc_INTRINSIC Vc_CONST Vc::Vector min() { return Vc::Vector(_Base::min()); } 45 | static Vc_INTRINSIC Vc_CONST Vc::Vector lowest() { return Vc::Vector(_Base::lowest()); } 46 | static Vc_INTRINSIC Vc_CONST Vc::Vector epsilon() { return Vc::Vector(_Base::epsilon()); } 47 | static Vc_INTRINSIC Vc_CONST Vc::Vector round_error() { return Vc::Vector(_Base::round_error()); } 48 | static Vc_INTRINSIC Vc_CONST Vc::Vector infinity() { return Vc::Vector(_Base::infinity()); } 49 | static Vc_INTRINSIC Vc_CONST Vc::Vector quiet_NaN() { return Vc::Vector(_Base::quiet_NaN()); } 50 | static Vc_INTRINSIC Vc_CONST Vc::Vector signaling_NaN() { return Vc::Vector(_Base::signaling_NaN()); } 51 | static Vc_INTRINSIC Vc_CONST Vc::Vector denorm_min() { return Vc::Vector(_Base::denorm_min()); } 52 | }; 53 | } // namespace std 54 | 55 | #ifdef Vc_IMPL_Scalar 56 | # include "scalar/limits.h" 57 | #elif defined(Vc_IMPL_AVX) 58 | # include "avx/limits.h" 59 | #elif defined(Vc_IMPL_SSE) 60 | # include "sse/limits.h" 61 | #endif 62 | 63 | #endif // VC_LIMITS_ 64 | 65 | // vim: ft=cpp foldmethod=marker 66 | -------------------------------------------------------------------------------- /Vc/scalar/helperimpl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2010-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_SCALAR_DEINTERLEAVE_H_ 29 | #define VC_SCALAR_DEINTERLEAVE_H_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Detail 36 | { 37 | template 38 | Vc_ALWAYS_INLINE void deinterleave(Scalar::Vector &a, Scalar::Vector &b, 39 | const M *mem, A) 40 | { 41 | a = mem[0]; 42 | b = mem[1]; 43 | } 44 | 45 | Vc_ALWAYS_INLINE void prefetchForOneRead(const void *, VectorAbi::Scalar) {} 46 | Vc_ALWAYS_INLINE void prefetchForModify(const void *, VectorAbi::Scalar) {} 47 | Vc_ALWAYS_INLINE void prefetchClose(const void *, VectorAbi::Scalar) {} 48 | Vc_ALWAYS_INLINE void prefetchMid(const void *, VectorAbi::Scalar) {} 49 | Vc_ALWAYS_INLINE void prefetchFar(const void *, VectorAbi::Scalar) {} 50 | } // namespace Detail 51 | } // namespace Vc 52 | 53 | #endif // VC_SCALAR_DEINTERLEAVE_H_ 54 | -------------------------------------------------------------------------------- /Vc/scalar/limits.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_SCALAR_LIMITS_H_ 29 | #define VC_SCALAR_LIMITS_H_ 30 | 31 | 32 | #endif // VC_SCALAR_LIMITS_H_ 33 | -------------------------------------------------------------------------------- /Vc/scalar/macros.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "../common/macros.h" 29 | 30 | #ifndef VC_SCALAR_MACROS_H_ 31 | #define VC_SCALAR_MACROS_H_ 32 | 33 | #endif // VC_SCALAR_MACROS_H_ 34 | -------------------------------------------------------------------------------- /Vc/scalar/simd_cast_caller.tcc: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef Vc_SCALAR_SIMD_CAST_CALLER_TCC_ 29 | #define Vc_SCALAR_SIMD_CAST_CALLER_TCC_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | #if Vc_IS_VERSION_1 36 | template 37 | template 38 | Vc_INTRINSIC Mask::Mask( 39 | U &&rhs, Common::enable_if_mask_converts_explicitly) 40 | : Mask(simd_cast(std::forward(rhs))) 41 | { 42 | } 43 | #endif 44 | } // namespace Vc 45 | 46 | #endif // Vc_SCALAR_SIMD_CAST_CALLER_TCC_ 47 | 48 | // vim: foldmethod=marker 49 | -------------------------------------------------------------------------------- /Vc/scalar/type_traits.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_SCALAR_TYPE_TRAITS_H_ 29 | #define VC_SCALAR_TYPE_TRAITS_H_ 30 | 31 | #include "types.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Scalar 36 | { 37 | namespace Traits 38 | { 39 | template struct is_vector : public std::false_type {}; 40 | template struct is_vector> : public std::true_type {}; 41 | 42 | template struct is_mask : public std::false_type {}; 43 | template struct is_mask> : public std::true_type {}; 44 | } // namespace Traits 45 | } 46 | } 47 | 48 | #endif // VC_SCALAR_TYPE_TRAITS_H_ 49 | 50 | // vim: foldmethod=marker 51 | -------------------------------------------------------------------------------- /Vc/scalar/types.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "../common/types.h" 29 | #include "../common/vectorabi.h" 30 | 31 | #ifndef VC_SCALAR_TYPES_H_ 32 | #define VC_SCALAR_TYPES_H_ 33 | 34 | #ifdef Vc_DEFAULT_IMPL_Scalar 35 | #define Vc_DOUBLE_V_SIZE 1 36 | #define Vc_FLOAT_V_SIZE 1 37 | #define Vc_INT_V_SIZE 1 38 | #define Vc_UINT_V_SIZE 1 39 | #define Vc_SHORT_V_SIZE 1 40 | #define Vc_USHORT_V_SIZE 1 41 | #endif 42 | 43 | namespace Vc_VERSIONED_NAMESPACE 44 | { 45 | namespace Scalar 46 | { 47 | template using Vector = Vc::Vector; 48 | typedef Vector double_v; 49 | typedef Vector float_v; 50 | typedef Vector int_v; 51 | typedef Vector uint_v; 52 | typedef Vector short_v; 53 | typedef Vector ushort_v; 54 | 55 | template using Mask = Vc::Mask; 56 | typedef Mask double_m; 57 | typedef Mask float_m; 58 | typedef Mask int_m; 59 | typedef Mask uint_m; 60 | typedef Mask short_m; 61 | typedef Mask ushort_m; 62 | 63 | template struct is_vector : public std::false_type {}; 64 | template struct is_vector> : public std::true_type {}; 65 | template struct is_mask : public std::false_type {}; 66 | template struct is_mask> : public std::true_type {}; 67 | } // namespace Scalar 68 | 69 | namespace Traits 70 | { 71 | template struct is_simd_mask_internal> 72 | : public std::true_type {}; 73 | 74 | template struct 75 | is_simd_vector_internal> 76 | : public is_valid_vector_argument {}; 77 | } // namespace Traits 78 | } // namespace Vc 79 | 80 | #endif // VC_SCALAR_TYPES_H_ 81 | -------------------------------------------------------------------------------- /Vc/simdize: -------------------------------------------------------------------------------- 1 | #include "vector.h" 2 | #include "Allocator" 3 | #include "common/simdize.h" 4 | 5 | // vim: ft=cpp 6 | -------------------------------------------------------------------------------- /Vc/span: -------------------------------------------------------------------------------- 1 | #include "common/span.h" 2 | 3 | // vim: ft=cpp 4 | -------------------------------------------------------------------------------- /Vc/sse/const_data.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2012-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_SSE_CONST_DATA_H_ 29 | #define VC_SSE_CONST_DATA_H_ 30 | 31 | #include "../common/data.h" 32 | #include "macros.h" 33 | 34 | namespace Vc_VERSIONED_NAMESPACE 35 | { 36 | namespace SSE 37 | { 38 | 39 | alignas(16) extern const unsigned int _IndexesFromZero4[4]; 40 | alignas(16) extern const unsigned short _IndexesFromZero8[8]; 41 | alignas(16) extern const unsigned char _IndexesFromZero16[16]; 42 | 43 | struct c_general 44 | { 45 | alignas(64) static const int absMaskFloat[4]; 46 | alignas(16) static const unsigned int signMaskFloat[4]; 47 | alignas(16) static const unsigned int highMaskFloat[4]; 48 | alignas(16) static const short minShort[8]; 49 | 50 | alignas(16) static const unsigned short one16[8]; 51 | alignas(16) static const unsigned int one32[4]; 52 | alignas(16) static const float oneFloat[4]; 53 | 54 | alignas(16) static const unsigned long long highMaskDouble[2]; 55 | alignas(16) static const double oneDouble[2]; 56 | alignas(16) static const long long absMaskDouble[2]; 57 | alignas(16) static const unsigned long long signMaskDouble[2]; 58 | alignas(16) static const unsigned long long frexpMask[2]; 59 | }; 60 | 61 | template struct c_trig 62 | { 63 | alignas(64) static const T data[]; 64 | }; 65 | #ifndef Vc_MSVC 66 | template <> alignas(64) const float c_trig::data[]; 67 | template <> alignas(64) const double c_trig::data[]; 68 | #endif 69 | 70 | template struct c_log 71 | { 72 | enum VectorSize { Size = 16 / sizeof(T) }; 73 | static Vc_ALWAYS_INLINE Vc_CONST const float *d(int i) { return reinterpret_cast(&data[i * Size]); } 74 | alignas(64) static const unsigned int data[21 * Size]; 75 | }; 76 | #ifndef Vc_MSVC 77 | template<> alignas(64) const unsigned int c_log::data[21 * 4]; 78 | #endif 79 | 80 | template<> struct c_log 81 | { 82 | enum VectorSize { Size = 16 / sizeof(double) }; 83 | static Vc_ALWAYS_INLINE Vc_CONST const double *d(int i) { return reinterpret_cast(&data[i * Size]); } 84 | alignas(64) static const unsigned long long data[21 * Size]; 85 | }; 86 | 87 | } // namespace SSE 88 | } // namespace Vc 89 | 90 | #endif // VC_SSE_CONST_DATA_H_ 91 | -------------------------------------------------------------------------------- /Vc/sse/helperimpl.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2010-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_SSE_DEINTERLEAVE_H_ 29 | #define VC_SSE_DEINTERLEAVE_H_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Detail 36 | { 37 | template 38 | inline void deinterleave(SSE::float_v &, SSE::float_v &, const float *, A); 39 | template 40 | inline void deinterleave(SSE::float_v &, SSE::float_v &, const short *, A); 41 | template 42 | inline void deinterleave(SSE::float_v &, SSE::float_v &, const ushort *, A); 43 | template 44 | inline void deinterleave(SSE::double_v &, SSE::double_v &, const double *, A); 45 | template 46 | inline void deinterleave(SSE::int_v &, SSE::int_v &, const int *, A); 47 | template 48 | inline void deinterleave(SSE::int_v &, SSE::int_v &, const short *, A); 49 | template 50 | inline void deinterleave(SSE::uint_v &, SSE::uint_v &, const uint *, A); 51 | template 52 | inline void deinterleave(SSE::uint_v &, SSE::uint_v &, const ushort *, A); 53 | template 54 | inline void deinterleave(SSE::short_v &, SSE::short_v &, const short *, A); 55 | template 56 | inline void deinterleave(SSE::ushort_v &, SSE::ushort_v &, const ushort *, A); 57 | 58 | Vc_ALWAYS_INLINE_L void prefetchForOneRead(const void *addr, VectorAbi::Sse) Vc_ALWAYS_INLINE_R; 59 | Vc_ALWAYS_INLINE_L void prefetchForModify(const void *addr, VectorAbi::Sse) Vc_ALWAYS_INLINE_R; 60 | Vc_ALWAYS_INLINE_L void prefetchClose(const void *addr, VectorAbi::Sse) Vc_ALWAYS_INLINE_R; 61 | Vc_ALWAYS_INLINE_L void prefetchMid(const void *addr, VectorAbi::Sse) Vc_ALWAYS_INLINE_R; 62 | Vc_ALWAYS_INLINE_L void prefetchFar(const void *addr, VectorAbi::Sse) Vc_ALWAYS_INLINE_R; 63 | } // namespace Detail 64 | } // namespace Vc 65 | 66 | #include "deinterleave.tcc" 67 | #include "prefetches.tcc" 68 | 69 | #endif // VC_SSE_DEINTERLEAVE_H_ 70 | -------------------------------------------------------------------------------- /Vc/sse/macros.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "../common/macros.h" 29 | 30 | #ifndef VC_SSE_MACROS_H_ 31 | #define VC_SSE_MACROS_H_ 32 | 33 | #if defined(Vc_IMPL_SSE4_1) && !defined(Vc_DISABLE_PTEST) 34 | #define Vc_USE_PTEST 35 | #endif 36 | 37 | #endif // VC_SSE_MACROS_H_ 38 | -------------------------------------------------------------------------------- /Vc/sse/prefetches.tcc: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2010-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_SSE_PREFETCHES_TCC_ 29 | #define VC_SSE_PREFETCHES_TCC_ 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | namespace Detail 34 | { 35 | Vc_ALWAYS_INLINE void prefetchForOneRead(const void *addr, VectorAbi::Sse) 36 | { 37 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_NTA); 38 | } 39 | Vc_ALWAYS_INLINE void prefetchClose(const void *addr, VectorAbi::Sse) 40 | { 41 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_T0); 42 | } 43 | Vc_ALWAYS_INLINE void prefetchMid(const void *addr, VectorAbi::Sse) 44 | { 45 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_T1); 46 | } 47 | Vc_ALWAYS_INLINE void prefetchFar(const void *addr, VectorAbi::Sse) 48 | { 49 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_T2); 50 | } 51 | Vc_ALWAYS_INLINE void prefetchForModify(const void *addr, VectorAbi::Sse) 52 | { 53 | #ifdef __3dNOW__ 54 | _m_prefetchw(const_cast(addr)); 55 | #else 56 | _mm_prefetch(static_cast(const_cast(addr)), _MM_HINT_T0); 57 | #endif 58 | } 59 | } // namespace Detail 60 | } // namespace Vc 61 | 62 | #endif // VC_SSE_PREFETCHES_TCC_ 63 | -------------------------------------------------------------------------------- /Vc/sse/simd_cast_caller.tcc: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef Vc_SSE_SIMD_CAST_CALLER_TCC_ 29 | #define Vc_SSE_SIMD_CAST_CALLER_TCC_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | #if Vc_IS_VERSION_1 36 | template 37 | template 38 | Vc_INTRINSIC Mask::Mask(U &&rhs, Common::enable_if_mask_converts_explicitly) 39 | : Mask(Vc::simd_cast(std::forward(rhs))) 40 | { 41 | } 42 | #endif 43 | } 44 | 45 | #endif // Vc_SSE_SIMD_CAST_CALLER_TCC_ 46 | 47 | // vim: foldmethod=marker 48 | -------------------------------------------------------------------------------- /Vc/sse/type_traits.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_SSE_TYPE_TRAITS_H_ 29 | #define VC_SSE_TYPE_TRAITS_H_ 30 | 31 | #include "macros.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace SSE 36 | { 37 | namespace Traits 38 | { 39 | template struct is_vector : public std::false_type {}; 40 | template struct is_vector> : public std::true_type {}; 41 | 42 | template struct is_mask : public std::false_type {}; 43 | template struct is_mask> : public std::true_type {}; 44 | } // namespace Traits 45 | } // namespace SSE 46 | } // namespace Vc 47 | 48 | #endif // VC_SSE_TYPE_TRAITS_H_ 49 | 50 | // vim: foldmethod=marker 51 | -------------------------------------------------------------------------------- /Vc/sse/types.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "../scalar/types.h" 29 | 30 | #ifndef VC_SSE_TYPES_H_ 31 | #define VC_SSE_TYPES_H_ 32 | 33 | #ifdef Vc_DEFAULT_IMPL_SSE 34 | #define Vc_DOUBLE_V_SIZE 2 35 | #define Vc_FLOAT_V_SIZE 4 36 | #define Vc_INT_V_SIZE 4 37 | #define Vc_UINT_V_SIZE 4 38 | #define Vc_SHORT_V_SIZE 8 39 | #define Vc_USHORT_V_SIZE 8 40 | #endif 41 | 42 | namespace Vc_VERSIONED_NAMESPACE 43 | { 44 | namespace SSE 45 | { 46 | template using Vector = Vc::Vector; 47 | typedef Vector double_v; 48 | typedef Vector float_v; 49 | typedef Vector int_v; 50 | typedef Vector uint_v; 51 | typedef Vector short_v; 52 | typedef Vector ushort_v; 53 | 54 | template using Mask = Vc::Mask; 55 | typedef Mask double_m; 56 | typedef Mask float_m; 57 | typedef Mask int_m; 58 | typedef Mask uint_m; 59 | typedef Mask short_m; 60 | typedef Mask ushort_m; 61 | 62 | template struct Const; 63 | 64 | template struct is_vector : public std::false_type {}; 65 | template struct is_vector> : public std::true_type {}; 66 | template struct is_mask : public std::false_type {}; 67 | template struct is_mask> : public std::true_type {}; 68 | } // namespace SSE 69 | 70 | namespace Traits 71 | { 72 | template struct 73 | is_simd_vector_internal> 74 | : public is_valid_vector_argument {}; 75 | 76 | template struct is_simd_mask_internal> 77 | : public std::true_type {}; 78 | } // namespace Traits 79 | } // namespace Vc 80 | 81 | #endif // VC_SSE_TYPES_H_ 82 | -------------------------------------------------------------------------------- /Vc/sse/vectorhelper.tcc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcDevel/Vc/8f862ab10d5ae99cc156ec625893fecb0870bf05/Vc/sse/vectorhelper.tcc -------------------------------------------------------------------------------- /Vc/traits/decay.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_DECAY_H_ 29 | #define VC_TRAITS_DECAY_H_ 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | namespace Traits 34 | { 35 | template using decay = typename std::decay::type; 36 | } // namespace Traits 37 | } // namespace Vc 38 | 39 | #endif // VC_TRAITS_DECAY_H_ 40 | 41 | // vim: foldmethod=marker 42 | -------------------------------------------------------------------------------- /Vc/traits/entry_type_of.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_ENTRY_TYPE_OF_H_ 29 | #define VC_TRAITS_ENTRY_TYPE_OF_H_ 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | namespace Traits 34 | { 35 | namespace entry_type_of_internal 36 | { 37 | template ::value> struct entry_type; 38 | 39 | template struct entry_type 40 | { 41 | using type = typename decay::EntryType; 42 | }; 43 | 44 | template struct entry_type 45 | { 46 | using type = typename std::remove_cv::type>::type; 47 | }; 48 | } // namespace entry_type_of_internal 49 | 50 | /** 51 | * Resolves to T::EntryType if \p T is a SIMD type, otherwise it resolves to \p T itself. 52 | */ 53 | template using entry_type_of = typename entry_type_of_internal::entry_type::type; 54 | 55 | } // namespace Traits 56 | } // namespace Vc_VERSIONED_NAMESPACE 57 | 58 | #endif // VC_TRAITS_ENTRY_TYPE_OF_H_ 59 | 60 | // vim: foldmethod=marker 61 | -------------------------------------------------------------------------------- /Vc/traits/has_addition_operator.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_HAS_ADDITION_OPERATOR_H_ 29 | #define VC_TRAITS_HAS_ADDITION_OPERATOR_H_ 30 | 31 | namespace has_addition_operator_impl 32 | { 33 | 34 | template () + std::declval())> std::true_type test(int); 35 | template std::false_type test(...); 36 | 37 | } // namespace has_addition_operator_impl 38 | 39 | template 40 | struct has_addition_operator : public decltype(has_addition_operator_impl::test(1)) 41 | { 42 | }; 43 | 44 | #endif // VC_TRAITS_HAS_ADDITION_OPERATOR_H_ 45 | -------------------------------------------------------------------------------- /Vc/traits/has_equality_operator.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_HAS_EQUALITY_OPERATOR_H_ 29 | #define VC_TRAITS_HAS_EQUALITY_OPERATOR_H_ 30 | 31 | namespace has_equality_operator_impl 32 | { 33 | 34 | template () == std::declval())>::value>> 36 | std::true_type test(int); 37 | template std::false_type test(...); 38 | 39 | } // namespace has_equality_operator_impl 40 | 41 | template 42 | struct has_equality_operator : public decltype(has_equality_operator_impl::test(1)) 43 | { 44 | }; 45 | 46 | #endif // VC_TRAITS_HAS_EQUALITY_OPERATOR_H_ 47 | -------------------------------------------------------------------------------- /Vc/traits/has_multiply_operator.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_HAS_MULTIPLY_OPERATOR_H_ 29 | #define VC_TRAITS_HAS_MULTIPLY_OPERATOR_H_ 30 | 31 | namespace has_multiply_operator_impl 32 | { 33 | 34 | template () * std::declval())> std::true_type test(int); 35 | template std::false_type test(...); 36 | 37 | } // namespace has_multiply_operator_impl 38 | 39 | template 40 | struct has_multiply_operator : public decltype(has_multiply_operator_impl::test(1)) 41 | { 42 | }; 43 | 44 | #endif // VC_TRAITS_HAS_MULTIPLY_OPERATOR_H_ 45 | -------------------------------------------------------------------------------- /Vc/traits/has_no_allocated_data.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_HAS_NO_ALLOCATED_DATA_H_ 29 | #define VC_TRAITS_HAS_NO_ALLOCATED_DATA_H_ 30 | 31 | #include 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Traits 36 | { 37 | 38 | /** 39 | * Implements the has_no_allocated_data trait. 40 | * 41 | * Specialize this type for your container class if you need to make it usable with SIMD 42 | * gathers/scatters. Example: 43 | * \code 44 | * namespace Vc 45 | * { 46 | * namespace Traits 47 | * { 48 | * template struct has_no_allocated_data_impl> : public std::true_type {}; 49 | * } 50 | * } 51 | * \endcode 52 | * 53 | * \see has_no_allocated_data 54 | */ 55 | template struct has_no_allocated_data_impl : public std::false_type {}; 56 | 57 | /** 58 | * Type trait that tells whether a container stores its data inside the object or inside allocated 59 | * memory outside of the object. 60 | * 61 | * Per default the trait assumes any type to store its data outside, on the heap. The only types 62 | * where it knows that the storage is inside the object are std::array, Vc::array, and T[] (builtin 63 | * arrays). 64 | * 65 | * The trait forwards the actual decision to has_no_allocated_data_impl, but removes const/volatile 66 | * and references from the type \p T to make the number of required specializations of 67 | * has_no_allocated_data_impl minimal. 68 | */ 69 | template 70 | struct has_no_allocated_data 71 | : public has_no_allocated_data_impl< 72 | typename std::remove_cv::type>::type> 73 | { 74 | }; 75 | 76 | // spezializations: 77 | template struct has_no_allocated_data_impl> : public std::true_type {}; 78 | template struct has_no_allocated_data_impl : public std::true_type {}; 79 | template struct has_no_allocated_data_impl : public std::true_type {}; 80 | } // namespace Traits 81 | } // namespace Vc 82 | 83 | #endif // VC_TRAITS_HAS_NO_ALLOCATED_DATA_H_ 84 | -------------------------------------------------------------------------------- /Vc/traits/has_subscript_operator.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_HAS_SUBSCRIPT_OPERATOR_H_ 29 | #define VC_TRAITS_HAS_SUBSCRIPT_OPERATOR_H_ 30 | 31 | namespace has_subscript_operator_impl 32 | { 33 | 34 | template ()[std::declval()])> std::true_type test(int); 35 | template std::false_type test(float); 36 | 37 | } // namespace has_subscript_operator_impl 38 | 39 | template 40 | struct has_subscript_operator : public decltype(has_subscript_operator_impl::test(1)) 41 | { 42 | }; 43 | 44 | #endif // VC_TRAITS_HAS_SUBSCRIPT_OPERATOR_H_ 45 | -------------------------------------------------------------------------------- /Vc/traits/is_implicit_cast_allowed.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_IS_IMPLICIT_CAST_ALLOWED_H_ 29 | #define VC_TRAITS_IS_IMPLICIT_CAST_ALLOWED_H_ 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | namespace Traits 34 | { 35 | template ::value> 36 | struct is_implicit_cast_allowed 37 | : public std::integral_constant< 38 | bool, std::is_same::value || 39 | (std::is_integral::value && 40 | (std::is_same::type, To>::value || 41 | std::is_same::type, To>::value))> { 42 | }; 43 | 44 | template 45 | struct is_implicit_cast_allowed : public std::is_same::type { 46 | }; 47 | 48 | template 49 | struct is_implicit_cast_allowed_mask : public is_implicit_cast_allowed { 50 | }; 51 | } // namespace Traits 52 | } // namespace Vc 53 | 54 | #endif // VC_TRAITS_IS_IMPLICIT_CAST_ALLOWED_H_ 55 | 56 | // vim: foldmethod=marker 57 | -------------------------------------------------------------------------------- /Vc/traits/is_index_sequence.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_IS_INDEX_SEQUENCE_H_ 29 | #define VC_IS_INDEX_SEQUENCE_H_ 30 | 31 | #include "../common/indexsequence.h" 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Traits 36 | { 37 | 38 | template struct is_index_sequence : public std::false_type {}; 39 | template 40 | struct is_index_sequence> : public std::true_type {}; 41 | 42 | static_assert(!is_index_sequence::value, ""); 43 | static_assert(is_index_sequence>::value, ""); 44 | 45 | } // namespace Traits 46 | } // namespace Vc 47 | 48 | #endif // VC_IS_INDEX_SEQUENCE_H_ 49 | 50 | // vim: foldmethod=marker 51 | -------------------------------------------------------------------------------- /Vc/traits/is_output_iterator.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TRAITS_IS_OUTPUT_ITERATOR_H_ 29 | #define VC_TRAITS_IS_OUTPUT_ITERATOR_H_ 30 | 31 | #include 32 | 33 | namespace Vc_VERSIONED_NAMESPACE 34 | { 35 | namespace Traits 36 | { 37 | namespace is_output_iterator_impl 38 | { 39 | template ::value_type, 40 | typename = decltype(*std::declval() = std::declval< 41 | ValueType>()) // tests that assignment to a 42 | // dereferenced iterator is possible, if 43 | // yes, T is an OutputIterator 44 | > 45 | std::true_type test(int); 46 | template std::false_type test(...); 47 | } // namespace is_output_iterator_impl 48 | 49 | template 50 | struct is_output_iterator 51 | : public std::conditional< 52 | std::is_void::value_type>::value, 53 | std::true_type, decltype(is_output_iterator_impl::test(int()))>::type 54 | { 55 | }; 56 | 57 | static_assert(!std::is_void::value_type>::value, ""); 58 | static_assert(is_output_iterator::value, ""); 59 | static_assert(!is_output_iterator::value, ""); 60 | 61 | } // namespace Traits 62 | } // namespace Vc 63 | 64 | #endif // VC_TRAITS_IS_OUTPUT_ITERATOR_H_ 65 | 66 | // vim: foldmethod=marker 67 | -------------------------------------------------------------------------------- /Vc/type_traits: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2013-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TYPE_TRAITS_ 29 | #define VC_TYPE_TRAITS_ 30 | 31 | #include 32 | 33 | #include "traits/type_traits.h" 34 | #include "common/macros.h" 35 | namespace Vc_VERSIONED_NAMESPACE 36 | { 37 | using Traits::is_simd_mask; 38 | using Traits::is_simd_vector; 39 | using Traits::is_integral; 40 | using Traits::is_floating_point; 41 | using Traits::is_arithmetic; 42 | using Traits::is_signed; 43 | using Traits::is_unsigned; 44 | 45 | template 46 | struct memory_alignment : public std::integral_constant {}; 47 | 48 | template<> struct memory_alignment : public std::integral_constant {}; 49 | template<> struct memory_alignment : public std::integral_constant {}; 50 | 51 | } 52 | 53 | #endif // VC_TYPE_TRAITS_ 54 | 55 | // vim: ft=cpp foldmethod=marker 56 | -------------------------------------------------------------------------------- /Vc/vector: -------------------------------------------------------------------------------- 1 | /*{{{ 2 | Copyright © 2013 Matthias Kretz 3 | 4 | Permission to use, copy, modify, and distribute this software 5 | and its documentation for any purpose and without fee is hereby 6 | granted, provided that the above copyright notice appear in all 7 | copies and that both that the copyright notice and this 8 | permission notice and warranty disclaimer appear in supporting 9 | documentation, and that the name of the author not be used in 10 | advertising or publicity pertaining to distribution of the 11 | software without specific, written prior permission. 12 | 13 | The author disclaim all warranties with regard to this 14 | software, including all implied warranties of merchantability 15 | and fitness. In no event shall the author be liable for any 16 | special, indirect or consequential damages or any damages 17 | whatsoever resulting from loss of use, data or profits, whether 18 | in an action of contract, negligence or other tortious action, 19 | arising out of or in connection with the use or performance of 20 | this software. 21 | 22 | }}}*/ 23 | 24 | #ifndef VC_VECTOR_ 25 | #define VC_VECTOR_ 26 | 27 | #include "common/subscript.h" 28 | #include 29 | 30 | namespace Vc_VERSIONED_NAMESPACE 31 | { 32 | /** 33 | * \ingroup Containers 34 | * \headerfile vector 35 | * 36 | * An adapted `std::vector` container with an additional subscript operator which 37 | * implements gather and scatter operations. 38 | * 39 | * The [std::vector](https://en.cppreference.com/w/cpp/container/vector) documentation applies. 40 | * 41 | * Example: 42 | * \code 43 | * struct Point { 44 | * float x, y; 45 | * }; 46 | * Vc::vector data; 47 | * data.resize(100); 48 | * // initialize values in data 49 | * float_v::IndexType indexes = ...; // values between 0-99 50 | * float_v x = data[indexes][&Point::x]; 51 | * float_v y = data[indexes][&Point::y]; 52 | * \endcode 53 | */ 54 | template > 55 | using vector = Common::AdaptSubscriptOperator>; 56 | 57 | namespace Traits 58 | { 59 | template 60 | struct has_contiguous_storage_impl> : public std::true_type {}; 61 | } // namespace Traits 62 | 63 | } // namespace 64 | 65 | #endif // VC_VECTOR_ 66 | // vim: ft=cpp 67 | -------------------------------------------------------------------------------- /changeVersion.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "`dirname "$0"`" 4 | 5 | # Read version number 6 | eval `awk '/Vc_VERSION_NUMBER 0x[0-9]+/ { h=$3 } 7 | END { 8 | major=strtonum(substr(h, 1, 4)) 9 | minor=strtonum("0x" substr(h, 5, 2)) 10 | patch=strtonum("0x" substr(h, 7, 2)) / 2 11 | printf "oldVersion=\"%d.%d.%d\"\n", major, minor, patch 12 | printf "newVersion=\"%d.%d.%d\"\n", major, minor, patch + 1 13 | }' include/Vc/version.h` 14 | echo "current version: $oldVersion" 15 | echo -n " new version: " 16 | read -e -i "$newVersion" newVersion 17 | 18 | versionString="$newVersion-dev" 19 | versionNumber=`echo $newVersion | awk '{ split($0, v, "."); printf "0x%02x%02x%02x", v[1], v[2], v[3] * 2 }'` 20 | versionNumber=`echo $versionNumber | awk '{ printf "0x%06x", (strtonum($0) + 1) }'` 21 | 22 | sed -i "s/^PROJECT_NUMBER = .*\$/PROJECT_NUMBER = $versionString/" doc/Doxyfile 23 | sed -i \ 24 | -e "s/Vc_VERSION_STRING \".*\"\$/Vc_VERSION_STRING \"$versionString\"/" \ 25 | -e "s/Vc_VERSION_NUMBER 0x.*\$/Vc_VERSION_NUMBER $versionNumber/" \ 26 | include/Vc/version.h 27 | -------------------------------------------------------------------------------- /cmake/AddTargetProperty.cmake: -------------------------------------------------------------------------------- 1 | #============================================================================= 2 | # Copyright 2010-2015 Matthias Kretz 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright notice, 9 | # this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above copyright notice, 11 | # this list of conditions and the following disclaimer in the documentation 12 | # and/or other materials provided with the distribution. 13 | # * Neither the names of contributing organizations nor the 14 | # names of its contributors may be used to endorse or promote products 15 | # derived from this software without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' 18 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR 21 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | #============================================================================= 28 | 29 | macro(add_target_property _target _prop _value) 30 | get_target_property(_oldprop "${_target}" ${_prop}) 31 | if(NOT _oldprop) 32 | set_target_properties("${_target}" PROPERTIES ${_prop} "${_value}") 33 | else(NOT _oldprop) 34 | set_target_properties("${_target}" PROPERTIES ${_prop} "${_oldprop} ${_value}") 35 | endif(NOT _oldprop) 36 | endmacro(add_target_property) 37 | -------------------------------------------------------------------------------- /cmake/FindVc.cmake: -------------------------------------------------------------------------------- 1 | # Locate the Vc template library. Vc can be found at https://github.com/VcDevel/Vc 2 | # 3 | # This file is meant to be copied into projects that want to use Vc. It will 4 | # search for VcConfig.cmake, which ships with Vc and will provide up-to-date 5 | # buildsystem changes. Thus there should not be any need to update FindVc.cmake 6 | # again after you integrated it into your project. 7 | # 8 | # This module defines the following variables: 9 | # Vc_FOUND 10 | # Vc_INCLUDE_DIR 11 | # Vc_LIBRARIES 12 | # Vc_DEFINITIONS 13 | # Vc_COMPILE_FLAGS 14 | # Vc_ARCHITECTURE_FLAGS 15 | # Vc_ALL_FLAGS (the union of the above three variables) 16 | # Vc_VERSION_MAJOR 17 | # Vc_VERSION_MINOR 18 | # Vc_VERSION_PATCH 19 | # Vc_VERSION 20 | # Vc_VERSION_STRING 21 | # Vc_INSTALL_DIR 22 | # Vc_LIB_DIR 23 | # Vc_CMAKE_MODULES_DIR 24 | # 25 | # The following two variables are set according to the compiler used. Feel free 26 | # to use them to skip whole compilation units. 27 | # Vc_SSE_INTRINSICS_BROKEN 28 | # Vc_AVX_INTRINSICS_BROKEN 29 | # 30 | #============================================================================= 31 | # Copyright 2009-2015 Matthias Kretz 32 | # 33 | # Redistribution and use in source and binary forms, with or without 34 | # modification, are permitted provided that the following conditions are 35 | # met: 36 | # 37 | # * Redistributions of source code must retain the above copyright notice, 38 | # this list of conditions and the following disclaimer. 39 | # * Redistributions in binary form must reproduce the above copyright notice, 40 | # this list of conditions and the following disclaimer in the documentation 41 | # and/or other materials provided with the distribution. 42 | # * Neither the names of contributing organizations nor the 43 | # names of its contributors may be used to endorse or promote products 44 | # derived from this software without specific prior written permission. 45 | # 46 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' 47 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 48 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 49 | # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR 50 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 51 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 52 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 53 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 54 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 55 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56 | #============================================================================= 57 | 58 | find_package(Vc ${Vc_FIND_VERSION} QUIET NO_MODULE PATHS $ENV{HOME} /opt/Vc) 59 | 60 | include(FindPackageHandleStandardArgs) 61 | find_package_handle_standard_args(Vc CONFIG_MODE) 62 | -------------------------------------------------------------------------------- /cmake/UserWarning.cmake: -------------------------------------------------------------------------------- 1 | macro(UserWarning _msg) 2 | if("$ENV{DASHBOARD_TEST_FROM_CTEST}" STREQUAL "") 3 | # developer (non-dashboard) build 4 | message(WARNING "${_msg}") 5 | else() 6 | # dashboard build 7 | message(STATUS "${_msg}") 8 | endif() 9 | endmacro() 10 | -------------------------------------------------------------------------------- /cmake/VcConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | ### General variables for project discovery/inspection 4 | set_and_check(@PROJECT_NAME@_INSTALL_DIR @PACKAGE_CMAKE_INSTALL_PREFIX@) 5 | set_and_check(@PROJECT_NAME@_INCLUDE_DIR @PACKAGE_CMAKE_INSTALL_PREFIX@/include) 6 | set_and_check(@PROJECT_NAME@_LIB_DIR @PACKAGE_CMAKE_INSTALL_PREFIX@/lib@LIB_SUFFIX@) 7 | set_and_check(@PROJECT_NAME@_CMAKE_MODULES_DIR ${@PROJECT_NAME@_LIB_DIR}/cmake/Vc) 8 | set(@PROJECT_NAME@_VERSION_STRING "@PROJECT_VERSION@") 9 | 10 | ### Setup @PROJECT_NAME@ defaults 11 | list(APPEND CMAKE_MODULE_PATH "${@PROJECT_NAME@_CMAKE_MODULES_DIR}") 12 | include("${@PROJECT_NAME@_CMAKE_MODULES_DIR}/VcMacros.cmake") 13 | 14 | set(@PROJECT_NAME@_DEFINITIONS) 15 | set(@PROJECT_NAME@_COMPILE_FLAGS) 16 | set(@PROJECT_NAME@_ARCHITECTURE_FLAGS) 17 | vc_set_preferred_compiler_flags() 18 | separate_arguments(@PROJECT_NAME@_ALL_FLAGS UNIX_COMMAND "${@PROJECT_NAME@_DEFINITIONS}") 19 | list(APPEND @PROJECT_NAME@_ALL_FLAGS ${@PROJECT_NAME@_COMPILE_FLAGS}) 20 | list(APPEND @PROJECT_NAME@_ALL_FLAGS ${@PROJECT_NAME@_ARCHITECTURE_FLAGS}) 21 | 22 | ### Import targets 23 | include("@PACKAGE_CMAKE_INSTALL_PREFIX@/@PACKAGE_INSTALL_DESTINATION@/@PROJECT_NAME@Targets.cmake") 24 | 25 | ### Define @PROJECT_NAME@_LIBRARIES for backwards compatibility 26 | get_target_property(vc_lib_location @PROJECT_NAME@::Vc INTERFACE_LOCATION) 27 | set_and_check(@PROJECT_NAME@_LIBRARIES ${vc_lib_location}) 28 | 29 | ### Handle required components - not used 30 | check_required_components(@PROJECT_NAME@) 31 | -------------------------------------------------------------------------------- /cmake/toolchain-arm-linux-gnueabi-gcc.cmake: -------------------------------------------------------------------------------- 1 | SET(CMAKE_SYSTEM_NAME Linux) 2 | SET(CMAKE_SYSTEM_PROCESSOR arm) 3 | -------------------------------------------------------------------------------- /cmake/toolchain-arm-linux.cmake: -------------------------------------------------------------------------------- 1 | SET(CMAKE_SYSTEM_NAME Linux) 2 | SET(CMAKE_SYSTEM_PROCESSOR arm) 3 | -------------------------------------------------------------------------------- /configure-icc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | CXX=icpc CC=icc cmake -DCMAKE_BUILD_TYPE=Release "`dirname $0`" 3 | -------------------------------------------------------------------------------- /doc/dox-real-ops.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2011-2014 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | /** 29 | * Check the sign bit of each vector entry. 30 | * 31 | * \return whether the sign bit is set. 32 | * 33 | * This function is especially useful to distinguish negative zero. 34 | * \code 35 | * float_v z = float_v::Zero(); // z.isNegative() will be m[0000], z < float_v::Zero() will be m[0000] 36 | * float_v nz = -0.f; // nz.isNegative() will be m[1111], nz < float_v::Zero() will be m[0000] 37 | * float_v n = -1.f; // n.isNegative() will be m[1111], n < float_v::Zero() will be m[1111] 38 | * \endcode 39 | */ 40 | inline MASK_TYPE isNegative() const; 41 | -------------------------------------------------------------------------------- /doc/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcDevel/Vc/8f862ab10d5ae99cc156ec625893fecb0870bf05/doc/logo.png -------------------------------------------------------------------------------- /doc/logo_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcDevel/Vc/8f862ab10d5ae99cc156ec625893fecb0870bf05/doc/logo_small.png -------------------------------------------------------------------------------- /doc/polarcoord-cartesian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcDevel/Vc/8f862ab10d5ae99cc156ec625893fecb0870bf05/doc/polarcoord-cartesian.png -------------------------------------------------------------------------------- /doc/polarcoord-polar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VcDevel/Vc/8f862ab10d5ae99cc156ec625893fecb0870bf05/doc/polarcoord-polar.png -------------------------------------------------------------------------------- /doc/qhelpgenerator-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | output="`qhelpgenerator "$@" 2>&1`" 3 | errors="`echo "$output"|grep "Error in line .*: Opening and ending tag mismatch."`" 4 | if echo "$1"|grep -q '\.qhp'; then 5 | file="$1" 6 | elif echo "$2"|grep -q '\.qhp'; then 7 | file="$2" 8 | elif echo "$3"|grep -q '\.qhp'; then 9 | file="$3" 10 | fi 11 | while test -n "$errors"; do 12 | for i in `echo "$errors"|tac|sed 's/^.* \([0-9]\+\):.*$/\1/'`; do 13 | sed -i "${i}d" "$file" 14 | done 15 | output="`qhelpgenerator "$@" 2>&1`" 16 | errors="`echo "$output"|grep "Error in line .*: Opening and ending tag mismatch."`" 17 | done 18 | echo "$output" 19 | -------------------------------------------------------------------------------- /examples/buddhabrot/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(QT4_FOUND AND QT4_USABLE) 2 | include(${QT_USE_FILE}) 3 | 4 | build_example(buddhabrot main.cpp LIBS ${QT_LIBRARIES}) 5 | 6 | # Special -DScalar target that uses fundamental types directly 7 | add_executable(example_buddhabrot_scalar2 main.cpp) 8 | add_target_property(example_buddhabrot_scalar2 COMPILE_DEFINITIONS "Scalar") 9 | set_property(TARGET example_buddhabrot_scalar2 APPEND PROPERTY COMPILE_OPTIONS ${Vc_ARCHITECTURE_FLAGS}) 10 | add_target_property(example_buddhabrot_scalar2 LABELS "Scalar") 11 | add_dependencies(Scalar example_buddhabrot_scalar2) 12 | add_dependencies(Examples example_buddhabrot_scalar2) 13 | target_link_libraries(example_buddhabrot_scalar2 Vc ${QT_LIBRARIES}) 14 | vc_add_run_target(example_buddhabrot_scalar2) 15 | endif() 16 | -------------------------------------------------------------------------------- /examples/buddhabrot/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2010-2011 Matthias Kretz 3 | 4 | Permission to use, copy, modify, and distribute this software 5 | and its documentation for any purpose and without fee is hereby 6 | granted, provided that the above copyright notice appear in all 7 | copies and that both that the copyright notice and this 8 | permission notice and warranty disclaimer appear in supporting 9 | documentation, and that the name of the author not be used in 10 | advertising or publicity pertaining to distribution of the 11 | software without specific, written prior permission. 12 | 13 | The author disclaim all warranties with regard to this 14 | software, including all implied warranties of merchantability 15 | and fitness. In no event shall the author be liable for any 16 | special, indirect or consequential damages or any damages 17 | whatsoever resulting from loss of use, data or profits, whether 18 | in an action of contract, negligence or other tortious action, 19 | arising out of or in connection with the use or performance of 20 | this software. 21 | 22 | */ 23 | 24 | #ifndef MAIN_H 25 | #define MAIN_H 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class ProgressWriter 33 | { 34 | public: 35 | ProgressWriter(); 36 | void setValue(float v); 37 | void done(); 38 | 39 | private: 40 | QTextStream m_out; 41 | }; 42 | 43 | class Baker 44 | { 45 | public: 46 | struct Options 47 | { 48 | int red[2]; 49 | int green[2]; 50 | int blue[2]; 51 | int steps[2]; 52 | int it[2]; 53 | Options(); 54 | }; 55 | 56 | Baker(); 57 | void setOptions(Options o) { m_opt = o; } 58 | void setSize(int w, int h); 59 | void setFilename(const QString &); 60 | void createImage(); 61 | 62 | private: 63 | Options m_opt; 64 | float m_x; // left 65 | float m_y; // top 66 | float m_width; 67 | float m_height; 68 | QImage m_image; 69 | QString m_filename; 70 | ProgressWriter m_progress; 71 | }; 72 | #endif // MAIN_H 73 | -------------------------------------------------------------------------------- /examples/cpuid/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(Vc_X86) 2 | add_executable(cpuid main.cpp) 3 | target_link_libraries(cpuid Vc) 4 | endif() 5 | -------------------------------------------------------------------------------- /examples/finitediff/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | build_example(finitediff main.cpp DISABLE Scalar) 2 | -------------------------------------------------------------------------------- /examples/linear_find/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | build_example(linear_find main.cpp) 2 | -------------------------------------------------------------------------------- /examples/mandelbrot/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(QT4_FOUND AND QT4_USABLE) 2 | include(${QT_USE_FILE}) 3 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) 4 | qt4_generate_moc(main.h moc_main.cpp) 5 | qt4_generate_moc(mandel.h moc_mandel.cpp) 6 | 7 | set(SOURCES main.cpp ${CMAKE_CURRENT_BINARY_DIR}/moc_main.cpp mandel.cpp 8 | ${CMAKE_CURRENT_BINARY_DIR}/moc_mandel.cpp) 9 | 10 | build_example(mandelbrot ${SOURCES} LIBS ${QT_LIBRARIES}) 11 | endif() 12 | -------------------------------------------------------------------------------- /examples/mandelbrot/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2010 Matthias Kretz 3 | 4 | Permission to use, copy, modify, and distribute this software 5 | and its documentation for any purpose and without fee is hereby 6 | granted, provided that the above copyright notice appear in all 7 | copies and that both that the copyright notice and this 8 | permission notice and warranty disclaimer appear in supporting 9 | documentation, and that the name of the author not be used in 10 | advertising or publicity pertaining to distribution of the 11 | software without specific, written prior permission. 12 | 13 | The author disclaim all warranties with regard to this 14 | software, including all implied warranties of merchantability 15 | and fitness. In no event shall the author be liable for any 16 | special, indirect or consequential damages or any damages 17 | whatsoever resulting from loss of use, data or profits, whether 18 | in an action of contract, negligence or other tortious action, 19 | arising out of or in connection with the use or performance of 20 | this software. 21 | 22 | */ 23 | 24 | #ifndef MAIN_H 25 | #define MAIN_H 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include "mandel.h" 35 | 36 | class MainWindow : public QWidget 37 | { 38 | Q_OBJECT 39 | public: 40 | MainWindow(QWidget *parent = 0); 41 | 42 | protected: 43 | void paintEvent(QPaintEvent *); 44 | void resizeEvent(QResizeEvent *); 45 | void mousePressEvent(QMouseEvent *); 46 | void mouseMoveEvent(QMouseEvent *); 47 | void mouseReleaseEvent(QMouseEvent *); 48 | void wheelEvent(QWheelEvent *); 49 | 50 | private slots: 51 | void vcImage(const QImage &, quint64); 52 | void scalarImage(const QImage &, quint64); 53 | 54 | private: 55 | void recreateImage(); 56 | void updateTitle(); 57 | 58 | float m_x; // left 59 | float m_y; // top 60 | float m_scale; 61 | QImage m_img1; 62 | QImage m_img2; 63 | QRect m_rect1; 64 | QRect m_rect2; 65 | QPoint m_dragStart; 66 | QPoint m_dragDelta; 67 | 68 | float m_cycles1, m_cycles2; 69 | 70 | Mandel m_mandelVc; 71 | Mandel m_mandelScalar; 72 | }; 73 | #endif // MAIN_H 74 | -------------------------------------------------------------------------------- /examples/mandelbrot/mandel.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2010 Matthias Kretz 3 | 4 | Permission to use, copy, modify, and distribute this software 5 | and its documentation for any purpose and without fee is hereby 6 | granted, provided that the above copyright notice appear in all 7 | copies and that both that the copyright notice and this 8 | permission notice and warranty disclaimer appear in supporting 9 | documentation, and that the name of the author not be used in 10 | advertising or publicity pertaining to distribution of the 11 | software without specific, written prior permission. 12 | 13 | The author disclaim all warranties with regard to this 14 | software, including all implied warranties of merchantability 15 | and fitness. In no event shall the author be liable for any 16 | special, indirect or consequential damages or any damages 17 | whatsoever resulting from loss of use, data or profits, whether 18 | in an action of contract, negligence or other tortious action, 19 | arising out of or in connection with the use or performance of 20 | this software. 21 | 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | enum MandelImpl { 32 | VcImpl, ScalarImpl 33 | }; 34 | 35 | class MandelBase : public QThread 36 | { 37 | Q_OBJECT 38 | public: 39 | void brot(const QSize &size, float x, float y, float scale); 40 | 41 | protected: 42 | MandelBase(QObject* _parent = 0); 43 | ~MandelBase(); 44 | void emitImage(const QImage &image, quint64 cycles) { emit ready(image, cycles); } 45 | 46 | void run(); 47 | virtual void mandelMe(QImage &image, float x, float y, float scale, int maxIterations) = 0; 48 | inline bool restart() const { return m_restart; } 49 | 50 | signals: 51 | void ready(const QImage &image, quint64 cycles); 52 | 53 | private: 54 | QMutex m_mutex; 55 | QWaitCondition m_wait; 56 | QSize m_size; 57 | float m_x, m_y, m_scale; 58 | bool m_restart; 59 | bool m_abort; 60 | }; 61 | 62 | template 63 | class Mandel : public MandelBase 64 | { 65 | public: 66 | Mandel(QObject *_parent = 0); 67 | 68 | protected: 69 | void mandelMe(QImage &image, float x, float y, float scale, int maxIterations); 70 | }; 71 | 72 | -------------------------------------------------------------------------------- /examples/matrix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | build_example(matrix main.cpp) 2 | -------------------------------------------------------------------------------- /examples/polarcoord/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | build_example(polarcoord main.cpp) 2 | -------------------------------------------------------------------------------- /examples/polarcoord/main.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. 2 | 3 | Copyright (C) 2009-2012 Matthias Kretz 4 | 5 | Permission to use, copy, modify, and distribute this software 6 | and its documentation for any purpose and without fee is hereby 7 | granted, provided that the above copyright notice appear in all 8 | copies and that both that the copyright notice and this 9 | permission notice and warranty disclaimer appear in supporting 10 | documentation, and that the name of the author not be used in 11 | advertising or publicity pertaining to distribution of the 12 | software without specific, written prior permission. 13 | 14 | The author disclaim all warranties with regard to this 15 | software, including all implied warranties of merchantability 16 | and fitness. In no event shall the author be liable for any 17 | special, indirect or consequential damages or any damages 18 | whatsoever resulting from loss of use, data or profits, whether 19 | in an action of contract, negligence or other tortious action, 20 | arising out of or in connection with the use or performance of 21 | this software. 22 | 23 | */ 24 | 25 | //! [includes] 26 | #include 27 | #include 28 | #include 29 | 30 | using Vc::float_v; 31 | //! [includes] 32 | 33 | //! [memory allocation] 34 | int Vc_CDECL main() 35 | { 36 | // allocate memory for our initial x and y coordinates. Note that you can also put it into a 37 | // normal float C-array but that you then must ensure alignment to Vc::VectorAlignment! 38 | Vc::Memory x_mem; 39 | Vc::Memory y_mem; 40 | Vc::Memory r_mem; 41 | Vc::Memory phi_mem; 42 | //! [memory allocation] 43 | 44 | //! [random init] 45 | // fill the memory with values from -1.f to 1.f 46 | for (size_t i = 0; i < x_mem.vectorsCount(); ++i) { 47 | x_mem.vector(i) = float_v::Random() * 2.f - 1.f; 48 | y_mem.vector(i) = float_v::Random() * 2.f - 1.f; 49 | } 50 | //! [random init] 51 | 52 | //! [conversion] 53 | // calculate the polar coordinates for all coordinates and overwrite the euclidian coordinates 54 | // with the result 55 | for (size_t i = 0; i < x_mem.vectorsCount(); ++i) { 56 | const float_v x = x_mem.vector(i); 57 | const float_v y = y_mem.vector(i); 58 | 59 | r_mem.vector(i) = Vc::sqrt(x * x + y * y); 60 | float_v phi = Vc::atan2(y, x) * 57.295780181884765625f; // 180/pi 61 | phi(phi < 0.f) += 360.f; 62 | phi_mem.vector(i) = phi; 63 | } 64 | //! [conversion] 65 | 66 | //! [output] 67 | // print the results 68 | for (size_t i = 0; i < x_mem.entriesCount(); ++i) { 69 | std::cout << std::setw(3) << i << ": "; 70 | std::cout << std::setw(10) << x_mem[i] << ", " << std::setw(10) << y_mem[i] << " -> "; 71 | std::cout << std::setw(10) << r_mem[i] << ", " << std::setw(10) << phi_mem[i] << '\n'; 72 | } 73 | 74 | return 0; 75 | } 76 | //! [output] 77 | -------------------------------------------------------------------------------- /examples/scaling/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | build_example(scaling main.cpp) 2 | -------------------------------------------------------------------------------- /examples/simdize/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | build_example(simdize main.cpp) 2 | -------------------------------------------------------------------------------- /examples/simdize/main.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc project 2 | Copyright (C) 2009-2020 Matthias Kretz 3 | Permission to use, copy, modify, and distribute this software 4 | and its documentation for any purpose and without fee is hereby 5 | granted, provided that the above copyright notice appear in all 6 | copies and that both that the copyright notice and this 7 | permission notice and warranty disclaimer appear in supporting 8 | documentation, and that the name of the author not be used in 9 | advertising or publicity pertaining to distribution of the 10 | software without specific, written prior permission. 11 | The author disclaim all warranties with regard to this 12 | software, including all implied warranties of merchantability 13 | and fitness. In no event shall the author be liable for any 14 | special, indirect or consequential damages or any damages 15 | whatsoever resulting from loss of use, data or profits, whether 16 | in an action of contract, negligence or other tortious action, 17 | arising out of or in connection with the use or performance of 18 | this software. 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | template struct PointTemplate { 25 | T x, y, z; 26 | 27 | Vc_SIMDIZE_INTERFACE((x, y, z)); 28 | }; 29 | 30 | using Point = PointTemplate; 31 | 32 | template class Vectorizer 33 | { 34 | public: 35 | using value_type = Vc::simdize; 36 | 37 | void append(const T &x) { decorate(data)[count++] = x; } 38 | bool isFull() const { return count == data.size(); } 39 | const value_type &contents() const { return data; } 40 | 41 | private: 42 | value_type data; 43 | std::size_t count = 0; 44 | }; 45 | 46 | int Vc_CDECL main() 47 | { 48 | Vectorizer v; 49 | float x = 0.f; 50 | while (!v.isFull()) { 51 | v.append(Point{x, x + 1, x + 2}); 52 | x += 10; 53 | } 54 | const auto &vec = v.contents(); 55 | std::cout << vec.x << '\n' << vec.y << '\n' << vec.z << '\n'; 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /examples/test_inside/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | build_example(test_inside main.cpp) 2 | -------------------------------------------------------------------------------- /examples/test_inside/main.cpp: -------------------------------------------------------------------------------- 1 | /*{{{ 2 | Copyright (C) 2013 Matthias Kretz 3 | 4 | Permission to use, copy, modify, and distribute this software 5 | and its documentation for any purpose and without fee is hereby 6 | granted, provided that the above copyright notice appear in all 7 | copies and that both that the copyright notice and this 8 | permission notice and warranty disclaimer appear in supporting 9 | documentation, and that the name of the author not be used in 10 | advertising or publicity pertaining to distribution of the 11 | software without specific, written prior permission. 12 | 13 | The author disclaim all warranties with regard to this 14 | software, including all implied warranties of merchantability 15 | and fitness. In no event shall the author be liable for any 16 | special, indirect or consequential damages or any damages 17 | whatsoever resulting from loss of use, data or profits, whether 18 | in an action of contract, negligence or other tortious action, 19 | arising out of or in connection with the use or performance of 20 | this software. 21 | 22 | }}}*/ 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | #include "../tsc.h" 30 | 31 | using Vc::double_v; 32 | using Vc::double_m; 33 | 34 | constexpr size_t ArraySize = 10240; 35 | 36 | using Point = std::array; 37 | using PointArray = std::array; 38 | 39 | static const std::array origin = {{ 0.2, 0.3, 0.4 }}; 40 | static const std::array boxsize = {{ 0.5, 0.3, 0.1 }}; 41 | 42 | double_m contains(const Point &point) 43 | { 44 | double_m inside[3]; 45 | for (int dir = 0; dir < 3; ++dir) { 46 | inside[dir] = abs(point[dir] - origin[dir]) < boxsize[dir]; 47 | } 48 | return inside[0] && inside[1] && inside[2]; 49 | } 50 | 51 | std::array contains(const PointArray &points) 52 | { 53 | std::array inside; 54 | auto storeIt = inside.begin(); 55 | for (const auto &p : points) { 56 | contains(p).store(&*storeIt); 57 | storeIt += double_v::Size; 58 | } 59 | return inside; 60 | } 61 | 62 | std::array g_inside; 63 | 64 | int Vc_CDECL main() 65 | { 66 | PointArray points; 67 | std::generate(points.begin(), points.end(), []() -> Point { 68 | return {{ double_v::Random(), double_v::Random(), double_v::Random() }}; 69 | }); 70 | 71 | TimeStampCounter tsc; 72 | tsc.start(); 73 | const auto &tmp = contains(points); 74 | tsc.stop(); 75 | g_inside = tmp; 76 | std::cout << tsc.cycles() << std::endl; 77 | 78 | return 0; 79 | } 80 | -------------------------------------------------------------------------------- /examples/tsc.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2017 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VC_TSC_H_ 29 | #define VC_TSC_H_ 30 | 31 | #ifdef _MSC_VER 32 | #include 33 | #pragma intrinsic(__rdtsc) 34 | #endif 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | class TimeStampCounter 42 | { 43 | public: 44 | void start(); 45 | void stop(); 46 | unsigned long long cycles() const; 47 | 48 | private: 49 | union Data { 50 | unsigned long long a; 51 | unsigned int b[2]; 52 | } m_start, m_end; 53 | }; 54 | 55 | inline void TimeStampCounter::start() 56 | { 57 | #if defined __MIC__ 58 | asm volatile("xor %%eax,%%eax\n\tcpuid\n\trdtsc" : "=a"(m_start.b[0]), "=d"(m_start.b[1]) :: "ebx", "ecx" ); 59 | #elif defined _MSC_VER 60 | unsigned int tmp; 61 | m_start.a = __rdtscp(&tmp); 62 | #elif defined __x86_64__ || defined __i386__ 63 | asm volatile("rdtscp" : "=a"(m_start.b[0]), "=d"(m_start.b[1]) :: "ecx" ); 64 | #else 65 | m_start = {}; 66 | #endif 67 | } 68 | 69 | inline void TimeStampCounter::stop() 70 | { 71 | #if defined __MIC__ 72 | asm volatile("xor %%eax,%%eax\n\tcpuid\n\trdtsc" : "=a"(m_end.b[0]), "=d"(m_end.b[1]) :: "ebx", "ecx" ); 73 | #elif defined _MSC_VER 74 | unsigned int tmp; 75 | m_end.a = __rdtscp(&tmp); 76 | #elif defined __x86_64__ || defined __i386__ 77 | asm volatile("rdtscp" : "=a"(m_end.b[0]), "=d"(m_end.b[1]) :: "ecx" ); 78 | #else 79 | m_end = {}; 80 | #endif 81 | } 82 | 83 | inline unsigned long long TimeStampCounter::cycles() const 84 | { 85 | return m_end.a - m_start.a; 86 | } 87 | 88 | inline std::ostream &operator<<(std::ostream &out, const TimeStampCounter &tsc) 89 | { 90 | std::ostringstream o; 91 | auto c = tsc.cycles(); 92 | int blocks[10]; 93 | int n = 0; 94 | for (int digits = std::ceil(std::log10(c)); digits > 0; digits -= 3) { 95 | blocks[n++] = c % 1000; 96 | c /= 1000; 97 | } 98 | if (n == 0) { 99 | return out; 100 | } 101 | o.fill('0'); 102 | o << blocks[--n]; 103 | while (n > 0) { 104 | o << '\'' << std::setw(3) << blocks[--n]; 105 | } 106 | return out << o.str(); 107 | } 108 | 109 | #endif // VC_TSC_H_ 110 | 111 | // vim: foldmethod=marker 112 | -------------------------------------------------------------------------------- /makeApidox.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd "`dirname "$0"`/doc" 4 | 5 | rm -rf html 6 | doxygen 7 | rm -f html/*.qhp 8 | -------------------------------------------------------------------------------- /makeApidoxLoop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd "`dirname "$0"`" 3 | test -f .makeApidox.stamp || touch .makeApidox.stamp 4 | while true; do 5 | ls -l -t Vc/* doc/dox.h doc/examples.h Vc/common/*|head -n1 > .makeApidox.stamp.new 6 | if ! diff -q .makeApidox.stamp.new .makeApidox.stamp; then 7 | ./makeApidox.sh 8 | mv -f .makeApidox.stamp.new .makeApidox.stamp 9 | else 10 | sleep 1s 11 | fi 12 | done 13 | -------------------------------------------------------------------------------- /makeInternalDox.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd "`dirname "$0"`/doc" 4 | 5 | rm -rf internal 6 | doxygen DoxyInternal 7 | -------------------------------------------------------------------------------- /makeRelease.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "`dirname "$0"`" 4 | 5 | # Read version number 6 | eval `awk '/Vc_VERSION_NUMBER 0x[0-9]+/ { h=$3 } 7 | END { 8 | major=strtonum(substr(h, 1, 4)) 9 | minor=strtonum("0x" substr(h, 5, 2)) 10 | patch=strtonum("0x" substr(h, 7, 2)) / 2 11 | printf "oldVersion=\"%d.%d.%d\"\n", major, minor, patch 12 | printf "newVersion=\"%d.%d.%d\"\n", major, minor, patch + 1 13 | }' Vc/version.h` 14 | echo "current version: $oldVersion" 15 | echo -n " new release: " 16 | read -e -i "$newVersion" newVersion 17 | 18 | versionString=$newVersion 19 | versionNumber=`echo $newVersion | awk '{ split($0, v, "."); printf "0x%02x%02x%02x", v[1], v[2], v[3] * 2 }'` 20 | 21 | # Update the version number 22 | sed -i \ 23 | -e "s/^PROJECT_NUMBER = .*\$/PROJECT_NUMBER = $versionString/" \ 24 | -e "s/^HTML_TIMESTAMP = YES/HTML_TIMESTAMP = NO/" \ 25 | doc/Doxyfile 26 | sed -i \ 27 | -e "s/Vc_VERSION_STRING \".*\"\$/Vc_VERSION_STRING \"$versionString\"/" \ 28 | -e "s/Vc_VERSION_NUMBER 0x.*\$/Vc_VERSION_NUMBER $versionNumber/" \ 29 | Vc/version.h 30 | cat Vc/version.h 31 | 32 | # Modify README.md to link to release docs 33 | ed README.md < ../"Vc-$versionString.tar.gz" 54 | 55 | # Create API docs tarball 56 | ./makeApidox.sh 57 | 58 | # Copy API docs to vcdevel.github.io 59 | git clone --depth 2 git@github.com:VcDevel/vcdevel.github.io && \ 60 | cp -a doc/html vcdevel.github.io/Vc-$versionString && \ 61 | cd vcdevel.github.io && \ 62 | git add Vc-$versionString && \ 63 | git commit -m "Add Vc $versionString release docs" && \ 64 | git push && \ 65 | cd .. && \ 66 | rm -r vcdevel.github.io 67 | 68 | # Create API docs tarball 69 | mv doc/html/*.qch "../Vc-${versionString}.qch" 70 | mv doc/html "Vc-docs-$versionString" && tar -czf "../Vc-docs-$versionString".tar.gz "Vc-docs-$versionString" 71 | rm -rf "Vc-docs-$versionString" 72 | 73 | # Get back to the state before the tag and fix up the version numbers afterwards 74 | git revert -n HEAD 75 | git reset HEAD README.md && git checkout README.md 76 | 77 | # Update the version number of the after-release code 78 | versionString="$versionString-dev" 79 | versionNumber=`echo $versionNumber | awk '{ printf "0x%06x", (strtonum($0) + 1) }'` 80 | 81 | sed -i \ 82 | -e "s/^PROJECT_NUMBER = .*\$/PROJECT_NUMBER = $versionString/" \ 83 | -e "s/^HTML_TIMESTAMP = YES/HTML_TIMESTAMP = NO/" \ 84 | doc/Doxyfile 85 | sed -i \ 86 | -e "s/Vc_VERSION_STRING \".*\"\$/Vc_VERSION_STRING \"$versionString\"/" \ 87 | -e "s/Vc_VERSION_NUMBER 0x.*\$/Vc_VERSION_NUMBER $versionNumber/" \ 88 | Vc/version.h 89 | git commit CMakeLists.txt doc/Doxyfile Vc/version.h -s -F- < 0) 7 | p2 = 2^floor(log2(y)); 8 | y -= p2; 9 | diff = p2 * round_to_float(pi/4); 10 | x -= diff; 11 | printf("(x -= %s) -> %s\n", hexfloat(diff), hexfloat(x)); 12 | endwhile 13 | diff = p2 * round_to_float(pi/4 - round_to_float(pi/4)); 14 | x -= diff; 15 | printf("(x -= %s) -> %s\n", hexfloat(diff), hexfloat(x)); 16 | printf("expected result: %s\n", hexfloat(expected)); 17 | endfunction 18 | -------------------------------------------------------------------------------- /math/generate_sindat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | cd "${0%/*}" 4 | 5 | function usage() { 6 | cat < 0 )); do 16 | case "$1" in 17 | --help|-h) usage; exit ;; 18 | esac 19 | shift 20 | done 21 | 22 | octave < >(cpp -dD -E -fpreprocessed -w -P | sed 's/^ *//' > godbolt/Vc) 47 | parse_file "Vc/algorithm" > >(cpp -dD -E -fpreprocessed -w -P | sed 's/^ *//' > godbolt/algorithm) 48 | parse_file "Vc/Vc" > >(cpp -dD -E -fpreprocessed -w -P | sed 's/^ *//' > godbolt/containers) 49 | -------------------------------------------------------------------------------- /print_target_architecture.cmake: -------------------------------------------------------------------------------- 1 | get_filename_component(_currentDir "${CMAKE_CURRENT_LIST_FILE}" PATH) 2 | include("${_currentDir}/cmake/OptimizeForArchitecture.cmake") 3 | 4 | if(arch STREQUAL "linux") 5 | set(CMAKE_SYSTEM_NAME "Linux") 6 | elseif(arch STREQUAL "darwin") 7 | set(CMAKE_SYSTEM_NAME "Darwin") 8 | elseif(arch MATCHES "mingw" OR arch MATCHES "[Ww]indows" OR arch MATCHES "win7" OR arch MATCHES "msys") 9 | set(CMAKE_SYSTEM_NAME "Windows") 10 | else() 11 | message(FATAL_ERROR "unhandled system") 12 | endif() 13 | 14 | AutodetectHostArchitecture() 15 | message(STATUS "${TARGET_ARCHITECTURE}") 16 | -------------------------------------------------------------------------------- /src/support_dummy.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2017 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include 29 | #include 30 | 31 | namespace Vc_VERSIONED_NAMESPACE 32 | { 33 | bool isImplementationSupported(Implementation impl) { return impl == ScalarImpl; } 34 | 35 | Vc::Implementation bestImplementationSupported() { return Vc::ScalarImpl; } 36 | 37 | unsigned int extraInstructionsSupported() { return 0; } 38 | } 39 | 40 | #undef Vc_TARGET_NO_SIMD 41 | 42 | // vim: sw=4 sts=4 et tw=100 43 | -------------------------------------------------------------------------------- /tests/abi.cmake: -------------------------------------------------------------------------------- 1 | ####################################################################### 2 | # test Vector ABI 3 | ####################################################################### 4 | 5 | macro(extract_asm marker) 6 | execute_process( 7 | COMMAND grep -A100 ${marker}_start ${ASM} 8 | COMMAND grep -B100 ${marker}_end 9 | COMMAND sed -e "s/ *#.*$//" 10 | COMMAND grep -v -e ${marker}_ -e "^\\." -e "^ *$" 11 | OUTPUT_VARIABLE asm) 12 | string(STRIP "${asm}" asm) 13 | string(REPLACE "(%rip)" "" asm "${asm}") 14 | string(REPLACE "\t" " " asm "${asm}") 15 | string(REGEX REPLACE " +" " " asm "${asm}") 16 | endmacro() 17 | 18 | extract_asm(vector_abi) 19 | 20 | if("${IMPL}" STREQUAL SSE) 21 | set(reference "v?mov[au]ps .*a_v, %xmm0.*call.* v?mov[au]ps %xmm0, .*b_v") 22 | elseif("${IMPL}" STREQUAL AVX OR "${IMPL}" STREQUAL AVX2) 23 | set(reference "vmov[au]ps .*a_v, %ymm0.*call.* vmov[au]ps %ymm0, .*b_v") 24 | else() 25 | message(FATAL_ERROR "Unknown IMPL '${IMPL}'") 26 | endif() 27 | 28 | if("${asm}" MATCHES "${reference}") 29 | message("PASS: Vector ABI") 30 | else() 31 | message(FATAL_ERROR "Failed.\n'${asm}'\n does not match\n'${reference}'") 32 | endif() 33 | 34 | ####################################################################### 35 | # test Mask ABI 36 | ####################################################################### 37 | string(REPLACE "_v" "_m" reference "${reference}") 38 | 39 | extract_asm(mask_abi) 40 | if("${asm}" MATCHES "${reference}") 41 | message("PASS: Mask ABI") 42 | else() 43 | message(FATAL_ERROR "Failed.\n'${asm}'\n does not match\n'${reference}'") 44 | endif() 45 | -------------------------------------------------------------------------------- /tests/abi.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | Vc::float_v test_vector_abi(Vc::float_v); 4 | Vc::float_m test_mask_abi(Vc::float_m); 5 | 6 | Vc::float_v a_v, b_v; 7 | Vc::float_m a_m, b_m; 8 | 9 | void my_test1() 10 | { 11 | asm volatile("vector_abi_start:"); 12 | b_v = test_vector_abi(a_v); 13 | asm volatile("vector_abi_end:"); 14 | } 15 | 16 | void my_test2() 17 | { 18 | asm volatile("mask_abi_start:"); 19 | b_m = test_mask_abi(a_m); 20 | asm volatile("mask_abi_end:"); 21 | } 22 | -------------------------------------------------------------------------------- /tests/alignmentinheritance.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2013-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "unittest.h" 29 | 30 | #if defined(Vc_ICC) || (defined(Vc_GCC) && Vc_GCC < 0x40800) 31 | class A {} __attribute__((aligned(64))); 32 | #else 33 | class alignas(64) A {}; 34 | #endif 35 | class B : public A {}; 36 | 37 | TEST(alignmentOfSubclass) { COMPARE(alignof(B), alignof(A)); } 38 | -------------------------------------------------------------------------------- /tests/deinterleave.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2010-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "unittest.h" 29 | #include 30 | #include 31 | 32 | using Vc::float_v; 33 | using Vc::double_v; 34 | using Vc::int_v; 35 | using Vc::uint_v; 36 | using Vc::short_v; 37 | using Vc::ushort_v; 38 | 39 | /* 40 | * V \ M | float | double | ushort | short | uint | int 41 | * ---------+---------------------------------------------- 42 | * float_v | X | | X | X | | 43 | * double_v | | X | | | | 44 | * int_v | | | | X | | X 45 | * uint_v | | | X | | X | 46 | * short_v | | | | X | | 47 | * ushort_v | | | X | | | 48 | */ 49 | 50 | TEST_TYPES(Pair, testDeinterleave, 51 | vir::Typelist, 52 | vir::Typelist, 53 | vir::Typelist, 54 | vir::Typelist, 55 | vir::Typelist, 56 | vir::Typelist, 57 | vir::Typelist, 58 | vir::Typelist, 59 | vir::Typelist, 60 | vir::Typelist) 61 | { 62 | typedef typename Pair::template at<0> V; 63 | typedef typename Pair::template at<1> M; 64 | 65 | const bool isSigned = std::numeric_limits::is_signed; 66 | 67 | const typename V::EntryType offset = isSigned ? -512 : 0; 68 | const V _0246 = V([](int n) { return n * 2; }) + offset; 69 | 70 | M memory[1024]; 71 | for (int i = 0; i < 1024; ++i) { 72 | memory[i] = static_cast(i + offset); 73 | } 74 | 75 | V a, b; 76 | 77 | static_assert(2 * V::Size < 1024, "fix the test, please"); 78 | for (int i = 0; i < 1024 - 2 * int(V::Size); ++i) { 79 | if (reinterpret_cast(&memory[i]) & (Vc::VectorAlignment - 1)) { 80 | Vc::deinterleave(&a, &b, &memory[i], Vc::Unaligned); 81 | } else { 82 | Vc::deinterleave(&a, &b, &memory[i]); 83 | } 84 | COMPARE(a, _0246 + i); 85 | COMPARE(b, _0246 + i + 1); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /tests/generators.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2016 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include 29 | #include 30 | 31 | template 32 | inline typename std::enable_if::value>::type 33 | iterateNumericRange(F &&f) 34 | { 35 | using L = std::numeric_limits; 36 | constexpr int nsteps = 17; 37 | const T step = L::max() / nsteps; 38 | for (int i = 0; i < nsteps; ++i) { 39 | f(T(L::lowest() + i * step)); 40 | } 41 | for (int i = 0; i < nsteps; ++i) { 42 | f(T(L::max() - i * step)); 43 | } 44 | f(T(-1)); 45 | f(-L::min()); 46 | f(-L::denorm_min()); 47 | f(T(0)); 48 | f(L::denorm_min()); 49 | f(L::min()); 50 | f(T(1)); 51 | } 52 | 53 | template 54 | inline typename std::enable_if::value>::type iterateNumericRange( 55 | F &&f) 56 | { 57 | using L = std::numeric_limits; 58 | constexpr int nsteps = 17; 59 | const T step = L::max() / nsteps; 60 | for (int i = 0; i < nsteps; ++i) { 61 | f(T(L::max() - i * step)); 62 | } 63 | f(T(1)); 64 | f(T(0)); 65 | if (std::is_signed::value) { 66 | f(T(-1)); 67 | for (int i = 0; i < nsteps; ++i) { 68 | f(T(L::min() + i * step)); 69 | } 70 | } 71 | } 72 | 73 | // vim: foldmethod=marker 74 | -------------------------------------------------------------------------------- /tests/gh200.cpp: -------------------------------------------------------------------------------- 1 | #include "unittest.h" 2 | #include 3 | 4 | TEST_TYPES(V, rounding, RealVectors) 5 | { 6 | using T = typename V::value_type; 7 | for (T d : { 1e100, 2.1, 2.9, 1.0, 2.0, 3.0, -2.1, -2.9, -1e100 }) { 8 | V v(d); 9 | COMPARE(Vc::trunc(v), V(std::trunc(d))) << "d = " << d; 10 | COMPARE(Vc::floor(v), V(std::floor(d))) << "d = " << d; 11 | COMPARE(Vc::ceil(v), V(std::ceil(d))) << "d = " << d; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/linkTest0.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace Vc; 6 | float_v foo0(float_v::AsArg a) 7 | { 8 | const float_v b = sin(a + float_v::One()); 9 | std::cerr << b; 10 | return b; 11 | } 12 | -------------------------------------------------------------------------------- /tests/linkTest1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace Vc; 6 | 7 | float_v fooLib0A(float_v::AsArg a); 8 | float_v fooLib1A(float_v::AsArg a); 9 | float_v fooLib0B(float_v::AsArg a); 10 | float_v fooLib1B(float_v::AsArg a); 11 | float_v fooLib2(float_v::AsArg a); 12 | float_v fooLib3(float_v::AsArg a); 13 | float_v foo0(float_v::AsArg a); 14 | float_v foo1(float_v::AsArg a) 15 | { 16 | const float_v b = sin(a + float_v::One()); 17 | std::cerr << b; 18 | return b; 19 | } 20 | 21 | int Vc_CDECL main() 22 | { 23 | float_v x = float_v::Random(); 24 | x = fooLib0A(fooLib0B(fooLib1A(fooLib1B(fooLib2(fooLib3(foo0(foo1(x)))))))); 25 | return static_cast(x.sum()) >> 8; 26 | } 27 | -------------------------------------------------------------------------------- /tests/linkTestLib0.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define CAT(a, b) a##b 6 | #define name(a, b) CAT(a, b) 7 | 8 | using namespace Vc; 9 | float_v 10 | #ifdef Vc_MSVC 11 | __declspec(dllexport) 12 | #endif 13 | name(fooLib0, POSTFIX)(float_v::AsArg a) 14 | { 15 | const float_v b = sin(a + float_v::One()); 16 | std::cerr << b; 17 | return b; 18 | } 19 | -------------------------------------------------------------------------------- /tests/linkTestLib1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define CAT(a, b) a##b 6 | #define name(a, b) CAT(a, b) 7 | 8 | using namespace Vc; 9 | float_v 10 | #ifdef Vc_MSVC 11 | __declspec(dllexport) 12 | #endif 13 | name(fooLib1, POSTFIX)(float_v::AsArg a) 14 | { 15 | const float_v b = sin(a + float_v::One()); 16 | std::cerr << b; 17 | return b; 18 | } 19 | -------------------------------------------------------------------------------- /tests/linkTestLib2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace Vc; 5 | float_v fooLib2(float_v::AsArg a) 6 | { 7 | const float_v b = sin(a + float_v::One()); 8 | std::cerr << b; 9 | return b; 10 | } 11 | -------------------------------------------------------------------------------- /tests/linkTestLib3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace Vc; 5 | float_v fooLib3(float_v::AsArg a) 6 | { 7 | const float_v b = sin(a + float_v::One()); 8 | std::cerr << b; 9 | return b; 10 | } 11 | -------------------------------------------------------------------------------- /tests/supportfunctions.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2013-2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "unittest.h" 29 | 30 | TEST(testCompiledImplementation) { VERIFY(Vc::currentImplementationSupported()); } 31 | 32 | TEST(testIsSupported) 33 | { 34 | using Vc::CpuId; 35 | VERIFY(Vc::isImplementationSupported(Vc::ScalarImpl)); 36 | COMPARE(Vc::isImplementationSupported(Vc::SSE2Impl ), CpuId::hasSse2()); 37 | COMPARE(Vc::isImplementationSupported(Vc::SSE3Impl ), CpuId::hasSse3()); 38 | COMPARE(Vc::isImplementationSupported(Vc::SSSE3Impl), CpuId::hasSsse3()); 39 | COMPARE(Vc::isImplementationSupported(Vc::SSE41Impl), CpuId::hasSse41()); 40 | COMPARE(Vc::isImplementationSupported(Vc::SSE42Impl), CpuId::hasSse42()); 41 | COMPARE(Vc::isImplementationSupported(Vc::AVXImpl ), CpuId::hasOsxsave() && CpuId::hasAvx()); 42 | COMPARE(Vc::isImplementationSupported(Vc::AVX2Impl ), CpuId::hasOsxsave() && CpuId::hasAvx2()); 43 | } 44 | 45 | TEST(testBestImplementation) 46 | { 47 | // when building with a recent and fully featured compiler the following should pass 48 | // but - old GCC versions have to fall back to Scalar, even though SSE is supported by the CPU 49 | // - ICC/MSVC can't use XOP/FMA4 50 | COMPARE(Vc::bestImplementationSupported(), Vc::CurrentImplementation::current()); 51 | } 52 | 53 | TEST(testExtraInstructions) 54 | { 55 | using Vc::CpuId; 56 | unsigned int extra = Vc::extraInstructionsSupported(); 57 | COMPARE(!(extra & Vc::Float16cInstructions), !CpuId::hasF16c()); 58 | COMPARE(!(extra & Vc::XopInstructions), !CpuId::hasXop()); 59 | COMPARE(!(extra & Vc::Fma4Instructions), !CpuId::hasFma4()); 60 | COMPARE(!(extra & Vc::PopcntInstructions), !CpuId::hasPopcnt()); 61 | COMPARE(!(extra & Vc::Sse4aInstructions), !CpuId::hasSse4a()); 62 | COMPARE(!(extra & Vc::FmaInstructions), !CpuId::hasFma()); 63 | COMPARE(!(extra & Vc::Bmi2Instructions), !CpuId::hasBmi2()); 64 | } 65 | 66 | // vim: foldmethod=marker 67 | -------------------------------------------------------------------------------- /tests/types.cpp: -------------------------------------------------------------------------------- 1 | /*{{{ 2 | Copyright © 2014-2015 Matthias Kretz 3 | 4 | Permission to use, copy, modify, and distribute this software 5 | and its documentation for any purpose and without fee is hereby 6 | granted, provided that the above copyright notice appear in all 7 | copies and that both that the copyright notice and this 8 | permission notice and warranty disclaimer appear in supporting 9 | documentation, and that the name of the author not be used in 10 | advertising or publicity pertaining to distribution of the 11 | software without specific, written prior permission. 12 | 13 | The author disclaim all warranties with regard to this 14 | software, including all implied warranties of merchantability 15 | and fitness. In no event shall the author be liable for any 16 | special, indirect or consequential damages or any damages 17 | whatsoever resulting from loss of use, data or profits, whether 18 | in an action of contract, negligence or other tortious action, 19 | arising out of or in connection with the use or performance of 20 | this software. 21 | 22 | }}}*/ 23 | 24 | #include "unittest.h" 25 | 26 | #if defined Vc_GCC && Vc_GCC >= 0x60000 27 | #pragma GCC diagnostic ignored "-Wignored-attributes" 28 | #endif 29 | 30 | #define ALL_TYPES concat> 31 | 32 | TEST_TYPES(V, check_EntryType, ALL_TYPES) 33 | { 34 | V v = V(); 35 | auto scalar = v.sum(); 36 | static_assert(std::is_same::value, ""); 37 | static_assert(std::is_same::value, ""); 38 | } 39 | 40 | TEST_TYPES(V, check_VectorType, AllVectors) 41 | { 42 | V v = V(); 43 | auto internalData = v.data(); 44 | static_assert(std::is_same::value, ""); 45 | static_assert(std::is_same::value, ""); 46 | } 47 | 48 | TEST_TYPES(V, check_MaskType, ALL_TYPES) 49 | { 50 | V v = V(); 51 | auto mask = v == v; 52 | static_assert(std::is_same::value, ""); 53 | static_assert(std::is_same::value, ""); 54 | } 55 | 56 | TEST_TYPES(V, check_IndexType, ALL_TYPES) 57 | { 58 | using IndexType = typename V::IndexType; 59 | static_assert(Vc::Traits::isSimdArray::value, 60 | "IndexType is not a SimdArray instance"); 61 | static_assert(IndexType::Size >= V::Size, 62 | "IndexType does not have the expected minimum size"); 63 | static_assert(std::is_same::value, 64 | "IndexType does not have the expected value_type"); 65 | } 66 | 67 | static_assert(!Vc::is_simd_vector::value, ""); 68 | 69 | TEST_TYPES(V, checkIntegerType, Vc::int64_v, Vc::uint64_v, Vc::int32_v, Vc::uint32_v, 70 | Vc::int16_v, Vc::uint16_v, Vc::int8_v, Vc::uint8_v) 71 | { 72 | V v; 73 | MEMCOMPARE(v, v); 74 | } 75 | -------------------------------------------------------------------------------- /tests/ulp.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2015 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #include "unittest.h" 29 | 30 | TEST_TYPES(V, testUlpDiff, concat) //{{{1 31 | { 32 | // MSVC takes too long in debug mode 33 | #if defined _MSC_VER && defined _DEBUG 34 | const auto range = 1000; 35 | #else 36 | const auto range = 10000; 37 | #endif 38 | 39 | typedef typename V::EntryType T; 40 | 41 | using vir::detail::ulpDiffToReference; 42 | COMPARE(ulpDiffToReference(V(0), V(0)), V(0)); 43 | COMPARE(ulpDiffToReference(V(std::numeric_limits::min()), V(0)), V(1)); 44 | COMPARE(ulpDiffToReference(V(0), V(std::numeric_limits::min())), V(1)); 45 | for (size_t count = 0; count < 1024 / V::Size; ++count) { 46 | const V base = (V::Random() - T(0.5)) * T(1000); 47 | typename V::IndexType exp; 48 | frexp(base, &exp); 49 | const V eps = ldexp(V(std::numeric_limits::epsilon()), exp - 1); 50 | //std::cout << base << ", " << exp << ", " << eps << std::endl; 51 | for (int i = -range; i <= range; ++i) { 52 | const V i_v = V(T(i)); 53 | const V diff = base + i_v * eps; 54 | 55 | // if diff and base have a different exponent then ulpDiffToReference has an uncertainty 56 | // of +/-1 57 | const V ulpDifference = ulpDiffToReference(diff, base); 58 | const V expectedDifference = abs(i_v); 59 | const V maxUncertainty = abs(exponent(abs(diff)) - exponent(abs(base))); 60 | 61 | VERIFY(all_of(abs(ulpDifference - expectedDifference) <= maxUncertainty)) 62 | << ", base = " << base << ", epsilon = " << eps << ", diff = " << diff; 63 | for (size_t k = 0; k < V::Size; ++k) { 64 | VERIFY(std::abs(ulpDifference[k] - expectedDifference[k]) <= maxUncertainty[k]); 65 | } 66 | } 67 | } 68 | } 69 | 70 | //}}}1 71 | // vim: foldmethod=marker 72 | -------------------------------------------------------------------------------- /tests/vectormemoryhelper.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the Vc library. {{{ 2 | Copyright © 2009-2014 Matthias Kretz 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the names of contributing organizations nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | }}}*/ 27 | 28 | #ifndef VECTORMEMORYHELPER_H 29 | #define VECTORMEMORYHELPER_H 30 | 31 | #include 32 | 33 | template 34 | class VectorMemoryHelper 35 | { 36 | char *const mem; 37 | char *const aligned; 38 | public: 39 | VectorMemoryHelper(int count) 40 | : mem(new char[count * sizeof(Vec) + Vc::VectorAlignment]), 41 | aligned(mem + (Vc::VectorAlignment - (reinterpret_cast( mem ) & ( Vc::VectorAlignment - 1 )))) 42 | { 43 | } 44 | ~VectorMemoryHelper() { delete[] mem; } 45 | 46 | operator typename Vec::EntryType *() { return reinterpret_cast(aligned); } 47 | }; 48 | 49 | #endif // VECTORMEMORYHELPER_H 50 | --------------------------------------------------------------------------------