A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://kokkos.github.io/kokkos-core-wiki/API/simd/where_expression.html below:

Experimental::where_expression - Kokkos documentation

Toggle table of contents sidebar

Experimental::where_expression

Header File: Kokkos_SIMD.hpp

Usage:

Kokkos::Experimental::where_expression references a subset of the values in a vector register. Which values are in the subset is described by a mask. where_expression thus forms the basis for masked operations on vector values.

Interface
namespace Experimental {
template <class M, class T>
class const_where_expression;
template <class M, class T>
class where_expression : public const_where_expression;
}
Template Parameters

The first template parameter M is the mask type, and should either be an instance of class template Kokkos::Experimental::simd_mask or bool. The second template parameter T is the value type, and should either be an instance of class template Kokkos::Experimental::simd or a fundamental type such as double.

Where Function

Where expression objects are only constructed by calling the non-member method Kokkos::Experimental::where:

Load/Store Methods Simd Flags Gather/Scatter Methods

These methods were added by Kokkos and are not present in the ISO C++ proposal.

Assignment Example
#include <Kokkos_SIMD.hpp>
#include <cstdio>

int main(int argc, char* argv[]) {
  Kokkos::initialize(argc,argv);
  {
    using simd_type = Kokkos::Experimental::simd<double>;
    // the first value in vector a will be negative after this
    simd_type a([] (std::size_t i) { return 1.0 * i - 1.0; });
    // we can use where expressions to set negative values to 0.0
    where(a < 0.0, a) = 0.0;
    // now it might be safer to call a function with domain limitations
    auto b = Kokkos::sqrt(a);
  }
  Kokkos::finalize();
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4