|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Find All · AcceleratedKernels.jl</title><meta name="title" content="Find All · AcceleratedKernels.jl"/><meta property="og:title" content="Find All · AcceleratedKernels.jl"/><meta property="twitter:title" content="Find All · AcceleratedKernels.jl"/><meta name="description" content="Documentation for AcceleratedKernels.jl."/><meta property="og:description" content="Documentation for AcceleratedKernels.jl."/><meta property="twitter:description" content="Documentation for AcceleratedKernels.jl."/><meta property="og:url" content="https://juliagpu.github.io/KernelAbstractions.jl/api/findall/"/><meta property="twitter:url" content="https://juliagpu.github.io/KernelAbstractions.jl/api/findall/"/><link rel="canonical" href="https://juliagpu.github.io/KernelAbstractions.jl/api/findall/"/><script data-outdated-warner src="../../assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.63.2/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="../.."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../../assets/documenter.js"></script><script src="../../search_index.js"></script><script src="../../siteinfo.js"></script><script src="../../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-mocha.css" data-theme-name="catppuccin-mocha"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-macchiato.css" data-theme-name="catppuccin-macchiato"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-frappe.css" data-theme-name="catppuccin-frappe"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-latte.css" data-theme-name="catppuccin-latte"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../../assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="../../"><img src="../../assets/logo.png" alt="AcceleratedKernels.jl logo"/></a><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><ul class="docs-menu"><li><a class="tocitem" href="../../">Overview</a></li><li><a class="tocitem" href="../../benchmarks/">Benchmarks</a></li><li><a class="tocitem" href="../../performance/">Performance Tips</a></li><li><span class="tocitem">Manual</span><ul><li><a class="tocitem" href="../using_backends/">Using Different Backends</a></li><li><a class="tocitem" href="../foreachindex/">General Loops</a></li><li><a class="tocitem" href="../map/">Map</a></li><li><a class="tocitem" href="../sort/">Sorting</a></li><li><a class="tocitem" href="../reduce/">Reduce</a></li><li><a class="tocitem" href="../mapreduce/">MapReduce</a></li><li><a class="tocitem" href="../accumulate/">Accumulate</a></li><li><a class="tocitem" href="../binarysearch/">Binary Search</a></li><li class="is-active"><a class="tocitem" href>Find All</a></li><li><a class="tocitem" href="../predicates/">Predicates</a></li><li><a class="tocitem" href="../arithmetics/">Arithmetics</a></li><li><a class="tocitem" href="../custom_structs/">Custom Structs</a></li><li><a class="tocitem" href="../task_partition/">Task Partitioning</a></li><li><a class="tocitem" href="../utilities/">Utilities</a></li></ul></li><li><a class="tocitem" href="../../testing/">Testing</a></li><li><a class="tocitem" href="../../debugging/">Debugging Kernels</a></li><li><a class="tocitem" href="../../roadmap/">Roadmap</a></li><li><a class="tocitem" href="../../references/">References</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">Manual</a></li><li class="is-active"><a href>Find All</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Find All</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://github.com/JuliaGPU/AcceleratedKernels.jl" title="View the repository on GitHub"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">GitHub</span></a><a class="docs-navbar-link" href="https://github.com/JuliaGPU/AcceleratedKernels.jl/blob/main/docs/src/api/findall.md" title="Edit source on GitHub"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></a></div></header><article class="content" id="documenter-page"><h3 id="Find-All-/-Stream-Compaction"><a class="docs-heading-anchor" href="#Find-All-/-Stream-Compaction">Find All / Stream Compaction</a><a id="Find-All-/-Stream-Compaction-1"></a><a class="docs-heading-anchor-permalink" href="#Find-All-/-Stream-Compaction" title="Permalink"></a></h3><article><details class="docstring" open="true"><summary id="AcceleratedKernels.findall"><a class="docstring-binding" href="#AcceleratedKernels.findall"><code>AcceleratedKernels.findall</code></a> — <span class="docstring-category">Function</span></summary><section><div><pre><code class="language-julia hljs">findall(A::AbstractArray, backend::Backend=get_backend(A); |
| 3 | + alg::FindallAlgorithm=ScanScatter(), |
| 4 | + max_tasks::Int=Threads.nthreads(), min_elems::Int=1, |
| 5 | + prefer_threads::Bool=true, |
| 6 | + temp::Union{Nothing, AbstractArray}=nothing, |
| 7 | + temp_bools::Union{Nothing, AbstractArray}=nothing) |
| 8 | +findall(pred, A::AbstractArray, backend::Backend=get_backend(A); |
| 9 | + alg::FindallAlgorithm=ScanScatter(), |
| 10 | + max_tasks::Int=Threads.nthreads(), min_elems::Int=1, |
| 11 | + prefer_threads::Bool=true, |
| 12 | + temp::Union{Nothing, AbstractArray}=nothing, |
| 13 | + temp_bools::Union{Nothing, AbstractArray}=nothing)</code></pre><p>Return the indices of the <code>true</code> elements of <code>A</code>, or of the elements for which <code>pred</code> returns <code>true</code>, in the same order and with the same index types as <code>Base.findall</code>. Values used as conditions must be <code>Bool</code>.</p><p>The supported inputs are arrays. Dictionaries, other iterables, and scalar inputs accepted by <code>Base.findall</code> are outside the scope of this package.</p><p><strong>Settings</strong></p><ul><li><code>alg=ScanScatter()</code> selects the GPU algorithm and its tuning parameters.</li><li><code>max_tasks=Threads.nthreads()</code> and <code>min_elems=1</code> control CPU task partitioning.</li><li><code>temp=nothing</code> may provide the <code>Int</code> buffer used for block or task counts.</li><li><code>temp_bools=nothing</code> may provide the Bool mask for the predicate form or for a mask whose element type is not <code>Bool</code>. It must have the same axes as <code>A</code> and must not alias it.</li></ul><p>On a GPU, <code>temp</code> needs at least <code>cld(length(A), alg.block_size * alg.items_per_thread)</code> elements. On a CPU, it needs one element per task used. Omitted buffers are allocated automatically.</p><p><strong>Examples</strong></p><pre><code class="language-julia hljs">import CUDA |
| 14 | +import AcceleratedKernels as AK |
| 15 | + |
| 16 | +v = CUDA.CuArray(Int32[5, -2, 8, -1, 3]) |
| 17 | +AK.findall(x -> x > 0, v) # [1, 3, 5] |
| 18 | + |
| 19 | +m = CUDA.CuArray(Bool[1 0; 0 1]) |
| 20 | +AK.findall(m) # [CartesianIndex(1, 1), CartesianIndex(2, 2)]</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaGPU/AcceleratedKernels.jl/blob/a3269febf09f89f1ee8bd9addaeb047d882d57da/src/findall.jl#L219-L263">source</a></section></details></article><article><details class="docstring" open="true"><summary id="AcceleratedKernels.ScanScatter"><a class="docstring-binding" href="#AcceleratedKernels.ScanScatter"><code>AcceleratedKernels.ScanScatter</code></a> — <span class="docstring-category">Type</span></summary><section><div><pre><code class="language-julia hljs">ScanScatter(; block_size=256, items_per_thread=16)</code></pre><p>Stable GPU stream compaction using per-block counts, a prefix scan, and a scatter pass. <code>block_size</code> must be a power of two between 1 and 1024; <code>items_per_thread</code> must be positive.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaGPU/AcceleratedKernels.jl/blob/a3269febf09f89f1ee8bd9addaeb047d882d57da/src/findall.jl#L3-L8">source</a></section></details></article></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../binarysearch/">« Binary Search</a><a class="docs-footer-nextpage" href="../predicates/">Predicates »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.19.0 on <span class="colophon-date" title="Thursday 3 September 2026 19:26">Thursday 3 September 2026</span>. Using Julia version 1.12.7.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> |
0 commit comments