Merge pull request #3474 from stanmoore1/kk_update_3.7

Update Kokkos library in LAMMPS to v3.7.0
This commit is contained in:
Axel Kohlmeyer
2022-10-11 16:30:19 -04:00
committed by GitHub
658 changed files with 42621 additions and 28656 deletions

View File

@ -47,8 +47,8 @@ if(DOWNLOAD_KOKKOS)
list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}")
list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
include(ExternalProject)
set(KOKKOS_URL "https://github.com/kokkos/kokkos/archive/3.6.01.tar.gz" CACHE STRING "URL for KOKKOS tarball")
set(KOKKOS_MD5 "0ec97fc0c356dd65bd2487defe81a7bf" CACHE STRING "MD5 checksum of KOKKOS tarball")
set(KOKKOS_URL "https://github.com/kokkos/kokkos/archive/3.7.00.tar.gz" CACHE STRING "URL for KOKKOS tarball")
set(KOKKOS_MD5 "84991eca9f066383abe119a5bc7a11c4" CACHE STRING "MD5 checksum of KOKKOS tarball")
mark_as_advanced(KOKKOS_URL)
mark_as_advanced(KOKKOS_MD5)
ExternalProject_Add(kokkos_build
@ -72,7 +72,7 @@ if(DOWNLOAD_KOKKOS)
add_dependencies(LAMMPS::KOKKOSCORE kokkos_build)
add_dependencies(LAMMPS::KOKKOSCONTAINERS kokkos_build)
elseif(EXTERNAL_KOKKOS)
find_package(Kokkos 3.6.01 REQUIRED CONFIG)
find_package(Kokkos 3.7.00 REQUIRED CONFIG)
target_link_libraries(lammps PRIVATE Kokkos::kokkos)
target_link_libraries(lmp PRIVATE Kokkos::kokkos)
else()

View File

@ -483,6 +483,9 @@ They must be specified in uppercase.
* - **Arch-ID**
- **HOST or GPU**
- **Description**
* - NATIVE
- HOST
- Local machine
* - AMDAVX
- HOST
- AMD 64-bit x86 CPU (AVX 1)
@ -522,9 +525,21 @@ They must be specified in uppercase.
* - BDW
- HOST
- Intel Broadwell Xeon E-class CPU (AVX 2 + transactional mem)
* - SKL
- HOST
- Intel Skylake Client CPU
* - SKX
- HOST
- Intel Sky Lake Xeon E-class HPC CPU (AVX512 + transactional mem)
- Intel Skylake Xeon Server CPU (AVX512)
* - ICL
- HOST
- Intel Ice Lake Client CPU (AVX512)
* - ICX
- HOST
- Intel Ice Lake Xeon Server CPU (AVX512)
* - SPR
- HOST
- Intel Sapphire Rapids Xeon Server CPU (AVX512)
* - KNC
- HOST
- Intel Knights Corner Xeon Phi
@ -596,7 +611,10 @@ They must be specified in uppercase.
- AMD GPU MI100 GFX908
* - VEGA90A
- GPU
- AMD GPU
- AMD GPU MI200 GFX90A
* - INTEL_GEN
- GPU
- SPIR64-based devices, e.g. Intel GPUs, using JIT
* - INTEL_DG1
- GPU
- Intel Iris XeMAX GPU
@ -611,9 +629,12 @@ They must be specified in uppercase.
- Intel GPU Gen12LP
* - INTEL_XEHP
- GPU
- Intel GPUs Xe-HP
- Intel GPU Xe-HP
* - INTEL_PVC
- GPU
- Intel GPU Ponte Vecchio
This list was last updated for version 3.5.0 of the Kokkos library.
This list was last updated for version 3.7.0 of the Kokkos library.
.. tabs::

View File

@ -27,7 +27,7 @@ When configuring your project just set:
-DKokkos_ROOT=${kokkos_install_prefix} \
-DCMAKE_CXX_COMPILER=${compiler_used_to_build_kokkos}
````
Note: You may need the following if using some versions of CMake (e.g. 3.12):
Note: You may need the following if your project requires a minimum CMake version older than 3.12:
````cmake
cmake_policy(SET CMP0074 NEW)
````
@ -171,6 +171,9 @@ Options can be enabled by specifying `-DKokkos_ENABLE_X`.
* Kokkos_ENABLE_HPX_ASYNC_DISPATCH
* Whether HPX supports asynchronous dispatch
* BOOL Default: OFF
* Kokkos_ENABLE_IMPL_CUDA_MALLOC_ASYNC
* Whether to enable CudaMallocAsync (requires CUDA Toolkit 11.2). This is an experimental performance feature and currently has issue when using with UCX. See https://github.com/kokkos/kokkos/issues/4228 for more details.
* BOOL Default: OFF
* Kokkos_ENABLE_LARGE_MEM_TESTS
* Whether to perform extra large memory tests
* BOOL_Default: OFF
@ -235,6 +238,9 @@ The following options control `find_package` paths for CMake-based TPLs:
## Architecture Keywords
Architecture-specific optimizations can be enabled by specifying `-DKokkos_ARCH_X`.
* Kokkos_ARCH_NATIVE
* Whether to optimize for the the local CPU architecture
* BOOL Default: OFF
* Kokkos_ARCH_AMDAVX
* Whether to optimize for the AMDAVX architecture
* BOOL Default: OFF
@ -310,12 +316,24 @@ Architecture-specific optimizations can be enabled by specifying `-DKokkos_ARCH_
* Kokkos_ARCH_POWER9
* Whether to optimize for the POWER9 architecture
* BOOL Default: OFF
* Kokkos_ARCH_ICL
* Whether to optimize for the ICL architecture
* BOOL Default: OFF
* Kokkos_ARCH_ICX
* Whether to optimize for the ICX architecture
* BOOL Default: OFF
* Kokkos_ARCH_SKL
* Whether to optimize for the SKL architecture
* BOOL Default: OFF
* Kokkos_ARCH_SKX
* Whether to optimize for the SKX architecture
* BOOL Default: OFF
* Kokkos_ARCH_SNB
* Whether to optimize for the SNB architecture
* BOOL Default: OFF
* Kokkos_ARCH_SPR
* Whether to optimize for the SPR architecture
* BOOL Default: OFF
* Kokkos_ARCH_TURING75
* Whether to optimize for the TURING75 architecture
* BOOL Default: OFF

View File

@ -1,5 +1,157 @@
# Change Log
## [3.7.00](https://github.com/kokkos/kokkos/tree/3.7.00) (2022-08-22)
[Full Changelog](https://github.com/kokkos/kokkos/compare/3.6.01...3.7.00)
### Features:
- Use non-volatile `join()` member functions and `operator+=` in `parallel_reduce/scan` [\#4931](https://github.com/kokkos/kokkos/pull/4931) [\#4954](https://github.com/kokkos/kokkos/pull/4954) [\#4951](https://github.com/kokkos/kokkos/pull/4951)
- Add `SIMD` sub package (requires C++17) [\#5016](https://github.com/kokkos/kokkos/pull/5016)
- Add `is_finalized()` [\#5247](https://github.com/kokkos/kokkos/pull/5247)
- Promote mathematical functions from `namespace Kokkos::Experimental` to `namespace Kokkos` [\#4791](https://github.com/kokkos/kokkos/pull/4791)
- Promote `min`, `max`, `clamp`, `minmax` functions from `namespace Kokkos::Experimental` to `namespace Kokkos` [\#5170](https://github.com/kokkos/kokkos/pull/5170)
- Add `round`, `logb`, `nextafter`, `copysign`, and `signbit` math functions [\#4768](https://github.com/kokkos/kokkos/pull/4768)
- Add `HIPManagedSpace`, similar to `CudaUVMSpace` [\#5112](https://github.com/kokkos/kokkos/pull/5112)
- Accept view construction allocation properties in `create_mirror[_view,_view_and_copy]` and `resize/realloc` [\#5125](https://github.com/kokkos/kokkos/pull/5125) [\#5095](https://github.com/kokkos/kokkos/pull/5095) [\#5035](https://github.com/kokkos/kokkos/pull/5035) [\#4805](https://github.com/kokkos/kokkos/pull/4805) [\#4844](https://github.com/kokkos/kokkos/pull/4844)
- Allow `MemorySpace::allocate()` to be called with execution space [\#4826](https://github.com/kokkos/kokkos/pull/4826)
- Experimental: Compile time view subscriber [\#4197](https://github.com/kokkos/kokkos/pull/4197)
### Backends and Archs Enhancements:
- Add support for Sapphire Rapids Intel architecture [\#5015](https://github.com/kokkos/kokkos/pull/5015)
- Add support for ICX, SKL and ICL Intel architectures [\#5013](https://github.com/kokkos/kokkos/pull/5013) [\#4929](https://github.com/kokkos/kokkos/pull/4929)
- Add arch flags for Intel GPU Ponte Vecchio [\#4932](https://github.com/kokkos/kokkos/pull/4932)
- SYCL: require GPU if GPU architecture was set at configuration time (i.e. do not allow fallback to CPU device) [\#5264](https://github.com/kokkos/kokkos/pull/5264) [\#5222](https://github.com/kokkos/kokkos/pull/5222)
- SYCL: Add `SYCL::sycl_queue()` for interoperability [\#5241](https://github.com/kokkos/kokkos/pull/5241)
- SYCL: Loosen restriction for using built-in `sycl::group_broadcast` [\#4552](https://github.com/kokkos/kokkos/pull/4552)
- SYCL: preserve address space [\#4396](https://github.com/kokkos/kokkos/pull/4396)
- OpenMPTarget: Adding a workaound for team scan [\#5219](https://github.com/kokkos/kokkos/pull/5219)
- OpenMPTarget: Adding logic to skip the kernel launch if `league_size=0` [\#5067](https://github.com/kokkos/kokkos/pull/5067)
- OpenMPTarget: Make sure `Kokkos::abort()` causes abnormal program termination when called on the host-side [\#4808](https://github.com/kokkos/kokkos/pull/4808)
- HIP: Make HIPHostPinnedSpace coarse-grained [\#5152](https://github.com/kokkos/kokkos/pull/5152)
- Refactor OpenMP `parallel_for` implementation to use more native OpenMP constructs [\#4664](https://github.com/kokkos/kokkos/pull/4664)
- Add option to optimize for local CPU architecture `Kokkos_ARCH_NATIVE` [\#4930](https://github.com/kokkos/kokkos/pull/4930)
### Implemented enhancements
- Add command line argument/environment variable to print the configuration [\#5233](https://github.com/kokkos/kokkos/pull/5233)
- Improve error message in view memory access violations [\#4950](https://github.com/kokkos/kokkos/pull/4950)
- Remove unnecessary fences in View initialization [\#4823](https://github.com/kokkos/kokkos/pull/4823)
- Make `View::shmem_size()` device-callable [\#4936](https://github.com/kokkos/kokkos/pull/4936)
- Update numerics support for `__float128` [\#5081](https://github.com/kokkos/kokkos/pull/5081)
- Add `log10` overload for `Kokkos::complex` [\#5009](https://github.com/kokkos/kokkos/pull/5009)
- Add `[[nodiscard]]` to `ScopeGuard` [\#5224](https://github.com/kokkos/kokkos/pull/5224)
- Add structured binding support for `Kokkos::Array` [\#4962](https://github.com/kokkos/kokkos/pull/4962)
- Enable accessing `Kokkos::Array` elements in constant expressions [\#4916](https://github.com/kokkos/kokkos/pull/4916)
- Mark `as_view_of_rank_n` as KOKKOS_FUNCTION [\#5248](https://github.com/kokkos/kokkos/pull/5248)
- Cleanup/rework fence overloads [\#5148](https://github.com/kokkos/kokkos/pull/5148)
- Assert that `Layout` construction from extents is valid in functions taking integer extents [\#5209](https://github.com/kokkos/kokkos/pull/5209)
- Add `fill_random` overload that takes an execution space as first argument [\#5181](https://github.com/kokkos/kokkos/pull/5181)
- Avoid some unnecessary fences in `parallel_reduce/scan` [\#5154](https://github.com/kokkos/kokkos/pull/5154)
- Include `KOKKOS_ENABLE_LIBDL` in options when printing configuration [\#5086](https://github.com/kokkos/kokkos/pull/5086)
- DynRankView: make `layout()` return the same as a corresponding static View [\#5026](https://github.com/kokkos/kokkos/pull/5026)
- Use `_mm_malloc` for icpx [\#5012](https://github.com/kokkos/kokkos/pull/5012)
- Avoid forcing matching execution spaces in `BinSort` constructor and `sort()` [\#4919](https://github.com/kokkos/kokkos/pull/4919)
- Check number of bins in `BinSort` [\#4890](https://github.com/kokkos/kokkos/pull/4890)
- Improve performance in parallel STL-like algorithms [\#4887](https://github.com/kokkos/kokkos/pull/4887) [\#4886](https://github.com/kokkos/kokkos/pull/4886)
- Disable `memset` on A64FX and launch `parallel_for` instead (performance) [\#4884](https://github.com/kokkos/kokkos/pull/4884)
- Allow non-power-of-two team sizes for team reductions and scans [\#4809](https://github.com/kokkos/kokkos/pull/4809)
#### Harmonization of Kokkos execution environment initialization:
- Warn when unable to detect local MPI rank and user explicitly asked for it [\#5263](https://github.com/kokkos/kokkos/pull/5263)
- Refactor parsing of command line arguments and environment variables [\#5221](https://github.com/kokkos/kokkos/pull/5221)
- Refactor device selection at initialization [\#5211](https://github.com/kokkos/kokkos/pull/5211)
- Rename tools settings for consistency [\#5201](https://github.com/kokkos/kokkos/pull/5201)
- Print help only once [\#5128](https://github.com/kokkos/kokkos/pull/5128)
- Update precedence rule in initialization [\#5130](https://github.com/kokkos/kokkos/pull/5130)
- Warn instead of just ignoring user settings when kokkos-tools is disabled [\#5088](https://github.com/kokkos/kokkos/pull/5088)
- Drop numa args in threads backend initialization [\#5127](https://github.com/kokkos/kokkos/pull/5127)
- Warn users when a flag prefixed with -[-]kokkos is not recognized and do not remove it [\#5256](https://github.com/kokkos/kokkos/pull/5256)
- Give back to Core what belongs to Core (aka moving tune_internals option from Tools back to Core) [\#5202](https://github.com/kokkos/kokkos/pull/5202)
#### Build system updates:
- `nvcc_wrapper`: filter out -pedantic-errors from nvcc options [\#5235](https://github.com/kokkos/kokkos/pull/5235)
- `nvcc_wrapper`: add known nvcc option --source-in-ptx [\#5052](https://github.com/kokkos/kokkos/pull/5052)
- Link libdl as interface library [\#5179](https://github.com/kokkos/kokkos/pull/5179)
- Only show GPU architectures with enabled corresponding backend [\#5119](https://github.com/kokkos/kokkos/pull/5119)
- Enable optional external desul build [\#5021](https://github.com/kokkos/kokkos/pull/5021) [\#5132](https://github.com/kokkos/kokkos/pull/5132)
- Export `Kokkos_CXX_STANDARD` variable with CMake [\#5068](https://github.com/kokkos/kokkos/pull/5068)
- Suppress warnings with nvc++ [\#5031](https://github.com/kokkos/kokkos/pull/5031)
- Disallow multiple host architectures in CMake [\#4996](https://github.com/kokkos/kokkos/pull/4996)
- Do not include compiler warning flags in the compile option of the cmake target [\#4989](https://github.com/kokkos/kokkos/pull/4989)
- AOT flags for OpenMPTarget targeting Intel GPUs [\#4915](https://github.com/kokkos/kokkos/pull/4915)
- Repurpose `Kokkos_ARCH_INTEL_GEN` for SYCL to mean JIT to be conforming with OMPT [\#4894](https://github.com/kokkos/kokkos/pull/4894)
- Replace amdgpu-target with offload-arch [\#4874](https://github.com/kokkos/kokkos/pull/4874)
- Do not enable `kokkos_launch_compiler` when `CMAKE_CXX_COMPILER_LAUNCHER` is set [\#4870](https://github.com/kokkos/kokkos/pull/4870)
- Move CMake version check up [\#4797](https://github.com/kokkos/kokkos/pull/4797)
### Incompatibilities:
- Remove `KOKKOS_THREAD_LOCAL` [\#5064](https://github.com/kokkos/kokkos/pull/5064)
- Remove `KOKKOS_ENABLE_POSIX_MEMALIGN` [\#5011](https://github.com/kokkos/kokkos/pull/5011)
- Remove unused `KOKKOS_ENABLE_TM` [\#4995](https://github.com/kokkos/kokkos/pull/4995)
- Remove unused cmakedefine `KOKKOS_ENABLE_COMPILER_WARNINGS` [\#4883](https://github.com/kokkos/kokkos/pull/4883)
- Remove unused `KOKKOS_ENABLE_DUALVIEW_MODIFY_CHECK` [\#4882](https://github.com/kokkos/kokkos/pull/4882)
- Drop Instruction Set Architecture (ISA) macros [\#4981](https://github.com/kokkos/kokkos/pull/4981)
- Warn in `ScopeGuard` about illegal usage [\#5250](https://github.com/kokkos/kokkos/pull/5250)
### Deprecations:
- Guard against non-public header inclusion [\#5178](https://github.com/kokkos/kokkos/pull/5178)
- Raise deprecation warnings if non empty WorkTag class is used [\#5230](https://github.com/kokkos/kokkos/pull/5230)
- Deprecate `parallel_*` overloads taking the label as trailing argument [\#5141](https://github.com/kokkos/kokkos/pull/5141)
- Deprecate nested types in functional [\#5185](https://github.com/kokkos/kokkos/pull/5185)
- Deprecate `InitArguments` struct and replace it with `InitializationSettings` [\#5135](https://github.com/kokkos/kokkos/pull/5135)
- Deprecate `finalize_all()` [\#5134](https://github.com/kokkos/kokkos/pull/5134)
- Deprecate command line arguments (other than `--help`) that are not prefixed with `kokkos-*` [\#5120](https://github.com/kokkos/kokkos/pull/5120)
- Deprecate `--[kokkos-]numa` cmdline arg and `KOKKOS_NUMA` env var [\#5117](https://github.com/kokkos/kokkos/pull/5117)
- Deprecate `--[kokkos-]threads` command line argument in favor of `--[kokkos-]num-threads` [\#5111](https://github.com/kokkos/kokkos/pull/5111)
- Deprecate `Kokkos::common_view_alloc_prop` [\#5059](https://github.com/kokkos/kokkos/pull/5059)
- Deprecate `Kokkos::is_reducer_type` [\#4957](https://github.com/kokkos/kokkos/pull/4957)
- Deprecate `OffsetView` constructors taking `index_list_type` [\#4810](https://github.com/kokkos/kokkos/pull/4810)
- Deprecate overloads of `Kokkos::sort` taking a parameter `bool always_use_kokkos_sort` [\#5382](https://github.com/kokkos/kokkos/issues/5382)
- Warn about `parallel_reduce` cases that call `join()` with volatile-qualified arguments [\#5215](https://github.com/kokkos/kokkos/pull/5215)
### Bug Fixes:
- CUDA Reductions: Fix data races reported by Nvidia `compute-sanitizer` [\#4855](https://github.com/kokkos/kokkos/pull/4855)
- Work around Intel compiler bug [\#5301](https://github.com/kokkos/kokkos/pull/5301)
- Avoid allocating memory for UniqueToken [\#5300](https://github.com/kokkos/kokkos/pull/5300)
- DynamicView: Properly resize mirror instances after construction [\#5276](https://github.com/kokkos/kokkos/pull/5276)
- Remove Kokkos::Rank limit of 6 ranks [\#5271](https://github.com/kokkos/kokkos/pull/5271)
- Do not forget to set last element to nullptr when removing a flag in `Kokkos::initialize` [\#5272](https://github.com/kokkos/kokkos/pull/5272)
- Fix CUDA+MSVC build issue [\#5261](https://github.com/kokkos/kokkos/pull/5261)
- Fix `DynamicView::resize_serial` [\#5220](https://github.com/kokkos/kokkos/pull/5220)
- Fix cmake default compiler flags for unknown compiler [\#5217](https://github.com/kokkos/kokkos/pull/5217)
- Fix `move_backward` [\#5191](https://github.com/kokkos/kokkos/pull/5191)
- Fixing issue 5196 - missing symbol with intel compiler [\#5207](https://github.com/kokkos/kokkos/pull/5207)
- Preserve `KOKKOS_INVALID_INDEX` in ViewDimension and ArrayLayout construction [\#5188](https://github.com/kokkos/kokkos/pull/5188)
- Finalize `deep_copy_space` early avoiding printing to `std::cerr` for Cuda [\#5151](https://github.com/kokkos/kokkos/pull/5151)
- Use correct policy in Threads MDRange `parallel_reduce` [\#5123](https://github.com/kokkos/kokkos/pull/5123)
- Fix building with NVCC as the CXX compiler while the CUDA backend is not enabled [\#5115](https://github.com/kokkos/kokkos/pull/5115)
- OpenMPTarget Index range fix for MDRange. [\#5089](https://github.com/kokkos/kokkos/pull/5089)
- Fix bug with CUDA's team reduction for empty ranges [\#5079](https://github.com/kokkos/kokkos/pull/5079)
- Fix using `ZeroMemset` for Serial [\#5077](https://github.com/kokkos/kokkos/pull/5077)
- Fix `Kokkos::Vector::push_back` for default execution space [\#5047](https://github.com/kokkos/kokkos/pull/5047)
- ScatterView: Fix ScatterMin/ScatterMax to use proper atomics [\#5045](https://github.com/kokkos/kokkos/pull/5045)
- Fix calling `ZeroMemset` in `deep_copy` [\#5040](https://github.com/kokkos/kokkos/pull/5040)
- Make View self-assignment not produce double-free [\#5024](https://github.com/kokkos/kokkos/pull/5024)
- Guard against unrecognized pragma with intel compilers [\#5019](https://github.com/kokkos/kokkos/pull/5019)
- Fix racing condition in `HIPParallelLaunch` [\#5008](https://github.com/kokkos/kokkos/pull/5008)
- KokkosP: Fix `device_id` in profiling [\#4997](https://github.com/kokkos/kokkos/pull/4997)
- Fix for `Kokkos::vector::insert` into empty vector with begin and end iterators [\#4988](https://github.com/kokkos/kokkos/pull/4988)
- Fix Core header files installation [\#4984](https://github.com/kokkos/kokkos/pull/4984)
- Fix bounds errors with `Kokkos::sort` [\#4980](https://github.com/kokkos/kokkos/pull/4980)
- Fixup let `RangePolicy::set_chunk_size` return a reference to self [\#4918](https://github.com/kokkos/kokkos/pull/4918)
- Fix allocating large Views [\#4907](https://github.com/kokkos/kokkos/pull/4907)
- Fix combined reductions with `Kokkos::View` [\#4896](https://github.com/kokkos/kokkos/pull/4896)
- Fixed `_CUDA_ARCH__` to `__CUDA_ARCH__` for CUDA LDG [\#4893](https://github.com/kokkos/kokkos/pull/4893)
- Fixup `View::access()` truncate parameter pack [\#4876](https://github.com/kokkos/kokkos/pull/4876)
- Fix `abort` with HIP backend for ROCm 5.0.2 and beyond [\#4873](https://github.com/kokkos/kokkos/pull/4873)
- Fix HIP version when printing the configuration [\#4872](https://github.com/kokkos/kokkos/pull/4872)
- Fix scratch lock array when using scratch level 1 [\#4871](https://github.com/kokkos/kokkos/pull/4871)
- Fix Makefile.kokkos to work with fujitsu compiler [\#4867](https://github.com/kokkos/kokkos/pull/4867)
- cmake: Correct link THREADS link option [\#4854](https://github.com/kokkos/kokkos/pull/4854)
- UniqueToken `impl_acquire` function should be device only [\#4819](https://github.com/kokkos/kokkos/pull/4819)
- Fix example calls to non existing static `print_configuration` [\#4806](https://github.com/kokkos/kokkos/pull/4806)
- Fix requests for large team scratch sizes [\#4728](https://github.com/kokkos/kokkos/pull/4728)
## [3.6.01](https://github.com/kokkos/kokkos/tree/3.6.01) (2022-05-23)
[Full Changelog](https://github.com/kokkos/kokkos/compare/3.6.00...3.6.01)

View File

@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
# Disable in-source builds to prevent source tree corruption.
if( "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}" )
@ -28,11 +29,6 @@ SET(KOKKOS_SRC_PATH ${Kokkos_SOURCE_DIR})
SET(KOKKOS_PATH ${Kokkos_SOURCE_DIR})
SET(KOKKOS_TOP_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
# Needed to simplify syntax of if statements
CMAKE_POLICY(SET CMP0054 NEW)
# Needed to make IN_LIST a valid operator
CMAKE_POLICY(SET CMP0057 NEW)
# Is this a build as part of Trilinos?
IF(COMMAND TRIBITS_PACKAGE_DECL)
SET(KOKKOS_HAS_TRILINOS ON)
@ -72,7 +68,6 @@ ENDFUNCTION()
LIST(APPEND CMAKE_MODULE_PATH cmake/Modules)
IF(NOT KOKKOS_HAS_TRILINOS)
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
@ -80,7 +75,7 @@ IF(NOT KOKKOS_HAS_TRILINOS)
# downstream dependencies need to match this!
SET(KOKKOS_COMPILE_LANGUAGE CXX)
# use lower case here since we didn't parse options yet
IF (Kokkos_ENABLE_COMPILE_AS_CMAKE_LANGUAGE)
IF (Kokkos_ENABLE_COMPILE_AS_CMAKE_LANGUAGE AND Kokkos_ENABLE_CUDA)
# Without this as a language for the package we would get a C++ compiler enabled.
# but we still need a C++ compiler even if we build all our cpp files as CUDA only
@ -90,9 +85,7 @@ IF(NOT KOKKOS_HAS_TRILINOS)
# days.
SET(KOKKOS_INTERNAL_EXTRA_COMPILE_LANGUAGE CXX)
IF (Kokkos_ENABLE_CUDA)
SET(KOKKOS_COMPILE_LANGUAGE CUDA)
ENDIF()
SET(KOKKOS_COMPILE_LANGUAGE CUDA)
ENDIF()
IF (Spack_WORKAROUND)
@ -135,14 +128,11 @@ ENDIF()
set(Kokkos_VERSION_MAJOR 3)
set(Kokkos_VERSION_MINOR 6)
set(Kokkos_VERSION_PATCH 01)
set(Kokkos_VERSION_MINOR 7)
set(Kokkos_VERSION_PATCH 00)
set(Kokkos_VERSION "${Kokkos_VERSION_MAJOR}.${Kokkos_VERSION_MINOR}.${Kokkos_VERSION_PATCH}")
math(EXPR KOKKOS_VERSION "${Kokkos_VERSION_MAJOR} * 10000 + ${Kokkos_VERSION_MINOR} * 100 + ${Kokkos_VERSION_PATCH}")
MESSAGE(STATUS "Setting policy CMP0074 to use <Package>_ROOT variables")
CMAKE_POLICY(SET CMP0074 NEW)
# Load either the real TriBITS or a TriBITS wrapper
# for certain utility functions that are universal (like GLOBAL_SET)
INCLUDE(${KOKKOS_SRC_PATH}/cmake/fake_tribits.cmake)
@ -204,11 +194,16 @@ KOKKOS_SETUP_BUILD_ENVIRONMENT()
OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF)
SET(KOKKOS_EXT_LIBRARIES Kokkos::kokkos Kokkos::kokkoscore Kokkos::kokkoscontainers Kokkos::kokkosalgorithms)
SET(KOKKOS_INT_LIBRARIES kokkos kokkoscore kokkoscontainers kokkosalgorithms)
SET(KOKKOS_SUB_LIBRARIES kokkoscore kokkoscontainers kokkosalgorithms)
IF (KOKKOS_CXX_STANDARD GREATER_EQUAL 17)
LIST(APPEND KOKKOS_EXT_LIBRARIES Kokkos::kokkossimd)
LIST(APPEND KOKKOS_SUB_LIBRARIES kokkossimd)
ENDIF()
SET(KOKKOS_INT_LIBRARIES kokkos ${KOKKOS_SUB_LIBRARIES})
SET_PROPERTY(GLOBAL PROPERTY KOKKOS_INT_LIBRARIES ${KOKKOS_INT_LIBRARIES})
IF (KOKKOS_HAS_TRILINOS)
SET(TRILINOS_INCDIR ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDE_DIR})
SET(TRILINOS_INCDIR ${${PROJECT_NAME}_INSTALL_INCLUDE_DIR})
SET(KOKKOS_HEADER_DIR ${TRILINOS_INCDIR})
SET(KOKKOS_IS_SUBDIRECTORY TRUE)
ELSEIF(HAS_PARENT)
@ -296,7 +291,7 @@ IF (NOT KOKKOS_HAS_TRILINOS AND NOT Kokkos_INSTALL_TESTING)
#Make sure in-tree projects can reference this as Kokkos::
#to match the installed target names
ADD_LIBRARY(Kokkos::kokkos ALIAS kokkos)
TARGET_LINK_LIBRARIES(kokkos INTERFACE kokkoscore kokkoscontainers kokkosalgorithms)
TARGET_LINK_LIBRARIES(kokkos INTERFACE ${KOKKOS_SUB_LIBRARIES})
KOKKOS_INTERNAL_ADD_LIBRARY_INSTALL(kokkos)
ENDIF()
INCLUDE(${KOKKOS_SRC_PATH}/cmake/kokkos_install.cmake)

View File

@ -11,21 +11,21 @@ CXXFLAGS += $(SHFLAGS)
endif
KOKKOS_VERSION_MAJOR = 3
KOKKOS_VERSION_MINOR = 6
KOKKOS_VERSION_PATCH = 01
KOKKOS_VERSION_MINOR = 7
KOKKOS_VERSION_PATCH = 00
KOKKOS_VERSION = $(shell echo $(KOKKOS_VERSION_MAJOR)*10000+$(KOKKOS_VERSION_MINOR)*100+$(KOKKOS_VERSION_PATCH) | bc)
# Options: Cuda,HIP,SYCL,OpenMPTarget,OpenMP,Threads,Serial
KOKKOS_DEVICES ?= "OpenMP"
#KOKKOS_DEVICES ?= "Threads"
# Options:
# Intel: KNC,KNL,SNB,HSW,BDW,SKX
# Intel: KNC,KNL,SNB,HSW,BDW,SKL,SKX,ICL,ICX,SPR
# NVIDIA: Kepler,Kepler30,Kepler32,Kepler35,Kepler37,Maxwell,Maxwell50,Maxwell52,Maxwell53,Pascal60,Pascal61,Volta70,Volta72,Turing75,Ampere80,Ampere86
# ARM: ARMv80,ARMv81,ARMv8-ThunderX,ARMv8-TX2,A64FX
# IBM: BGQ,Power7,Power8,Power9
# AMD-GPUS: Vega900,Vega906,Vega908,Vega90A
# AMD-CPUS: AMDAVX,Zen,Zen2,Zen3
# Intel-GPUs: Gen9,Gen11,Gen12LP,DG1,XeHP
# Intel-GPUs: Gen9,Gen11,Gen12LP,DG1,XeHP,PVC
KOKKOS_ARCH ?= ""
# Options: yes,no
KOKKOS_DEBUG ?= "no"
@ -193,6 +193,8 @@ KOKKOS_INTERNAL_COMPILER_INTEL_CLANG := $(call kokkos_has_string,$(KOKKOS_CXX_VE
KOKKOS_INTERNAL_COMPILER_APPLE_CLANG := $(call kokkos_has_string,$(KOKKOS_CXX_VERSION),Apple clang)
KOKKOS_INTERNAL_COMPILER_HCC := $(call kokkos_has_string,$(KOKKOS_CXX_VERSION),HCC)
KOKKOS_INTERNAL_COMPILER_GCC := $(call kokkos_has_string,$(KOKKOS_CXX_VERSION),GCC)
# TODO fujitsu can emulate gcc or clang. Only clang mode works at the moment.
KOKKOS_INTERNAL_COMPILER_FUJITSU := $(call kokkos_has_string,$(KOKKOS_CXX_VERSION),FUJITSU)
# Check Host Compiler if using NVCC through nvcc_wrapper
ifeq ($(KOKKOS_INTERNAL_COMPILER_NVCC), 1)
@ -221,8 +223,23 @@ endif
ifeq ($(KOKKOS_INTERNAL_COMPILER_HCC), 1)
KOKKOS_INTENAL_COMPILER_CLANG = 0
endif
# Fujitsu passes also as clang and gcc respectively
ifeq ($(KOKKOS_INTERNAL_COMPILER_FUJITSU), 1)
ifeq ($(KOKKOS_INTERNAL_COMPILER_GCC), 1)
# TODO handle gcc flags and workaround for bug?
# fujitsu (gcc mode) is bugged, see https://github.com/kokkos/kokkos/issues/4730
$(warning Warning: ${CXX} in Trad Mode '-Nnoclang' (default) is not recommended. Use 'CXX = ${CXX} -Nclang' instead.)
# HACK since fujitsu only accepts some gcc flags, disable gcc here?
# KOKKOS_INTERNAL_COMPILER_GCC = 0
endif
# TODO handle clang flags
# warnings: works fine as is
# openmp: handled
#KOKKOS_INTERNAL_COMPILER_CLANG = 0
endif
ifeq ($(KOKKOS_INTERNAL_COMPILER_CLANG), 1)
# TODO empty variable if fujitsu (clang mode) passes as clang
KOKKOS_INTERNAL_COMPILER_CLANG_VERSION := $(shell $(CXX) --version | grep version | cut -d ' ' -f3 | tr -d '.')
ifeq ($(KOKKOS_INTERNAL_USE_CUDA), 1)
@ -272,7 +289,12 @@ else
ifeq ($(KOKKOS_INTERNAL_COMPILER_CRAY_CLANG), 1)
KOKKOS_INTERNAL_OPENMP_FLAG := -fopenmp
else
KOKKOS_INTERNAL_OPENMP_FLAG := -fopenmp=libomp
ifeq ($(KOKKOS_INTERNAL_COMPILER_FUJITSU), 1)
# fujitsu (clang mode) fails with `=libomp`
KOKKOS_INTERNAL_OPENMP_FLAG := -fopenmp
else
KOKKOS_INTERNAL_OPENMP_FLAG := -fopenmp=libomp
endif
endif
else
ifeq ($(KOKKOS_INTERNAL_COMPILER_APPLE_CLANG), 1)
@ -300,11 +322,15 @@ ifeq ($(KOKKOS_INTERNAL_COMPILER_XL), 1)
else
ifeq ($(KOKKOS_INTERNAL_COMPILER_CLANG), 1)
#KOKKOS_INTERNAL_OPENMPTARGET_FLAG := -DKOKKOS_BUG_WORKAROUND_IBM_CLANG_OMP45_VIEW_INIT -fopenmp-implicit-declare-target -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp -fopenmp=libomp
KOKKOS_INTERNAL_OPENMPTARGET_FLAG := -DKOKKOS_WORKAROUND_OPENMPTARGET_CLANG -fopenmp -fopenmp=libomp
KOKKOS_INTERNAL_OPENMPTARGET_FLAG := -DKOKKOS_WORKAROUND_OPENMPTARGET_CLANG -fopenmp -fopenmp=libomp -Wno-openmp-mapping
KOKKOS_INTERNAL_OPENMPTARGET_LIB := -lomptarget
else
#Assume GCC
KOKKOS_INTERNAL_OPENMPTARGET_FLAG := -fopenmp -foffload=nvptx-none
ifeq ($(KOKKOS_INTERNAL_COMPILER_INTEL_CLANG), 1)
KOKKOS_INTERNAL_OPENMPTARGET_FLAG := -fiopenmp -Wno-openmp-mapping
else
#Assume GCC
KOKKOS_INTERNAL_OPENMPTARGET_FLAG := -fopenmp -foffload=nvptx-none
endif
endif
endif
@ -344,8 +370,12 @@ KOKKOS_INTERNAL_USE_ARCH_WSM := $(call kokkos_has_string,$(KOKKOS_ARCH),WSM)
KOKKOS_INTERNAL_USE_ARCH_SNB := $(call kokkos_has_string,$(KOKKOS_ARCH),SNB)
KOKKOS_INTERNAL_USE_ARCH_HSW := $(call kokkos_has_string,$(KOKKOS_ARCH),HSW)
KOKKOS_INTERNAL_USE_ARCH_BDW := $(call kokkos_has_string,$(KOKKOS_ARCH),BDW)
KOKKOS_INTERNAL_USE_ARCH_SKL := $(call kokkos_has_string,$(KOKKOS_ARCH),SKL)
KOKKOS_INTERNAL_USE_ARCH_SKX := $(call kokkos_has_string,$(KOKKOS_ARCH),SKX)
KOKKOS_INTERNAL_USE_ARCH_KNL := $(call kokkos_has_string,$(KOKKOS_ARCH),KNL)
KOKKOS_INTERNAL_USE_ARCH_ICL := $(call kokkos_has_string,$(KOKKOS_ARCH),ICL)
KOKKOS_INTERNAL_USE_ARCH_ICX := $(call kokkos_has_string,$(KOKKOS_ARCH),ICX)
KOKKOS_INTERNAL_USE_ARCH_SPR := $(call kokkos_has_string,$(KOKKOS_ARCH),SPR)
KOKKOS_INTERNAL_USE_ARCH_INTEL_GEN := $(call kokkos_has_string,$(KOKKOS_ARCH),IntelGen)
KOKKOS_INTERNAL_USE_ARCH_INTEL_GEN9 := $(call kokkos_has_string,$(KOKKOS_ARCH),IntelGen9)
@ -353,6 +383,7 @@ KOKKOS_INTERNAL_USE_ARCH_INTEL_GEN11 := $(call kokkos_has_string,$(KOKKOS_ARCH),
KOKKOS_INTERNAL_USE_ARCH_INTEL_GEN12LP := $(call kokkos_has_string,$(KOKKOS_ARCH),IntelGen12LP)
KOKKOS_INTERNAL_USE_ARCH_INTEL_DG1 := $(call kokkos_has_string,$(KOKKOS_ARCH),IntelDG1)
KOKKOS_INTERNAL_USE_ARCH_INTEL_XEHP := $(call kokkos_has_string,$(KOKKOS_ARCH),IntelXeHP)
KOKKOS_INTERNAL_USE_ARCH_INTEL_PVC := $(call kokkos_has_string,$(KOKKOS_ARCH),PVC)
# NVIDIA based.
NVCC_WRAPPER := $(KOKKOS_PATH)/bin/nvcc_wrapper
@ -436,19 +467,9 @@ KOKKOS_INTERNAL_USE_ARCH_SSE42 := $(shell expr $(KOKKOS_INTERNAL_USE_ARCH_W
KOKKOS_INTERNAL_USE_ARCH_AVX := $(shell expr $(KOKKOS_INTERNAL_USE_ARCH_SNB) + $(KOKKOS_INTERNAL_USE_ARCH_AMDAVX))
KOKKOS_INTERNAL_USE_ARCH_AVX2 := $(shell expr $(KOKKOS_INTERNAL_USE_ARCH_HSW) + $(KOKKOS_INTERNAL_USE_ARCH_BDW) + $(KOKKOS_INTERNAL_USE_ARCH_ZEN) + $(KOKKOS_INTERNAL_USE_ARCH_ZEN2) + $(KOKKOS_INTERNAL_USE_ARCH_ZEN3))
KOKKOS_INTERNAL_USE_ARCH_AVX512MIC := $(shell expr $(KOKKOS_INTERNAL_USE_ARCH_KNL))
KOKKOS_INTERNAL_USE_ARCH_AVX512XEON := $(shell expr $(KOKKOS_INTERNAL_USE_ARCH_SKX))
# Decide what ISA level we are able to support.
KOKKOS_INTERNAL_USE_ISA_X86_64 := $(shell expr $(KOKKOS_INTERNAL_USE_ARCH_WSM) + $(KOKKOS_INTERNAL_USE_ARCH_SNB) + $(KOKKOS_INTERNAL_USE_ARCH_HSW) + $(KOKKOS_INTERNAL_USE_ARCH_BDW) + $(KOKKOS_INTERNAL_USE_ARCH_KNL) + $(KOKKOS_INTERNAL_USE_ARCH_SKX) + $(KOKKOS_INTERNAL_USE_ARCH_ZEN) + $(KOKKOS_INTERNAL_USE_ARCH_ZEN2) + $(KOKKOS_INTERNAL_USE_ARCH_ZEN3))
KOKKOS_INTERNAL_USE_ISA_KNC := $(shell expr $(KOKKOS_INTERNAL_USE_ARCH_KNC))
KOKKOS_INTERNAL_USE_ISA_POWERPCLE := $(shell expr $(KOKKOS_INTERNAL_USE_ARCH_POWER8) + $(KOKKOS_INTERNAL_USE_ARCH_POWER9))
KOKKOS_INTERNAL_USE_ISA_POWERPCBE := $(shell expr $(KOKKOS_INTERNAL_USE_ARCH_POWER7))
# Decide whether we can support transactional memory
KOKKOS_INTERNAL_USE_TM := $(shell expr $(KOKKOS_INTERNAL_USE_ARCH_BDW) + $(KOKKOS_INTERNAL_USE_ARCH_SKX))
# Incompatible flags?
KOKKOS_INTERNAL_USE_ARCH_MULTIHOST := $(strip $(shell echo "$(KOKKOS_INTERNAL_USE_ARCH_SSE42)+$(KOKKOS_INTERNAL_USE_ARCH_AVX)+$(KOKKOS_INTERNAL_USE_ARCH_AVX2)+$(KOKKOS_INTERNAL_USE_ARCH_AVX512MIC)+$(KOKKOS_INTERNAL_USE_ARCH_AVX512XEON)+$(KOKKOS_INTERNAL_USE_ARCH_KNC)+$(KOKKOS_INTERNAL_USE_ARCH_IBM)+$(KOKKOS_INTERNAL_USE_ARCH_ARM)>1") | bc)
KOKKOS_INTERNAL_USE_ARCH_MULTIHOST := $(strip $(shell echo "$(KOKKOS_INTERNAL_USE_ARCH_SSE42)+$(KOKKOS_INTERNAL_USE_ARCH_AVX)+$(KOKKOS_INTERNAL_USE_ARCH_AVX2)+$(KOKKOS_INTERNAL_USE_ARCH_AVX512MIC)+$(KOKKOS_INTERNAL_USE_ARCH_SKL)+$(KOKKOS_INTERNAL_USE_ARCH_SKX)+$(KOKKOS_INTERNAL_USE_ARCH_ICL)+$(KOKKOS_INTERNAL_USE_ARCH_ICX)+$(KOKKOS_INTERNAL_USE_ARCH_SPR)+$(KOKKOS_INTERNAL_USE_ARCH_KNC)+$(KOKKOS_INTERNAL_USE_ARCH_IBM)+$(KOKKOS_INTERNAL_USE_ARCH_ARM)>1") | bc)
KOKKOS_INTERNAL_USE_ARCH_MULTIGPU := $(strip $(shell echo "$(KOKKOS_INTERNAL_USE_ARCH_NVIDIA)>1") | bc)
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_MULTIHOST), 1)
@ -551,36 +572,6 @@ ifeq ($(KOKKOS_INTERNAL_USE_SERIAL), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ENABLE_SERIAL")
endif
ifeq ($(KOKKOS_INTERNAL_USE_TM), 1)
tmp := $(call kokkos_append_header,"$H""ifndef __CUDA_ARCH__")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ENABLE_TM")
tmp := $(call kokkos_append_header,"$H""endif")
endif
ifeq ($(KOKKOS_INTERNAL_USE_ISA_X86_64), 1)
tmp := $(call kokkos_append_header,"$H""ifndef __CUDA_ARCH__")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_USE_ISA_X86_64")
tmp := $(call kokkos_append_header,"$H""endif")
endif
ifeq ($(KOKKOS_INTERNAL_USE_ISA_KNC), 1)
tmp := $(call kokkos_append_header,"$H""ifndef __CUDA_ARCH__")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_USE_ISA_KNC")
tmp := $(call kokkos_append_header,"$H""endif")
endif
ifeq ($(KOKKOS_INTERNAL_USE_ISA_POWERPCLE), 1)
tmp := $(call kokkos_append_header,"$H""ifndef __CUDA_ARCH__")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_USE_ISA_POWERPCLE")
tmp := $(call kokkos_append_header,"$H""endif")
endif
ifeq ($(KOKKOS_INTERNAL_USE_ISA_POWERPCBE), 1)
tmp := $(call kokkos_append_header,"$H""ifndef __CUDA_ARCH__")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_USE_ISA_POWERPCBE")
tmp := $(call kokkos_append_header,"$H""endif")
endif
#only add the c++ standard flags if this is not CMake
tmp := $(call kokkos_append_header,"/* General Settings */")
ifneq ($(KOKKOS_INTERNAL_DISABLE_DEPRECATED_CODE), 1)
@ -1041,7 +1032,28 @@ ifeq ($(KOKKOS_INTERNAL_USE_ARCH_AVX512MIC), 1)
endif
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_AVX512XEON), 1)
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_SKL), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AVX512XEON")
ifeq ($(KOKKOS_INTERNAL_COMPILER_INTEL), 1)
KOKKOS_CXXFLAGS += -xSKYLAKE
KOKKOS_LDFLAGS += -xSKYLAKE
else
ifeq ($(KOKKOS_INTERNAL_COMPILER_CRAY), 1)
else
ifeq ($(KOKKOS_INTERNAL_COMPILER_PGI), 1)
else
# Nothing here yet.
KOKKOS_CXXFLAGS += -march=skylake
KOKKOS_LDFLAGS += -march=skylake
endif
endif
endif
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_SKX), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AVX512XEON")
ifeq ($(KOKKOS_INTERNAL_COMPILER_INTEL), 1)
@ -1055,13 +1067,31 @@ ifeq ($(KOKKOS_INTERNAL_USE_ARCH_AVX512XEON), 1)
else
# Nothing here yet.
KOKKOS_CXXFLAGS += -march=skylake-avx512 -mtune=skylake-avx512 -mrtm
KOKKOS_LDFLAGS += -march=skylake-avx512 -mtune=skylake-avx512 -mrtm
KOKKOS_CXXFLAGS += -march=skylake-avx512 -mtune=skylake-avx512
KOKKOS_LDFLAGS += -march=skylake-avx512 -mtune=skylake-avx512
endif
endif
endif
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_ICL), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AVX512XEON")
KOKKOS_CXXFLAGS += -march=icelake-client -mtune=icelake-client
KOKKOS_LDFLAGS += -march=icelake-client -mtune=icelake-client
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_ICX), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AVX512XEON")
KOKKOS_CXXFLAGS += -march=icelake-server -mtune=icelake-server
KOKKOS_LDFLAGS += -march=icelake-server -mtune=icelake-server
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_SPR), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AVX512XEON")
KOKKOS_CXXFLAGS += -march=sapphirerapids -mtune=sapphirerapids
KOKKOS_LDFLAGS += -march=sapphirerapids -mtune=sapphirerapids
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_KNC), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_KNC")
KOKKOS_CXXFLAGS += -mmic
@ -1091,7 +1121,7 @@ endif
ifeq ($(KOKKOS_INTERNAL_USE_OPENMPTARGET), 1)
ifeq ($(KOKKOS_INTERNAL_COMPILER_CLANG), 1)
KOKKOS_INTERNAL_CUDA_ARCH_FLAG=-fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march
KOKKOS_INTERNAL_CUDA_ARCH_FLAG=-fopenmp-targets=nvptx64 -Xopenmp-target -march
endif
KOKKOS_INTERNAL_USE_CUDA_ARCH = 1
endif
@ -1192,29 +1222,29 @@ ifeq ($(KOKKOS_INTERNAL_USE_HIP), 1)
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_VEGA900), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_VEGA900")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_VEGA")
KOKKOS_INTERNAL_HIP_ARCH_FLAG := --amdgpu-target=gfx900
KOKKOS_INTERNAL_HIP_ARCH_FLAG := --offload-arch=gfx900
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_VEGA906), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_VEGA906")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_VEGA")
KOKKOS_INTERNAL_HIP_ARCH_FLAG := --amdgpu-target=gfx906
KOKKOS_INTERNAL_HIP_ARCH_FLAG := --offload-arch=gfx906
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_VEGA908), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_VEGA908")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_VEGA")
KOKKOS_INTERNAL_HIP_ARCH_FLAG := --amdgpu-target=gfx908
KOKKOS_INTERNAL_HIP_ARCH_FLAG := --offload-arch=gfx908
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_VEGA90A), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_VEGA90A")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_VEGA")
KOKKOS_INTERNAL_HIP_ARCH_FLAG := --amdgpu-target=gfx90a
KOKKOS_INTERNAL_HIP_ARCH_FLAG := --offload-arch=gfx90a
endif
KOKKOS_SRC += $(wildcard $(KOKKOS_PATH)/core/src/HIP/*.cpp)
KOKKOS_HEADERS += $(wildcard $(KOKKOS_PATH)/core/src/HIP/*.hpp)
ifeq ($(KOKKOS_INTERNAL_DISABLE_DESUL_ATOMICS), 0)
KOKKOS_SRC += $(KOKKOS_PATH)/core/src/desul/src/Lock_Array_HIP.cpp
KOKKOS_SRC += $(KOKKOS_PATH)/tpls/desul/src/Lock_Array_HIP.cpp
endif
KOKKOS_CXXFLAGS+=$(KOKKOS_INTERNAL_HIP_ARCH_FLAG)
@ -1230,51 +1260,67 @@ ifeq ($(KOKKOS_INTERNAL_USE_HIP), 1)
endif
endif
# Figure out the architecture flag for SYCL.
# Figure out Intel architecture flags.
ifeq ($(KOKKOS_INTERNAL_USE_SYCL), 1)
# Lets start with adding architecture defines
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_INTEL_GEN), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GPU")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GEN")
KOKKOS_INTERNAL_SYCL_ARCH_FLAG := -fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xsycl-target-backend "-device gen9-"
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_INTEL_GEN9), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GPU")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GEN9")
KOKKOS_INTERNAL_SYCL_ARCH_FLAG := -fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xsycl-target-backend "-device gen9"
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_INTEL_GEN11), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GPU")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GEN11")
KOKKOS_INTERNAL_SYCL_ARCH_FLAG := -fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xsycl-target-backend "-device gen11"
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_INTEL_GEN12LP), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GPU")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GEN12LP")
KOKKOS_INTERNAL_SYCL_ARCH_FLAG := -fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xsycl-target-backend "-device gen12lp"
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_INTEL_DG1), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GPU")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_DG1")
KOKKOS_INTERNAL_SYCL_ARCH_FLAG := -fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xsycl-target-backend "-device dg1"
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_INTEL_XEHP), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GPU")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_XEHP")
KOKKOS_INTERNAL_SYCL_ARCH_FLAG := -fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xsycl-target-backend "-device xehp"
endif
KOKKOS_INTERNAL_LC_BACKEND := sycl
endif
ifeq ($(KOKKOS_INTERNAL_USE_OPENMPTARGET), 1)
KOKKOS_INTERNAL_LC_BACKEND := openmp
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_INTEL_GEN), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GPU")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GEN")
KOKKOS_INTERNAL_INTEL_ARCH_FLAG := -f${KOKKOS_INTERNAL_LC_BACKEND}-targets=spir64
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_INTEL_GEN9), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GPU")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GEN9")
KOKKOS_INTERNAL_INTEL_ARCH_FLAG := -f${KOKKOS_INTERNAL_LC_BACKEND}-targets=spir64_gen -X${KOKKOS_INTERNAL_LC_BACKEND}-target-backend "-device gen9"
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_INTEL_GEN11), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GPU")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GEN11")
KOKKOS_INTERNAL_INTEL_ARCH_FLAG := -f${KOKKOS_INTERNAL_LC_BACKEND}-targets=spir64_gen -X${KOKKOS_INTERNAL_LC_BACKEND}-target-backend "-device gen11"
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_INTEL_GEN12LP), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GPU")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GEN12LP")
KOKKOS_INTERNAL_INTEL_ARCH_FLAG := -f${KOKKOS_INTERNAL_LC_BACKEND}-targets=spir64_gen -X${KOKKOS_INTERNAL_LC_BACKEND}-target-backend "-device gen12lp"
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_INTEL_DG1), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GPU")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_DG1")
KOKKOS_INTERNAL_INTEL_ARCH_FLAG := -f${KOKKOS_INTERNAL_LC_BACKEND}-targets=spir64_gen -X${KOKKOS_INTERNAL_LC_BACKEND}-target-backend "-device dg1"
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_INTEL_XEHP), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GPU")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_XEHP")
KOKKOS_INTERNAL_INTEL_ARCH_FLAG := -f${KOKKOS_INTERNAL_LC_BACKEND}-targets=spir64_gen -X${KOKKOS_INTERNAL_LC_BACKEND}-target-backend "-device xehp"
endif
ifeq ($(KOKKOS_INTERNAL_USE_ARCH_INTEL_PVC), 1)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_GPU")
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_INTEL_PVC")
KOKKOS_INTERNAL_INTEL_ARCH_FLAG := -f${KOKKOS_INTERNAL_LC_BACKEND}-targets=spir64_gen -X${KOKKOS_INTERNAL_LC_BACKEND}-target-backend "-device 12.4.0"
endif
ifeq ($(KOKKOS_INTERNAL_USE_SYCL), 1)
KOKKOS_SRC += $(wildcard $(KOKKOS_PATH)/core/src/SYCL/*.cpp)
KOKKOS_HEADERS += $(wildcard $(KOKKOS_PATH)/core/src/SYCL/*.hpp)
KOKKOS_CXXFLAGS+=-fsycl -fno-sycl-id-queries-fit-in-int -fsycl-unnamed-lambda
KOKKOS_CXXFLAGS+=$(KOKKOS_INTERNAL_SYCL_ARCH_FLAG)
KOKKOS_CXXFLAGS+=-fsycl -fno-sycl-id-queries-fit-in-int -fsycl-unnamed-lambda -fsycl-dead-args-optimization
KOKKOS_CXXFLAGS+=$(KOKKOS_INTERNAL_INTEL_ARCH_FLAG)
KOKKOS_LDFLAGS+=-fsycl
KOKKOS_LDFLAGS+=$(KOKKOS_INTERNAL_SYCL_ARCH_FLAG)
KOKKOS_LDFLAGS+=$(KOKKOS_INTERNAL_INTEL_ARCH_FLAG)
endif
ifeq ($(KOKKOS_INTERNAL_USE_OPENMPTARGET), 1)
KOKKOS_CXXFLAGS+=$(KOKKOS_INTERNAL_INTEL_ARCH_FLAG) -D__STRICT_ANSI__
KOKKOS_LDFLAGS+=$(KOKKOS_INTERNAL_INTEL_ARCH_FLAG)
endif
ifeq ($(KOKKOS_INTERNAL_DISABLE_DESUL_ATOMICS), 0)
tmp := $(call kokkos_append_header,"$H""define KOKKOS_ENABLE_IMPL_DESUL_ATOMICS")
KOKKOS_CPPFLAGS+=-I$(KOKKOS_PATH)/tpls/desul/include
else
ifeq ($(KOKKOS_INTERNAL_ENABLE_DESUL_ATOMICS), 1)
$(error Contradictory Desul atomics options: KOKKOS_OPTIONS=$(KOKKOS_OPTIONS) )
@ -1359,7 +1405,7 @@ KOKKOS_SRC += $(wildcard $(KOKKOS_PATH)/containers/src/impl/*.cpp)
ifeq ($(KOKKOS_INTERNAL_USE_CUDA), 1)
KOKKOS_SRC += $(wildcard $(KOKKOS_PATH)/core/src/Cuda/*.cpp)
ifeq ($(KOKKOS_INTERNAL_DISABLE_DESUL_ATOMICS), 0)
KOKKOS_SRC += $(KOKKOS_PATH)/core/src/desul/src/Lock_Array_CUDA.cpp
KOKKOS_SRC += $(KOKKOS_PATH)/tpls/desul/src/Lock_Array_CUDA.cpp
endif
KOKKOS_HEADERS += $(wildcard $(KOKKOS_PATH)/core/src/Cuda/*.hpp)
ifneq ($(CUDA_PATH),)
@ -1417,6 +1463,11 @@ ifeq ($(KOKKOS_INTERNAL_USE_THREADS), 1)
KOKKOS_TPL_LIBRARY_NAMES += pthread
endif
ifeq ($(KOKKOS_INTERNAL_USE_SERIAL), 1)
KOKKOS_SRC += $(wildcard $(KOKKOS_PATH)/core/src/Serial/*.cpp)
KOKKOS_HEADERS += $(wildcard $(KOKKOS_PATH)/core/src/Serial/*.hpp)
endif
ifeq ($(KOKKOS_INTERNAL_USE_HPX), 1)
KOKKOS_SRC += $(wildcard $(KOKKOS_PATH)/core/src/HPX/*.cpp)
KOKKOS_HEADERS += $(wildcard $(KOKKOS_PATH)/core/src/HPX/*.hpp)
@ -1449,15 +1500,6 @@ ifneq ($(KOKKOS_INTERNAL_USE_MEMKIND), 1)
KOKKOS_SRC := $(filter-out $(KOKKOS_PATH)/core/src/impl/Kokkos_HBWSpace.cpp,$(KOKKOS_SRC))
endif
# Don't include Kokkos_Serial.cpp or Kokkos_Serial_Task.cpp if not using Serial
# device to avoid a link warning.
ifeq ($(KOKKOS_INTERNAL_USE_SERIAL), 1)
endif
ifneq ($(KOKKOS_INTERNAL_USE_SERIAL), 1)
KOKKOS_SRC := $(filter-out $(KOKKOS_PATH)/core/src/impl/Kokkos_Serial.cpp,$(KOKKOS_SRC))
KOKKOS_SRC := $(filter-out $(KOKKOS_PATH)/core/src/impl/Kokkos_Serial_Task.cpp,$(KOKKOS_SRC))
endif
# With Cygwin functions such as fdopen and fileno are not defined
# when strict ansi is enabled. strict ansi gets enabled with -std=c++14
# though. So we hard undefine it here. Not sure if that has any bad side effects

View File

@ -16,10 +16,6 @@ Kokkos_HostSpace.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/impl/Kokkos_Ho
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/impl/Kokkos_HostSpace.cpp
Kokkos_hwloc.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/impl/Kokkos_hwloc.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/impl/Kokkos_hwloc.cpp
Kokkos_Serial.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/impl/Kokkos_Serial.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/impl/Kokkos_Serial.cpp
Kokkos_Serial_Task.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/impl/Kokkos_Serial_Task.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/impl/Kokkos_Serial_Task.cpp
Kokkos_TaskQueue.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/impl/Kokkos_TaskQueue.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/impl/Kokkos_TaskQueue.cpp
Kokkos_HostThreadTeam.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/impl/Kokkos_HostThreadTeam.cpp
@ -41,6 +37,13 @@ Kokkos_HostSpace_deepcopy.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/impl/
Kokkos_NumericTraits.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/impl/Kokkos_NumericTraits.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/impl/Kokkos_NumericTraits.cpp
ifeq ($(KOKKOS_INTERNAL_USE_SERIAL), 1)
Kokkos_Serial.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/Serial/Kokkos_Serial.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/Serial/Kokkos_Serial.cpp
Kokkos_Serial_Task.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/Serial/Kokkos_Serial_Task.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/Serial/Kokkos_Serial_Task.cpp
endif
ifeq ($(KOKKOS_INTERNAL_USE_CUDA), 1)
Kokkos_Cuda_Instance.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/Cuda/Kokkos_Cuda_Instance.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/Cuda/Kokkos_Cuda_Instance.cpp
@ -50,8 +53,8 @@ Kokkos_Cuda_Task.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/Cuda/Kokkos_Cu
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/Cuda/Kokkos_Cuda_Task.cpp
Kokkos_Cuda_Locks.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/Cuda/Kokkos_Cuda_Locks.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/Cuda/Kokkos_Cuda_Locks.cpp
Lock_Array_CUDA.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/desul/src/Lock_Array_CUDA.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/desul/src/Lock_Array_CUDA.cpp
Lock_Array_CUDA.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/tpls/desul/src/Lock_Array_CUDA.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/tpls/desul/src/Lock_Array_CUDA.cpp
endif
ifeq ($(KOKKOS_INTERNAL_USE_SYCL), 1)
@ -70,20 +73,18 @@ Kokkos_HIP_Instance.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/HIP/Kokkos_
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/HIP/Kokkos_HIP_Instance.cpp
Kokkos_HIP_Locks.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/HIP/Kokkos_HIP_Locks.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/HIP/Kokkos_HIP_Locks.cpp
Lock_Array_HIP.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/desul/src/Lock_Array_HIP.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/desul/src/Lock_Array_HIP.cpp
Lock_Array_HIP.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/tpls/desul/src/Lock_Array_HIP.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/tpls/desul/src/Lock_Array_HIP.cpp
endif
ifeq ($(KOKKOS_INTERNAL_USE_THREADS), 1)
Kokkos_ThreadsExec_base.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/Threads/Kokkos_ThreadsExec_base.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/Threads/Kokkos_ThreadsExec_base.cpp
Kokkos_ThreadsExec.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/Threads/Kokkos_ThreadsExec.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/Threads/Kokkos_ThreadsExec.cpp
endif
ifeq ($(KOKKOS_INTERNAL_USE_OPENMP), 1)
Kokkos_OpenMP_Exec.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/OpenMP/Kokkos_OpenMP_Exec.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/OpenMP/Kokkos_OpenMP_Exec.cpp
Kokkos_OpenMP_Instance.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/OpenMP/Kokkos_OpenMP_Instance.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/OpenMP/Kokkos_OpenMP_Instance.cpp
Kokkos_OpenMP_Task.o: $(KOKKOS_CPP_DEPENDS) $(KOKKOS_PATH)/core/src/OpenMP/Kokkos_OpenMP_Task.cpp
$(CXX) $(KOKKOS_CPPFLAGS) $(KOKKOS_CXXFLAGS) $(CXXFLAGS) -c $(KOKKOS_PATH)/core/src/OpenMP/Kokkos_OpenMP_Task.cpp
endif

View File

@ -10,270 +10,48 @@ hierarchies and multiple types of execution resources. It currently can use
CUDA, HIP, SYCL, HPX, OpenMP and C++ threads as backend programming models with several other
backends in development.
Kokkos Core is part of the Kokkos C++ Performance Portability Programming EcoSystem,
which also provides math kernels (https://github.com/kokkos/kokkos-kernels), as well as
profiling and debugging tools (https://github.com/kokkos/kokkos-tools).
**Kokkos Core is part of the Kokkos C++ Performance Portability Programming EcoSystem.**
For the complete documentation, click below:
# [kokkos.github.io/kokkos-core-wiki](https://kokkos.github.io/kokkos-core-wiki)
# Learning about Kokkos
The best way to start learning about Kokkos is going through the Kokkos Lectures.
They are online available at https://kokkos.link/the-lectures and contain a mix
of lecture videos and hands-on exercises covering all the important Kokkos Ecosystem
capabilities.
To start learning about Kokkos:
A programming guide and API reference can be found on the Wiki
(https://github.com/kokkos/kokkos/wiki).
- [Kokkos Lectures](https://kokkos.github.io/kokkos-core-wiki/videolectures.html): they contain a mix of lecture videos and hands-on exercises covering all the important Kokkos Ecosystem capabilities.
- [Programming guide](https://kokkos.github.io/kokkos-core-wiki/programmingguide.html): contains in "narrative" form a technical description of the programming model, machine model, and the main building blocks like the Views and parallel dispatch.
- [API reference](https://kokkos.github.io/kokkos-core-wiki/): organized by category, i.e., [core](https://kokkos.github.io/kokkos-core-wiki/API/core-index.html), [algorithms](https://kokkos.github.io/kokkos-core-wiki/API/algorithms-index.html) and [containers](https://kokkos.github.io/kokkos-core-wiki/API/containers-index.html) or, if you prefer, in [alphabetical order](https://kokkos.github.io/kokkos-core-wiki/API/alphabetical.html).
- [Use cases and Examples](https://kokkos.github.io/kokkos-core-wiki/usecases.html): a series of examples ranging from how to use Kokkos with MPI to Fortran interoperability.
For questions find us on Slack: https://kokkosteam.slack.com or open a github issue.
For non-public questions send an email to
crtrott(at)sandia.gov
For non-public questions send an email to: *crtrott(at)sandia.gov*
# Contributing to Kokkos
We are open and try to encourage contributions from external developers.
To do so please first open an issue describing the contribution and then issue
a pull request against the develop branch. For larger features it may be good
to get guidance from the core development team first through the github issue.
Please see [this page](https://kokkos.github.io/kokkos-core-wiki/contributing.html) for details on how to contribute.
Note that Kokkos Core is licensed under standard 3-clause BSD terms of use.
Which means contributing to Kokkos allows anyone else to use your contributions
not just for public purposes but also for closed source commercial projects.
For specifics see the LICENSE file contained in the repository or distribution.
# Requirements, Building and Installing
# Requirements
### Minimum Compiler Versions
Generally Kokkos should work with all compiler versions newer than the minimum.
However as in all sufficiently complex enough code, we have to work around compiler
bugs with almost all compilers. So compiler versions we don't test may have issues
we are unaware of.
* GCC: 5.3.0
* Clang: 4.0.0
* Intel: 17.0.1
* NVCC: 9.2.88
* NVC++: 21.5
* ROCm: 4.3
* MSVC: 19.29
* IBM XL: 16.1.1
* Fujitsu: 4.5.0
* ARM/Clang 20.1
### Primary Tested Compilers
* GCC: 5.3.0, 6.1.0, 7.3.0, 8.3, 9.2, 10.0
* NVCC: 9.2.88, 10.1, 11.0
* Clang: 8.0.0, 9.0.0, 10.0.0, 12.0.0
* Intel 17.4, 18.1, 19.5
* MSVC: 19.29
* ARM/Clang: 20.1
* IBM XL: 16.1.1
* ROCm: 4.3.0
### Build system:
* CMake >= 3.16: required
* CMake >= 3.18: Fortran linkage. This does not affect most mixed Fortran/Kokkos builds. See [build issues](BUILD.md#KnownIssues).
* CMake >= 3.21.1 for NVC++
Primary tested compiler are passing in release mode
with warnings as errors. They also are tested with a comprehensive set of
backend combinations (i.e. OpenMP, Threads, Serial, OpenMP+Serial, ...).
We are using the following set of flags:
* GCC:
````
-Wall -Wunused-parameter -Wshadow -pedantic
-Werror -Wsign-compare -Wtype-limits
-Wignored-qualifiers -Wempty-body
-Wclobbered -Wuninitialized
````
* Intel:
````
-Wall -Wunused-parameter -Wshadow -pedantic
-Werror -Wsign-compare -Wtype-limits
-Wuninitialized
````
* Clang:
````
-Wall -Wunused-parameter -Wshadow -pedantic
-Werror -Wsign-compare -Wtype-limits
-Wuninitialized
````
* NVCC:
````
-Wall -Wunused-parameter -Wshadow -pedantic
-Werror -Wsign-compare -Wtype-limits
-Wuninitialized
````
Other compilers are tested occasionally, in particular when pushing from develop to
master branch. These are tested less rigorously without `-Werror` and only for a select set of backends.
# Building and Installing Kokkos
Kokkos provide a CMake build system and a raw Makefile build system.
The CMake build system is strongly encouraged and will be the most rigorously supported in future releases.
Full details are given in the [build instructions](BUILD.md). Basic setups are shown here:
## CMake
The best way to install Kokkos is using the CMake build system. Assuming Kokkos lives in `$srcdir`:
````bash
cmake $srcdir \
-DCMAKE_CXX_COMPILER=$path_to_compiler \
-DCMAKE_INSTALL_PREFIX=$path_to_install \
-DKokkos_ENABLE_OPENMP=On \
-DKokkos_ARCH_HSW=On \
-DKokkos_HWLOC_DIR=$path_to_hwloc
````
then simply type `make install`. The Kokkos CMake package will then be installed in `$path_to_install` to be used by downstream packages.
To validate the Kokkos build, configure with
````
-DKokkos_ENABLE_TESTS=On
````
and run `make test` after completing the build.
For your CMake project using Kokkos, code such as the following:
````cmake
find_package(Kokkos)
...
target_link_libraries(myTarget Kokkos::kokkos)
````
should be added to your CMakeLists.txt. Your configure should additionally include
````
-DKokkos_DIR=$path_to_install/cmake/lib/Kokkos
````
or
````
-DKokkos_ROOT=$path_to_install
````
for the install location given above.
## Spack
An alternative to manually building with the CMake is to use the Spack package manager.
To get started, download the Spack [repo](https://github.com/spack/spack).
````
A basic installation would be done as:
````bash
> spack install kokkos
````
Spack allows options and and compilers to be tuned in the install command.
````bash
> spack install kokkos@3.0 %gcc@7.3.0 +openmp
````
This example illustrates the three most common parameters to Spack:
* Variants: specified with, e.g. `+openmp`, this activates (or deactivates with, e.g. `~openmp`) certain options.
* Version: immediately following `kokkos` the `@version` can specify a particular Kokkos to build
* Compiler: a default compiler will be chosen if not specified, but an exact compiler version can be given with the `%`option.
For a complete list of Kokkos options, run:
````bash
> spack info kokkos
````
Spack currently installs packages to a location determined by a unique hash. This hash name is not really "human readable".
Generally, Spack usage should never really require you to reference the computer-generated unique install folder.
More details are given in the [build instructions](BUILD.md). If you must know, you can locate Spack Kokkos installations with:
````bash
> spack find -p kokkos ...
````
where `...` is the unique spec identifying the particular Kokkos configuration and version.
Some more details can found in the Kokkos spack [documentation](Spack.md) or the Spack [website](https://spack.readthedocs.io/en/latest).
## Raw Makefile
Raw Makefiles are only supported via inline builds. See below.
## Inline Builds vs. Installed Package
For individual projects, it may be preferable to build Kokkos inline rather than link to an installed package.
The main reason is that you may otherwise need many different
configurations of Kokkos installed depending on the required compile time
features an application needs. For example there is only one default
execution space, which means you need different installations to have OpenMP
or C++ threads as the default space. Also for the CUDA backend there are certain
choices, such as allowing relocatable device code, which must be made at
installation time. Building Kokkos inline uses largely the same process
as compiling an application against an installed Kokkos library.
For CMake, this means copying over the Kokkos source code into your project and adding `add_subdirectory(kokkos)` to your CMakeLists.txt.
For raw Makefiles, see the example benchmarks/bytes_and_flops/Makefile which can be used with an installed library and or an inline build.
# Kokkos and CUDA UVM
Kokkos does support UVM as a specific memory space called CudaUVMSpace.
Allocations made with that space are accessible from host and device.
You can tell Kokkos to use that as the default space for Cuda allocations.
In either case UVM comes with a number of restrictions:
* You can't access allocations on the host while a kernel is potentially
running. This will lead to segfaults. To avoid that you either need to
call Kokkos::Cuda::fence() (or just Kokkos::fence()), after kernels, or
you can set the environment variable CUDA_LAUNCH_BLOCKING=1.
* In multi socket multi GPU machines without NVLINK, UVM defaults
to using zero copy allocations for technical reasons related to using multiple
GPUs from the same process. If an executable doesn't do that (e.g. each
MPI rank of an application uses a single GPU [can be the same GPU for
multiple MPI ranks]) you can set CUDA_MANAGED_FORCE_DEVICE_ALLOC=1.
This will enforce proper UVM allocations, but can lead to errors if
more than a single GPU is used by a single process.
All requirements including minimum and primary tested compiler versions can be found [here](https://kokkos.github.io/kokkos-core-wiki/requirements.html).
Building and installation instructions are described [here](https://kokkos.github.io/kokkos-core-wiki/building.html).
# Citing Kokkos
If you publish work which mentions Kokkos, please cite the following paper:
Please see the [following page](https://kokkos.github.io/kokkos-core-wiki/citation.html).
````BibTex
@ARTICLE{9485033,
author={Trott, Christian R. and Lebrun-Grandié, Damien and Arndt, Daniel and Ciesko, Jan and Dang, Vinh and Ellingwood, Nathan and Gayatri, Rahulkumar and Harvey, Evan and Hollman, Daisy S. and Ibanez, Dan and Liber, Nevin and Madsen, Jonathan and Miles, Jeff and Poliakoff, David and Powell, Amy and Rajamanickam, Sivasankaran and Simberg, Mikael and Sunderland, Dan and Turcksin, Bruno and Wilke, Jeremiah},
journal={IEEE Transactions on Parallel and Distributed Systems},
title={Kokkos 3: Programming Model Extensions for the Exascale Era},
year={2022},
volume={33},
number={4},
pages={805-817},
doi={10.1109/TPDS.2021.3097283}}
````
If you use more than one Kokkos EcoSystem package, please also cite:
````BibTex
@ARTICLE{9502936,
author={Trott, Christian and Berger-Vergiat, Luc and Poliakoff, David and Rajamanickam, Sivasankaran and Lebrun-Grandie, Damien and Madsen, Jonathan and Al Awar, Nader and Gligoric, Milos and Shipman, Galen and Womeldorff, Geoff},
journal={Computing in Science Engineering},
title={The Kokkos EcoSystem: Comprehensive Performance Portability for High Performance Computing},
year={2021},
volume={23},
number={5},
pages={10-18},
doi={10.1109/MCSE.2021.3098509}}
````
And if you feel generous: feel free to cite the original Kokkos paper which describes most of the basic Kokkos concepts:
````BibTeX
@article{CarterEdwards20143202,
title = "Kokkos: Enabling manycore performance portability through polymorphic memory access patterns ",
journal = "Journal of Parallel and Distributed Computing ",
volume = "74",
number = "12",
pages = "3202 - 3216",
year = "2014",
note = "Domain-Specific Languages and High-Level Frameworks for High-Performance Computing ",
issn = "0743-7315",
doi = "https://doi.org/10.1016/j.jpdc.2014.07.003",
url = "http://www.sciencedirect.com/science/article/pii/S0743731514001257",
author = "H. Carter Edwards and Christian R. Trott and Daniel Sunderland"
}
````
##### [LICENSE](https://github.com/kokkos/kokkos/blob/master/LICENSE)
# License
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
Under the terms of Contract DE-NA0003525 with NTESS,
the U.S. Government retains certain rights in this software.
The full license statement used in all headers is available [here](https://kokkos.github.io/kokkos-core-wiki/license.html) or
[here](https://github.com/kokkos/kokkos/blob/master/LICENSE).

View File

@ -11,6 +11,7 @@ FILE(GLOB ALGO_HEADERS *.hpp)
FILE(GLOB ALGO_SOURCES *.cpp)
LIST(APPEND ALGO_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}_config.h)
APPEND_GLOB(ALGO_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/std_algorithms/*.hpp)
APPEND_GLOB(ALGO_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/std_algorithms/impl/*.hpp)
INSTALL (
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"

View File

@ -44,6 +44,10 @@
#ifndef KOKKOS_RANDOM_HPP
#define KOKKOS_RANDOM_HPP
#ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
#define KOKKOS_IMPL_PUBLIC_INCLUDE
#define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_RANDOM
#endif
#include <Kokkos_Core.hpp>
#include <Kokkos_Complex.hpp>
@ -648,63 +652,44 @@ struct Random_UniqueIndex {
}
};
#ifdef KOKKOS_ENABLE_CUDA
template <class MemorySpace>
struct Random_UniqueIndex<Kokkos::Device<Kokkos::Cuda, MemorySpace>> {
using locks_view_type =
View<int**, Kokkos::Device<Kokkos::Cuda, MemorySpace>>;
KOKKOS_FUNCTION
static int get_state_idx(const locks_view_type& locks_) {
#ifdef __CUDA_ARCH__
const int i_offset =
(threadIdx.x * blockDim.y + threadIdx.y) * blockDim.z + threadIdx.z;
int i = (((blockIdx.x * gridDim.y + blockIdx.y) * gridDim.z + blockIdx.z) *
blockDim.x * blockDim.y * blockDim.z +
i_offset) %
locks_.extent(0);
while (Kokkos::atomic_compare_exchange(&locks_(i, 0), 0, 1)) {
i += blockDim.x * blockDim.y * blockDim.z;
if (i >= static_cast<int>(locks_.extent(0))) {
i = i_offset;
}
}
return i;
#else
(void)locks_;
return 0;
#endif
}
};
#if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_HIP)
#if defined(KOKKOS_ENABLE_CUDA)
#define KOKKOS_IMPL_EXECUTION_SPACE_CUDA_OR_HIP Kokkos::Cuda
#elif defined(KOKKOS_ENABLE_HIP)
#define KOKKOS_IMPL_EXECUTION_SPACE_CUDA_OR_HIP Kokkos::Experimental::HIP
#endif
#ifdef KOKKOS_ENABLE_HIP
template <class MemorySpace>
struct Random_UniqueIndex<
Kokkos::Device<Kokkos::Experimental::HIP, MemorySpace>> {
Kokkos::Device<KOKKOS_IMPL_EXECUTION_SPACE_CUDA_OR_HIP, MemorySpace>> {
using locks_view_type =
View<int**, Kokkos::Device<Kokkos::Experimental::HIP, MemorySpace>>;
View<int**, Kokkos::Device<KOKKOS_IMPL_EXECUTION_SPACE_CUDA_OR_HIP,
MemorySpace>>;
KOKKOS_FUNCTION
static int get_state_idx(const locks_view_type& locks_) {
#ifdef __HIP_DEVICE_COMPILE__
const int i_offset =
(threadIdx.x * blockDim.y + threadIdx.y) * blockDim.z + threadIdx.z;
int i = (((blockIdx.x * gridDim.y + blockIdx.y) * gridDim.z + blockIdx.z) *
KOKKOS_IF_ON_DEVICE((
const int i_offset =
(threadIdx.x * blockDim.y + threadIdx.y) * blockDim.z + threadIdx.z;
int i =
(((blockIdx.x * gridDim.y + blockIdx.y) * gridDim.z + blockIdx.z) *
blockDim.x * blockDim.y * blockDim.z +
i_offset) %
locks_.extent(0);
while (Kokkos::atomic_compare_exchange(&locks_(i, 0), 0, 1)) {
i += blockDim.x * blockDim.y * blockDim.z;
if (i >= static_cast<int>(locks_.extent(0))) {
i = i_offset;
}
}
return i;
#else
(void)locks_;
return 0;
#endif
while (Kokkos::atomic_compare_exchange(&locks_(i, 0), 0, 1)) {
i += blockDim.x * blockDim.y * blockDim.z;
if (i >= static_cast<int>(locks_.extent(0))) {
i = i_offset;
}
}
return i;))
KOKKOS_IF_ON_HOST(((void)locks_; return 0;))
}
};
#undef KOKKOS_IMPL_EXECUTION_SPACE_CUDA_OR_HIP
#endif
#ifdef KOKKOS_ENABLE_SYCL
@ -1279,7 +1264,6 @@ struct fill_random_functor_begin_end;
template <class ViewType, class RandomPool, int loops, class IndexType>
struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 0,
IndexType> {
using execution_space = typename ViewType::execution_space;
ViewType a;
RandomPool rand_pool;
typename ViewType::const_value_type begin, end;
@ -1303,7 +1287,6 @@ struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 0,
template <class ViewType, class RandomPool, int loops, class IndexType>
struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 1,
IndexType> {
using execution_space = typename ViewType::execution_space;
ViewType a;
RandomPool rand_pool;
typename ViewType::const_value_type begin, end;
@ -1331,7 +1314,6 @@ struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 1,
template <class ViewType, class RandomPool, int loops, class IndexType>
struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 2,
IndexType> {
using execution_space = typename ViewType::execution_space;
ViewType a;
RandomPool rand_pool;
typename ViewType::const_value_type begin, end;
@ -1361,7 +1343,6 @@ struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 2,
template <class ViewType, class RandomPool, int loops, class IndexType>
struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 3,
IndexType> {
using execution_space = typename ViewType::execution_space;
ViewType a;
RandomPool rand_pool;
typename ViewType::const_value_type begin, end;
@ -1392,7 +1373,6 @@ struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 3,
template <class ViewType, class RandomPool, int loops, class IndexType>
struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 4,
IndexType> {
using execution_space = typename ViewType::execution_space;
ViewType a;
RandomPool rand_pool;
typename ViewType::const_value_type begin, end;
@ -1424,7 +1404,6 @@ struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 4,
template <class ViewType, class RandomPool, int loops, class IndexType>
struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 5,
IndexType> {
using execution_space = typename ViewType::execution_space;
ViewType a;
RandomPool rand_pool;
typename ViewType::const_value_type begin, end;
@ -1458,7 +1437,6 @@ struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 5,
template <class ViewType, class RandomPool, int loops, class IndexType>
struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 6,
IndexType> {
using execution_space = typename ViewType::execution_space;
ViewType a;
RandomPool rand_pool;
typename ViewType::const_value_type begin, end;
@ -1494,7 +1472,6 @@ struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 6,
template <class ViewType, class RandomPool, int loops, class IndexType>
struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 7,
IndexType> {
using execution_space = typename ViewType::execution_space;
ViewType a;
RandomPool rand_pool;
typename ViewType::const_value_type begin, end;
@ -1532,7 +1509,6 @@ struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 7,
template <class ViewType, class RandomPool, int loops, class IndexType>
struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 8,
IndexType> {
using execution_space = typename ViewType::execution_space;
ViewType a;
RandomPool rand_pool;
typename ViewType::const_value_type begin, end;
@ -1569,34 +1545,57 @@ struct fill_random_functor_begin_end<ViewType, RandomPool, loops, 8,
}
};
template <class ViewType, class RandomPool, class IndexType = int64_t>
void fill_random(ViewType a, RandomPool g,
template <class ExecutionSpace, class ViewType, class RandomPool,
class IndexType = int64_t>
void fill_random(const ExecutionSpace& exec, ViewType a, RandomPool g,
typename ViewType::const_value_type begin,
typename ViewType::const_value_type end) {
int64_t LDA = a.extent(0);
if (LDA > 0)
parallel_for("Kokkos::fill_random", (LDA + 127) / 128,
Impl::fill_random_functor_begin_end<ViewType, RandomPool, 128,
ViewType::Rank, IndexType>(
a, g, begin, end));
parallel_for(
"Kokkos::fill_random",
Kokkos::RangePolicy<ExecutionSpace>(exec, 0, (LDA + 127) / 128),
Impl::fill_random_functor_begin_end<ViewType, RandomPool, 128,
ViewType::Rank, IndexType>(
a, g, begin, end));
}
} // namespace Impl
template <class ExecutionSpace, class ViewType, class RandomPool,
class IndexType = int64_t>
void fill_random(const ExecutionSpace& exec, ViewType a, RandomPool g,
typename ViewType::const_value_type begin,
typename ViewType::const_value_type end) {
Impl::apply_to_view_of_static_rank(
[&](auto dst) { Kokkos::Impl::fill_random(exec, dst, g, begin, end); },
a);
}
template <class ExecutionSpace, class ViewType, class RandomPool,
class IndexType = int64_t>
void fill_random(const ExecutionSpace& exec, ViewType a, RandomPool g,
typename ViewType::const_value_type range) {
fill_random(exec, a, g, 0, range);
}
template <class ViewType, class RandomPool, class IndexType = int64_t>
void fill_random(ViewType a, RandomPool g,
typename ViewType::const_value_type begin,
typename ViewType::const_value_type end) {
Impl::apply_to_view_of_static_rank(
[&](auto dst) { Kokkos::Impl::fill_random(dst, g, begin, end); }, a);
fill_random(typename ViewType::execution_space{}, a, g, begin, end);
}
template <class ViewType, class RandomPool, class IndexType = int64_t>
void fill_random(ViewType a, RandomPool g,
typename ViewType::const_value_type range) {
fill_random(a, g, 0, range);
fill_random(typename ViewType::execution_space{}, a, g, 0, range);
}
} // namespace Kokkos
#ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_RANDOM
#undef KOKKOS_IMPL_PUBLIC_INCLUDE
#undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_RANDOM
#endif
#endif

View File

@ -44,6 +44,10 @@
#ifndef KOKKOS_SORT_HPP_
#define KOKKOS_SORT_HPP_
#ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
#define KOKKOS_IMPL_PUBLIC_INCLUDE
#define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_SORT
#endif
#include <Kokkos_Core.hpp>
@ -120,13 +124,13 @@ class BinSort {
// If a Kokkos::View then can generate constant random access
// otherwise can only use the constant type.
using src_view_type = typename std::conditional<
using src_view_type = std::conditional_t<
Kokkos::is_view<SrcViewType>::value,
Kokkos::View<typename SrcViewType::const_data_type,
typename SrcViewType::array_layout,
typename SrcViewType::device_type,
Kokkos::MemoryTraits<Kokkos::RandomAccess> >,
typename SrcViewType::const_type>::type;
typename SrcViewType::const_type>;
using perm_view_type = typename PermuteViewType::const_type;
@ -151,8 +155,11 @@ class BinSort {
}
};
using execution_space = typename Space::execution_space;
using bin_op_type = BinSortOp;
// Naming this alias "execution_space" would be problematic since it would be
// considered as execution space for the various functors which might use
// another execution space through sort() or create_permute_vector().
using exec_space = typename Space::execution_space;
using bin_op_type = BinSortOp;
struct bin_count_tag {};
struct bin_offset_tag {};
@ -171,13 +178,13 @@ class BinSort {
// If a Kokkos::View then can generate constant random access
// otherwise can only use the constant type.
using const_rnd_key_view_type = typename std::conditional<
using const_rnd_key_view_type = std::conditional_t<
Kokkos::is_view<KeyViewType>::value,
Kokkos::View<typename KeyViewType::const_data_type,
typename KeyViewType::array_layout,
typename KeyViewType::device_type,
Kokkos::MemoryTraits<Kokkos::RandomAccess> >,
const_key_view_type>::type;
const_key_view_type>;
using non_const_key_scalar = typename KeyViewType::non_const_value_type;
using const_key_scalar = typename KeyViewType::const_value_type;
@ -220,6 +227,14 @@ class BinSort {
range_begin(range_begin_),
range_end(range_end_),
sort_within_bins(sort_within_bins_) {
static_assert(
Kokkos::SpaceAccessibility<ExecutionSpace,
typename Space::memory_space>::accessible,
"The provided execution space must be able to access the memory space "
"BinSort was initialized with!");
if (bin_op.max_bins() <= 0)
Kokkos::abort(
"The number of bins in the BinSortOp object must be greater than 0!");
bin_count_atomic = Kokkos::View<int*, Space>(
"Kokkos::SortImpl::BinSortFunctor::bin_count", bin_op.max_bins());
bin_count_const = bin_count_atomic;
@ -235,7 +250,7 @@ class BinSort {
BinSort(const_key_view_type keys_, int range_begin_, int range_end_,
BinSortOp bin_op_, bool sort_within_bins_ = false)
: BinSort(execution_space{}, keys_, range_begin_, range_end_, bin_op_,
: BinSort(exec_space{}, keys_, range_begin_, range_end_, bin_op_,
sort_within_bins_) {}
template <typename ExecutionSpace>
@ -245,13 +260,19 @@ class BinSort {
BinSort(const_key_view_type keys_, BinSortOp bin_op_,
bool sort_within_bins_ = false)
: BinSort(execution_space{}, keys_, bin_op_, sort_within_bins_) {}
: BinSort(exec_space{}, keys_, bin_op_, sort_within_bins_) {}
//----------------------------------------
// Create the permutation vector, the bin_offset array and the bin_count
// array. Can be called again if keys changed
template <class ExecutionSpace = execution_space>
void create_permute_vector(const ExecutionSpace& exec = execution_space{}) {
template <class ExecutionSpace = exec_space>
void create_permute_vector(const ExecutionSpace& exec = exec_space{}) {
static_assert(
Kokkos::SpaceAccessibility<ExecutionSpace,
typename Space::memory_space>::accessible,
"The provided execution space must be able to access the memory space "
"BinSort was initialized with!");
const size_t len = range_end - range_begin;
Kokkos::parallel_for(
"Kokkos::Sort::BinCount",
@ -281,6 +302,17 @@ class BinSort {
template <class ExecutionSpace, class ValuesViewType>
void sort(const ExecutionSpace& exec, ValuesViewType const& values,
int values_range_begin, int values_range_end) const {
static_assert(
Kokkos::SpaceAccessibility<ExecutionSpace,
typename Space::memory_space>::accessible,
"The provided execution space must be able to access the memory space "
"BinSort was initialized with!");
static_assert(
Kokkos::SpaceAccessibility<
ExecutionSpace, typename ValuesViewType::memory_space>::accessible,
"The provided execution space must be able to access the memory space "
"of the View argument!");
using scratch_view_type =
Kokkos::View<typename ValuesViewType::data_type,
typename ValuesViewType::array_layout,
@ -340,7 +372,7 @@ class BinSort {
template <class ValuesViewType>
void sort(ValuesViewType const& values, int values_range_begin,
int values_range_end) const {
execution_space exec;
exec_space exec;
sort(exec, values, values_range_begin, values_range_end);
exec.fence("Kokkos::Sort: fence after sorting");
}
@ -428,7 +460,7 @@ struct BinOp1D {
BinOp1D() = default;
// Construct BinOp with number of bins, minimum value and maxuimum value
// Construct BinOp with number of bins, minimum value and maximum value
BinOp1D(int max_bins__, typename KeyViewType::const_value_type min,
typename KeyViewType::const_value_type max)
: max_bins_(max_bins__ + 1),
@ -554,11 +586,7 @@ struct min_max_functor {
template <class ExecutionSpace, class ViewType>
std::enable_if_t<Kokkos::is_execution_space<ExecutionSpace>::value> sort(
const ExecutionSpace& exec, ViewType const& view,
bool const always_use_kokkos_sort = false) {
if (!always_use_kokkos_sort) {
if (Impl::try_std_sort(view, exec)) return;
}
const ExecutionSpace& exec, ViewType const& view) {
using CompType = BinOp1D<ViewType>;
Kokkos::MinMaxScalar<typename ViewType::non_const_value_type> result;
@ -596,12 +624,38 @@ std::enable_if_t<Kokkos::is_execution_space<ExecutionSpace>::value> sort(
bin_sort.sort(exec, view);
}
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
template <class ExecutionSpace, class ViewType>
KOKKOS_DEPRECATED_WITH_COMMENT(
"Use the overload not taking bool always_use_kokkos_sort")
std::enable_if_t<Kokkos::is_execution_space<ExecutionSpace>::value> sort(
const ExecutionSpace& exec, ViewType const& view,
bool const always_use_kokkos_sort) {
if (!always_use_kokkos_sort && Impl::try_std_sort(view, exec)) {
return;
} else {
sort(exec, view);
}
}
#endif
template <class ViewType>
void sort(ViewType const& view, bool const always_use_kokkos_sort = false) {
void sort(ViewType const& view) {
typename ViewType::execution_space exec;
sort(exec, view);
exec.fence("Kokkos::Sort: fence after sorting");
}
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
template <class ViewType>
KOKKOS_DEPRECATED_WITH_COMMENT(
"Use the overload not taking bool always_use_kokkos_sort")
void sort(ViewType const& view, bool const always_use_kokkos_sort) {
typename ViewType::execution_space exec;
sort(exec, view, always_use_kokkos_sort);
exec.fence("Kokkos::Sort: fence after sorting");
}
#endif
template <class ExecutionSpace, class ViewType>
std::enable_if_t<Kokkos::is_execution_space<ExecutionSpace>::value> sort(
@ -635,4 +689,8 @@ void sort(ViewType view, size_t const begin, size_t const end) {
} // namespace Kokkos
#ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_SORT
#undef KOKKOS_IMPL_PUBLIC_INCLUDE
#undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_SORT
#endif
#endif

View File

@ -44,59 +44,103 @@
#ifndef KOKKOS_STD_ALGORITHMS_HPP
#define KOKKOS_STD_ALGORITHMS_HPP
#ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
#define KOKKOS_IMPL_PUBLIC_INCLUDE
#define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_STD_ALGORITHMS
#endif
/// \file Kokkos_StdAlgorithms.hpp
/// \brief Kokkos counterparts for Standard C++ Library algorithms
#include <std_algorithms/Kokkos_Constraints.hpp>
#include <std_algorithms/Kokkos_RandomAccessIterator.hpp>
#include <std_algorithms/Kokkos_BeginEnd.hpp>
#include "std_algorithms/impl/Kokkos_Constraints.hpp"
#include "std_algorithms/impl/Kokkos_RandomAccessIterator.hpp"
#include "std_algorithms/Kokkos_BeginEnd.hpp"
// distance
#include <std_algorithms/Kokkos_Distance.hpp>
#include "std_algorithms/Kokkos_Distance.hpp"
// move, swap, iter_swap
#include "std_algorithms/Kokkos_ModifyingOperations.hpp"
// note that we categorize below the headers
// following the std classification.
// find, find_if, find_if_not
// for_each, for_each_n
// mismatch
// equal
// count_if, count
// all_of, any_of, none_of
// adjacent_find
// lexicographical_compare
// search, search_n
// find_first_of, find_end
#include <std_algorithms/Kokkos_NonModifyingSequenceOperations.hpp>
// modifying ops
#include "std_algorithms/Kokkos_Swap.hpp"
#include "std_algorithms/Kokkos_IterSwap.hpp"
// replace, replace_copy_if, replace_copy, replace_if
// copy, copy_n, copy_backward, copy_if
// fill, fill_n
// transform
// generate, generate_n
// reverse, reverse_copy
// move, move_backward
// swap_ranges
// unique, unique_copy
// rotate, rotate_copy
// remove, remove_if, remove_copy, remove_copy_if
// shift_left, shift_right
#include <std_algorithms/Kokkos_ModifyingSequenceOperations.hpp>
// non-modifying sequence
#include "std_algorithms/Kokkos_AdjacentFind.hpp"
#include "std_algorithms/Kokkos_Count.hpp"
#include "std_algorithms/Kokkos_CountIf.hpp"
#include "std_algorithms/Kokkos_AllOf.hpp"
#include "std_algorithms/Kokkos_AnyOf.hpp"
#include "std_algorithms/Kokkos_NoneOf.hpp"
#include "std_algorithms/Kokkos_Equal.hpp"
#include "std_algorithms/Kokkos_Find.hpp"
#include "std_algorithms/Kokkos_FindIf.hpp"
#include "std_algorithms/Kokkos_FindIfNot.hpp"
#include "std_algorithms/Kokkos_FindEnd.hpp"
#include "std_algorithms/Kokkos_FindFirstOf.hpp"
#include "std_algorithms/Kokkos_ForEach.hpp"
#include "std_algorithms/Kokkos_ForEachN.hpp"
#include "std_algorithms/Kokkos_LexicographicalCompare.hpp"
#include "std_algorithms/Kokkos_Mismatch.hpp"
#include "std_algorithms/Kokkos_Search.hpp"
#include "std_algorithms/Kokkos_SearchN.hpp"
// is_sorted_until, is_sorted
#include <std_algorithms/Kokkos_SortingOperations.hpp>
// modifying sequence
#include "std_algorithms/Kokkos_Fill.hpp"
#include "std_algorithms/Kokkos_FillN.hpp"
#include "std_algorithms/Kokkos_Replace.hpp"
#include "std_algorithms/Kokkos_ReplaceIf.hpp"
#include "std_algorithms/Kokkos_ReplaceCopyIf.hpp"
#include "std_algorithms/Kokkos_ReplaceCopy.hpp"
#include "std_algorithms/Kokkos_Copy.hpp"
#include "std_algorithms/Kokkos_CopyN.hpp"
#include "std_algorithms/Kokkos_CopyBackward.hpp"
#include "std_algorithms/Kokkos_CopyIf.hpp"
#include "std_algorithms/Kokkos_Transform.hpp"
#include "std_algorithms/Kokkos_Generate.hpp"
#include "std_algorithms/Kokkos_GenerateN.hpp"
#include "std_algorithms/Kokkos_Reverse.hpp"
#include "std_algorithms/Kokkos_ReverseCopy.hpp"
#include "std_algorithms/Kokkos_Move.hpp"
#include "std_algorithms/Kokkos_MoveBackward.hpp"
#include "std_algorithms/Kokkos_SwapRanges.hpp"
#include "std_algorithms/Kokkos_Unique.hpp"
#include "std_algorithms/Kokkos_UniqueCopy.hpp"
#include "std_algorithms/Kokkos_Rotate.hpp"
#include "std_algorithms/Kokkos_RotateCopy.hpp"
#include "std_algorithms/Kokkos_Remove.hpp"
#include "std_algorithms/Kokkos_RemoveIf.hpp"
#include "std_algorithms/Kokkos_RemoveCopy.hpp"
#include "std_algorithms/Kokkos_RemoveCopyIf.hpp"
#include "std_algorithms/Kokkos_ShiftLeft.hpp"
#include "std_algorithms/Kokkos_ShiftRight.hpp"
// min_element, max_element, minmax_element
#include <std_algorithms/Kokkos_MinMaxElementOperations.hpp>
// sorting
#include "std_algorithms/Kokkos_IsSortedUntil.hpp"
#include "std_algorithms/Kokkos_IsSorted.hpp"
// is_partitioned, partition_copy, partition_point
#include <std_algorithms/Kokkos_PartitioningOperations.hpp>
// min/max element
#include "std_algorithms/Kokkos_MinElement.hpp"
#include "std_algorithms/Kokkos_MaxElement.hpp"
#include "std_algorithms/Kokkos_MinMaxElement.hpp"
// adjacent_difference
// reduce, transform_reduce
// exclusive_scan, transform_exclusive_scan
// inclusive_scan, transform_inclusive_scan
#include <std_algorithms/Kokkos_Numeric.hpp>
// partitioning
#include "std_algorithms/Kokkos_IsPartitioned.hpp"
#include "std_algorithms/Kokkos_PartitionCopy.hpp"
#include "std_algorithms/Kokkos_PartitionPoint.hpp"
// numeric
#include "std_algorithms/Kokkos_AdjacentDifference.hpp"
#include "std_algorithms/Kokkos_Reduce.hpp"
#include "std_algorithms/Kokkos_TransformReduce.hpp"
#include "std_algorithms/Kokkos_ExclusiveScan.hpp"
#include "std_algorithms/Kokkos_TransformExclusiveScan.hpp"
#include "std_algorithms/Kokkos_InclusiveScan.hpp"
#include "std_algorithms/Kokkos_TransformInclusiveScan.hpp"
#ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_STD_ALGORITHMS
#undef KOKKOS_IMPL_PUBLIC_INCLUDE
#undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_STD_ALGORITHMS
#endif
#endif

View File

@ -42,106 +42,15 @@
//@HEADER
*/
#ifndef KOKKOS_STD_NUMERICS_ADJACENT_DIFFERENCE_HPP
#define KOKKOS_STD_NUMERICS_ADJACENT_DIFFERENCE_HPP
#ifndef KOKKOS_STD_ALGORITHMS_ADJACENT_DIFFERENCE_HPP
#define KOKKOS_STD_ALGORITHMS_ADJACENT_DIFFERENCE_HPP
#include <Kokkos_Core.hpp>
#include "../Kokkos_BeginEnd.hpp"
#include "../Kokkos_Constraints.hpp"
#include "../Kokkos_Distance.hpp"
#include "impl/Kokkos_AdjacentDifference.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
namespace Impl {
// ------------------------
//
// functors
//
// ------------------------
template <class ValueType1, class ValueType2, class RetType = ValueType2>
struct StdAdjacentDifferenceDefaultBinaryOpFunctor {
KOKKOS_FUNCTION
constexpr RetType operator()(const ValueType1& a, const ValueType2& b) const {
return a - b;
}
};
template <class InputIteratorType, class OutputIteratorType,
class BinaryOperator>
struct StdAdjacentDiffFunctor {
using index_type = typename InputIteratorType::difference_type;
const InputIteratorType m_first_from;
const OutputIteratorType m_first_dest;
BinaryOperator m_op;
KOKKOS_FUNCTION
void operator()(const index_type i) const {
const auto& my_value = m_first_from[i];
if (i == 0) {
m_first_dest[i] = my_value;
} else {
const auto& left_value = m_first_from[i - 1];
m_first_dest[i] = m_op(my_value, left_value);
}
}
KOKKOS_FUNCTION
StdAdjacentDiffFunctor(InputIteratorType first_from,
OutputIteratorType first_dest, BinaryOperator op)
: m_first_from(std::move(first_from)),
m_first_dest(std::move(first_dest)),
m_op(std::move(op)) {}
};
// ------------------------------------------
// adjacent_difference_impl
// ------------------------------------------
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class BinaryOp>
OutputIteratorType adjacent_difference_impl(const std::string& label,
const ExecutionSpace& ex,
InputIteratorType first_from,
InputIteratorType last_from,
OutputIteratorType first_dest,
BinaryOp bin_op) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first_from, first_dest);
Impl::static_assert_iterators_have_matching_difference_type(first_from,
first_dest);
Impl::expect_valid_range(first_from, last_from);
if (first_from == last_from) {
return first_dest;
}
// aliases
using value_type = typename OutputIteratorType::value_type;
using aux_view_type = ::Kokkos::View<value_type*, ExecutionSpace>;
using functor_t =
StdAdjacentDiffFunctor<InputIteratorType, OutputIteratorType, BinaryOp>;
// run
const auto num_elements =
Kokkos::Experimental::distance(first_from, last_from);
aux_view_type aux_view("aux_view", num_elements);
::Kokkos::parallel_for(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
functor_t(first_from, first_dest, bin_op));
ex.fence("Kokkos::adjacent_difference: fence after operation");
// return
return first_dest + num_elements;
}
} // end namespace Impl
// ------------------------
//
// public API
//
// ------------------------
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType>
std::enable_if_t<!::Kokkos::is_view<InputIteratorType>::value,

View File

@ -0,0 +1,124 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_ADJACENT_FIND_HPP
#define KOKKOS_STD_ALGORITHMS_ADJACENT_FIND_HPP
#include "impl/Kokkos_AdjacentFind.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
// overload set1
template <class ExecutionSpace, class IteratorType>
IteratorType adjacent_find(const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
return Impl::adjacent_find_impl("Kokkos::adjacent_find_iterator_api_default",
ex, first, last);
}
template <class ExecutionSpace, class IteratorType>
IteratorType adjacent_find(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last) {
return Impl::adjacent_find_impl(label, ex, first, last);
}
template <class ExecutionSpace, class DataType, class... Properties>
auto adjacent_find(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::adjacent_find_impl("Kokkos::adjacent_find_view_api_default", ex,
KE::begin(v), KE::end(v));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto adjacent_find(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::adjacent_find_impl(label, ex, KE::begin(v), KE::end(v));
}
// overload set2
template <class ExecutionSpace, class IteratorType, class BinaryPredicateType>
IteratorType adjacent_find(const ExecutionSpace& ex, IteratorType first,
IteratorType last, BinaryPredicateType pred) {
return Impl::adjacent_find_impl("Kokkos::adjacent_find_iterator_api_default",
ex, first, last, pred);
}
template <class ExecutionSpace, class IteratorType, class BinaryPredicateType>
IteratorType adjacent_find(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
BinaryPredicateType pred) {
return Impl::adjacent_find_impl(label, ex, first, last, pred);
}
template <class ExecutionSpace, class DataType, class... Properties,
class BinaryPredicateType>
auto adjacent_find(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
BinaryPredicateType pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::adjacent_find_impl("Kokkos::adjacent_find_view_api_default", ex,
KE::begin(v), KE::end(v), pred);
}
template <class ExecutionSpace, class DataType, class... Properties,
class BinaryPredicateType>
auto adjacent_find(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
BinaryPredicateType pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::adjacent_find_impl(label, ex, KE::begin(v), KE::end(v), pred);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,94 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_ALL_OF_HPP
#define KOKKOS_STD_ALGORITHMS_ALL_OF_HPP
#include "impl/Kokkos_AllOfAnyOfNoneOf.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class Predicate>
bool all_of(const ExecutionSpace& ex, InputIterator first, InputIterator last,
Predicate predicate) {
return Impl::all_of_impl("Kokkos::all_of_iterator_api_default", ex, first,
last, predicate);
}
template <class ExecutionSpace, class InputIterator, class Predicate>
bool all_of(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last, Predicate predicate) {
return Impl::all_of_impl(label, ex, first, last, predicate);
}
template <class ExecutionSpace, class DataType, class... Properties,
class Predicate>
bool all_of(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::all_of_impl("Kokkos::all_of_view_api_default", ex, KE::cbegin(v),
KE::cend(v), std::move(predicate));
}
template <class ExecutionSpace, class DataType, class... Properties,
class Predicate>
bool all_of(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::all_of_impl(label, ex, KE::cbegin(v), KE::cend(v),
std::move(predicate));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,94 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_ANY_OF_HPP
#define KOKKOS_STD_ALGORITHMS_ANY_OF_HPP
#include "impl/Kokkos_AllOfAnyOfNoneOf.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class Predicate>
bool any_of(const ExecutionSpace& ex, InputIterator first, InputIterator last,
Predicate predicate) {
return Impl::any_of_impl("Kokkos::any_of_view_api_default", ex, first, last,
predicate);
}
template <class ExecutionSpace, class InputIterator, class Predicate>
bool any_of(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last, Predicate predicate) {
return Impl::any_of_impl(label, ex, first, last, predicate);
}
template <class ExecutionSpace, class DataType, class... Properties,
class Predicate>
bool any_of(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::any_of_impl("Kokkos::any_of_view_api_default", ex, KE::cbegin(v),
KE::cend(v), std::move(predicate));
}
template <class ExecutionSpace, class DataType, class... Properties,
class Predicate>
bool any_of(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::any_of_impl(label, ex, KE::cbegin(v), KE::cend(v),
std::move(predicate));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -46,8 +46,8 @@
#define KOKKOS_BEGIN_END_HPP
#include <Kokkos_View.hpp>
#include "Kokkos_RandomAccessIterator.hpp"
#include "Kokkos_Constraints.hpp"
#include "impl/Kokkos_RandomAccessIterator.hpp"
#include "impl/Kokkos_Constraints.hpp"
/// \file Kokkos_BeginEnd.hpp
/// \brief Kokkos begin, end, cbegin, cend

View File

@ -0,0 +1,97 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_COPY_HPP
#define KOKKOS_STD_ALGORITHMS_COPY_HPP
#include "impl/Kokkos_CopyCopyN.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class OutputIterator>
OutputIterator copy(const ExecutionSpace& ex, InputIterator first,
InputIterator last, OutputIterator d_first) {
return Impl::copy_impl("Kokkos::copy_iterator_api_default", ex, first, last,
d_first);
}
template <class ExecutionSpace, class InputIterator, class OutputIterator>
OutputIterator copy(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last,
OutputIterator d_first) {
return Impl::copy_impl(label, ex, first, last, d_first);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto copy(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
namespace KE = ::Kokkos::Experimental;
return Impl::copy_impl("Kokkos::copy_view_api_default", ex,
KE::cbegin(source), KE::cend(source), KE::begin(dest));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto copy(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
namespace KE = ::Kokkos::Experimental;
return Impl::copy_impl(label, ex, KE::cbegin(source), KE::cend(source),
KE::begin(dest));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,95 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_COPY_BACKWARD_HPP
#define KOKKOS_STD_ALGORITHMS_COPY_BACKWARD_HPP
#include "impl/Kokkos_CopyBackward.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType2 copy_backward(const ExecutionSpace& ex, IteratorType1 first,
IteratorType1 last, IteratorType2 d_last) {
return Impl::copy_backward_impl("Kokkos::copy_backward_iterator_api_default",
ex, first, last, d_last);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType2 copy_backward(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first, IteratorType1 last,
IteratorType2 d_last) {
return Impl::copy_backward_impl(label, ex, first, last, d_last);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto copy_backward(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::copy_backward_impl("Kokkos::copy_backward_view_api_default", ex,
cbegin(source), cend(source), end(dest));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto copy_backward(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::copy_backward_impl(label, ex, cbegin(source), cend(source),
end(dest));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,99 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_COPY_IF_HPP
#define KOKKOS_STD_ALGORITHMS_COPY_IF_HPP
#include "impl/Kokkos_CopyIf.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class Predicate>
OutputIterator copy_if(const ExecutionSpace& ex, InputIterator first,
InputIterator last, OutputIterator d_first,
Predicate pred) {
return Impl::copy_if_impl("Kokkos::copy_if_iterator_api_default", ex, first,
last, d_first, std::move(pred));
}
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class Predicate>
OutputIterator copy_if(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last,
OutputIterator d_first, Predicate pred) {
return Impl::copy_if_impl(label, ex, first, last, d_first, std::move(pred));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class Predicate>
auto copy_if(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest, Predicate pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::copy_if_impl("Kokkos::copy_if_view_api_default", ex,
cbegin(source), cend(source), begin(dest),
std::move(pred));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class Predicate>
auto copy_if(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest, Predicate pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::copy_if_impl(label, ex, cbegin(source), cend(source),
begin(dest), std::move(pred));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,98 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_COPY_N_HPP
#define KOKKOS_STD_ALGORITHMS_COPY_N_HPP
#include "impl/Kokkos_CopyCopyN.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class Size,
class OutputIterator>
OutputIterator copy_n(const ExecutionSpace& ex, InputIterator first, Size count,
OutputIterator result) {
return Impl::copy_n_impl("Kokkos::copy_n_iterator_api_default", ex, first,
count, result);
}
template <class ExecutionSpace, class InputIterator, class Size,
class OutputIterator>
OutputIterator copy_n(const std::string& label, const ExecutionSpace& ex,
InputIterator first, Size count, OutputIterator result) {
return Impl::copy_n_impl(label, ex, first, count, result);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class Size, class DataType2, class... Properties2>
auto copy_n(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source, Size count,
::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
namespace KE = ::Kokkos::Experimental;
return Impl::copy_n_impl("Kokkos::copy_n_view_api_default", ex,
KE::cbegin(source), count, KE::begin(dest));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class Size, class DataType2, class... Properties2>
auto copy_n(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source, Size count,
::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
namespace KE = ::Kokkos::Experimental;
return Impl::copy_n_impl(label, ex, KE::cbegin(source), count,
KE::begin(dest));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,94 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_COUNT_HPP
#define KOKKOS_STD_ALGORITHMS_COUNT_HPP
#include "impl/Kokkos_CountCountIf.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType, class T>
typename IteratorType::difference_type count(const ExecutionSpace& ex,
IteratorType first,
IteratorType last,
const T& value) {
return Impl::count_impl("Kokkos::count_iterator_api_default", ex, first, last,
value);
}
template <class ExecutionSpace, class IteratorType, class T>
typename IteratorType::difference_type count(const std::string& label,
const ExecutionSpace& ex,
IteratorType first,
IteratorType last,
const T& value) {
return Impl::count_impl(label, ex, first, last, value);
}
template <class ExecutionSpace, class DataType, class... Properties, class T>
auto count(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v, const T& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::count_impl("Kokkos::count_view_api_default", ex, KE::cbegin(v),
KE::cend(v), value);
}
template <class ExecutionSpace, class DataType, class... Properties, class T>
auto count(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v, const T& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::count_impl(label, ex, KE::cbegin(v), KE::cend(v), value);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,99 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_COUNT_IF_HPP
#define KOKKOS_STD_ALGORITHMS_COUNT_IF_HPP
#include "impl/Kokkos_CountCountIf.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType, class Predicate>
typename IteratorType::difference_type count_if(const ExecutionSpace& ex,
IteratorType first,
IteratorType last,
Predicate predicate) {
return Impl::count_if_impl("Kokkos::count_if_iterator_api_default", ex, first,
last, std::move(predicate));
}
template <class ExecutionSpace, class IteratorType, class Predicate>
typename IteratorType::difference_type count_if(const std::string& label,
const ExecutionSpace& ex,
IteratorType first,
IteratorType last,
Predicate predicate) {
return Impl::count_if_impl(label, ex, first, last, std::move(predicate));
}
template <class ExecutionSpace, class DataType, class... Properties,
class Predicate>
auto count_if(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::count_if_impl("Kokkos::count_if_view_api_default", ex,
KE::cbegin(v), KE::cend(v), std::move(predicate));
}
template <class ExecutionSpace, class DataType, class... Properties,
class Predicate>
auto count_if(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::count_if_impl(label, ex, KE::cbegin(v), KE::cend(v),
std::move(predicate));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -45,8 +45,8 @@
#ifndef KOKKOS_STD_ALGORITHMS_DISTANCE_HPP
#define KOKKOS_STD_ALGORITHMS_DISTANCE_HPP
#include "Kokkos_Constraints.hpp"
#include "Kokkos_RandomAccessIterator.hpp"
#include "impl/Kokkos_Constraints.hpp"
#include "impl/Kokkos_RandomAccessIterator.hpp"
namespace Kokkos {
namespace Experimental {

View File

@ -0,0 +1,198 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_EQUAL_HPP
#define KOKKOS_STD_ALGORITHMS_EQUAL_HPP
#include "impl/Kokkos_Equal.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
std::enable_if_t< ::Kokkos::Experimental::Impl::are_iterators<
IteratorType1, IteratorType2>::value,
bool>
equal(const ExecutionSpace& ex, IteratorType1 first1, IteratorType1 last1,
IteratorType2 first2) {
return Impl::equal_impl("Kokkos::equal_iterator_api_default", ex, first1,
last1, first2);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
std::enable_if_t< ::Kokkos::Experimental::Impl::are_iterators<
IteratorType1, IteratorType2>::value,
bool>
equal(const std::string& label, const ExecutionSpace& ex, IteratorType1 first1,
IteratorType1 last1, IteratorType2 first2) {
return Impl::equal_impl(label, ex, first1, last1, first2);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
std::enable_if_t< ::Kokkos::Experimental::Impl::are_iterators<
IteratorType1, IteratorType2>::value,
bool>
equal(const ExecutionSpace& ex, IteratorType1 first1, IteratorType1 last1,
IteratorType2 first2, BinaryPredicateType predicate) {
return Impl::equal_impl("Kokkos::equal_iterator_api_default", ex, first1,
last1, first2, std::move(predicate));
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
std::enable_if_t< ::Kokkos::Experimental::Impl::are_iterators<
IteratorType1, IteratorType2>::value,
bool>
equal(const std::string& label, const ExecutionSpace& ex, IteratorType1 first1,
IteratorType1 last1, IteratorType2 first2,
BinaryPredicateType predicate) {
return Impl::equal_impl(label, ex, first1, last1, first2,
std::move(predicate));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
bool equal(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view1,
::Kokkos::View<DataType2, Properties2...>& view2) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view1);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view2);
namespace KE = ::Kokkos::Experimental;
return Impl::equal_impl("Kokkos::equal_view_api_default", ex,
KE::cbegin(view1), KE::cend(view1),
KE::cbegin(view2));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
bool equal(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view1,
::Kokkos::View<DataType2, Properties2...>& view2) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view1);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view2);
namespace KE = ::Kokkos::Experimental;
return Impl::equal_impl(label, ex, KE::cbegin(view1), KE::cend(view1),
KE::cbegin(view2));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryPredicateType>
bool equal(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view1,
::Kokkos::View<DataType2, Properties2...>& view2,
BinaryPredicateType predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view1);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view2);
namespace KE = ::Kokkos::Experimental;
return Impl::equal_impl("Kokkos::equal_view_api_default", ex,
KE::cbegin(view1), KE::cend(view1), KE::cbegin(view2),
std::move(predicate));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryPredicateType>
bool equal(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view1,
::Kokkos::View<DataType2, Properties2...>& view2,
BinaryPredicateType predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view1);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view2);
namespace KE = ::Kokkos::Experimental;
return Impl::equal_impl(label, ex, KE::cbegin(view1), KE::cend(view1),
KE::cbegin(view2), std::move(predicate));
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
std::enable_if_t< ::Kokkos::Experimental::Impl::are_iterators<
IteratorType1, IteratorType2>::value,
bool>
equal(const ExecutionSpace& ex, IteratorType1 first1, IteratorType1 last1,
IteratorType2 first2, IteratorType2 last2) {
return Impl::equal_impl("Kokkos::equal_iterator_api_default", ex, first1,
last1, first2, last2);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
std::enable_if_t< ::Kokkos::Experimental::Impl::are_iterators<
IteratorType1, IteratorType2>::value,
bool>
equal(const std::string& label, const ExecutionSpace& ex, IteratorType1 first1,
IteratorType1 last1, IteratorType2 first2, IteratorType2 last2) {
return Impl::equal_impl(label, ex, first1, last1, first2, last2);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
std::enable_if_t< ::Kokkos::Experimental::Impl::are_iterators<
IteratorType1, IteratorType2>::value,
bool>
equal(const ExecutionSpace& ex, IteratorType1 first1, IteratorType1 last1,
IteratorType2 first2, IteratorType2 last2,
BinaryPredicateType predicate) {
return Impl::equal_impl("Kokkos::equal_iterator_api_default", ex, first1,
last1, first2, last2, std::move(predicate));
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
std::enable_if_t< ::Kokkos::Experimental::Impl::are_iterators<
IteratorType1, IteratorType2>::value,
bool>
equal(const std::string& label, const ExecutionSpace& ex, IteratorType1 first1,
IteratorType1 last1, IteratorType2 first2, IteratorType2 last2,
BinaryPredicateType predicate) {
return Impl::equal_impl(label, ex, first1, last1, first2, last2,
std::move(predicate));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,190 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_EXCLUSIVE_SCAN_HPP
#define KOKKOS_STD_ALGORITHMS_EXCLUSIVE_SCAN_HPP
#include "impl/Kokkos_ExclusiveScan.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
// overload set 1
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class ValueType>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
exclusive_scan(const ExecutionSpace& ex, InputIteratorType first,
InputIteratorType last, OutputIteratorType first_dest,
ValueType init_value) {
static_assert(std::is_move_constructible<ValueType>::value,
"ValueType must be move constructible.");
return Impl::exclusive_scan_default_op_impl(
"Kokkos::exclusive_scan_default_functors_iterator_api", ex, first, last,
first_dest, init_value);
}
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class ValueType>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
exclusive_scan(const std::string& label, const ExecutionSpace& ex,
InputIteratorType first, InputIteratorType last,
OutputIteratorType first_dest, ValueType init_value) {
static_assert(std::is_move_constructible<ValueType>::value,
"ValueType must be move constructible.");
return Impl::exclusive_scan_default_op_impl(label, ex, first, last,
first_dest, init_value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class ValueType>
auto exclusive_scan(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
ValueType init_value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
static_assert(std::is_move_constructible<ValueType>::value,
"ValueType must be move constructible.");
namespace KE = ::Kokkos::Experimental;
return Impl::exclusive_scan_default_op_impl(
"Kokkos::exclusive_scan_default_functors_view_api", ex,
KE::cbegin(view_from), KE::cend(view_from), KE::begin(view_dest),
init_value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class ValueType>
auto exclusive_scan(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
ValueType init_value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
static_assert(std::is_move_constructible<ValueType>::value,
"ValueType must be move constructible.");
namespace KE = ::Kokkos::Experimental;
return Impl::exclusive_scan_default_op_impl(label, ex, KE::cbegin(view_from),
KE::cend(view_from),
KE::begin(view_dest), init_value);
}
// overload set 2
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class ValueType, class BinaryOpType>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
exclusive_scan(const ExecutionSpace& ex, InputIteratorType first,
InputIteratorType last, OutputIteratorType first_dest,
ValueType init_value, BinaryOpType bop) {
Impl::static_assert_is_not_openmptarget(ex);
static_assert(std::is_move_constructible<ValueType>::value,
"ValueType must be move constructible.");
return Impl::exclusive_scan_custom_op_impl(
"Kokkos::exclusive_scan_custom_functors_iterator_api", ex, first, last,
first_dest, init_value, bop);
}
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class ValueType, class BinaryOpType>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
exclusive_scan(const std::string& label, const ExecutionSpace& ex,
InputIteratorType first, InputIteratorType last,
OutputIteratorType first_dest, ValueType init_value,
BinaryOpType bop) {
Impl::static_assert_is_not_openmptarget(ex);
static_assert(std::is_move_constructible<ValueType>::value,
"ValueType must be move constructible.");
return Impl::exclusive_scan_custom_op_impl(label, ex, first, last, first_dest,
init_value, bop);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class ValueType,
class BinaryOpType>
auto exclusive_scan(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
ValueType init_value, BinaryOpType bop) {
Impl::static_assert_is_not_openmptarget(ex);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
static_assert(std::is_move_constructible<ValueType>::value,
"ValueType must be move constructible.");
namespace KE = ::Kokkos::Experimental;
return Impl::exclusive_scan_custom_op_impl(
"Kokkos::exclusive_scan_custom_functors_view_api", ex,
KE::cbegin(view_from), KE::cend(view_from), KE::begin(view_dest),
init_value, bop);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class ValueType,
class BinaryOpType>
auto exclusive_scan(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
ValueType init_value, BinaryOpType bop) {
Impl::static_assert_is_not_openmptarget(ex);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
static_assert(std::is_move_constructible<ValueType>::value,
"ValueType must be move constructible.");
namespace KE = ::Kokkos::Experimental;
return Impl::exclusive_scan_custom_op_impl(
label, ex, KE::cbegin(view_from), KE::cend(view_from),
KE::begin(view_dest), init_value, bop);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,86 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_FILL_HPP
#define KOKKOS_STD_ALGORITHMS_FILL_HPP
#include "impl/Kokkos_FillFillN.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType, class T>
void fill(const ExecutionSpace& ex, IteratorType first, IteratorType last,
const T& value) {
Impl::fill_impl("Kokkos::fill_iterator_api_default", ex, first, last, value);
}
template <class ExecutionSpace, class IteratorType, class T>
void fill(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, const T& value) {
Impl::fill_impl(label, ex, first, last, value);
}
template <class ExecutionSpace, class DataType, class... Properties, class T>
void fill(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view, const T& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::fill_impl("Kokkos::fill_view_api_default", ex, begin(view), end(view),
value);
}
template <class ExecutionSpace, class DataType, class... Properties, class T>
void fill(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view, const T& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::fill_impl(label, ex, begin(view), end(view), value);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,91 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_FILL_N_HPP
#define KOKKOS_STD_ALGORITHMS_FILL_N_HPP
#include "impl/Kokkos_FillFillN.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType, class SizeType, class T>
IteratorType fill_n(const ExecutionSpace& ex, IteratorType first, SizeType n,
const T& value) {
return Impl::fill_n_impl("Kokkos::fill_n_iterator_api_default", ex, first, n,
value);
}
template <class ExecutionSpace, class IteratorType, class SizeType, class T>
IteratorType fill_n(const std::string& label, const ExecutionSpace& ex,
IteratorType first, SizeType n, const T& value) {
return Impl::fill_n_impl(label, ex, first, n, value);
}
template <class ExecutionSpace, class DataType, class... Properties,
class SizeType, class T>
auto fill_n(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view, SizeType n,
const T& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::fill_n_impl("Kokkos::fill_n_view_api_default", ex, begin(view),
n, value);
}
template <class ExecutionSpace, class DataType, class... Properties,
class SizeType, class T>
auto fill_n(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view, SizeType n,
const T& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::fill_n_impl(label, ex, begin(view), n, value);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,89 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_FIND_HPP
#define KOKKOS_STD_ALGORITHMS_FIND_HPP
#include "impl/Kokkos_FindIfOrNot.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class T>
InputIterator find(const ExecutionSpace& ex, InputIterator first,
InputIterator last, const T& value) {
return Impl::find_impl("Kokkos::find_iterator_api_default", ex, first, last,
value);
}
template <class ExecutionSpace, class InputIterator, class T>
InputIterator find(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last, const T& value) {
return Impl::find_impl(label, ex, first, last, value);
}
template <class ExecutionSpace, class DataType, class... Properties, class T>
auto find(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view, const T& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::find_impl("Kokkos::find_view_api_default", ex, KE::begin(view),
KE::end(view), value);
}
template <class ExecutionSpace, class DataType, class... Properties, class T>
auto find(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view, const T& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::find_impl(label, ex, KE::begin(view), KE::end(view), value);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,149 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_FIND_END_HPP
#define KOKKOS_STD_ALGORITHMS_FIND_END_HPP
#include "impl/Kokkos_FindEnd.hpp"
#include "Kokkos_Equal.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
// overload set 1: no binary predicate passed
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType1 find_end(const ExecutionSpace& ex, IteratorType1 first,
IteratorType1 last, IteratorType2 s_first,
IteratorType2 s_last) {
return Impl::find_end_impl("Kokkos::find_end_iterator_api_default", ex, first,
last, s_first, s_last);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType1 find_end(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first, IteratorType1 last,
IteratorType2 s_first, IteratorType2 s_last) {
return Impl::find_end_impl(label, ex, first, last, s_first, s_last);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto find_end(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
const ::Kokkos::View<DataType2, Properties2...>& s_view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(s_view);
namespace KE = ::Kokkos::Experimental;
return Impl::find_end_impl("Kokkos::find_end_view_api_default", ex,
KE::begin(view), KE::end(view), KE::begin(s_view),
KE::end(s_view));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto find_end(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
const ::Kokkos::View<DataType2, Properties2...>& s_view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(s_view);
namespace KE = ::Kokkos::Experimental;
return Impl::find_end_impl(label, ex, KE::begin(view), KE::end(view),
KE::begin(s_view), KE::end(s_view));
}
// overload set 2: binary predicate passed
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
IteratorType1 find_end(const ExecutionSpace& ex, IteratorType1 first,
IteratorType1 last, IteratorType2 s_first,
IteratorType2 s_last, const BinaryPredicateType& pred) {
return Impl::find_end_impl("Kokkos::find_end_iterator_api_default", ex, first,
last, s_first, s_last, pred);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
IteratorType1 find_end(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first, IteratorType1 last,
IteratorType2 s_first, IteratorType2 s_last,
const BinaryPredicateType& pred) {
return Impl::find_end_impl(label, ex, first, last, s_first, s_last, pred);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryPredicateType>
auto find_end(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
const ::Kokkos::View<DataType2, Properties2...>& s_view,
const BinaryPredicateType& pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(s_view);
namespace KE = ::Kokkos::Experimental;
return Impl::find_end_impl("Kokkos::find_end_view_api_default", ex,
KE::begin(view), KE::end(view), KE::begin(s_view),
KE::end(s_view), pred);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryPredicateType>
auto find_end(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
const ::Kokkos::View<DataType2, Properties2...>& s_view,
const BinaryPredicateType& pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(s_view);
namespace KE = ::Kokkos::Experimental;
return Impl::find_end_impl(label, ex, KE::begin(view), KE::end(view),
KE::begin(s_view), KE::end(s_view), pred);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,150 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_FIND_FIRST_OF_HPP
#define KOKKOS_STD_ALGORITHMS_FIND_FIRST_OF_HPP
#include "impl/Kokkos_FindFirstOf.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
// overload set 1: no binary predicate passed
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType1 find_first_of(const ExecutionSpace& ex, IteratorType1 first,
IteratorType1 last, IteratorType2 s_first,
IteratorType2 s_last) {
return Impl::find_first_of_impl("Kokkos::find_first_of_iterator_api_default",
ex, first, last, s_first, s_last);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType1 find_first_of(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first, IteratorType1 last,
IteratorType2 s_first, IteratorType2 s_last) {
return Impl::find_first_of_impl(label, ex, first, last, s_first, s_last);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto find_first_of(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
const ::Kokkos::View<DataType2, Properties2...>& s_view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(s_view);
namespace KE = ::Kokkos::Experimental;
return Impl::find_first_of_impl("Kokkos::find_first_of_view_api_default", ex,
KE::begin(view), KE::end(view),
KE::begin(s_view), KE::end(s_view));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto find_first_of(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
const ::Kokkos::View<DataType2, Properties2...>& s_view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(s_view);
namespace KE = ::Kokkos::Experimental;
return Impl::find_first_of_impl(label, ex, KE::begin(view), KE::end(view),
KE::begin(s_view), KE::end(s_view));
}
// overload set 2: binary predicate passed
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
IteratorType1 find_first_of(const ExecutionSpace& ex, IteratorType1 first,
IteratorType1 last, IteratorType2 s_first,
IteratorType2 s_last,
const BinaryPredicateType& pred) {
return Impl::find_first_of_impl("Kokkos::find_first_of_iterator_api_default",
ex, first, last, s_first, s_last, pred);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
IteratorType1 find_first_of(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first, IteratorType1 last,
IteratorType2 s_first, IteratorType2 s_last,
const BinaryPredicateType& pred) {
return Impl::find_first_of_impl(label, ex, first, last, s_first, s_last,
pred);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryPredicateType>
auto find_first_of(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
const ::Kokkos::View<DataType2, Properties2...>& s_view,
const BinaryPredicateType& pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(s_view);
namespace KE = ::Kokkos::Experimental;
return Impl::find_first_of_impl("Kokkos::find_first_of_view_api_default", ex,
KE::begin(view), KE::end(view),
KE::begin(s_view), KE::end(s_view), pred);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryPredicateType>
auto find_first_of(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
const ::Kokkos::View<DataType2, Properties2...>& s_view,
const BinaryPredicateType& pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(s_view);
namespace KE = ::Kokkos::Experimental;
return Impl::find_first_of_impl(label, ex, KE::begin(view), KE::end(view),
KE::begin(s_view), KE::end(s_view), pred);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,95 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_FIND_IF_HPP
#define KOKKOS_STD_ALGORITHMS_FIND_IF_HPP
#include "impl/Kokkos_FindIfOrNot.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType, class PredicateType>
IteratorType find_if(const ExecutionSpace& ex, IteratorType first,
IteratorType last, PredicateType predicate) {
return Impl::find_if_or_not_impl<true>("Kokkos::find_if_iterator_api_default",
ex, first, last, std::move(predicate));
}
template <class ExecutionSpace, class IteratorType, class PredicateType>
IteratorType find_if(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
PredicateType predicate) {
return Impl::find_if_or_not_impl<true>(label, ex, first, last,
std::move(predicate));
}
template <class ExecutionSpace, class DataType, class... Properties,
class Predicate>
auto find_if(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::find_if_or_not_impl<true>("Kokkos::find_if_view_api_default", ex,
KE::begin(v), KE::end(v),
std::move(predicate));
}
template <class ExecutionSpace, class DataType, class... Properties,
class Predicate>
auto find_if(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::find_if_or_not_impl<true>(label, ex, KE::begin(v), KE::end(v),
std::move(predicate));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,98 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_FIND_IF_NOT_HPP
#define KOKKOS_STD_ALGORITHMS_FIND_IF_NOT_HPP
#include "impl/Kokkos_FindIfOrNot.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType, class Predicate>
IteratorType find_if_not(const ExecutionSpace& ex, IteratorType first,
IteratorType last, Predicate predicate) {
return Impl::find_if_or_not_impl<false>(
"Kokkos::find_if_not_iterator_api_default", ex, first, last,
std::move(predicate));
}
template <class ExecutionSpace, class IteratorType, class Predicate>
IteratorType find_if_not(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
Predicate predicate) {
return Impl::find_if_or_not_impl<false>(label, ex, first, last,
std::move(predicate));
}
template <class ExecutionSpace, class DataType, class... Properties,
class Predicate>
auto find_if_not(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::find_if_or_not_impl<false>(
"Kokkos::find_if_not_view_api_default", ex, KE::begin(v), KE::end(v),
std::move(predicate));
}
template <class ExecutionSpace, class DataType, class... Properties,
class Predicate>
auto find_if_not(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::find_if_or_not_impl<false>(label, ex, KE::begin(v), KE::end(v),
std::move(predicate));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,95 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_FOR_EACH_HPP
#define KOKKOS_STD_ALGORITHMS_FOR_EACH_HPP
#include "impl/Kokkos_ForEachForEachN.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType, class UnaryFunctorType>
UnaryFunctorType for_each(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
UnaryFunctorType functor) {
return Impl::for_each_impl(label, ex, first, last, std::move(functor));
}
template <class ExecutionSpace, class IteratorType, class UnaryFunctorType>
UnaryFunctorType for_each(const ExecutionSpace& ex, IteratorType first,
IteratorType last, UnaryFunctorType functor) {
return Impl::for_each_impl("Kokkos::for_each_iterator_api_default", ex, first,
last, std::move(functor));
}
template <class ExecutionSpace, class DataType, class... Properties,
class UnaryFunctorType>
UnaryFunctorType for_each(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
UnaryFunctorType functor) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::for_each_impl(label, ex, KE::begin(v), KE::end(v),
std::move(functor));
}
template <class ExecutionSpace, class DataType, class... Properties,
class UnaryFunctorType>
UnaryFunctorType for_each(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
UnaryFunctorType functor) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::for_each_impl("Kokkos::for_each_view_api_default", ex,
KE::begin(v), KE::end(v), std::move(functor));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,96 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_FOR_EACH_N_HPP
#define KOKKOS_STD_ALGORITHMS_FOR_EACH_N_HPP
#include "impl/Kokkos_ForEachForEachN.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType, class SizeType,
class UnaryFunctorType>
IteratorType for_each_n(const std::string& label, const ExecutionSpace& ex,
IteratorType first, SizeType n,
UnaryFunctorType functor) {
return Impl::for_each_n_impl(label, ex, first, n, std::move(functor));
}
template <class ExecutionSpace, class IteratorType, class SizeType,
class UnaryFunctorType>
IteratorType for_each_n(const ExecutionSpace& ex, IteratorType first,
SizeType n, UnaryFunctorType functor) {
return Impl::for_each_n_impl("Kokkos::for_each_n_iterator_api_default", ex,
first, n, std::move(functor));
}
template <class ExecutionSpace, class DataType, class... Properties,
class SizeType, class UnaryFunctorType>
auto for_each_n(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v, SizeType n,
UnaryFunctorType functor) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::for_each_n_impl(label, ex, KE::begin(v), n, std::move(functor));
}
template <class ExecutionSpace, class DataType, class... Properties,
class SizeType, class UnaryFunctorType>
auto for_each_n(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v, SizeType n,
UnaryFunctorType functor) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::for_each_n_impl("Kokkos::for_each_n_view_api_default", ex,
KE::begin(v), n, std::move(functor));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,91 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_GENERATE_HPP
#define KOKKOS_STD_ALGORITHMS_GENERATE_HPP
#include "impl/Kokkos_GenerateGenerateN.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType, class Generator>
void generate(const ExecutionSpace& ex, IteratorType first, IteratorType last,
Generator g) {
Impl::generate_impl("Kokkos::generate_iterator_api_default", ex, first, last,
std::move(g));
}
template <class ExecutionSpace, class IteratorType, class Generator>
void generate(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, Generator g) {
Impl::generate_impl(label, ex, first, last, std::move(g));
}
template <class ExecutionSpace, class DataType, class... Properties,
class Generator>
void generate(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
Generator g) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::generate_impl("Kokkos::generate_view_api_default", ex, begin(view),
end(view), std::move(g));
}
template <class ExecutionSpace, class DataType, class... Properties,
class Generator>
void generate(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
Generator g) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::generate_impl(label, ex, begin(view), end(view), std::move(g));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,93 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_GENERATE_N_HPP
#define KOKKOS_STD_ALGORITHMS_GENERATE_N_HPP
#include "impl/Kokkos_GenerateGenerateN.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType, class Size, class Generator>
IteratorType generate_n(const ExecutionSpace& ex, IteratorType first,
Size count, Generator g) {
Impl::generate_n_impl("Kokkos::generate_n_iterator_api_default", ex, first,
count, std::move(g));
return first + count;
}
template <class ExecutionSpace, class IteratorType, class Size, class Generator>
IteratorType generate_n(const std::string& label, const ExecutionSpace& ex,
IteratorType first, Size count, Generator g) {
Impl::generate_n_impl(label, ex, first, count, std::move(g));
return first + count;
}
template <class ExecutionSpace, class DataType, class... Properties, class Size,
class Generator>
auto generate_n(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view, Size count,
Generator g) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::generate_n_impl("Kokkos::generate_n_view_api_default", ex,
begin(view), count, std::move(g));
}
template <class ExecutionSpace, class DataType, class... Properties, class Size,
class Generator>
auto generate_n(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view, Size count,
Generator g) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::generate_n_impl(label, ex, begin(view), count, std::move(g));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,223 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_INCLUSIVE_SCAN_HPP
#define KOKKOS_STD_ALGORITHMS_INCLUSIVE_SCAN_HPP
#include "impl/Kokkos_InclusiveScan.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
// overload set 1
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
inclusive_scan(const ExecutionSpace& ex, InputIteratorType first,
InputIteratorType last, OutputIteratorType first_dest) {
return Impl::inclusive_scan_default_op_impl(
"Kokkos::inclusive_scan_default_functors_iterator_api", ex, first, last,
first_dest);
}
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
inclusive_scan(const std::string& label, const ExecutionSpace& ex,
InputIteratorType first, InputIteratorType last,
OutputIteratorType first_dest) {
return Impl::inclusive_scan_default_op_impl(label, ex, first, last,
first_dest);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto inclusive_scan(
const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
namespace KE = ::Kokkos::Experimental;
return Impl::inclusive_scan_default_op_impl(
"Kokkos::inclusive_scan_default_functors_view_api", ex,
KE::cbegin(view_from), KE::cend(view_from), KE::begin(view_dest));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto inclusive_scan(
const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
namespace KE = ::Kokkos::Experimental;
return Impl::inclusive_scan_default_op_impl(label, ex, KE::cbegin(view_from),
KE::cend(view_from),
KE::begin(view_dest));
}
// overload set 2 (accepting custom binary op)
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class BinaryOp>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
inclusive_scan(const ExecutionSpace& ex, InputIteratorType first,
InputIteratorType last, OutputIteratorType first_dest,
BinaryOp binary_op) {
return Impl::inclusive_scan_custom_binary_op_impl(
"Kokkos::inclusive_scan_custom_functors_iterator_api", ex, first, last,
first_dest, binary_op);
}
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class BinaryOp>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
inclusive_scan(const std::string& label, const ExecutionSpace& ex,
InputIteratorType first, InputIteratorType last,
OutputIteratorType first_dest, BinaryOp binary_op) {
return Impl::inclusive_scan_custom_binary_op_impl(label, ex, first, last,
first_dest, binary_op);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryOp>
auto inclusive_scan(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
BinaryOp binary_op) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
namespace KE = ::Kokkos::Experimental;
return Impl::inclusive_scan_custom_binary_op_impl(
"Kokkos::inclusive_scan_custom_functors_view_api", ex,
KE::cbegin(view_from), KE::cend(view_from), KE::begin(view_dest),
binary_op);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryOp>
auto inclusive_scan(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
BinaryOp binary_op) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
namespace KE = ::Kokkos::Experimental;
return Impl::inclusive_scan_custom_binary_op_impl(
label, ex, KE::cbegin(view_from), KE::cend(view_from),
KE::begin(view_dest), binary_op);
}
// overload set 3
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class BinaryOp, class ValueType>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
inclusive_scan(const ExecutionSpace& ex, InputIteratorType first,
InputIteratorType last, OutputIteratorType first_dest,
BinaryOp binary_op, ValueType init_value) {
return Impl::inclusive_scan_custom_binary_op_impl(
"Kokkos::inclusive_scan_custom_functors_iterator_api", ex, first, last,
first_dest, binary_op, init_value);
}
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class BinaryOp, class ValueType>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
inclusive_scan(const std::string& label, const ExecutionSpace& ex,
InputIteratorType first, InputIteratorType last,
OutputIteratorType first_dest, BinaryOp binary_op,
ValueType init_value) {
return Impl::inclusive_scan_custom_binary_op_impl(
label, ex, first, last, first_dest, binary_op, init_value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryOp,
class ValueType>
auto inclusive_scan(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
BinaryOp binary_op, ValueType init_value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
namespace KE = ::Kokkos::Experimental;
return Impl::inclusive_scan_custom_binary_op_impl(
"Kokkos::inclusive_scan_custom_functors_view_api", ex,
KE::cbegin(view_from), KE::cend(view_from), KE::begin(view_dest),
binary_op, init_value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryOp,
class ValueType>
auto inclusive_scan(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
BinaryOp binary_op, ValueType init_value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
namespace KE = ::Kokkos::Experimental;
return Impl::inclusive_scan_custom_binary_op_impl(
label, ex, KE::cbegin(view_from), KE::cend(view_from),
KE::begin(view_dest), binary_op, init_value);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,92 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_IS_PARTITIONED_HPP
#define KOKKOS_STD_ALGORITHMS_IS_PARTITIONED_HPP
#include "impl/Kokkos_IsPartitioned.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType, class PredicateType>
bool is_partitioned(const ExecutionSpace& ex, IteratorType first,
IteratorType last, PredicateType p) {
return Impl::is_partitioned_impl(
"Kokkos::is_partitioned_iterator_api_default", ex, first, last,
std::move(p));
}
template <class ExecutionSpace, class IteratorType, class PredicateType>
bool is_partitioned(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, PredicateType p) {
return Impl::is_partitioned_impl(label, ex, first, last, std::move(p));
}
template <class ExecutionSpace, class PredicateType, class DataType,
class... Properties>
bool is_partitioned(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
PredicateType p) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::is_partitioned_impl("Kokkos::is_partitioned_view_api_default",
ex, cbegin(v), cend(v), std::move(p));
}
template <class ExecutionSpace, class PredicateType, class DataType,
class... Properties>
bool is_partitioned(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
PredicateType p) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::is_partitioned_impl(label, ex, cbegin(v), cend(v), std::move(p));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,131 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_IS_SORTED_HPP
#define KOKKOS_STD_ALGORITHMS_IS_SORTED_HPP
#include "impl/Kokkos_IsSorted.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType>
bool is_sorted(const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
return Impl::is_sorted_impl("Kokkos::is_sorted_iterator_api_default", ex,
first, last);
}
template <class ExecutionSpace, class IteratorType>
bool is_sorted(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last) {
return Impl::is_sorted_impl(label, ex, first, last);
}
template <class ExecutionSpace, class DataType, class... Properties>
bool is_sorted(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_impl("Kokkos::is_sorted_view_api_default", ex,
KE::cbegin(view), KE::cend(view));
}
template <class ExecutionSpace, class DataType, class... Properties>
bool is_sorted(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_impl(label, ex, KE::cbegin(view), KE::cend(view));
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
bool is_sorted(const ExecutionSpace& ex, IteratorType first, IteratorType last,
ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::is_sorted_impl("Kokkos::is_sorted_iterator_api_default", ex,
first, last, std::move(comp));
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
bool is_sorted(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::is_sorted_impl(label, ex, first, last, std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties,
class ComparatorType>
bool is_sorted(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_not_openmptarget(ex);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_impl("Kokkos::is_sorted_view_api_default", ex,
KE::cbegin(view), KE::cend(view),
std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties,
class ComparatorType>
bool is_sorted(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_not_openmptarget(ex);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_impl(label, ex, KE::cbegin(view), KE::cend(view),
std::move(comp));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,134 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_IS_SORTED_UNTIL_HPP
#define KOKKOS_STD_ALGORITHMS_IS_SORTED_UNTIL_HPP
#include "impl/Kokkos_IsSortedUntil.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType>
IteratorType is_sorted_until(const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
return Impl::is_sorted_until_impl(
"Kokkos::is_sorted_until_iterator_api_default", ex, first, last);
}
template <class ExecutionSpace, class IteratorType>
IteratorType is_sorted_until(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last) {
return Impl::is_sorted_until_impl(label, ex, first, last);
}
template <class ExecutionSpace, class DataType, class... Properties>
auto is_sorted_until(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_until_impl("Kokkos::is_sorted_until_view_api_default",
ex, KE::begin(view), KE::end(view));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto is_sorted_until(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_until_impl(label, ex, KE::begin(view), KE::end(view));
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
IteratorType is_sorted_until(const ExecutionSpace& ex, IteratorType first,
IteratorType last, ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::is_sorted_until_impl(
"Kokkos::is_sorted_until_iterator_api_default", ex, first, last,
std::move(comp));
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
IteratorType is_sorted_until(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::is_sorted_until_impl(label, ex, first, last, std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties,
class ComparatorType>
auto is_sorted_until(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_not_openmptarget(ex);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_until_impl("Kokkos::is_sorted_until_view_api_default",
ex, KE::begin(view), KE::end(view),
std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties,
class ComparatorType>
auto is_sorted_until(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_not_openmptarget(ex);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_until_impl(label, ex, KE::begin(view), KE::end(view),
std::move(comp));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -42,38 +42,17 @@
//@HEADER
*/
#ifndef KOKKOS_MODIFYING_OPERATIONS_HPP
#define KOKKOS_MODIFYING_OPERATIONS_HPP
#ifndef KOKKOS_STD_ALGORITHMS_ITER_SWAP_HPP
#define KOKKOS_STD_ALGORITHMS_ITER_SWAP_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_BeginEnd.hpp"
#include "Kokkos_Constraints.hpp"
#include "impl/Kokkos_Constraints.hpp"
#include "Kokkos_Swap.hpp"
namespace Kokkos {
namespace Experimental {
// move
template <typename T>
KOKKOS_INLINE_FUNCTION std::remove_reference_t<T>&& move(T&& t) {
return static_cast<std::remove_reference_t<T>&&>(t);
}
// swap
template <class T>
KOKKOS_INLINE_FUNCTION void swap(T& a, T& b) noexcept {
static_assert(
std::is_move_assignable<T>::value && std::is_move_constructible<T>::value,
"Kokkos::Experimental::swap arguments must be move assignable "
"and move constructible");
T tmp = std::move(a);
a = std::move(b);
b = std::move(tmp);
}
//----------------------------------------------------------------------------
// this is here because we use the swap function above
namespace Impl {
template <class IteratorType1, class IteratorType2>
struct StdIterSwapFunctor {
IteratorType1 m_a;

View File

@ -0,0 +1,154 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_LEXICOGRAPHICAL_COMPARE_HPP
#define KOKKOS_STD_ALGORITHMS_LEXICOGRAPHICAL_COMPARE_HPP
#include "impl/Kokkos_LexicographicalCompare.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
bool lexicographical_compare(const ExecutionSpace& ex, IteratorType1 first1,
IteratorType1 last1, IteratorType2 first2,
IteratorType2 last2) {
return Impl::lexicographical_compare_impl(
"Kokkos::lexicographical_compare_iterator_api_default", ex, first1, last1,
first2, last2);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
bool lexicographical_compare(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first1, IteratorType1 last1,
IteratorType2 first2, IteratorType2 last2) {
return Impl::lexicographical_compare_impl(label, ex, first1, last1, first2,
last2);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
bool lexicographical_compare(
const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view1,
::Kokkos::View<DataType2, Properties2...>& view2) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view1);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view2);
namespace KE = ::Kokkos::Experimental;
return Impl::lexicographical_compare_impl(
"Kokkos::lexicographical_compare_view_api_default", ex, KE::cbegin(view1),
KE::cend(view1), KE::cbegin(view2), KE::cend(view2));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
bool lexicographical_compare(
const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view1,
::Kokkos::View<DataType2, Properties2...>& view2) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view1);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view2);
namespace KE = ::Kokkos::Experimental;
return Impl::lexicographical_compare_impl(label, ex, KE::cbegin(view1),
KE::cend(view1), KE::cbegin(view2),
KE::cend(view2));
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class ComparatorType>
bool lexicographical_compare(const ExecutionSpace& ex, IteratorType1 first1,
IteratorType1 last1, IteratorType2 first2,
IteratorType2 last2, ComparatorType comp) {
return Impl::lexicographical_compare_impl(
"Kokkos::lexicographical_compare_iterator_api_default", ex, first1, last1,
first2, last2, comp);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class ComparatorType>
bool lexicographical_compare(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first1, IteratorType1 last1,
IteratorType2 first2, IteratorType2 last2,
ComparatorType comp) {
return Impl::lexicographical_compare_impl(label, ex, first1, last1, first2,
last2, comp);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class ComparatorType>
bool lexicographical_compare(
const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view1,
::Kokkos::View<DataType2, Properties2...>& view2, ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view1);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view2);
namespace KE = ::Kokkos::Experimental;
return Impl::lexicographical_compare_impl(
"Kokkos::lexicographical_compare_view_api_default", ex, KE::cbegin(view1),
KE::cend(view1), KE::cbegin(view2), KE::cend(view2), comp);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class ComparatorType>
bool lexicographical_compare(
const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view1,
::Kokkos::View<DataType2, Properties2...>& view2, ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view1);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view2);
namespace KE = ::Kokkos::Experimental;
return Impl::lexicographical_compare_impl(label, ex, KE::cbegin(view1),
KE::cend(view1), KE::cbegin(view2),
KE::cend(view2), comp);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,132 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_MAX_ELEMENT_HPP
#define KOKKOS_STD_ALGORITHMS_MAX_ELEMENT_HPP
#include "impl/Kokkos_MinMaxMinmaxElement.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType>
auto max_element(const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
return Impl::min_or_max_element_impl<MaxFirstLoc>(
"Kokkos::max_element_iterator_api_default", ex, first, last);
}
template <class ExecutionSpace, class IteratorType>
auto max_element(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last) {
return Impl::min_or_max_element_impl<MaxFirstLoc>(label, ex, first, last);
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
auto max_element(const ExecutionSpace& ex, IteratorType first,
IteratorType last, ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MaxFirstLocCustomComparator>(
"Kokkos::max_element_iterator_api_default", ex, first, last,
std::move(comp));
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
auto max_element(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MaxFirstLocCustomComparator>(
label, ex, first, last, std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto max_element(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::min_or_max_element_impl<MaxFirstLoc>(
"Kokkos::max_element_view_api_default", ex, begin(v), end(v));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto max_element(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::min_or_max_element_impl<MaxFirstLoc>(label, ex, begin(v),
end(v));
}
template <class ExecutionSpace, class DataType, class ComparatorType,
class... Properties>
auto max_element(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MaxFirstLocCustomComparator>(
"Kokkos::max_element_view_api_default", ex, begin(v), end(v),
std::move(comp));
}
template <class ExecutionSpace, class DataType, class ComparatorType,
class... Properties>
auto max_element(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MaxFirstLocCustomComparator>(
label, ex, begin(v), end(v), std::move(comp));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,132 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_MIN_ELEMENT_HPP
#define KOKKOS_STD_ALGORITHMS_MIN_ELEMENT_HPP
#include "impl/Kokkos_MinMaxMinmaxElement.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType>
auto min_element(const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
return Impl::min_or_max_element_impl<MinFirstLoc>(
"Kokkos::min_element_iterator_api_default", ex, first, last);
}
template <class ExecutionSpace, class IteratorType>
auto min_element(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last) {
return Impl::min_or_max_element_impl<MinFirstLoc>(label, ex, first, last);
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
auto min_element(const ExecutionSpace& ex, IteratorType first,
IteratorType last, ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MinFirstLocCustomComparator>(
"Kokkos::min_element_iterator_api_default", ex, first, last,
std::move(comp));
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
auto min_element(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MinFirstLocCustomComparator>(
label, ex, first, last, std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto min_element(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::min_or_max_element_impl<MinFirstLoc>(
"Kokkos::min_element_view_api_default", ex, begin(v), end(v));
}
template <class ExecutionSpace, class DataType, class ComparatorType,
class... Properties>
auto min_element(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MinFirstLocCustomComparator>(
"Kokkos::min_element_view_api_default", ex, begin(v), end(v),
std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto min_element(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::min_or_max_element_impl<MinFirstLoc>(label, ex, begin(v),
end(v));
}
template <class ExecutionSpace, class DataType, class ComparatorType,
class... Properties>
auto min_element(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MinFirstLocCustomComparator>(
label, ex, begin(v), end(v), std::move(comp));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,133 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_MINMAX_ELEMENT_HPP
#define KOKKOS_STD_ALGORITHMS_MINMAX_ELEMENT_HPP
#include "impl/Kokkos_MinMaxMinmaxElement.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType>
auto minmax_element(const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
return Impl::minmax_element_impl<MinMaxFirstLastLoc>(
"Kokkos::minmax_element_iterator_api_default", ex, first, last);
}
template <class ExecutionSpace, class IteratorType>
auto minmax_element(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last) {
return Impl::minmax_element_impl<MinMaxFirstLastLoc>(label, ex, first, last);
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
auto minmax_element(const ExecutionSpace& ex, IteratorType first,
IteratorType last, ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::minmax_element_impl<MinMaxFirstLastLocCustomComparator>(
"Kokkos::minmax_element_iterator_api_default", ex, first, last,
std::move(comp));
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
auto minmax_element(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::minmax_element_impl<MinMaxFirstLastLocCustomComparator>(
label, ex, first, last, std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto minmax_element(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::minmax_element_impl<MinMaxFirstLastLoc>(
"Kokkos::minmax_element_view_api_default", ex, begin(v), end(v));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto minmax_element(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::minmax_element_impl<MinMaxFirstLastLoc>(label, ex, begin(v),
end(v));
}
template <class ExecutionSpace, class DataType, class ComparatorType,
class... Properties>
auto minmax_element(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Impl::static_assert_is_not_openmptarget(ex);
return Impl::minmax_element_impl<MinMaxFirstLastLocCustomComparator>(
"Kokkos::minmax_element_view_api_default", ex, begin(v), end(v),
std::move(comp));
}
template <class ExecutionSpace, class DataType, class ComparatorType,
class... Properties>
auto minmax_element(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Impl::static_assert_is_not_openmptarget(ex);
return Impl::minmax_element_impl<MinMaxFirstLastLocCustomComparator>(
label, ex, begin(v), end(v), std::move(comp));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -1,409 +0,0 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_MIN_MAX_ELEMENT_OPERATIONS_HPP
#define KOKKOS_STD_MIN_MAX_ELEMENT_OPERATIONS_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_BeginEnd.hpp"
#include "Kokkos_Constraints.hpp"
#include "Kokkos_Distance.hpp"
#include "Kokkos_ModifyingOperations.hpp"
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class IteratorType, class ReducerType>
struct StdMinOrMaxElemFunctor {
using index_type = typename IteratorType::difference_type;
using red_value_type = typename ReducerType::value_type;
IteratorType m_first;
ReducerType m_reducer;
KOKKOS_FUNCTION
void operator()(const index_type i, red_value_type& red_value) const {
m_reducer.join(red_value, red_value_type{m_first[i], i});
}
KOKKOS_FUNCTION
StdMinOrMaxElemFunctor(IteratorType first, ReducerType reducer)
: m_first(std::move(first)), m_reducer(std::move(reducer)) {}
};
template <class IteratorType, class ReducerType>
struct StdMinMaxElemFunctor {
using index_type = typename IteratorType::difference_type;
using red_value_type = typename ReducerType::value_type;
IteratorType m_first;
ReducerType m_reducer;
KOKKOS_FUNCTION
void operator()(const index_type i, red_value_type& red_value) const {
const auto& my_value = m_first[i];
m_reducer.join(red_value, red_value_type{my_value, my_value, i, i});
}
KOKKOS_FUNCTION
StdMinMaxElemFunctor(IteratorType first, ReducerType reducer)
: m_first(std::move(first)), m_reducer(std::move(reducer)) {}
};
// ------------------------------------------
// min_or_max_element_impl
// ------------------------------------------
template <template <class... Args> class ReducerType, class ExecutionSpace,
class IteratorType, class... Args>
IteratorType min_or_max_element_impl(const std::string& label,
const ExecutionSpace& ex,
IteratorType first, IteratorType last,
Args&&... args) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::expect_valid_range(first, last);
if (first == last) {
return last;
}
// aliases
using index_type = typename IteratorType::difference_type;
using value_type = typename IteratorType::value_type;
using reducer_type = ReducerType<value_type, index_type, Args...>;
using reduction_value_type = typename reducer_type::value_type;
using func_t = StdMinOrMaxElemFunctor<IteratorType, reducer_type>;
// run
reduction_value_type red_result;
reducer_type reducer(red_result, std::forward<Args>(args)...);
const auto num_elements = Kokkos::Experimental::distance(first, last);
::Kokkos::parallel_reduce(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_t(first, reducer), reducer);
// fence not needed because reducing into scalar
// return
return first + red_result.loc;
}
// ------------------------------------------
// minmax_element_impl
// ------------------------------------------
template <template <class... Args> class ReducerType, class ExecutionSpace,
class IteratorType, class... Args>
::Kokkos::pair<IteratorType, IteratorType> minmax_element_impl(
const std::string& label, const ExecutionSpace& ex, IteratorType first,
IteratorType last, Args&&... args) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::expect_valid_range(first, last);
if (first == last) {
return {first, first};
}
// aliases
using index_type = typename IteratorType::difference_type;
using value_type = typename IteratorType::value_type;
using reducer_type = ReducerType<value_type, index_type, Args...>;
using reduction_value_type = typename reducer_type::value_type;
using func_t = StdMinMaxElemFunctor<IteratorType, reducer_type>;
// run
reduction_value_type red_result;
reducer_type reducer(red_result, std::forward<Args>(args)...);
const auto num_elements = Kokkos::Experimental::distance(first, last);
::Kokkos::parallel_reduce(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_t(first, reducer), reducer);
// fence not needed because reducing into scalar
// return
return {first + red_result.min_loc, first + red_result.max_loc};
}
} // end namespace Impl
// ----------------------
// min_element public API
// ----------------------
template <class ExecutionSpace, class IteratorType>
auto min_element(const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
return Impl::min_or_max_element_impl<MinFirstLoc>(
"Kokkos::min_element_iterator_api_default", ex, first, last);
}
template <class ExecutionSpace, class IteratorType>
auto min_element(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last) {
return Impl::min_or_max_element_impl<MinFirstLoc>(label, ex, first, last);
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
auto min_element(const ExecutionSpace& ex, IteratorType first,
IteratorType last, ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MinFirstLocCustomComparator>(
"Kokkos::min_element_iterator_api_default", ex, first, last,
std::move(comp));
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
auto min_element(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MinFirstLocCustomComparator>(
label, ex, first, last, std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto min_element(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::min_or_max_element_impl<MinFirstLoc>(
"Kokkos::min_element_view_api_default", ex, begin(v), end(v));
}
template <class ExecutionSpace, class DataType, class ComparatorType,
class... Properties>
auto min_element(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MinFirstLocCustomComparator>(
"Kokkos::min_element_view_api_default", ex, begin(v), end(v),
std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto min_element(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::min_or_max_element_impl<MinFirstLoc>(label, ex, begin(v),
end(v));
}
template <class ExecutionSpace, class DataType, class ComparatorType,
class... Properties>
auto min_element(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MinFirstLocCustomComparator>(
label, ex, begin(v), end(v), std::move(comp));
}
// ----------------------
// max_element public API
// ----------------------
template <class ExecutionSpace, class IteratorType>
auto max_element(const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
return Impl::min_or_max_element_impl<MaxFirstLoc>(
"Kokkos::max_element_iterator_api_default", ex, first, last);
}
template <class ExecutionSpace, class IteratorType>
auto max_element(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last) {
return Impl::min_or_max_element_impl<MaxFirstLoc>(label, ex, first, last);
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
auto max_element(const ExecutionSpace& ex, IteratorType first,
IteratorType last, ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MaxFirstLocCustomComparator>(
"Kokkos::max_element_iterator_api_default", ex, first, last,
std::move(comp));
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
auto max_element(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MaxFirstLocCustomComparator>(
label, ex, first, last, std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto max_element(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::min_or_max_element_impl<MaxFirstLoc>(
"Kokkos::max_element_view_api_default", ex, begin(v), end(v));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto max_element(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::min_or_max_element_impl<MaxFirstLoc>(label, ex, begin(v),
end(v));
}
template <class ExecutionSpace, class DataType, class ComparatorType,
class... Properties>
auto max_element(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MaxFirstLocCustomComparator>(
"Kokkos::max_element_view_api_default", ex, begin(v), end(v),
std::move(comp));
}
template <class ExecutionSpace, class DataType, class ComparatorType,
class... Properties>
auto max_element(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Impl::static_assert_is_not_openmptarget(ex);
return Impl::min_or_max_element_impl<MaxFirstLocCustomComparator>(
label, ex, begin(v), end(v), std::move(comp));
}
// -------------------------
// minmax_element public API
// -------------------------
template <class ExecutionSpace, class IteratorType>
auto minmax_element(const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
return Impl::minmax_element_impl<MinMaxFirstLastLoc>(
"Kokkos::minmax_element_iterator_api_default", ex, first, last);
}
template <class ExecutionSpace, class IteratorType>
auto minmax_element(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last) {
return Impl::minmax_element_impl<MinMaxFirstLastLoc>(label, ex, first, last);
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
auto minmax_element(const ExecutionSpace& ex, IteratorType first,
IteratorType last, ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::minmax_element_impl<MinMaxFirstLastLocCustomComparator>(
"Kokkos::minmax_element_iterator_api_default", ex, first, last,
std::move(comp));
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
auto minmax_element(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::minmax_element_impl<MinMaxFirstLastLocCustomComparator>(
label, ex, first, last, std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto minmax_element(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::minmax_element_impl<MinMaxFirstLastLoc>(
"Kokkos::minmax_element_view_api_default", ex, begin(v), end(v));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto minmax_element(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::minmax_element_impl<MinMaxFirstLastLoc>(label, ex, begin(v),
end(v));
}
template <class ExecutionSpace, class DataType, class ComparatorType,
class... Properties>
auto minmax_element(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Impl::static_assert_is_not_openmptarget(ex);
return Impl::minmax_element_impl<MinMaxFirstLastLocCustomComparator>(
"Kokkos::minmax_element_view_api_default", ex, begin(v), end(v),
std::move(comp));
}
template <class ExecutionSpace, class DataType, class ComparatorType,
class... Properties>
auto minmax_element(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
Impl::static_assert_is_not_openmptarget(ex);
return Impl::minmax_element_impl<MinMaxFirstLastLocCustomComparator>(
label, ex, begin(v), end(v), std::move(comp));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,160 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_MISMATCH_HPP
#define KOKKOS_STD_ALGORITHMS_MISMATCH_HPP
#include "impl/Kokkos_Mismatch.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
// FIXME: add mismatch overloads accepting 3 iterators.
// An overload consistent with other algorithms:
//
// auto mismatch(const ExecSpace& ex, It1 first1, It1 last1, It2 first2) {...}
//
// makes API ambiguous (with the overload accepting views).
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
::Kokkos::pair<IteratorType1, IteratorType2> mismatch(const ExecutionSpace& ex,
IteratorType1 first1,
IteratorType1 last1,
IteratorType2 first2,
IteratorType2 last2) {
return Impl::mismatch_impl("Kokkos::mismatch_iterator_api_default", ex,
first1, last1, first2, last2);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
::Kokkos::pair<IteratorType1, IteratorType2> mismatch(
const ExecutionSpace& ex, IteratorType1 first1, IteratorType1 last1,
IteratorType2 first2, IteratorType2 last2,
BinaryPredicateType&& predicate) {
return Impl::mismatch_impl("Kokkos::mismatch_iterator_api_default", ex,
first1, last1, first2, last2,
std::forward<BinaryPredicateType>(predicate));
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
::Kokkos::pair<IteratorType1, IteratorType2> mismatch(
const std::string& label, const ExecutionSpace& ex, IteratorType1 first1,
IteratorType1 last1, IteratorType2 first2, IteratorType2 last2) {
return Impl::mismatch_impl(label, ex, first1, last1, first2, last2);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
::Kokkos::pair<IteratorType1, IteratorType2> mismatch(
const std::string& label, const ExecutionSpace& ex, IteratorType1 first1,
IteratorType1 last1, IteratorType2 first2, IteratorType2 last2,
BinaryPredicateType&& predicate) {
return Impl::mismatch_impl(label, ex, first1, last1, first2, last2,
std::forward<BinaryPredicateType>(predicate));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto mismatch(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view1,
const ::Kokkos::View<DataType2, Properties2...>& view2) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view1);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view2);
namespace KE = ::Kokkos::Experimental;
return Impl::mismatch_impl("Kokkos::mismatch_view_api_default", ex,
KE::begin(view1), KE::end(view1), KE::begin(view2),
KE::end(view2));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryPredicateType>
auto mismatch(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view1,
const ::Kokkos::View<DataType2, Properties2...>& view2,
BinaryPredicateType&& predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view1);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view2);
namespace KE = ::Kokkos::Experimental;
return Impl::mismatch_impl("Kokkos::mismatch_view_api_default", ex,
KE::begin(view1), KE::end(view1), KE::begin(view2),
KE::end(view2),
std::forward<BinaryPredicateType>(predicate));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto mismatch(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view1,
const ::Kokkos::View<DataType2, Properties2...>& view2) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view1);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view2);
namespace KE = ::Kokkos::Experimental;
return Impl::mismatch_impl(label, ex, KE::begin(view1), KE::end(view1),
KE::begin(view2), KE::end(view2));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryPredicateType>
auto mismatch(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view1,
const ::Kokkos::View<DataType2, Properties2...>& view2,
BinaryPredicateType&& predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view1);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view2);
namespace KE = ::Kokkos::Experimental;
return Impl::mismatch_impl(label, ex, KE::begin(view1), KE::end(view1),
KE::begin(view2), KE::end(view2),
std::forward<BinaryPredicateType>(predicate));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,94 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_MOVE_HPP
#define KOKKOS_STD_ALGORITHMS_MOVE_HPP
#include "impl/Kokkos_Move.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class OutputIterator>
OutputIterator move(const ExecutionSpace& ex, InputIterator first,
InputIterator last, OutputIterator d_first) {
return Impl::move_impl("Kokkos::move_iterator_api_default", ex, first, last,
d_first);
}
template <class ExecutionSpace, class InputIterator, class OutputIterator>
OutputIterator move(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last,
OutputIterator d_first) {
return Impl::move_impl(label, ex, first, last, d_first);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto move(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::move_impl("Kokkos::move_view_api_default", ex, begin(source),
end(source), begin(dest));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto move(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::move_impl(label, ex, begin(source), end(source), begin(dest));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,95 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_MOVE_BACKWARD_HPP
#define KOKKOS_STD_ALGORITHMS_MOVE_BACKWARD_HPP
#include "impl/Kokkos_MoveBackward.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType2 move_backward(const ExecutionSpace& ex, IteratorType1 first,
IteratorType1 last, IteratorType2 d_last) {
return Impl::move_backward_impl("Kokkos::move_backward_iterator_api_default",
ex, first, last, d_last);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto move_backward(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::move_backward_impl("Kokkos::move_backward_view_api_default", ex,
begin(source), end(source), end(dest));
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType2 move_backward(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first, IteratorType1 last,
IteratorType2 d_last) {
return Impl::move_backward_impl(label, ex, first, last, d_last);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto move_backward(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::move_backward_impl(label, ex, begin(source), end(source),
end(dest));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,94 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_NONE_OF_HPP
#define KOKKOS_STD_ALGORITHMS_NONE_OF_HPP
#include "impl/Kokkos_AllOfAnyOfNoneOf.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType, class Predicate>
bool none_of(const ExecutionSpace& ex, IteratorType first, IteratorType last,
Predicate predicate) {
return Impl::none_of_impl("Kokkos::none_of_iterator_api_default", ex, first,
last, predicate);
}
template <class ExecutionSpace, class IteratorType, class Predicate>
bool none_of(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, Predicate predicate) {
return Impl::none_of_impl(label, ex, first, last, predicate);
}
template <class ExecutionSpace, class DataType, class... Properties,
class Predicate>
bool none_of(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::none_of_impl("Kokkos::none_of_view_api_default", ex,
KE::cbegin(v), KE::cend(v), std::move(predicate));
}
template <class ExecutionSpace, class DataType, class... Properties,
class Predicate>
bool none_of(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
Predicate predicate) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
namespace KE = ::Kokkos::Experimental;
return Impl::none_of_impl(label, ex, KE::cbegin(v), KE::cend(v),
std::move(predicate));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,110 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_PARTITION_COPY_HPP
#define KOKKOS_STD_ALGORITHMS_PARTITION_COPY_HPP
#include "impl/Kokkos_PartitionCopy.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorTrueType, class OutputIteratorFalseType,
class PredicateType>
::Kokkos::pair<OutputIteratorTrueType, OutputIteratorFalseType> partition_copy(
const ExecutionSpace& ex, InputIteratorType from_first,
InputIteratorType from_last, OutputIteratorTrueType to_first_true,
OutputIteratorFalseType to_first_false, PredicateType p) {
return Impl::partition_copy_impl(
"Kokkos::partition_copy_iterator_api_default", ex, from_first, from_last,
to_first_true, to_first_false, std::move(p));
}
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorTrueType, class OutputIteratorFalseType,
class PredicateType>
::Kokkos::pair<OutputIteratorTrueType, OutputIteratorFalseType> partition_copy(
const std::string& label, const ExecutionSpace& ex,
InputIteratorType from_first, InputIteratorType from_last,
OutputIteratorTrueType to_first_true,
OutputIteratorFalseType to_first_false, PredicateType p) {
return Impl::partition_copy_impl(label, ex, from_first, from_last,
to_first_true, to_first_false, std::move(p));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class DataType3,
class... Properties3, class PredicateType>
auto partition_copy(
const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest_true,
const ::Kokkos::View<DataType3, Properties3...>& view_dest_false,
PredicateType p) {
return Impl::partition_copy_impl("Kokkos::partition_copy_view_api_default",
ex, cbegin(view_from), cend(view_from),
begin(view_dest_true),
begin(view_dest_false), std::move(p));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class DataType3,
class... Properties3, class PredicateType>
auto partition_copy(
const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest_true,
const ::Kokkos::View<DataType3, Properties3...>& view_dest_false,
PredicateType p) {
return Impl::partition_copy_impl(label, ex, cbegin(view_from),
cend(view_from), begin(view_dest_true),
begin(view_dest_false), std::move(p));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,91 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_PARTITION_POINT_HPP
#define KOKKOS_STD_ALGORITHMS_PARTITION_POINT_HPP
#include "impl/Kokkos_PartitionPoint.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType, class UnaryPredicate>
IteratorType partition_point(const ExecutionSpace& ex, IteratorType first,
IteratorType last, UnaryPredicate p) {
return Impl::partition_point_impl(
"Kokkos::partitioned_point_iterator_api_default", ex, first, last,
std::move(p));
}
template <class ExecutionSpace, class IteratorType, class UnaryPredicate>
IteratorType partition_point(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
UnaryPredicate p) {
return Impl::partition_point_impl(label, ex, first, last, std::move(p));
}
template <class ExecutionSpace, class UnaryPredicate, class DataType,
class... Properties>
auto partition_point(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
UnaryPredicate p) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::partition_point_impl(label, ex, begin(v), end(v), std::move(p));
}
template <class ExecutionSpace, class UnaryPredicate, class DataType,
class... Properties>
auto partition_point(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
UnaryPredicate p) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::partition_point_impl("Kokkos::partition_point_view_api_default",
ex, begin(v), end(v), std::move(p));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -1,491 +0,0 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_PARTITIONING_OPERATIONS_HPP
#define KOKKOS_STD_PARTITIONING_OPERATIONS_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_BeginEnd.hpp"
#include "Kokkos_Constraints.hpp"
#include "Kokkos_ModifyingOperations.hpp"
#include "Kokkos_NonModifyingSequenceOperations.hpp"
namespace Kokkos {
namespace Experimental {
namespace Impl {
// -------------------------
//
// functors
//
// -------------------------
template <class IteratorType, class ReducerType, class PredicateType>
struct StdIsPartitionedFunctor {
using red_value_type = typename ReducerType::value_type;
using index_type = typename IteratorType::difference_type;
IteratorType m_first;
ReducerType m_reducer;
PredicateType m_p;
KOKKOS_FUNCTION
void operator()(const index_type i, red_value_type& redValue) const {
const auto predicate_value = m_p(m_first[i]);
constexpr index_type m_red_id_min =
::Kokkos::reduction_identity<index_type>::min();
constexpr index_type m_red_id_max =
::Kokkos::reduction_identity<index_type>::max();
auto rv = predicate_value ? red_value_type{i, m_red_id_min}
: red_value_type{m_red_id_max, i};
m_reducer.join(redValue, rv);
}
KOKKOS_FUNCTION
StdIsPartitionedFunctor(IteratorType first, ReducerType reducer,
PredicateType p)
: m_first(std::move(first)),
m_reducer(std::move(reducer)),
m_p(std::move(p)) {}
};
template <class IteratorType, class ReducerType, class PredicateType>
struct StdPartitionPointFunctor {
using red_value_type = typename ReducerType::value_type;
using index_type = typename IteratorType::difference_type;
IteratorType m_first;
ReducerType m_reducer;
PredicateType m_p;
KOKKOS_FUNCTION
void operator()(const index_type i, red_value_type& redValue) const {
const auto predicate_value = m_p(m_first[i]);
auto rv =
predicate_value
? red_value_type{::Kokkos::reduction_identity<index_type>::min()}
: red_value_type{i};
m_reducer.join(redValue, rv);
}
KOKKOS_FUNCTION
StdPartitionPointFunctor(IteratorType first, ReducerType reducer,
PredicateType p)
: m_first(std::move(first)),
m_reducer(std::move(reducer)),
m_p(std::move(p)) {}
};
template <class ValueType>
struct StdPartitionCopyScalar {
ValueType true_count_;
ValueType false_count_;
// Here we implement the copy assignment operators explicitly for consistency
// with how the Scalar structs are implemented inside
// Kokkos_Parallel_Reduce.hpp.
KOKKOS_FUNCTION
void operator=(const StdPartitionCopyScalar& other) {
true_count_ = other.true_count_;
false_count_ = other.false_count_;
}
KOKKOS_FUNCTION
void operator=(const volatile StdPartitionCopyScalar& other) volatile {
true_count_ = other.true_count_;
false_count_ = other.false_count_;
}
// this is needed for
// OpenMPTarget/Kokkos_OpenMPTarget_Parallel.hpp:699:21: error: no viable
// overloaded '=' m_returnvalue = 0;
//
KOKKOS_FUNCTION
void operator=(const ValueType value) {
true_count_ = value;
false_count_ = value;
}
};
template <class IndexType, class FirstFrom, class FirstDestTrue,
class FirstDestFalse, class PredType>
struct StdPartitionCopyFunctor {
using value_type = StdPartitionCopyScalar<IndexType>;
FirstFrom m_first_from;
FirstDestTrue m_first_dest_true;
FirstDestFalse m_first_dest_false;
PredType m_pred;
KOKKOS_FUNCTION
StdPartitionCopyFunctor(FirstFrom first_from, FirstDestTrue first_dest_true,
FirstDestFalse first_dest_false, PredType pred)
: m_first_from(std::move(first_from)),
m_first_dest_true(std::move(first_dest_true)),
m_first_dest_false(std::move(first_dest_false)),
m_pred(std::move(pred)) {}
KOKKOS_FUNCTION
void operator()(const IndexType i, value_type& update,
const bool final_pass) const {
const auto& myval = m_first_from[i];
if (final_pass) {
if (m_pred(myval)) {
m_first_dest_true[update.true_count_] = myval;
} else {
m_first_dest_false[update.false_count_] = myval;
}
}
if (m_pred(myval)) {
update.true_count_ += 1;
} else {
update.false_count_ += 1;
}
}
KOKKOS_FUNCTION
void init(value_type& update) const {
update.true_count_ = 0;
update.false_count_ = 0;
}
KOKKOS_FUNCTION
void join(volatile value_type& update,
volatile const value_type& input) const {
update.true_count_ += input.true_count_;
update.false_count_ += input.false_count_;
}
};
// ------------------------------------------
// is_partitioned_impl
// ------------------------------------------
template <class ExecutionSpace, class IteratorType, class PredicateType>
bool is_partitioned_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
PredicateType pred) {
// true if all elements in the range [first, last) that satisfy
// the predicate "pred" appear before all elements that don't.
// Also returns true if [first, last) is empty.
// also true if all elements satisfy the predicate.
// we implement it by finding:
// - the max location where predicate is true (max_loc_true)
// - the min location where predicate is false (min_loc_false)
// so the range is partitioned if max_loc_true < (min_loc_false)
// checks
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::expect_valid_range(first, last);
// trivial case
if (first == last) {
return true;
}
// aliases
using index_type = typename IteratorType::difference_type;
using reducer_type = StdIsPartitioned<index_type>;
using reduction_value_type = typename reducer_type::value_type;
using func_t =
StdIsPartitionedFunctor<IteratorType, reducer_type, PredicateType>;
// run
reduction_value_type red_result;
reducer_type reducer(red_result);
const auto num_elements = Kokkos::Experimental::distance(first, last);
::Kokkos::parallel_reduce(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_t(first, reducer, pred), reducer);
// fence not needed because reducing into scalar
// decide and return
constexpr index_type red_id_min =
::Kokkos::reduction_identity<index_type>::min();
constexpr index_type red_id_max =
::Kokkos::reduction_identity<index_type>::max();
if (red_result.max_loc_true != red_id_max &&
red_result.min_loc_false != red_id_min) {
return red_result.max_loc_true < red_result.min_loc_false;
} else if (first + red_result.max_loc_true == --last) {
return true;
} else {
return false;
}
}
// ------------------------------------------
// partition_point_impl
// ------------------------------------------
template <class ExecutionSpace, class IteratorType, class PredicateType>
IteratorType partition_point_impl(const std::string& label,
const ExecutionSpace& ex, IteratorType first,
IteratorType last, PredicateType pred) {
// locates the end of the first partition, that is, the first
// element that does not satisfy p or last if all elements satisfy p.
// Implementation below finds the first location where p is false.
// checks
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::expect_valid_range(first, last);
if (first == last) {
return first;
}
// aliases
using index_type = typename IteratorType::difference_type;
using reducer_type = StdPartitionPoint<index_type>;
using reduction_value_type = typename reducer_type::value_type;
using func_t =
StdPartitionPointFunctor<IteratorType, reducer_type, PredicateType>;
// run
reduction_value_type red_result;
reducer_type reducer(red_result);
const auto num_elements = Kokkos::Experimental::distance(first, last);
::Kokkos::parallel_reduce(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_t(first, reducer, pred), reducer);
// fence not needed because reducing into scalar
// decide and return
if (red_result.min_loc_false ==
::Kokkos::reduction_identity<index_type>::min()) {
// if all elements are true, return last
return last;
} else {
return first + red_result.min_loc_false;
}
}
// ------------------------------------------
// partition_copy_impl
// ------------------------------------------
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorTrueType, class OutputIteratorFalseType,
class PredicateType>
::Kokkos::pair<OutputIteratorTrueType, OutputIteratorFalseType>
partition_copy_impl(const std::string& label, const ExecutionSpace& ex,
InputIteratorType from_first, InputIteratorType from_last,
OutputIteratorTrueType to_first_true,
OutputIteratorFalseType to_first_false,
PredicateType pred) {
// impl uses a scan, this is similar how we implemented copy_if
// checks
Impl::static_assert_random_access_and_accessible(
ex, from_first, to_first_true, to_first_false);
Impl::static_assert_iterators_have_matching_difference_type(
from_first, to_first_true, to_first_false);
Impl::expect_valid_range(from_first, from_last);
if (from_first == from_last) {
return {to_first_true, to_first_false};
}
// aliases
using index_type = typename InputIteratorType::difference_type;
using func_type =
StdPartitionCopyFunctor<index_type, InputIteratorType,
OutputIteratorTrueType, OutputIteratorFalseType,
PredicateType>;
// run
const auto num_elements =
Kokkos::Experimental::distance(from_first, from_last);
typename func_type::value_type counts{0, 0};
::Kokkos::parallel_scan(
label, RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_type(from_first, to_first_true, to_first_false, pred), counts);
// fence not needed here because of the scan into counts
return {to_first_true + counts.true_count_,
to_first_false + counts.false_count_};
}
} // end namespace Impl
// ----------------------
// is_partitioned public API
// ----------------------
template <class ExecutionSpace, class IteratorType, class PredicateType>
bool is_partitioned(const ExecutionSpace& ex, IteratorType first,
IteratorType last, PredicateType p) {
return Impl::is_partitioned_impl(
"Kokkos::is_partitioned_iterator_api_default", ex, first, last,
std::move(p));
}
template <class ExecutionSpace, class IteratorType, class PredicateType>
bool is_partitioned(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, PredicateType p) {
return Impl::is_partitioned_impl(label, ex, first, last, std::move(p));
}
template <class ExecutionSpace, class PredicateType, class DataType,
class... Properties>
bool is_partitioned(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
PredicateType p) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::is_partitioned_impl("Kokkos::is_partitioned_view_api_default",
ex, cbegin(v), cend(v), std::move(p));
}
template <class ExecutionSpace, class PredicateType, class DataType,
class... Properties>
bool is_partitioned(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
PredicateType p) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::is_partitioned_impl(label, ex, cbegin(v), cend(v), std::move(p));
}
// ----------------------
// partition_copy
// ----------------------
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorTrueType, class OutputIteratorFalseType,
class PredicateType>
::Kokkos::pair<OutputIteratorTrueType, OutputIteratorFalseType> partition_copy(
const ExecutionSpace& ex, InputIteratorType from_first,
InputIteratorType from_last, OutputIteratorTrueType to_first_true,
OutputIteratorFalseType to_first_false, PredicateType p) {
return Impl::partition_copy_impl(
"Kokkos::partition_copy_iterator_api_default", ex, from_first, from_last,
to_first_true, to_first_false, std::move(p));
}
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorTrueType, class OutputIteratorFalseType,
class PredicateType>
::Kokkos::pair<OutputIteratorTrueType, OutputIteratorFalseType> partition_copy(
const std::string& label, const ExecutionSpace& ex,
InputIteratorType from_first, InputIteratorType from_last,
OutputIteratorTrueType to_first_true,
OutputIteratorFalseType to_first_false, PredicateType p) {
return Impl::partition_copy_impl(label, ex, from_first, from_last,
to_first_true, to_first_false, std::move(p));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class DataType3,
class... Properties3, class PredicateType>
auto partition_copy(
const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest_true,
const ::Kokkos::View<DataType3, Properties3...>& view_dest_false,
PredicateType p) {
return Impl::partition_copy_impl("Kokkos::partition_copy_view_api_default",
ex, cbegin(view_from), cend(view_from),
begin(view_dest_true),
begin(view_dest_false), std::move(p));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class DataType3,
class... Properties3, class PredicateType>
auto partition_copy(
const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest_true,
const ::Kokkos::View<DataType3, Properties3...>& view_dest_false,
PredicateType p) {
return Impl::partition_copy_impl(label, ex, cbegin(view_from),
cend(view_from), begin(view_dest_true),
begin(view_dest_false), std::move(p));
}
// ----------------------
// partition_point
// ----------------------
template <class ExecutionSpace, class IteratorType, class UnaryPredicate>
IteratorType partition_point(const ExecutionSpace& ex, IteratorType first,
IteratorType last, UnaryPredicate p) {
return Impl::partition_point_impl(
"Kokkos::partitioned_point_iterator_api_default", ex, first, last,
std::move(p));
}
template <class ExecutionSpace, class IteratorType, class UnaryPredicate>
IteratorType partition_point(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
UnaryPredicate p) {
return Impl::partition_point_impl(label, ex, first, last, std::move(p));
}
template <class ExecutionSpace, class UnaryPredicate, class DataType,
class... Properties>
auto partition_point(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
UnaryPredicate p) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::partition_point_impl(label, ex, begin(v), end(v), std::move(p));
}
template <class ExecutionSpace, class UnaryPredicate, class DataType,
class... Properties>
auto partition_point(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& v,
UnaryPredicate p) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(v);
return Impl::partition_point_impl("Kokkos::partition_point_view_api_default",
ex, begin(v), end(v), std::move(p));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -42,119 +42,14 @@
//@HEADER
*/
#ifndef KOKKOS_STD_NUMERICS_REDUCE_HPP
#define KOKKOS_STD_NUMERICS_REDUCE_HPP
#ifndef KOKKOS_STD_ALGORITHMS_REDUCE_HPP
#define KOKKOS_STD_ALGORITHMS_REDUCE_HPP
#include <Kokkos_Core.hpp>
#include "../Kokkos_BeginEnd.hpp"
#include "../Kokkos_Constraints.hpp"
#include "../Kokkos_Distance.hpp"
#include "../Kokkos_ModifyingOperations.hpp"
#include "../Kokkos_ReducerWithArbitraryJoinerNoNeutralElement.hpp"
#include "impl/Kokkos_Reduce.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class ValueType>
struct StdReduceDefaultJoinFunctor {
KOKKOS_FUNCTION
constexpr ValueType operator()(const ValueType& a, const ValueType& b) const {
return a + b;
}
KOKKOS_FUNCTION
constexpr ValueType operator()(const volatile ValueType& a,
const volatile ValueType& b) const {
return a + b;
}
};
template <class IteratorType, class ReducerType>
struct StdReduceFunctor {
using red_value_type = typename ReducerType::value_type;
using index_type = typename IteratorType::difference_type;
const IteratorType m_first;
const ReducerType m_reducer;
KOKKOS_FUNCTION
void operator()(const index_type i, red_value_type& red_value) const {
auto tmp_wrapped_value = red_value_type{m_first[i], false};
if (red_value.is_initial) {
red_value = tmp_wrapped_value;
} else {
m_reducer.join(red_value, tmp_wrapped_value);
}
}
KOKKOS_FUNCTION
StdReduceFunctor(IteratorType first, ReducerType reducer)
: m_first(std::move(first)), m_reducer(std::move(reducer)) {}
};
//------------------------------
// reduce_custom_functors_impl
//------------------------------
template <class ExecutionSpace, class IteratorType, class ValueType,
class JoinerType>
ValueType reduce_custom_functors_impl(const std::string& label,
const ExecutionSpace& ex,
IteratorType first, IteratorType last,
ValueType init_reduction_value,
JoinerType joiner) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::static_assert_is_not_openmptarget(ex);
Impl::expect_valid_range(first, last);
if (first == last) {
// init is returned, unmodified
return init_reduction_value;
}
// aliases
using reducer_type =
ReducerWithArbitraryJoinerNoNeutralElement<ValueType, JoinerType>;
using functor_type = StdReduceFunctor<IteratorType, reducer_type>;
using reduction_value_type = typename reducer_type::value_type;
// run
reduction_value_type result;
reducer_type reducer(result, joiner);
const auto num_elements = Kokkos::Experimental::distance(first, last);
::Kokkos::parallel_reduce(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
functor_type(first, reducer), reducer);
// fence not needed since reducing into scalar
return joiner(result.val, init_reduction_value);
}
template <class ExecutionSpace, class IteratorType, class ValueType>
ValueType reduce_default_functors_impl(const std::string& label,
const ExecutionSpace& ex,
IteratorType first, IteratorType last,
ValueType init_reduction_value) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::static_assert_is_not_openmptarget(ex);
Impl::expect_valid_range(first, last);
using value_type = Kokkos::Impl::remove_cvref_t<ValueType>;
using joiner_type = Impl::StdReduceDefaultJoinFunctor<value_type>;
return reduce_custom_functors_impl(
label, ex, first, last, std::move(init_reduction_value), joiner_type());
}
} // end namespace Impl
///////////////////////////////
//
// reduce public API
//
///////////////////////////////
//
// overload set 1

View File

@ -0,0 +1,91 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_REMOVE_HPP
#define KOKKOS_STD_ALGORITHMS_REMOVE_HPP
#include "impl/Kokkos_RemoveAllVariants.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class Iterator, class ValueType>
Iterator remove(const ExecutionSpace& ex, Iterator first, Iterator last,
const ValueType& value) {
return Impl::remove_impl("Kokkos::remove_iterator_api_default", ex, first,
last, value);
}
template <class ExecutionSpace, class Iterator, class ValueType>
Iterator remove(const std::string& label, const ExecutionSpace& ex,
Iterator first, Iterator last, const ValueType& value) {
return Impl::remove_impl(label, ex, first, last, value);
}
template <class ExecutionSpace, class DataType, class... Properties,
class ValueType>
auto remove(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
const ValueType& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::remove_impl("Kokkos::remove_iterator_api_default", ex,
::Kokkos::Experimental::begin(view),
::Kokkos::Experimental::end(view), value);
}
template <class ExecutionSpace, class DataType, class... Properties,
class ValueType>
auto remove(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
const ValueType& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::remove_impl(label, ex, ::Kokkos::Experimental::begin(view),
::Kokkos::Experimental::end(view), value);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,106 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_REMOVE_COPY_HPP
#define KOKKOS_STD_ALGORITHMS_REMOVE_COPY_HPP
#include "impl/Kokkos_RemoveAllVariants.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class ValueType>
OutputIterator remove_copy(const ExecutionSpace& ex, InputIterator first_from,
InputIterator last_from, OutputIterator first_dest,
const ValueType& value) {
return Impl::remove_copy_impl("Kokkos::remove_copy_iterator_api_default", ex,
first_from, last_from, first_dest, value);
}
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class ValueType>
OutputIterator remove_copy(const std::string& label, const ExecutionSpace& ex,
InputIterator first_from, InputIterator last_from,
OutputIterator first_dest, const ValueType& value) {
return Impl::remove_copy_impl(label, ex, first_from, last_from, first_dest,
value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class ValueType>
auto remove_copy(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
const ValueType& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
return Impl::remove_copy_impl("Kokkos::remove_copy_iterator_api_default", ex,
::Kokkos::Experimental::cbegin(view_from),
::Kokkos::Experimental::cend(view_from),
::Kokkos::Experimental::begin(view_dest),
value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class ValueType>
auto remove_copy(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
const ValueType& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
return Impl::remove_copy_impl(
label, ex, ::Kokkos::Experimental::cbegin(view_from),
::Kokkos::Experimental::cend(view_from),
::Kokkos::Experimental::begin(view_dest), value);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,110 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_REMOVE_COPY_IF_HPP
#define KOKKOS_STD_ALGORITHMS_REMOVE_COPY_IF_HPP
#include "impl/Kokkos_RemoveAllVariants.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class UnaryPredicate>
OutputIterator remove_copy_if(const ExecutionSpace& ex,
InputIterator first_from, InputIterator last_from,
OutputIterator first_dest,
const UnaryPredicate& pred) {
return Impl::remove_copy_if_impl(
"Kokkos::remove_copy_if_iterator_api_default", ex, first_from, last_from,
first_dest, pred);
}
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class UnaryPredicate>
OutputIterator remove_copy_if(const std::string& label,
const ExecutionSpace& ex,
InputIterator first_from, InputIterator last_from,
OutputIterator first_dest,
const UnaryPredicate& pred) {
return Impl::remove_copy_if_impl(label, ex, first_from, last_from, first_dest,
pred);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class UnaryPredicate>
auto remove_copy_if(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
const UnaryPredicate& pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
return Impl::remove_copy_if_impl(
"Kokkos::remove_copy_if_iterator_api_default", ex,
::Kokkos::Experimental::cbegin(view_from),
::Kokkos::Experimental::cend(view_from),
::Kokkos::Experimental::begin(view_dest), pred);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class UnaryPredicate>
auto remove_copy_if(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
const UnaryPredicate& pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
return Impl::remove_copy_if_impl(
label, ex, ::Kokkos::Experimental::cbegin(view_from),
::Kokkos::Experimental::cend(view_from),
::Kokkos::Experimental::begin(view_dest), pred);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,92 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_REMOVE_IF_HPP
#define KOKKOS_STD_ALGORITHMS_REMOVE_IF_HPP
#include "impl/Kokkos_RemoveAllVariants.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class Iterator, class UnaryPredicate>
Iterator remove_if(const ExecutionSpace& ex, Iterator first, Iterator last,
UnaryPredicate pred) {
return Impl::remove_if_impl("Kokkos::remove_if_iterator_api_default", ex,
first, last, pred);
}
template <class ExecutionSpace, class Iterator, class UnaryPredicate>
Iterator remove_if(const std::string& label, const ExecutionSpace& ex,
Iterator first, Iterator last, UnaryPredicate pred) {
return Impl::remove_if_impl(label, ex, first, last, pred);
}
template <class ExecutionSpace, class DataType, class... Properties,
class UnaryPredicate>
auto remove_if(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
UnaryPredicate pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::remove_if_impl("Kokkos::remove_if_iterator_api_default", ex,
::Kokkos::Experimental::begin(view),
::Kokkos::Experimental::end(view), pred);
}
template <class ExecutionSpace, class DataType, class... Properties,
class UnaryPredicate>
auto remove_if(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
UnaryPredicate pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::remove_if_impl(label, ex, ::Kokkos::Experimental::begin(view),
::Kokkos::Experimental::end(view), pred);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,93 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_REPLACE_HPP
#define KOKKOS_STD_ALGORITHMS_REPLACE_HPP
#include "impl/Kokkos_Replace.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class Iterator, class ValueType>
void replace(const ExecutionSpace& ex, Iterator first, Iterator last,
const ValueType& old_value, const ValueType& new_value) {
return Impl::replace_impl("Kokkos::replace_iterator_api", ex, first, last,
old_value, new_value);
}
template <class ExecutionSpace, class Iterator, class ValueType>
void replace(const std::string& label, const ExecutionSpace& ex, Iterator first,
Iterator last, const ValueType& old_value,
const ValueType& new_value) {
return Impl::replace_impl(label, ex, first, last, old_value, new_value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class ValueType>
void replace(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
const ValueType& old_value, const ValueType& new_value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::replace_impl("Kokkos::replace_view_api", ex, KE::begin(view),
KE::end(view), old_value, new_value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class ValueType>
void replace(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
const ValueType& old_value, const ValueType& new_value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::replace_impl(label, ex, KE::begin(view), KE::end(view),
old_value, new_value);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,107 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_REPLACE_COPY_HPP
#define KOKKOS_STD_ALGORITHMS_REPLACE_COPY_HPP
#include "impl/Kokkos_ReplaceCopy.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class ValueType>
OutputIterator replace_copy(const ExecutionSpace& ex, InputIterator first_from,
InputIterator last_from, OutputIterator first_dest,
const ValueType& old_value,
const ValueType& new_value) {
return Impl::replace_copy_impl("Kokkos::replace_copy_iterator_api", ex,
first_from, last_from, first_dest, old_value,
new_value);
}
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class ValueType>
OutputIterator replace_copy(const std::string& label, const ExecutionSpace& ex,
InputIterator first_from, InputIterator last_from,
OutputIterator first_dest,
const ValueType& old_value,
const ValueType& new_value) {
return Impl::replace_copy_impl(label, ex, first_from, last_from, first_dest,
old_value, new_value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class ValueType>
auto replace_copy(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
const ValueType& old_value, const ValueType& new_value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
namespace KE = ::Kokkos::Experimental;
return Impl::replace_copy_impl("Kokkos::replace_copy_view_api", ex,
KE::cbegin(view_from), KE::cend(view_from),
KE::begin(view_dest), old_value, new_value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class ValueType>
auto replace_copy(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
const ValueType& old_value, const ValueType& new_value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
namespace KE = ::Kokkos::Experimental;
return Impl::replace_copy_impl(label, ex, KE::cbegin(view_from),
KE::cend(view_from), KE::begin(view_dest),
old_value, new_value);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,111 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_REPLACE_COPY_IF_HPP
#define KOKKOS_STD_ALGORITHMS_REPLACE_COPY_IF_HPP
#include "impl/Kokkos_ReplaceCopyIf.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class PredicateType, class ValueType>
OutputIterator replace_copy_if(const ExecutionSpace& ex,
InputIterator first_from,
InputIterator last_from,
OutputIterator first_dest, PredicateType pred,
const ValueType& new_value) {
return Impl::replace_copy_if_impl("Kokkos::replace_copy_if_iterator_api", ex,
first_from, last_from, first_dest, pred,
new_value);
}
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class PredicateType, class ValueType>
OutputIterator replace_copy_if(const std::string& label,
const ExecutionSpace& ex,
InputIterator first_from,
InputIterator last_from,
OutputIterator first_dest, PredicateType pred,
const ValueType& new_value) {
return Impl::replace_copy_if_impl(label, ex, first_from, last_from,
first_dest, pred, new_value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class PredicateType,
class ValueType>
auto replace_copy_if(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
PredicateType pred, const ValueType& new_value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
namespace KE = ::Kokkos::Experimental;
return Impl::replace_copy_if_impl("Kokkos::replace_copy_if_view_api", ex,
KE::cbegin(view_from), KE::cend(view_from),
KE::begin(view_dest), pred, new_value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class PredicateType,
class ValueType>
auto replace_copy_if(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
PredicateType pred, const ValueType& new_value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
namespace KE = ::Kokkos::Experimental;
return Impl::replace_copy_if_impl(label, ex, KE::cbegin(view_from),
KE::cend(view_from), KE::begin(view_dest),
pred, new_value);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,96 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_REPLACE_IF_HPP
#define KOKKOS_STD_ALGORITHMS_REPLACE_IF_HPP
#include "impl/Kokkos_ReplaceIf.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class Predicate,
class ValueType>
void replace_if(const ExecutionSpace& ex, InputIterator first,
InputIterator last, Predicate pred,
const ValueType& new_value) {
return Impl::replace_if_impl("Kokkos::replace_if_iterator_api", ex, first,
last, pred, new_value);
}
template <class ExecutionSpace, class InputIterator, class Predicate,
class ValueType>
void replace_if(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last, Predicate pred,
const ValueType& new_value) {
return Impl::replace_if_impl(label, ex, first, last, pred, new_value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class Predicate, class ValueType>
void replace_if(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
Predicate pred, const ValueType& new_value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::replace_if_impl("Kokkos::replace_if_view_api", ex,
KE::begin(view), KE::end(view), pred, new_value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class Predicate, class ValueType>
void replace_if(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
Predicate pred, const ValueType& new_value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::replace_if_impl(label, ex, KE::begin(view), KE::end(view), pred,
new_value);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,87 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_REVERSE_HPP
#define KOKKOS_STD_ALGORITHMS_REVERSE_HPP
#include "impl/Kokkos_Reverse.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator>
void reverse(const ExecutionSpace& ex, InputIterator first,
InputIterator last) {
return Impl::reverse_impl("Kokkos::reverse_iterator_api_default", ex, first,
last);
}
template <class ExecutionSpace, class InputIterator>
void reverse(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last) {
return Impl::reverse_impl(label, ex, first, last);
}
template <class ExecutionSpace, class DataType, class... Properties>
void reverse(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::reverse_impl("Kokkos::reverse_view_api_default", ex,
KE::begin(view), KE::end(view));
}
template <class ExecutionSpace, class DataType, class... Properties>
void reverse(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::reverse_impl(label, ex, KE::begin(view), KE::end(view));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,95 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_REVERSE_COPY_HPP
#define KOKKOS_STD_ALGORITHMS_REVERSE_COPY_HPP
#include "impl/Kokkos_ReverseCopy.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class OutputIterator>
OutputIterator reverse_copy(const ExecutionSpace& ex, InputIterator first,
InputIterator last, OutputIterator d_first) {
return Impl::reverse_copy_impl("Kokkos::reverse_copy_iterator_api_default",
ex, first, last, d_first);
}
template <class ExecutionSpace, class InputIterator, class OutputIterator>
OutputIterator reverse_copy(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last,
OutputIterator d_first) {
return Impl::reverse_copy_impl(label, ex, first, last, d_first);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto reverse_copy(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::reverse_copy_impl("Kokkos::reverse_copy_view_api_default", ex,
cbegin(source), cend(source), begin(dest));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto reverse_copy(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::reverse_copy_impl(label, ex, cbegin(source), cend(source),
begin(dest));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,89 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_ROTATE_HPP
#define KOKKOS_STD_ALGORITHMS_ROTATE_HPP
#include "impl/Kokkos_Rotate.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType>
IteratorType rotate(const ExecutionSpace& ex, IteratorType first,
IteratorType n_first, IteratorType last) {
return Impl::rotate_impl("Kokkos::rotate_iterator_api_default", ex, first,
n_first, last);
}
template <class ExecutionSpace, class IteratorType>
IteratorType rotate(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType n_first,
IteratorType last) {
return Impl::rotate_impl(label, ex, first, n_first, last);
}
template <class ExecutionSpace, class DataType, class... Properties>
auto rotate(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
std::size_t n_location) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::rotate_impl("Kokkos::rotate_view_api_default", ex, begin(view),
begin(view) + n_location, end(view));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto rotate(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
std::size_t n_location) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::rotate_impl(label, ex, begin(view), begin(view) + n_location,
end(view));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,100 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_ROTATE_COPY_HPP
#define KOKKOS_STD_ALGORITHMS_ROTATE_COPY_HPP
#include "impl/Kokkos_RotateCopy.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class OutputIterator>
OutputIterator rotate_copy(const ExecutionSpace& ex, InputIterator first,
InputIterator n_first, InputIterator last,
OutputIterator d_first) {
return Impl::rotate_copy_impl("Kokkos::rotate_copy_iterator_api_default", ex,
first, n_first, last, d_first);
}
template <class ExecutionSpace, class InputIterator, class OutputIterator>
OutputIterator rotate_copy(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator n_first,
InputIterator last, OutputIterator d_first) {
return Impl::rotate_copy_impl(label, ex, first, n_first, last, d_first);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto rotate_copy(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
std::size_t n_location,
const ::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::rotate_copy_impl("Kokkos::rotate_copy_view_api_default", ex,
cbegin(source), cbegin(source) + n_location,
cend(source), begin(dest));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto rotate_copy(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
std::size_t n_location,
const ::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::rotate_copy_impl(label, ex, cbegin(source),
cbegin(source) + n_location, cend(source),
begin(dest));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,148 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_SEARCH_HPP
#define KOKKOS_STD_ALGORITHMS_SEARCH_HPP
#include "impl/Kokkos_Search.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
// overload set 1: no binary predicate passed
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType1 search(const ExecutionSpace& ex, IteratorType1 first,
IteratorType1 last, IteratorType2 s_first,
IteratorType2 s_last) {
return Impl::search_impl("Kokkos::search_iterator_api_default", ex, first,
last, s_first, s_last);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType1 search(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first, IteratorType1 last,
IteratorType2 s_first, IteratorType2 s_last) {
return Impl::search_impl(label, ex, first, last, s_first, s_last);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto search(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
const ::Kokkos::View<DataType2, Properties2...>& s_view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(s_view);
namespace KE = ::Kokkos::Experimental;
return Impl::search_impl("Kokkos::search_view_api_default", ex,
KE::begin(view), KE::end(view), KE::begin(s_view),
KE::end(s_view));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto search(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
const ::Kokkos::View<DataType2, Properties2...>& s_view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(s_view);
namespace KE = ::Kokkos::Experimental;
return Impl::search_impl(label, ex, KE::begin(view), KE::end(view),
KE::begin(s_view), KE::end(s_view));
}
// overload set 2: binary predicate passed
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
IteratorType1 search(const ExecutionSpace& ex, IteratorType1 first,
IteratorType1 last, IteratorType2 s_first,
IteratorType2 s_last, const BinaryPredicateType& pred) {
return Impl::search_impl("Kokkos::search_iterator_api_default", ex, first,
last, s_first, s_last, pred);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
IteratorType1 search(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first, IteratorType1 last,
IteratorType2 s_first, IteratorType2 s_last,
const BinaryPredicateType& pred) {
return Impl::search_impl(label, ex, first, last, s_first, s_last, pred);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryPredicateType>
auto search(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
const ::Kokkos::View<DataType2, Properties2...>& s_view,
const BinaryPredicateType& pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(s_view);
namespace KE = ::Kokkos::Experimental;
return Impl::search_impl("Kokkos::search_view_api_default", ex,
KE::begin(view), KE::end(view), KE::begin(s_view),
KE::end(s_view), pred);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryPredicateType>
auto search(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view,
const ::Kokkos::View<DataType2, Properties2...>& s_view,
const BinaryPredicateType& pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(s_view);
namespace KE = ::Kokkos::Experimental;
return Impl::search_impl(label, ex, KE::begin(view), KE::end(view),
KE::begin(s_view), KE::end(s_view), pred);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,144 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_SEARCH_N_HPP
#define KOKKOS_STD_ALGORITHMS_SEARCH_N_HPP
#include "impl/Kokkos_SearchN.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
// overload set 1: no binary predicate passed
template <class ExecutionSpace, class IteratorType, class SizeType,
class ValueType>
IteratorType search_n(const ExecutionSpace& ex, IteratorType first,
IteratorType last, SizeType count,
const ValueType& value) {
return Impl::search_n_impl("Kokkos::search_n_iterator_api_default", ex, first,
last, count, value);
}
template <class ExecutionSpace, class IteratorType, class SizeType,
class ValueType>
IteratorType search_n(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, SizeType count,
const ValueType& value) {
return Impl::search_n_impl(label, ex, first, last, count, value);
}
template <class ExecutionSpace, class DataType, class... Properties,
class SizeType, class ValueType>
auto search_n(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
SizeType count, const ValueType& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::search_n_impl("Kokkos::search_n_view_api_default", ex,
KE::begin(view), KE::end(view), count, value);
}
template <class ExecutionSpace, class DataType, class... Properties,
class SizeType, class ValueType>
auto search_n(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
SizeType count, const ValueType& value) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::search_n_impl(label, ex, KE::begin(view), KE::end(view), count,
value);
}
// overload set 2: binary predicate passed
template <class ExecutionSpace, class IteratorType, class SizeType,
class ValueType, class BinaryPredicateType>
IteratorType search_n(const ExecutionSpace& ex, IteratorType first,
IteratorType last, SizeType count, const ValueType& value,
const BinaryPredicateType& pred) {
return Impl::search_n_impl("Kokkos::search_n_iterator_api_default", ex, first,
last, count, value, pred);
}
template <class ExecutionSpace, class IteratorType, class SizeType,
class ValueType, class BinaryPredicateType>
IteratorType search_n(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, SizeType count,
const ValueType& value, const BinaryPredicateType& pred) {
return Impl::search_n_impl(label, ex, first, last, count, value, pred);
}
template <class ExecutionSpace, class DataType, class... Properties,
class SizeType, class ValueType, class BinaryPredicateType>
auto search_n(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
SizeType count, const ValueType& value,
const BinaryPredicateType& pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::search_n_impl("Kokkos::search_n_view_api_default", ex,
KE::begin(view), KE::end(view), count, value,
pred);
}
template <class ExecutionSpace, class DataType, class... Properties,
class SizeType, class ValueType, class BinaryPredicateType>
auto search_n(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
SizeType count, const ValueType& value,
const BinaryPredicateType& pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::search_n_impl(label, ex, KE::begin(view), KE::end(view), count,
value, pred);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,89 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_SHIFT_LEFT_HPP
#define KOKKOS_STD_ALGORITHMS_SHIFT_LEFT_HPP
#include "impl/Kokkos_ShiftLeft.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType>
IteratorType shift_left(const ExecutionSpace& ex, IteratorType first,
IteratorType last,
typename IteratorType::difference_type n) {
return Impl::shift_left_impl("Kokkos::shift_left_iterator_api_default", ex,
first, last, n);
}
template <class ExecutionSpace, class IteratorType>
IteratorType shift_left(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
typename IteratorType::difference_type n) {
return Impl::shift_left_impl(label, ex, first, last, n);
}
template <class ExecutionSpace, class DataType, class... Properties>
auto shift_left(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
typename decltype(begin(view))::difference_type n) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::shift_left_impl("Kokkos::shift_left_view_api_default", ex,
begin(view), end(view), n);
}
template <class ExecutionSpace, class DataType, class... Properties>
auto shift_left(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
typename decltype(begin(view))::difference_type n) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::shift_left_impl(label, ex, begin(view), end(view), n);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,89 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_SHIFT_RIGHT_HPP
#define KOKKOS_STD_ALGORITHMS_SHIFT_RIGHT_HPP
#include "impl/Kokkos_ShiftRight.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType>
IteratorType shift_right(const ExecutionSpace& ex, IteratorType first,
IteratorType last,
typename IteratorType::difference_type n) {
return Impl::shift_right_impl("Kokkos::shift_right_iterator_api_default", ex,
first, last, n);
}
template <class ExecutionSpace, class IteratorType>
IteratorType shift_right(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
typename IteratorType::difference_type n) {
return Impl::shift_right_impl(label, ex, first, last, n);
}
template <class ExecutionSpace, class DataType, class... Properties>
auto shift_right(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
typename decltype(begin(view))::difference_type n) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::shift_right_impl("Kokkos::shift_right_view_api_default", ex,
begin(view), end(view), n);
}
template <class ExecutionSpace, class DataType, class... Properties>
auto shift_right(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
typename decltype(begin(view))::difference_type n) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::shift_right_impl(label, ex, begin(view), end(view), n);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -1,378 +0,0 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_SORTING_OPERATIONS_HPP
#define KOKKOS_STD_SORTING_OPERATIONS_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_BeginEnd.hpp"
#include "Kokkos_Constraints.hpp"
#include "Kokkos_NonModifyingSequenceOperations.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
// ------------------
//
// functors
//
// ------------------
template <class IteratorType, class IndicatorViewType, class ComparatorType>
struct StdIsSortedUntilFunctor {
using index_type = typename IteratorType::difference_type;
IteratorType m_first;
IndicatorViewType m_indicator;
ComparatorType m_comparator;
KOKKOS_FUNCTION
void operator()(const index_type i, int& update, const bool final) const {
const auto& val_i = m_first[i];
const auto& val_ip1 = m_first[i + 1];
if (m_comparator(val_ip1, val_i)) {
++update;
}
if (final) {
m_indicator(i) = update;
}
}
KOKKOS_FUNCTION
StdIsSortedUntilFunctor(IteratorType _first1, IndicatorViewType indicator,
ComparatorType comparator)
: m_first(std::move(_first1)),
m_indicator(std::move(indicator)),
m_comparator(std::move(comparator)) {}
};
template <class IteratorType, class ComparatorType>
struct StdIsSortedFunctor {
using index_type = typename IteratorType::difference_type;
IteratorType m_first;
ComparatorType m_comparator;
KOKKOS_FUNCTION
void operator()(const index_type i, std::size_t& update) const {
const auto& val_i = m_first[i];
const auto& val_ip1 = m_first[i + 1];
if (m_comparator(val_ip1, val_i)) {
++update;
}
}
KOKKOS_FUNCTION
StdIsSortedFunctor(IteratorType _first1, ComparatorType comparator)
: m_first(std::move(_first1)), m_comparator(std::move(comparator)) {}
};
// ------------------------------------------
// is_sorted_until_impl
// ------------------------------------------
template <class ExecutionSpace, class IteratorType, class ComparatorType>
IteratorType is_sorted_until_impl(const std::string& label,
const ExecutionSpace& ex, IteratorType first,
IteratorType last, ComparatorType comp) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::expect_valid_range(first, last);
const auto num_elements = Kokkos::Experimental::distance(first, last);
// trivial case
if (num_elements <= 1) {
return last;
}
/*
use scan and a helper "indicator" view
such that we scan the data and fill the indicator with
partial sum that is always 0 unless we find a pair that
breaks the sorting, so in that case the indicator will
have a 1 starting at the location where the sorting breaks.
So finding that 1 means finding the location we want.
*/
// aliases
using indicator_value_type = std::size_t;
using indicator_view_type =
::Kokkos::View<indicator_value_type*, ExecutionSpace>;
using functor_type =
StdIsSortedUntilFunctor<IteratorType, indicator_view_type,
ComparatorType>;
// do scan
// use num_elements-1 because each index handles i and i+1
const auto num_elements_minus_one = num_elements - 1;
indicator_view_type indicator("is_sorted_until_indicator_helper",
num_elements_minus_one);
::Kokkos::parallel_scan(
label, RangePolicy<ExecutionSpace>(ex, 0, num_elements_minus_one),
functor_type(first, indicator, std::move(comp)));
// try to find the first sentinel value, which indicates
// where the sorting condition breaks
namespace KE = ::Kokkos::Experimental;
constexpr indicator_value_type sentinel_value = 1;
auto r =
KE::find(ex, KE::cbegin(indicator), KE::cend(indicator), sentinel_value);
const auto shift = r - ::Kokkos::Experimental::cbegin(indicator);
return first + (shift + 1);
}
template <class ExecutionSpace, class IteratorType>
IteratorType is_sorted_until_impl(const std::string& label,
const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
using value_type = typename IteratorType::value_type;
using pred_t = Impl::StdAlgoLessThanBinaryPredicate<value_type>;
return is_sorted_until_impl(label, ex, first, last, pred_t());
}
// ------------------------------------------
// is_sorted_impl
// ------------------------------------------
template <class ExecutionSpace, class IteratorType, class ComparatorType>
bool is_sorted_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
ComparatorType comp) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::expect_valid_range(first, last);
const auto num_elements = Kokkos::Experimental::distance(first, last);
if (num_elements <= 1) {
return true;
}
// use num_elements-1 because each index handles i and i+1
const auto num_elements_minus_one = num_elements - 1;
using functor_type = StdIsSortedFunctor<IteratorType, ComparatorType>;
// result is incremented by one if sorting breaks at index i
std::size_t result = 0;
::Kokkos::parallel_reduce(
label, RangePolicy<ExecutionSpace>(ex, 0, num_elements_minus_one),
functor_type(first, std::move(comp)), result);
return result == 0;
}
template <class ExecutionSpace, class IteratorType>
bool is_sorted_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last) {
using value_type = typename IteratorType::value_type;
using pred_t = Impl::StdAlgoLessThanBinaryPredicate<value_type>;
return is_sorted_impl(label, ex, first, last, pred_t());
}
} // namespace Impl
// ----------------------------------
// is_sorted_until public API
// ----------------------------------
template <class ExecutionSpace, class IteratorType>
IteratorType is_sorted_until(const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
return Impl::is_sorted_until_impl(
"Kokkos::is_sorted_until_iterator_api_default", ex, first, last);
}
template <class ExecutionSpace, class IteratorType>
IteratorType is_sorted_until(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last) {
return Impl::is_sorted_until_impl(label, ex, first, last);
}
template <class ExecutionSpace, class DataType, class... Properties>
auto is_sorted_until(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_until_impl("Kokkos::is_sorted_until_view_api_default",
ex, KE::begin(view), KE::end(view));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto is_sorted_until(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_until_impl(label, ex, KE::begin(view), KE::end(view));
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
IteratorType is_sorted_until(const ExecutionSpace& ex, IteratorType first,
IteratorType last, ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::is_sorted_until_impl(
"Kokkos::is_sorted_until_iterator_api_default", ex, first, last,
std::move(comp));
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
IteratorType is_sorted_until(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::is_sorted_until_impl(label, ex, first, last, std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties,
class ComparatorType>
auto is_sorted_until(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_not_openmptarget(ex);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_until_impl("Kokkos::is_sorted_until_view_api_default",
ex, KE::begin(view), KE::end(view),
std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties,
class ComparatorType>
auto is_sorted_until(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_not_openmptarget(ex);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_until_impl(label, ex, KE::begin(view), KE::end(view),
std::move(comp));
}
// ----------------------------------
// is_sorted public API
// ----------------------------------
template <class ExecutionSpace, class IteratorType>
bool is_sorted(const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
return Impl::is_sorted_impl("Kokkos::is_sorted_iterator_api_default", ex,
first, last);
}
template <class ExecutionSpace, class IteratorType>
bool is_sorted(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last) {
return Impl::is_sorted_impl(label, ex, first, last);
}
template <class ExecutionSpace, class DataType, class... Properties>
bool is_sorted(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_impl("Kokkos::is_sorted_view_api_default", ex,
KE::cbegin(view), KE::cend(view));
}
template <class ExecutionSpace, class DataType, class... Properties>
bool is_sorted(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_impl(label, ex, KE::cbegin(view), KE::cend(view));
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
bool is_sorted(const ExecutionSpace& ex, IteratorType first, IteratorType last,
ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::is_sorted_impl("Kokkos::is_sorted_iterator_api_default", ex,
first, last, std::move(comp));
}
template <class ExecutionSpace, class IteratorType, class ComparatorType>
bool is_sorted(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, ComparatorType comp) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::is_sorted_impl(label, ex, first, last, std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties,
class ComparatorType>
bool is_sorted(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_not_openmptarget(ex);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_impl("Kokkos::is_sorted_view_api_default", ex,
KE::cbegin(view), KE::cend(view),
std::move(comp));
}
template <class ExecutionSpace, class DataType, class... Properties,
class ComparatorType>
bool is_sorted(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
ComparatorType comp) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
Impl::static_assert_is_not_openmptarget(ex);
namespace KE = ::Kokkos::Experimental;
return Impl::is_sorted_impl(label, ex, KE::cbegin(view), KE::cend(view),
std::move(comp));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,69 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_SWAP_HPP
#define KOKKOS_STD_ALGORITHMS_SWAP_HPP
#include <Kokkos_Core.hpp>
namespace Kokkos {
namespace Experimental {
// swap
template <class T>
KOKKOS_INLINE_FUNCTION void swap(T& a, T& b) noexcept {
static_assert(
std::is_move_assignable<T>::value && std::is_move_constructible<T>::value,
"Kokkos::Experimental::swap arguments must be move assignable "
"and move constructible");
T tmp = std::move(a);
a = std::move(b);
b = std::move(tmp);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,97 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_SWAP_RANGES_HPP
#define KOKKOS_STD_ALGORITHMS_SWAP_RANGES_HPP
#include "impl/Kokkos_SwapRanges.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType2 swap_ranges(const ExecutionSpace& ex, IteratorType1 first1,
IteratorType1 last1, IteratorType2 first2) {
return Impl::swap_ranges_impl("Kokkos::swap_ranges_iterator_api_default", ex,
first1, last1, first2);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto swap_ranges(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
assert(source.extent(0) == dest.extent(0));
return Impl::swap_ranges_impl("Kokkos::swap_ranges_view_api_default", ex,
begin(source), end(source), begin(dest));
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType2 swap_ranges(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first1, IteratorType1 last1,
IteratorType2 first2) {
return Impl::swap_ranges_impl(label, ex, first1, last1, first2);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto swap_ranges(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
assert(source.extent(0) == dest.extent(0));
return Impl::swap_ranges_impl(label, ex, begin(source), end(source),
begin(dest));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,166 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_TRANSFORM_HPP
#define KOKKOS_STD_ALGORITHMS_TRANSFORM_HPP
#include "impl/Kokkos_Transform.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class UnaryOperation>
std::enable_if_t< ::Kokkos::Experimental::Impl::are_iterators<
InputIterator, OutputIterator>::value,
OutputIterator>
transform(const ExecutionSpace& ex, InputIterator first1, InputIterator last1,
OutputIterator d_first, UnaryOperation unary_op) {
return Impl::transform_impl("Kokkos::transform_iterator_api_default", ex,
first1, last1, d_first, std::move(unary_op));
}
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class UnaryOperation>
std::enable_if_t< ::Kokkos::Experimental::Impl::are_iterators<
InputIterator, OutputIterator>::value,
OutputIterator>
transform(const std::string& label, const ExecutionSpace& ex,
InputIterator first1, InputIterator last1, OutputIterator d_first,
UnaryOperation unary_op) {
return Impl::transform_impl(label, ex, first1, last1, d_first,
std::move(unary_op));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class UnaryOperation>
auto transform(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest,
UnaryOperation unary_op) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::transform_impl("Kokkos::transform_view_api_default", ex,
begin(source), end(source), begin(dest),
std::move(unary_op));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class UnaryOperation>
auto transform(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
::Kokkos::View<DataType2, Properties2...>& dest,
UnaryOperation unary_op) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::transform_impl(label, ex, begin(source), end(source),
begin(dest), std::move(unary_op));
}
template <class ExecutionSpace, class InputIterator1, class InputIterator2,
class OutputIterator, class BinaryOperation>
std::enable_if_t< ::Kokkos::Experimental::Impl::are_iterators<
InputIterator1, InputIterator2, OutputIterator>::value,
OutputIterator>
transform(const ExecutionSpace& ex, InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, OutputIterator d_first,
BinaryOperation binary_op) {
return Impl::transform_impl("Kokkos::transform_iterator_api_default", ex,
first1, last1, first2, d_first,
std::move(binary_op));
}
template <class ExecutionSpace, class InputIterator1, class InputIterator2,
class OutputIterator, class BinaryOperation>
std::enable_if_t< ::Kokkos::Experimental::Impl::are_iterators<
InputIterator1, InputIterator2, OutputIterator>::value,
OutputIterator>
transform(const std::string& label, const ExecutionSpace& ex,
InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
OutputIterator d_first, BinaryOperation binary_op) {
return Impl::transform_impl(label, ex, first1, last1, first2, d_first,
std::move(binary_op));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class DataType3,
class... Properties3, class BinaryOperation>
auto transform(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source1,
const ::Kokkos::View<DataType2, Properties2...>& source2,
::Kokkos::View<DataType3, Properties3...>& dest,
BinaryOperation binary_op) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source1);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source2);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::transform_impl("Kokkos::transform_view_api_default", ex,
begin(source1), end(source1), begin(source2),
begin(dest), std::move(binary_op));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class DataType3,
class... Properties3, class BinaryOperation>
auto transform(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source1,
const ::Kokkos::View<DataType2, Properties2...>& source2,
::Kokkos::View<DataType3, Properties3...>& dest,
BinaryOperation binary_op) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source1);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source2);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::transform_impl(label, ex, begin(source1), end(source1),
begin(source2), begin(dest),
std::move(binary_op));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,131 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_TRASFORM_EXCLUSIVE_SCAN_HPP
#define KOKKOS_STD_ALGORITHMS_TRASFORM_EXCLUSIVE_SCAN_HPP
#include "impl/Kokkos_TransformExclusiveScan.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class ValueType, class BinaryOpType,
class UnaryOpType>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
transform_exclusive_scan(const ExecutionSpace& ex, InputIteratorType first,
InputIteratorType last, OutputIteratorType first_dest,
ValueType init_value, BinaryOpType binary_op,
UnaryOpType unary_op) {
Impl::static_assert_is_not_openmptarget(ex);
static_assert(std::is_move_constructible<ValueType>::value,
"ValueType must be move constructible.");
return Impl::transform_exclusive_scan_impl(
"Kokkos::transform_exclusive_scan_custom_functors_iterator_api", ex,
first, last, first_dest, init_value, binary_op, unary_op);
}
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class ValueType, class BinaryOpType,
class UnaryOpType>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
transform_exclusive_scan(const std::string& label, const ExecutionSpace& ex,
InputIteratorType first, InputIteratorType last,
OutputIteratorType first_dest, ValueType init_value,
BinaryOpType binary_op, UnaryOpType unary_op) {
Impl::static_assert_is_not_openmptarget(ex);
static_assert(std::is_move_constructible<ValueType>::value,
"ValueType must be move constructible.");
return Impl::transform_exclusive_scan_impl(label, ex, first, last, first_dest,
init_value, binary_op, unary_op);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class ValueType,
class BinaryOpType, class UnaryOpType>
auto transform_exclusive_scan(
const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
ValueType init_value, BinaryOpType binary_op, UnaryOpType unary_op) {
Impl::static_assert_is_not_openmptarget(ex);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
static_assert(std::is_move_constructible<ValueType>::value,
"ValueType must be move constructible.");
namespace KE = ::Kokkos::Experimental;
return Impl::transform_exclusive_scan_impl(
"Kokkos::transform_exclusive_scan_custom_functors_view_api", ex,
KE::cbegin(view_from), KE::cend(view_from), KE::begin(view_dest),
init_value, binary_op, unary_op);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class ValueType,
class BinaryOpType, class UnaryOpType>
auto transform_exclusive_scan(
const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
ValueType init_value, BinaryOpType binary_op, UnaryOpType unary_op) {
Impl::static_assert_is_not_openmptarget(ex);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
static_assert(std::is_move_constructible<ValueType>::value,
"ValueType must be move constructible.");
namespace KE = ::Kokkos::Experimental;
return Impl::transform_exclusive_scan_impl(
label, ex, KE::cbegin(view_from), KE::cend(view_from),
KE::begin(view_dest), init_value, binary_op, unary_op);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,190 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_TRANSFORM_INCLUSIVE_SCAN_HPP
#define KOKKOS_STD_ALGORITHMS_TRANSFORM_INCLUSIVE_SCAN_HPP
#include "impl/Kokkos_TransformInclusiveScan.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
// overload set 1 (no init value)
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class BinaryOpType, class UnaryOpType>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
transform_inclusive_scan(const ExecutionSpace& ex, InputIteratorType first,
InputIteratorType last, OutputIteratorType first_dest,
BinaryOpType binary_op, UnaryOpType unary_op) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::transform_inclusive_scan_impl(
"Kokkos::transform_inclusive_scan_custom_functors_iterator_api", ex,
first, last, first_dest, binary_op, unary_op);
}
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class BinaryOpType, class UnaryOpType>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
transform_inclusive_scan(const std::string& label, const ExecutionSpace& ex,
InputIteratorType first, InputIteratorType last,
OutputIteratorType first_dest, BinaryOpType binary_op,
UnaryOpType unary_op) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::transform_inclusive_scan_impl(label, ex, first, last, first_dest,
binary_op, unary_op);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryOpType,
class UnaryOpType>
auto transform_inclusive_scan(
const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
BinaryOpType binary_op, UnaryOpType unary_op) {
Impl::static_assert_is_not_openmptarget(ex);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
namespace KE = ::Kokkos::Experimental;
return Impl::transform_inclusive_scan_impl(
"Kokkos::transform_inclusive_scan_custom_functors_view_api", ex,
KE::cbegin(view_from), KE::cend(view_from), KE::begin(view_dest),
binary_op, unary_op);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryOpType,
class UnaryOpType>
auto transform_inclusive_scan(
const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
BinaryOpType binary_op, UnaryOpType unary_op) {
Impl::static_assert_is_not_openmptarget(ex);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
namespace KE = ::Kokkos::Experimental;
return Impl::transform_inclusive_scan_impl(
label, ex, KE::cbegin(view_from), KE::cend(view_from),
KE::begin(view_dest), binary_op, unary_op);
}
// overload set 2 (init value)
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class BinaryOpType, class UnaryOpType,
class ValueType>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
transform_inclusive_scan(const ExecutionSpace& ex, InputIteratorType first,
InputIteratorType last, OutputIteratorType first_dest,
BinaryOpType binary_op, UnaryOpType unary_op,
ValueType init_value) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::transform_inclusive_scan_impl(
"Kokkos::transform_inclusive_scan_custom_functors_iterator_api", ex,
first, last, first_dest, binary_op, unary_op, init_value);
}
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class BinaryOpType, class UnaryOpType,
class ValueType>
std::enable_if_t<::Kokkos::Experimental::Impl::are_iterators<
InputIteratorType, OutputIteratorType>::value,
OutputIteratorType>
transform_inclusive_scan(const std::string& label, const ExecutionSpace& ex,
InputIteratorType first, InputIteratorType last,
OutputIteratorType first_dest, BinaryOpType binary_op,
UnaryOpType unary_op, ValueType init_value) {
Impl::static_assert_is_not_openmptarget(ex);
return Impl::transform_inclusive_scan_impl(label, ex, first, last, first_dest,
binary_op, unary_op, init_value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryOpType,
class UnaryOpType, class ValueType>
auto transform_inclusive_scan(
const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
BinaryOpType binary_op, UnaryOpType unary_op, ValueType init_value) {
Impl::static_assert_is_not_openmptarget(ex);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
namespace KE = ::Kokkos::Experimental;
return Impl::transform_inclusive_scan_impl(
"Kokkos::transform_inclusive_scan_custom_functors_view_api", ex,
KE::cbegin(view_from), KE::cend(view_from), KE::begin(view_dest),
binary_op, unary_op, init_value);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryOpType,
class UnaryOpType, class ValueType>
auto transform_inclusive_scan(
const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& view_from,
const ::Kokkos::View<DataType2, Properties2...>& view_dest,
BinaryOpType binary_op, UnaryOpType unary_op, ValueType init_value) {
Impl::static_assert_is_not_openmptarget(ex);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_from);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view_dest);
namespace KE = ::Kokkos::Experimental;
return Impl::transform_inclusive_scan_impl(
label, ex, KE::cbegin(view_from), KE::cend(view_from),
KE::begin(view_dest), binary_op, unary_op, init_value);
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -42,219 +42,14 @@
//@HEADER
*/
#ifndef KOKKOS_STD_NUMERICS_TRANSFORM_REDUCE_HPP
#define KOKKOS_STD_NUMERICS_TRANSFORM_REDUCE_HPP
#ifndef KOKKOS_STD_ALGORITHMS_TRANSFORM_REDUCE_HPP
#define KOKKOS_STD_ALGORITHMS_TRANSFORM_REDUCE_HPP
#include <Kokkos_Core.hpp>
#include "../Kokkos_Constraints.hpp"
#include "../Kokkos_Distance.hpp"
#include "../Kokkos_ModifyingOperations.hpp"
#include "../Kokkos_BeginEnd.hpp"
#include "../Kokkos_ReducerWithArbitraryJoinerNoNeutralElement.hpp"
#include "impl/Kokkos_TransformReduce.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
namespace Impl {
//
// helper functors
//
template <class ValueType>
struct StdTranformReduceDefaultBinaryTransformFunctor {
KOKKOS_FUNCTION
constexpr ValueType operator()(const ValueType& a, const ValueType& b) const {
return (a * b);
}
};
template <class ValueType>
struct StdTranformReduceDefaultJoinFunctor {
KOKKOS_FUNCTION
constexpr ValueType operator()(const ValueType& a, const ValueType& b) const {
return a + b;
}
KOKKOS_FUNCTION
constexpr ValueType operator()(const volatile ValueType& a,
const volatile ValueType& b) const {
return a + b;
}
};
template <class IteratorType, class ReducerType, class TransformType>
struct StdTransformReduceSingleIntervalFunctor {
using red_value_type = typename ReducerType::value_type;
using index_type = typename IteratorType::difference_type;
const IteratorType m_first;
const ReducerType m_reducer;
const TransformType m_transform;
KOKKOS_FUNCTION
void operator()(const index_type i, red_value_type& red_value) const {
auto tmp_wrapped_value = red_value_type{m_transform(m_first[i]), false};
if (red_value.is_initial) {
red_value = tmp_wrapped_value;
} else {
m_reducer.join(red_value, tmp_wrapped_value);
}
}
KOKKOS_FUNCTION
StdTransformReduceSingleIntervalFunctor(IteratorType first,
ReducerType reducer,
TransformType transform)
: m_first(std::move(first)),
m_reducer(std::move(reducer)),
m_transform(std::move(transform)) {}
};
template <class IndexType, class IteratorType1, class IteratorType2,
class ReducerType, class TransformType>
struct StdTransformReduceTwoIntervalsFunctor {
using red_value_type = typename ReducerType::value_type;
const IteratorType1 m_first1;
const IteratorType2 m_first2;
const ReducerType m_reducer;
const TransformType m_transform;
KOKKOS_FUNCTION
void operator()(const IndexType i, red_value_type& red_value) const {
auto tmp_wrapped_value =
red_value_type{m_transform(m_first1[i], m_first2[i]), false};
if (red_value.is_initial) {
red_value = tmp_wrapped_value;
} else {
m_reducer.join(red_value, tmp_wrapped_value);
}
}
KOKKOS_FUNCTION
StdTransformReduceTwoIntervalsFunctor(IteratorType1 first1,
IteratorType2 first2,
ReducerType reducer,
TransformType transform)
: m_first1(std::move(first1)),
m_first2(std::move(first2)),
m_reducer(std::move(reducer)),
m_transform(std::move(transform)) {}
};
//------------------------------
//
// impl functions
//
//------------------------------
template <class ExecutionSpace, class IteratorType, class ValueType,
class JoinerType, class UnaryTransformerType>
ValueType transform_reduce_custom_functors_impl(
const std::string& label, const ExecutionSpace& ex, IteratorType first,
IteratorType last, ValueType init_reduction_value, JoinerType joiner,
UnaryTransformerType transformer) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::static_assert_is_not_openmptarget(ex);
Impl::expect_valid_range(first, last);
if (first == last) {
// init is returned, unmodified
return init_reduction_value;
}
// aliases
using reducer_type =
ReducerWithArbitraryJoinerNoNeutralElement<ValueType, JoinerType>;
using functor_type =
StdTransformReduceSingleIntervalFunctor<IteratorType, reducer_type,
UnaryTransformerType>;
using reduction_value_type = typename reducer_type::value_type;
// run
reduction_value_type result;
reducer_type reducer(result, joiner);
const auto num_elements = Kokkos::Experimental::distance(first, last);
::Kokkos::parallel_reduce(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
functor_type(first, reducer, transformer), reducer);
// fence not needed since reducing into scalar
// as per standard, transform is not applied to the init value
// https://en.cppreference.com/w/cpp/algorithm/transform_reduce
return joiner(result.val, init_reduction_value);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class ValueType, class JoinerType, class BinaryTransformerType>
ValueType transform_reduce_custom_functors_impl(
const std::string& label, const ExecutionSpace& ex, IteratorType1 first1,
IteratorType1 last1, IteratorType2 first2, ValueType init_reduction_value,
JoinerType joiner, BinaryTransformerType transformer) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first1, first2);
Impl::static_assert_is_not_openmptarget(ex);
Impl::static_assert_iterators_have_matching_difference_type(first1, first2);
Impl::expect_valid_range(first1, last1);
if (first1 == last1) {
// init is returned, unmodified
return init_reduction_value;
}
// aliases
using index_type = typename IteratorType1::difference_type;
using reducer_type =
ReducerWithArbitraryJoinerNoNeutralElement<ValueType, JoinerType>;
using functor_type =
StdTransformReduceTwoIntervalsFunctor<index_type, IteratorType1,
IteratorType2, reducer_type,
BinaryTransformerType>;
using reduction_value_type = typename reducer_type::value_type;
// run
reduction_value_type result;
reducer_type reducer(result, joiner);
const auto num_elements = Kokkos::Experimental::distance(first1, last1);
::Kokkos::parallel_reduce(
label, RangePolicy<ExecutionSpace>(ex, 0, num_elements),
functor_type(first1, first2, reducer, transformer), reducer);
// fence not needed since reducing into scalar
return joiner(result.val, init_reduction_value);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class ValueType>
ValueType transform_reduce_default_functors_impl(
const std::string& label, const ExecutionSpace& ex, IteratorType1 first1,
IteratorType1 last1, IteratorType2 first2, ValueType init_reduction_value) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first1, first2);
Impl::static_assert_is_not_openmptarget(ex);
Impl::static_assert_iterators_have_matching_difference_type(first1, first2);
Impl::expect_valid_range(first1, last1);
// aliases
using transformer_type =
Impl::StdTranformReduceDefaultBinaryTransformFunctor<ValueType>;
using joiner_type = Impl::StdTranformReduceDefaultJoinFunctor<ValueType>;
return transform_reduce_custom_functors_impl(
label, ex, first1, last1, first2, std::move(init_reduction_value),
joiner_type(), transformer_type());
}
} // end namespace Impl
///////////////////////////////
//
// transform_reduce public API
//
///////////////////////////////
// ----------------------------
// overload set1:

View File

@ -0,0 +1,124 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_UNIQUE_HPP
#define KOKKOS_STD_ALGORITHMS_UNIQUE_HPP
#include "impl/Kokkos_Unique.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
// note: the enable_if below is to avoid "call to ... is ambiguous"
// for example in the unit test when using a variadic function
// overload set1
template <class ExecutionSpace, class IteratorType>
std::enable_if_t<!::Kokkos::is_view<IteratorType>::value, IteratorType> unique(
const ExecutionSpace& ex, IteratorType first, IteratorType last) {
return Impl::unique_impl("Kokkos::unique_iterator_api_default", ex, first,
last);
}
template <class ExecutionSpace, class IteratorType>
std::enable_if_t<!::Kokkos::is_view<IteratorType>::value, IteratorType> unique(
const std::string& label, const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
return Impl::unique_impl(label, ex, first, last);
}
template <class ExecutionSpace, class DataType, class... Properties>
auto unique(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return ::Kokkos::Experimental::unique("Kokkos::unique_view_api_default", ex,
begin(view), end(view));
}
template <class ExecutionSpace, class DataType, class... Properties>
auto unique(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return ::Kokkos::Experimental::unique(label, ex, begin(view), end(view));
}
// overload set2
template <class ExecutionSpace, class IteratorType, class BinaryPredicate>
IteratorType unique(const ExecutionSpace& ex, IteratorType first,
IteratorType last, BinaryPredicate pred) {
return Impl::unique_impl("Kokkos::unique_iterator_api_default", ex, first,
last, pred);
}
template <class ExecutionSpace, class IteratorType, class BinaryPredicate>
IteratorType unique(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last,
BinaryPredicate pred) {
return Impl::unique_impl(label, ex, first, last, pred);
}
template <class ExecutionSpace, class DataType, class... Properties,
class BinaryPredicate>
auto unique(const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
BinaryPredicate pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::unique_impl("Kokkos::unique_view_api_default", ex, begin(view),
end(view), std::move(pred));
}
template <class ExecutionSpace, class DataType, class... Properties,
class BinaryPredicate>
auto unique(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType, Properties...>& view,
BinaryPredicate pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(view);
return Impl::unique_impl(label, ex, begin(view), end(view), std::move(pred));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,143 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_UNIQUE_COPY_HPP
#define KOKKOS_STD_ALGORITHMS_UNIQUE_COPY_HPP
#include "impl/Kokkos_UniqueCopy.hpp"
#include "Kokkos_BeginEnd.hpp"
namespace Kokkos {
namespace Experimental {
// overload set1
template <class ExecutionSpace, class InputIterator, class OutputIterator>
std::enable_if_t<!::Kokkos::is_view<InputIterator>::value, OutputIterator>
unique_copy(const ExecutionSpace& ex, InputIterator first, InputIterator last,
OutputIterator d_first) {
return Impl::unique_copy_impl("Kokkos::unique_copy_iterator_api_default", ex,
first, last, d_first);
}
template <class ExecutionSpace, class InputIterator, class OutputIterator>
std::enable_if_t<!::Kokkos::is_view<InputIterator>::value, OutputIterator>
unique_copy(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last, OutputIterator d_first) {
return Impl::unique_copy_impl(label, ex, first, last, d_first);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto unique_copy(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
const ::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return ::Kokkos::Experimental::unique_copy(
"Kokkos::unique_copy_view_api_default", ex, cbegin(source), cend(source),
begin(dest));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2>
auto unique_copy(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
const ::Kokkos::View<DataType2, Properties2...>& dest) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return ::Kokkos::Experimental::unique_copy(label, ex, cbegin(source),
cend(source), begin(dest));
}
// overload set2
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class BinaryPredicate>
OutputIterator unique_copy(const ExecutionSpace& ex, InputIterator first,
InputIterator last, OutputIterator d_first,
BinaryPredicate pred) {
return Impl::unique_copy_impl("Kokkos::unique_copy_iterator_api_default", ex,
first, last, d_first, pred);
}
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class BinaryPredicate>
OutputIterator unique_copy(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last,
OutputIterator d_first, BinaryPredicate pred) {
return Impl::unique_copy_impl(label, ex, first, last, d_first, pred);
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryPredicate>
auto unique_copy(const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
const ::Kokkos::View<DataType2, Properties2...>& dest,
BinaryPredicate pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::unique_copy_impl("Kokkos::unique_copy_view_api_default", ex,
cbegin(source), cend(source), begin(dest),
std::move(pred));
}
template <class ExecutionSpace, class DataType1, class... Properties1,
class DataType2, class... Properties2, class BinaryPredicate>
auto unique_copy(const std::string& label, const ExecutionSpace& ex,
const ::Kokkos::View<DataType1, Properties1...>& source,
const ::Kokkos::View<DataType2, Properties2...>& dest,
BinaryPredicate pred) {
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(source);
Impl::static_assert_is_admissible_to_kokkos_std_algorithms(dest);
return Impl::unique_copy_impl(label, ex, cbegin(source), cend(source),
begin(dest), std::move(pred));
}
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,135 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_ADJACENT_DIFFERENCE_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_ADJACENT_DIFFERENCE_IMPL_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class ValueType1, class ValueType2, class RetType = ValueType2>
struct StdAdjacentDifferenceDefaultBinaryOpFunctor {
KOKKOS_FUNCTION
constexpr RetType operator()(const ValueType1& a, const ValueType2& b) const {
return a - b;
}
};
template <class InputIteratorType, class OutputIteratorType,
class BinaryOperator>
struct StdAdjacentDiffFunctor {
using index_type = typename InputIteratorType::difference_type;
const InputIteratorType m_first_from;
const OutputIteratorType m_first_dest;
BinaryOperator m_op;
KOKKOS_FUNCTION
void operator()(const index_type i) const {
const auto& my_value = m_first_from[i];
if (i == 0) {
m_first_dest[i] = my_value;
} else {
const auto& left_value = m_first_from[i - 1];
m_first_dest[i] = m_op(my_value, left_value);
}
}
KOKKOS_FUNCTION
StdAdjacentDiffFunctor(InputIteratorType first_from,
OutputIteratorType first_dest, BinaryOperator op)
: m_first_from(std::move(first_from)),
m_first_dest(std::move(first_dest)),
m_op(std::move(op)) {}
};
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class BinaryOp>
OutputIteratorType adjacent_difference_impl(const std::string& label,
const ExecutionSpace& ex,
InputIteratorType first_from,
InputIteratorType last_from,
OutputIteratorType first_dest,
BinaryOp bin_op) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first_from, first_dest);
Impl::static_assert_iterators_have_matching_difference_type(first_from,
first_dest);
Impl::expect_valid_range(first_from, last_from);
if (first_from == last_from) {
return first_dest;
}
// aliases
using value_type = typename OutputIteratorType::value_type;
using aux_view_type = ::Kokkos::View<value_type*, ExecutionSpace>;
using functor_t =
StdAdjacentDiffFunctor<InputIteratorType, OutputIteratorType, BinaryOp>;
// run
const auto num_elements =
Kokkos::Experimental::distance(first_from, last_from);
aux_view_type aux_view("aux_view", num_elements);
::Kokkos::parallel_for(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
functor_t(first_from, first_dest, bin_op));
ex.fence("Kokkos::adjacent_difference: fence after operation");
// return
return first_dest + num_elements;
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,140 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_ADJACENT_FIND_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_ADJACENT_FIND_IMPL_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class IndexType, class IteratorType, class ReducerType,
class PredicateType>
struct StdAdjacentFindFunctor {
using red_value_type = typename ReducerType::value_type;
IteratorType m_first;
ReducerType m_reducer;
PredicateType m_p;
KOKKOS_FUNCTION
void operator()(const IndexType i, red_value_type& red_value) const {
const auto& my_value = m_first[i];
const auto& next_value = m_first[i + 1];
const bool are_equal = m_p(my_value, next_value);
auto rv =
are_equal
? red_value_type{i}
: red_value_type{::Kokkos::reduction_identity<IndexType>::min()};
m_reducer.join(red_value, rv);
}
KOKKOS_FUNCTION
StdAdjacentFindFunctor(IteratorType first, ReducerType reducer,
PredicateType p)
: m_first(std::move(first)),
m_reducer(std::move(reducer)),
m_p(std::move(p)) {}
};
template <class ExecutionSpace, class IteratorType, class PredicateType>
IteratorType adjacent_find_impl(const std::string& label,
const ExecutionSpace& ex, IteratorType first,
IteratorType last, PredicateType pred) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::expect_valid_range(first, last);
const auto num_elements = Kokkos::Experimental::distance(first, last);
if (num_elements <= 1) {
return last;
}
using index_type = typename IteratorType::difference_type;
using reducer_type = FirstLoc<index_type>;
using reduction_value_type = typename reducer_type::value_type;
using func_t = StdAdjacentFindFunctor<index_type, IteratorType, reducer_type,
PredicateType>;
reduction_value_type red_result;
reducer_type reducer(red_result);
// note that we use below num_elements-1 because
// each index i in the reduction checks i and (i+1).
::Kokkos::parallel_reduce(
label, RangePolicy<ExecutionSpace>(ex, 0, num_elements - 1),
func_t(first, reducer, pred), reducer);
// fence not needed because reducing into scalar
if (red_result.min_loc_true ==
::Kokkos::reduction_identity<index_type>::min()) {
return last;
} else {
return first + red_result.min_loc_true;
}
}
template <class ExecutionSpace, class IteratorType>
IteratorType adjacent_find_impl(const std::string& label,
const ExecutionSpace& ex, IteratorType first,
IteratorType last) {
using value_type = typename IteratorType::value_type;
using default_pred_t = StdAlgoEqualBinaryPredicate<value_type>;
return adjacent_find_impl(label, ex, first, last, default_pred_t());
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,77 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_ALL_OF_ANY_OF_NONE_OF_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_ALL_OF_ANY_OF_NONE_OF_IMPL_HPP
#include "Kokkos_FindIfOrNot.hpp"
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class ExecutionSpace, class InputIterator, class Predicate>
bool all_of_impl(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last, Predicate predicate) {
return (find_if_or_not_impl<false>(label, ex, first, last, predicate) ==
last);
}
template <class ExecutionSpace, class InputIterator, class Predicate>
bool any_of_impl(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last, Predicate predicate) {
return (find_if_or_not_impl<true>(label, ex, first, last, predicate) != last);
}
template <class ExecutionSpace, class IteratorType, class Predicate>
bool none_of_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, Predicate predicate) {
return (find_if_or_not_impl<true>(label, ex, first, last, predicate) == last);
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,103 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_COPY_BACKWARD_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_COPY_BACKWARD_IMPL_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class IndexType, class IteratorType1, class IteratorType2>
struct StdCopyBackwardFunctor {
static_assert(std::is_signed<IndexType>::value,
"Kokkos: StdCopyBackwardFunctor requires signed index type");
IteratorType1 m_last;
IteratorType2 m_dest_last;
KOKKOS_FUNCTION
void operator()(IndexType i) const { m_dest_last[-i - 1] = m_last[-i - 1]; }
KOKKOS_FUNCTION
StdCopyBackwardFunctor(IteratorType1 _last, IteratorType2 _dest_last)
: m_last(std::move(_last)), m_dest_last(std::move(_dest_last)) {}
};
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType2 copy_backward_impl(const std::string& label,
const ExecutionSpace& ex, IteratorType1 first,
IteratorType1 last, IteratorType2 d_last) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first, d_last);
Impl::static_assert_iterators_have_matching_difference_type(first, d_last);
Impl::expect_valid_range(first, last);
// aliases
using index_type = typename IteratorType1::difference_type;
using func_t =
StdCopyBackwardFunctor<index_type, IteratorType1, IteratorType2>;
// run
const auto num_elements = Kokkos::Experimental::distance(first, last);
::Kokkos::parallel_for(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_t(last, d_last));
ex.fence("Kokkos::copy_backward: fence after operation");
// return
return d_last - num_elements;
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,116 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_COPY_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_COPY_IMPL_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class IndexType, class InputIterator, class OutputIterator>
struct StdCopyFunctor {
InputIterator m_first;
OutputIterator m_dest_first;
KOKKOS_FUNCTION
void operator()(IndexType i) const { m_dest_first[i] = m_first[i]; }
KOKKOS_FUNCTION
StdCopyFunctor(InputIterator _first, OutputIterator _dest_first)
: m_first(std::move(_first)), m_dest_first(std::move(_dest_first)) {}
};
template <class ExecutionSpace, class InputIterator, class OutputIterator>
OutputIterator copy_impl(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last,
OutputIterator d_first) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first, d_first);
Impl::static_assert_iterators_have_matching_difference_type(first, d_first);
Impl::expect_valid_range(first, last);
// aliases
using index_type = typename InputIterator::difference_type;
using func_t = StdCopyFunctor<index_type, InputIterator, OutputIterator>;
// run
const auto num_elements = Kokkos::Experimental::distance(first, last);
::Kokkos::parallel_for(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_t(first, d_first));
ex.fence("Kokkos::copy: fence after operation");
// return
return d_first + num_elements;
}
template <class ExecutionSpace, class InputIterator, class Size,
class OutputIterator>
OutputIterator copy_n_impl(const std::string& label, const ExecutionSpace& ex,
InputIterator first_from, Size count,
OutputIterator first_dest) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first_from, first_dest);
Impl::static_assert_iterators_have_matching_difference_type(first_from,
first_dest);
if (count > 0) {
return copy_impl(label, ex, first_from, first_from + count, first_dest);
} else {
return first_dest;
}
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,142 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_COPY_IF_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_COPY_IF_IMPL_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class IndexType, class FirstFrom, class FirstDest, class PredType>
struct StdCopyIfFunctor {
FirstFrom m_first_from;
FirstDest m_first_dest;
PredType m_pred;
KOKKOS_FUNCTION
StdCopyIfFunctor(FirstFrom first_from, FirstDest first_dest, PredType pred)
: m_first_from(std::move(first_from)),
m_first_dest(std::move(first_dest)),
m_pred(std::move(pred)) {}
KOKKOS_FUNCTION
void operator()(const IndexType i, IndexType& update,
const bool final_pass) const {
const auto& myval = m_first_from[i];
if (final_pass) {
if (m_pred(myval)) {
m_first_dest[update] = myval;
}
}
if (m_pred(myval)) {
update += 1;
}
}
};
template <class ExecutionSpace, class InputIterator, class OutputIterator,
class PredicateType>
OutputIterator copy_if_impl(const std::string& label, const ExecutionSpace& ex,
InputIterator first, InputIterator last,
OutputIterator d_first, PredicateType pred) {
/*
To explain the impl, suppose that our data is:
| 1 | 1 | 2 | 2 | 3 | -2 | 4 | 4 | 4 | 5 | 7 | -10 |
and we want to copy only the even entries,
We can use an exclusive scan where the "update"
is incremented only for the elements that satisfy the predicate.
This way, the update allows us to track where in the destination
we need to copy the elements:
In this case, counting only the even entries, the exlusive scan
during the final pass would yield:
| 0 | 0 | 0 | 1 | 2 | 2 | 3 | 4 | 5 | 6 | 6 | 6 |
* * * * * * *
which provides the indexing in the destination where
each starred (*) element needs to be copied to since
the starred elements are those that satisfy the predicate.
*/
// checks
Impl::static_assert_random_access_and_accessible(ex, first, d_first);
Impl::static_assert_iterators_have_matching_difference_type(first, d_first);
Impl::expect_valid_range(first, last);
if (first == last) {
return d_first;
} else {
// aliases
using index_type = typename InputIterator::difference_type;
using func_type = StdCopyIfFunctor<index_type, InputIterator,
OutputIterator, PredicateType>;
// run
const auto num_elements = Kokkos::Experimental::distance(first, last);
index_type count = 0;
::Kokkos::parallel_scan(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_type(first, d_first, pred), count);
// fence not needed because of the scan accumulating into count
return d_first + count;
}
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,112 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_COUNT_IF_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_COUNT_IF_IMPL_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class IteratorType, class Predicate>
struct StdCountIfFunctor {
using index_type = typename IteratorType::difference_type;
IteratorType m_first;
Predicate m_predicate;
KOKKOS_FUNCTION
void operator()(index_type i, index_type& lsum) const {
if (m_predicate(m_first[i])) {
lsum++;
}
}
KOKKOS_FUNCTION
StdCountIfFunctor(IteratorType _first, Predicate _predicate)
: m_first(std::move(_first)), m_predicate(std::move(_predicate)) {}
};
template <class ExecutionSpace, class IteratorType, class Predicate>
typename IteratorType::difference_type count_if_impl(const std::string& label,
const ExecutionSpace& ex,
IteratorType first,
IteratorType last,
Predicate predicate) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::expect_valid_range(first, last);
// aliases
using func_t = StdCountIfFunctor<IteratorType, Predicate>;
// run
const auto num_elements = Kokkos::Experimental::distance(first, last);
typename IteratorType::difference_type count = 0;
::Kokkos::parallel_reduce(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_t(first, predicate), count);
ex.fence("Kokkos::count_if: fence after operation");
return count;
}
template <class ExecutionSpace, class IteratorType, class T>
auto count_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, const T& value) {
return count_if_impl(
label, ex, first, last,
::Kokkos::Experimental::Impl::StdAlgoEqualsValUnaryPredicate<T>(value));
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,147 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_EQUAL_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_EQUAL_IMPL_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class IndexType, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
struct StdEqualFunctor {
IteratorType1 m_first1;
IteratorType2 m_first2;
BinaryPredicateType m_predicate;
KOKKOS_FUNCTION
void operator()(IndexType i, std::size_t& lsum) const {
if (!m_predicate(m_first1[i], m_first2[i])) {
lsum = 1;
}
}
KOKKOS_FUNCTION
StdEqualFunctor(IteratorType1 _first1, IteratorType2 _first2,
BinaryPredicateType _predicate)
: m_first1(std::move(_first1)),
m_first2(std::move(_first2)),
m_predicate(std::move(_predicate)) {}
};
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
bool equal_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first1, IteratorType1 last1, IteratorType2 first2,
BinaryPredicateType predicate) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first1, first2);
Impl::static_assert_iterators_have_matching_difference_type(first1, first2);
Impl::expect_valid_range(first1, last1);
// aliases
using index_type = typename IteratorType1::difference_type;
using func_t = StdEqualFunctor<index_type, IteratorType1, IteratorType2,
BinaryPredicateType>;
// run
const auto num_elements = Kokkos::Experimental::distance(first1, last1);
std::size_t different = 0;
::Kokkos::parallel_reduce(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_t(first1, first2, predicate), different);
ex.fence("Kokkos::equal: fence after operation");
return !different;
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
bool equal_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first1, IteratorType1 last1,
IteratorType2 first2) {
using value_type1 = typename IteratorType1::value_type;
using value_type2 = typename IteratorType2::value_type;
using pred_t = StdAlgoEqualBinaryPredicate<value_type1, value_type2>;
return equal_impl(label, ex, first1, last1, first2, pred_t());
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
bool equal_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first1, IteratorType1 last1, IteratorType2 first2,
IteratorType2 last2, BinaryPredicateType predicate) {
const auto d1 = ::Kokkos::Experimental::distance(first1, last1);
const auto d2 = ::Kokkos::Experimental::distance(first2, last2);
if (d1 != d2) {
return false;
}
return equal_impl(label, ex, first1, last1, first2, predicate);
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
bool equal_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first1, IteratorType1 last1, IteratorType2 first2,
IteratorType2 last2) {
Impl::expect_valid_range(first1, last1);
Impl::expect_valid_range(first2, last2);
using value_type1 = typename IteratorType1::value_type;
using value_type2 = typename IteratorType2::value_type;
using pred_t = StdAlgoEqualBinaryPredicate<value_type1, value_type2>;
return equal_impl(label, ex, first1, last1, first2, last2, pred_t());
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,232 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_EXCLUSIVE_SCAN_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_EXCLUSIVE_SCAN_IMPL_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include "Kokkos_ValueWrapperForNoNeutralElement.hpp"
#include "Kokkos_IdentityReferenceUnaryFunctor.hpp"
#include <std_algorithms/Kokkos_TransformExclusiveScan.hpp>
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class ExeSpace, class IndexType, class ValueType, class FirstFrom,
class FirstDest>
struct ExclusiveScanDefaultFunctorForKnownNeutralElement {
using execution_space = ExeSpace;
ValueType m_init_value;
FirstFrom m_first_from;
FirstDest m_first_dest;
KOKKOS_FUNCTION
ExclusiveScanDefaultFunctorForKnownNeutralElement(ValueType init,
FirstFrom first_from,
FirstDest first_dest)
: m_init_value(std::move(init)),
m_first_from(std::move(first_from)),
m_first_dest(std::move(first_dest)) {}
KOKKOS_FUNCTION
void operator()(const IndexType i, ValueType& update,
const bool final_pass) const {
if (final_pass) m_first_dest[i] = update + m_init_value;
update += m_first_from[i];
}
};
template <class ExeSpace, class IndexType, class ValueType, class FirstFrom,
class FirstDest>
struct ExclusiveScanDefaultFunctor {
using execution_space = ExeSpace;
using value_type =
::Kokkos::Experimental::Impl::ValueWrapperForNoNeutralElement<ValueType>;
ValueType m_init_value;
FirstFrom m_first_from;
FirstDest m_first_dest;
KOKKOS_FUNCTION
ExclusiveScanDefaultFunctor(ValueType init, FirstFrom first_from,
FirstDest first_dest)
: m_init_value(std::move(init)),
m_first_from(std::move(first_from)),
m_first_dest(std::move(first_dest)) {}
KOKKOS_FUNCTION
void operator()(const IndexType i, value_type& update,
const bool final_pass) const {
if (final_pass) {
if (i == 0) {
m_first_dest[i] = m_init_value;
} else {
m_first_dest[i] = update.val + m_init_value;
}
}
const auto tmp = value_type{m_first_from[i], false};
this->join(update, tmp);
}
KOKKOS_FUNCTION
void init(value_type& update) const {
update.val = {};
update.is_initial = true;
}
KOKKOS_FUNCTION
void join(value_type& update, const value_type& input) const {
if (update.is_initial) {
update.val = input.val;
update.is_initial = false;
} else {
update.val = update.val + input.val;
}
}
};
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class ValueType, class BinaryOpType>
OutputIteratorType exclusive_scan_custom_op_impl(
const std::string& label, const ExecutionSpace& ex,
InputIteratorType first_from, InputIteratorType last_from,
OutputIteratorType first_dest, ValueType init_value, BinaryOpType bop) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first_from, first_dest);
Impl::static_assert_iterators_have_matching_difference_type(first_from,
first_dest);
Impl::expect_valid_range(first_from, last_from);
// aliases
using index_type = typename InputIteratorType::difference_type;
using unary_op_type = StdNumericScanIdentityReferenceUnaryFunctor<ValueType>;
using func_type =
TransformExclusiveScanFunctor<ExecutionSpace, index_type, ValueType,
InputIteratorType, OutputIteratorType,
BinaryOpType, unary_op_type>;
// run
const auto num_elements =
Kokkos::Experimental::distance(first_from, last_from);
::Kokkos::parallel_scan(
label, RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_type(init_value, first_from, first_dest, bop, unary_op_type()));
ex.fence("Kokkos::exclusive_scan_custom_op: fence after operation");
// return
return first_dest + num_elements;
}
template <typename ValueType>
using ex_scan_has_reduction_identity_sum_t =
decltype(Kokkos::reduction_identity<ValueType>::sum());
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class ValueType>
OutputIteratorType exclusive_scan_default_op_impl(const std::string& label,
const ExecutionSpace& ex,
InputIteratorType first_from,
InputIteratorType last_from,
OutputIteratorType first_dest,
ValueType init_value) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first_from, first_dest);
Impl::static_assert_iterators_have_matching_difference_type(first_from,
first_dest);
Impl::expect_valid_range(first_from, last_from);
// does it make sense to do this static_assert too?
// using input_iterator_value_type = typename InputIteratorType::value_type;
// static_assert
// (std::is_convertible<std::remove_cv_t<input_iterator_value_type>,
// ValueType>::value,
// "exclusive_scan: InputIteratorType::value_type not convertible to
// ValueType");
// we are unnecessarily duplicating code, but this is on purpose
// so that we can use the default_op for OpenMPTarget.
// Originally, I had this implemented as:
// '''
// using bop_type = StdExclusiveScanDefaultJoinFunctor<ValueType>;
// call exclusive_scan_custom_op_impl(..., bop_type());
// '''
// which avoids duplicating the functors, but for OpenMPTarget
// I cannot use a custom binary op.
// This is the same problem that occurs for reductions.
// aliases
using index_type = typename InputIteratorType::difference_type;
using func_type = std::conditional_t<
::Kokkos::is_detected<ex_scan_has_reduction_identity_sum_t,
ValueType>::value,
ExclusiveScanDefaultFunctorForKnownNeutralElement<
ExecutionSpace, index_type, ValueType, InputIteratorType,
OutputIteratorType>,
ExclusiveScanDefaultFunctor<ExecutionSpace, index_type, ValueType,
InputIteratorType, OutputIteratorType>>;
// run
const auto num_elements =
Kokkos::Experimental::distance(first_from, last_from);
::Kokkos::parallel_scan(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_type(init_value, first_from, first_dest));
ex.fence("Kokkos::exclusive_scan_default_op: fence after operation");
return first_dest + num_elements;
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -42,83 +42,65 @@
//@HEADER
*/
#include <Kokkos_Macros.hpp>
#if defined(KOKKOS_ENABLE_THREADS)
#ifndef KOKKOS_STD_ALGORITHMS_FILL_AND_FILL_N_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_FILL_AND_FILL_N_IMPL_HPP
#include <Kokkos_Core_fwd.hpp>
/* Standard C++ libraries */
#include <cstdlib>
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
#include <iostream>
#include <stdexcept>
#include <thread>
#include <mutex>
#include <Kokkos_Threads.hpp>
//----------------------------------------------------------------------------
namespace Kokkos {
namespace Experimental {
namespace Impl {
namespace {
std::mutex host_internal_cppthread_mutex;
template <class InputIterator, class T>
struct StdFillFunctor {
using index_type = typename InputIterator::difference_type;
InputIterator m_first;
T m_value;
// std::thread compatible driver.
// Recovery from an exception would require constant intra-thread health
// verification; which would negatively impact runtime. As such simply
// abort the process.
KOKKOS_FUNCTION
void operator()(index_type i) const { m_first[i] = m_value; }
void internal_cppthread_driver() {
try {
ThreadsExec::driver();
} catch (const std::exception& x) {
std::cerr << "Exception thrown from worker thread: " << x.what()
<< std::endl;
std::cerr.flush();
std::abort();
} catch (...) {
std::cerr << "Exception thrown from worker thread" << std::endl;
std::cerr.flush();
std::abort();
KOKKOS_FUNCTION
StdFillFunctor(InputIterator _first, T _value)
: m_first(std::move(_first)), m_value(std::move(_value)) {}
};
template <class ExecutionSpace, class IteratorType, class T>
void fill_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, const T& value) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::expect_valid_range(first, last);
// run
const auto num_elements = Kokkos::Experimental::distance(first, last);
::Kokkos::parallel_for(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
StdFillFunctor<IteratorType, T>(first, value));
ex.fence("Kokkos::fill: fence after operation");
}
template <class ExecutionSpace, class IteratorType, class SizeType, class T>
IteratorType fill_n_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType first, SizeType n, const T& value) {
auto last = first + n;
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::expect_valid_range(first, last);
if (n <= 0) {
return first;
}
}
} // namespace
//----------------------------------------------------------------------------
// Spawn a thread
void ThreadsExec::spawn() {
std::thread t(internal_cppthread_driver);
t.detach();
}
//----------------------------------------------------------------------------
bool ThreadsExec::is_process() {
static const std::thread::id master_pid = std::this_thread::get_id();
return master_pid == std::this_thread::get_id();
}
void ThreadsExec::global_lock() { host_internal_cppthread_mutex.lock(); }
void ThreadsExec::global_unlock() { host_internal_cppthread_mutex.unlock(); }
//----------------------------------------------------------------------------
void ThreadsExec::wait_yield(volatile int& flag, const int value) {
while (value == flag) {
std::this_thread::yield();
}
fill_impl(label, ex, first, last, value);
return last;
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#else
void KOKKOS_CORE_SRC_THREADS_EXEC_BASE_PREVENT_LINK_ERROR() {}
#endif /* end #if defined( KOKKOS_ENABLE_THREADS ) */
#endif

View File

@ -0,0 +1,191 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_FIND_END_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_FIND_END_IMPL_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class IndexType, class IteratorType1, class IteratorType2,
class ReducerType, class PredicateType>
struct StdFindEndFunctor {
using red_value_type = typename ReducerType::value_type;
IteratorType1 m_first;
IteratorType1 m_last;
IteratorType2 m_s_first;
IteratorType2 m_s_last;
ReducerType m_reducer;
PredicateType m_p;
KOKKOS_FUNCTION
void operator()(const IndexType i, red_value_type& red_value) const {
namespace KE = ::Kokkos::Experimental;
auto myit = m_first + i;
bool found = true;
const auto search_count = KE::distance(m_s_first, m_s_last);
for (IndexType k = 0; k < search_count; ++k) {
// note that we add this EXPECT to check if we are in a valid range
// but I think we can remvoe this beceause the guarantee we don't go
// out of bounds is taken care of at the calling site
// where we launch the par-reduce.
KOKKOS_EXPECTS((myit + k) < m_last);
if (!m_p(myit[k], m_s_first[k])) {
found = false;
break;
}
}
const auto rv =
found ? red_value_type{i}
: red_value_type{::Kokkos::reduction_identity<IndexType>::max()};
m_reducer.join(red_value, rv);
}
KOKKOS_FUNCTION
StdFindEndFunctor(IteratorType1 first, IteratorType1 last,
IteratorType2 s_first, IteratorType2 s_last,
ReducerType reducer, PredicateType p)
: m_first(std::move(first)),
m_last(std::move(last)),
m_s_first(std::move(s_first)),
m_s_last(std::move(s_last)),
m_reducer(std::move(reducer)),
m_p(std::move(p)) {}
};
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
IteratorType1 find_end_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first, IteratorType1 last,
IteratorType2 s_first, IteratorType2 s_last,
const BinaryPredicateType& pred) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first, s_first);
Impl::static_assert_iterators_have_matching_difference_type(first, s_first);
Impl::expect_valid_range(first, last);
Impl::expect_valid_range(s_first, s_last);
// the target sequence should not be larger than the range [first, last)
namespace KE = ::Kokkos::Experimental;
const auto num_elements = KE::distance(first, last);
const auto s_count = KE::distance(s_first, s_last);
KOKKOS_EXPECTS(num_elements >= s_count);
(void)s_count; // needed when macro above is a no-op
if (s_first == s_last) {
return last;
}
if (first == last) {
return last;
}
// special case where the two ranges have equal size
if (num_elements == s_count) {
const auto equal_result = equal_impl(label, ex, first, last, s_first, pred);
return (equal_result) ? first : last;
} else {
using index_type = typename IteratorType1::difference_type;
using reducer_type = LastLoc<index_type>;
using reduction_value_type = typename reducer_type::value_type;
using func_t = StdFindEndFunctor<index_type, IteratorType1, IteratorType2,
reducer_type, BinaryPredicateType>;
// run
reduction_value_type red_result;
reducer_type reducer(red_result);
// decide the size of the range policy of the par_red:
// note that the last feasible index to start looking is the index
// whose distance from the "last" is equal to the sequence count.
// the +1 is because we need to include that location too.
const auto range_size = num_elements - s_count + 1;
// run par reduce
::Kokkos::parallel_reduce(
label, RangePolicy<ExecutionSpace>(ex, 0, range_size),
func_t(first, last, s_first, s_last, reducer, pred), reducer);
// fence not needed because reducing into scalar
// decide and return
if (red_result.max_loc_true ==
::Kokkos::reduction_identity<index_type>::max()) {
// if here, a subrange has not been found
return last;
} else {
// a location has been found
return first + red_result.max_loc_true;
}
}
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType1 find_end_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType1 first, IteratorType1 last,
IteratorType2 s_first, IteratorType2 s_last) {
using value_type1 = typename IteratorType1::value_type;
using value_type2 = typename IteratorType2::value_type;
using predicate_type = StdAlgoEqualBinaryPredicate<value_type1, value_type2>;
return find_end_impl(label, ex, first, last, s_first, s_last,
predicate_type());
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,161 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_FIND_FIRST_OF_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_FIND_FIRST_OF_IMPL_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class IndexType, class IteratorType1, class IteratorType2,
class ReducerType, class PredicateType>
struct StdFindFirstOfFunctor {
using red_value_type = typename ReducerType::value_type;
IteratorType1 m_first;
IteratorType2 m_s_first;
IteratorType2 m_s_last;
ReducerType m_reducer;
PredicateType m_p;
KOKKOS_FUNCTION
void operator()(const IndexType i, red_value_type& red_value) const {
namespace KE = ::Kokkos::Experimental;
const auto& myvalue = m_first[i];
bool found = false;
const auto search_count = KE::distance(m_s_first, m_s_last);
for (IndexType k = 0; k < search_count; ++k) {
if (m_p(myvalue, m_s_first[k])) {
found = true;
break;
}
}
const auto rv =
found ? red_value_type{i}
: red_value_type{::Kokkos::reduction_identity<IndexType>::min()};
m_reducer.join(red_value, rv);
}
KOKKOS_FUNCTION
StdFindFirstOfFunctor(IteratorType1 first, IteratorType2 s_first,
IteratorType2 s_last, ReducerType reducer,
PredicateType p)
: m_first(std::move(first)),
m_s_first(std::move(s_first)),
m_s_last(std::move(s_last)),
m_reducer(std::move(reducer)),
m_p(std::move(p)) {}
};
template <class ExecutionSpace, class IteratorType1, class IteratorType2,
class BinaryPredicateType>
IteratorType1 find_first_of_impl(const std::string& label,
const ExecutionSpace& ex, IteratorType1 first,
IteratorType1 last, IteratorType2 s_first,
IteratorType2 s_last,
const BinaryPredicateType& pred) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first, s_first);
Impl::static_assert_iterators_have_matching_difference_type(first, s_first);
Impl::expect_valid_range(first, last);
Impl::expect_valid_range(s_first, s_last);
if ((s_first == s_last) || (first == last)) {
return last;
}
using index_type = typename IteratorType1::difference_type;
using reducer_type = FirstLoc<index_type>;
using reduction_value_type = typename reducer_type::value_type;
using func_t = StdFindFirstOfFunctor<index_type, IteratorType1, IteratorType2,
reducer_type, BinaryPredicateType>;
// run
reduction_value_type red_result;
reducer_type reducer(red_result);
const auto num_elements = Kokkos::Experimental::distance(first, last);
::Kokkos::parallel_reduce(
label, RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_t(first, s_first, s_last, reducer, pred), reducer);
// fence not needed because reducing into scalar
// decide and return
if (red_result.min_loc_true ==
::Kokkos::reduction_identity<index_type>::min()) {
// if here, nothing found
return last;
} else {
// a location has been found
return first + red_result.min_loc_true;
}
}
template <class ExecutionSpace, class IteratorType1, class IteratorType2>
IteratorType1 find_first_of_impl(const std::string& label,
const ExecutionSpace& ex, IteratorType1 first,
IteratorType1 last, IteratorType2 s_first,
IteratorType2 s_last) {
using value_type1 = typename IteratorType1::value_type;
using value_type2 = typename IteratorType2::value_type;
using predicate_type = StdAlgoEqualBinaryPredicate<value_type1, value_type2>;
return find_first_of_impl(label, ex, first, last, s_first, s_last,
predicate_type());
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,146 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_FIND_IF_AND_FIND_IF_NOT_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_FIND_IF_AND_FIND_IF_NOT_IMPL_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <bool is_find_if, class IndexType, class IteratorType,
class ReducerType, class PredicateType>
struct StdFindIfOrNotFunctor {
using red_value_type = typename ReducerType::value_type;
IteratorType m_first;
ReducerType m_reducer;
PredicateType m_p;
KOKKOS_FUNCTION
void operator()(const IndexType i, red_value_type& red_value) const {
const auto& my_value = m_first[i];
// if doing find_if, look for when predicate is true
// if doing find_if_not, look for when predicate is false
const bool found_condition = is_find_if ? m_p(my_value) : !m_p(my_value);
auto rv =
found_condition
? red_value_type{i}
: red_value_type{::Kokkos::reduction_identity<IndexType>::min()};
m_reducer.join(red_value, rv);
}
KOKKOS_FUNCTION
StdFindIfOrNotFunctor(IteratorType first, ReducerType reducer,
PredicateType p)
: m_first(std::move(first)),
m_reducer(std::move(reducer)),
m_p(std::move(p)) {}
};
template <bool is_find_if, class ExecutionSpace, class IteratorType,
class PredicateType>
IteratorType find_if_or_not_impl(const std::string& label,
const ExecutionSpace& ex, IteratorType first,
IteratorType last, PredicateType pred) {
// checks
Impl::static_assert_random_access_and_accessible(
ex, first); // only need one It per type
Impl::expect_valid_range(first, last);
if (first == last) {
return last;
}
// aliases
using index_type = typename IteratorType::difference_type;
using reducer_type = FirstLoc<index_type>;
using reduction_value_type = typename reducer_type::value_type;
using func_t = StdFindIfOrNotFunctor<is_find_if, index_type, IteratorType,
reducer_type, PredicateType>;
// run
reduction_value_type red_result;
reducer_type reducer(red_result);
const auto num_elements = Kokkos::Experimental::distance(first, last);
::Kokkos::parallel_reduce(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_t(first, reducer, pred), reducer);
// fence not needed because reducing into scalar
// decide and return
if (red_result.min_loc_true ==
::Kokkos::reduction_identity<index_type>::min()) {
// here, it means a valid loc has not been found,
return last;
} else {
// a location has been found
return first + red_result.min_loc_true;
}
}
template <class ExecutionSpace, class InputIterator, class T>
InputIterator find_impl(const std::string& label, ExecutionSpace ex,
InputIterator first, InputIterator last,
const T& value) {
return find_if_or_not_impl<true>(
label, ex, first, last,
::Kokkos::Experimental::Impl::StdAlgoEqualsValUnaryPredicate<T>(value));
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,113 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_FOR_EACH_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_FOR_EACH_IMPL_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class IteratorType, class UnaryFunctorType>
struct StdForEachFunctor {
using index_type = typename IteratorType::difference_type;
IteratorType m_first;
UnaryFunctorType m_functor;
KOKKOS_FUNCTION
void operator()(index_type i) const { m_functor(m_first[i]); }
KOKKOS_FUNCTION
StdForEachFunctor(IteratorType _first, UnaryFunctorType _functor)
: m_first(std::move(_first)), m_functor(std::move(_functor)) {}
};
template <class ExecutionSpace, class IteratorType, class UnaryFunctorType>
UnaryFunctorType for_each_impl(const std::string& label,
const ExecutionSpace& ex, IteratorType first,
IteratorType last, UnaryFunctorType functor) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::expect_valid_range(first, last);
// run
const auto num_elements = Kokkos::Experimental::distance(first, last);
::Kokkos::parallel_for(
label, RangePolicy<ExecutionSpace>(ex, 0, num_elements),
StdForEachFunctor<IteratorType, UnaryFunctorType>(first, functor));
ex.fence("Kokkos::for_each: fence after operation");
return functor;
}
template <class ExecutionSpace, class IteratorType, class SizeType,
class UnaryFunctorType>
IteratorType for_each_n_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType first, SizeType n,
UnaryFunctorType functor) {
auto last = first + n;
Impl::static_assert_random_access_and_accessible(ex, first, last);
Impl::expect_valid_range(first, last);
if (n == 0) {
return first;
}
for_each_impl(label, ex, first, last, std::move(functor));
// no neeed to fence since for_each_impl fences already
return last;
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -0,0 +1,105 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_GENERATE_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_GENERATE_IMPL_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <class IteratorType, class Generator>
struct StdGenerateFunctor {
using index_type = typename IteratorType::difference_type;
IteratorType m_first;
Generator m_generator;
KOKKOS_FUNCTION
void operator()(index_type i) const { m_first[i] = m_generator(); }
KOKKOS_FUNCTION
StdGenerateFunctor(IteratorType _first, Generator _g)
: m_first(std::move(_first)), m_generator(std::move(_g)) {}
};
template <class ExecutionSpace, class IteratorType, class Generator>
void generate_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType first, IteratorType last, Generator g) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first);
Impl::expect_valid_range(first, last);
// aliases
using func_t = StdGenerateFunctor<IteratorType, Generator>;
// run
const auto num_elements = Kokkos::Experimental::distance(first, last);
::Kokkos::parallel_for(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_t(first, g));
ex.fence("Kokkos::generate: fence after operation");
}
template <class ExecutionSpace, class IteratorType, class Size, class Generator>
IteratorType generate_n_impl(const std::string& label, const ExecutionSpace& ex,
IteratorType first, Size count, Generator g) {
if (count <= 0) {
return first;
}
generate_impl(label, ex, first, first + count, g);
return first + count;
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

View File

@ -42,8 +42,8 @@
//@HEADER
*/
#ifndef KOKKOS_STD_HELPER_PREDICATES_HPP
#define KOKKOS_STD_HELPER_PREDICATES_HPP
#ifndef KOKKOS_STD_ALGORITHMS_HELPER_PREDICATES_HPP
#define KOKKOS_STD_ALGORITHMS_HELPER_PREDICATES_HPP
#include <Kokkos_Macros.hpp>

View File

@ -42,8 +42,8 @@
//@HEADER
*/
#ifndef KOKKOS_STD_NUMERIC_IDENTITY_REFERENCE_UNARY_FUNCTOR_HPP
#define KOKKOS_STD_NUMERIC_IDENTITY_REFERENCE_UNARY_FUNCTOR_HPP
#ifndef KOKKOS_STD_ALGORITHMS_NUMERIC_IDENTITY_REFERENCE_UNARY_FUNCTOR_HPP
#define KOKKOS_STD_ALGORITHMS_NUMERIC_IDENTITY_REFERENCE_UNARY_FUNCTOR_HPP
#include <Kokkos_Macros.hpp>

View File

@ -0,0 +1,243 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_STD_ALGORITHMS_INCLUSIVE_SCAN_IMPL_HPP
#define KOKKOS_STD_ALGORITHMS_INCLUSIVE_SCAN_IMPL_HPP
#include <Kokkos_Core.hpp>
#include "Kokkos_Constraints.hpp"
#include "Kokkos_HelperPredicates.hpp"
#include <std_algorithms/Kokkos_TransformInclusiveScan.hpp>
#include <std_algorithms/Kokkos_Distance.hpp>
#include <string>
namespace Kokkos {
namespace Experimental {
namespace Impl {
template <typename ValueType>
using in_scan_has_reduction_identity_sum_t =
decltype(Kokkos::reduction_identity<ValueType>::sum());
template <class ExeSpace, class IndexType, class ValueType, class FirstFrom,
class FirstDest>
struct InclusiveScanDefaultFunctorForKnownIdentityElement {
using execution_space = ExeSpace;
FirstFrom m_first_from;
FirstDest m_first_dest;
KOKKOS_FUNCTION
InclusiveScanDefaultFunctorForKnownIdentityElement(FirstFrom first_from,
FirstDest first_dest)
: m_first_from(std::move(first_from)),
m_first_dest(std::move(first_dest)) {}
KOKKOS_FUNCTION
void operator()(const IndexType i, ValueType& update,
const bool final_pass) const {
update += m_first_from[i];
if (final_pass) {
m_first_dest[i] = update;
}
}
};
template <class ExeSpace, class IndexType, class ValueType, class FirstFrom,
class FirstDest>
struct InclusiveScanDefaultFunctor {
using execution_space = ExeSpace;
using value_type = ValueWrapperForNoNeutralElement<ValueType>;
FirstFrom m_first_from;
FirstDest m_first_dest;
KOKKOS_FUNCTION
InclusiveScanDefaultFunctor(FirstFrom first_from, FirstDest first_dest)
: m_first_from(std::move(first_from)),
m_first_dest(std::move(first_dest)) {}
KOKKOS_FUNCTION
void operator()(const IndexType i, value_type& update,
const bool final_pass) const {
const auto tmp = value_type{m_first_from[i], false};
this->join(update, tmp);
if (final_pass) {
m_first_dest[i] = update.val;
}
}
KOKKOS_FUNCTION
void init(value_type& update) const {
update.val = {};
update.is_initial = true;
}
KOKKOS_FUNCTION
void join(value_type& update, const value_type& input) const {
if (update.is_initial) {
update.val = input.val;
} else {
update.val = update.val + input.val;
}
update.is_initial = false;
}
};
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType>
OutputIteratorType inclusive_scan_default_op_impl(
const std::string& label, const ExecutionSpace& ex,
InputIteratorType first_from, InputIteratorType last_from,
OutputIteratorType first_dest) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first_from, first_dest);
Impl::static_assert_iterators_have_matching_difference_type(first_from,
first_dest);
Impl::expect_valid_range(first_from, last_from);
// aliases
using index_type = typename InputIteratorType::difference_type;
using value_type =
std::remove_const_t<typename InputIteratorType::value_type>;
using func_type = std::conditional_t<
::Kokkos::is_detected<in_scan_has_reduction_identity_sum_t,
value_type>::value,
InclusiveScanDefaultFunctorForKnownIdentityElement<
ExecutionSpace, index_type, value_type, InputIteratorType,
OutputIteratorType>,
InclusiveScanDefaultFunctor<ExecutionSpace, index_type, value_type,
InputIteratorType, OutputIteratorType>>;
// run
const auto num_elements =
Kokkos::Experimental::distance(first_from, last_from);
::Kokkos::parallel_scan(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_type(first_from, first_dest));
ex.fence("Kokkos::inclusive_scan_default_op: fence after operation");
// return
return first_dest + num_elements;
}
// -------------------------------------------------------------
// inclusive_scan_custom_binary_op_impl
// -------------------------------------------------------------
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class BinaryOpType>
OutputIteratorType inclusive_scan_custom_binary_op_impl(
const std::string& label, const ExecutionSpace& ex,
InputIteratorType first_from, InputIteratorType last_from,
OutputIteratorType first_dest, BinaryOpType binary_op) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first_from, first_dest);
Impl::static_assert_iterators_have_matching_difference_type(first_from,
first_dest);
Impl::expect_valid_range(first_from, last_from);
// aliases
using index_type = typename InputIteratorType::difference_type;
using value_type =
std::remove_const_t<typename InputIteratorType::value_type>;
using unary_op_type = StdNumericScanIdentityReferenceUnaryFunctor<value_type>;
using func_type = TransformInclusiveScanNoInitValueFunctor<
ExecutionSpace, index_type, value_type, InputIteratorType,
OutputIteratorType, BinaryOpType, unary_op_type>;
// run
const auto num_elements =
Kokkos::Experimental::distance(first_from, last_from);
::Kokkos::parallel_scan(
label, RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_type(first_from, first_dest, binary_op, unary_op_type()));
ex.fence("Kokkos::inclusive_scan_custom_binary_op: fence after operation");
// return
return first_dest + num_elements;
}
// -------------------------------------------------------------
// inclusive_scan_custom_binary_op_impl with init_value
// -------------------------------------------------------------
template <class ExecutionSpace, class InputIteratorType,
class OutputIteratorType, class BinaryOpType, class ValueType>
OutputIteratorType inclusive_scan_custom_binary_op_impl(
const std::string& label, const ExecutionSpace& ex,
InputIteratorType first_from, InputIteratorType last_from,
OutputIteratorType first_dest, BinaryOpType binary_op,
ValueType init_value) {
// checks
Impl::static_assert_random_access_and_accessible(ex, first_from, first_dest);
Impl::static_assert_iterators_have_matching_difference_type(first_from,
first_dest);
Impl::expect_valid_range(first_from, last_from);
// aliases
using index_type = typename InputIteratorType::difference_type;
using unary_op_type = StdNumericScanIdentityReferenceUnaryFunctor<ValueType>;
using func_type = TransformInclusiveScanWithInitValueFunctor<
ExecutionSpace, index_type, ValueType, InputIteratorType,
OutputIteratorType, BinaryOpType, unary_op_type>;
// run
const auto num_elements =
Kokkos::Experimental::distance(first_from, last_from);
::Kokkos::parallel_scan(label,
RangePolicy<ExecutionSpace>(ex, 0, num_elements),
func_type(first_from, first_dest, binary_op,
unary_op_type(), init_value));
ex.fence("Kokkos::inclusive_scan_custom_binary_op: fence after operation");
// return
return first_dest + num_elements;
}
} // namespace Impl
} // namespace Experimental
} // namespace Kokkos
#endif

Some files were not shown because too many files have changed in this diff Show More