-<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Home · Polyester.jl</title><meta name="title" content="Home · Polyester.jl"/><meta property="og:title" content="Home · Polyester.jl"/><meta property="twitter:title" content="Home · Polyester.jl"/><meta name="description" content="Documentation for Polyester.jl."/><meta property="og:description" content="Documentation for Polyester.jl."/><meta property="twitter:description" content="Documentation for Polyester.jl."/><meta property="og:url" content="https://JuliaSIMD.github.io/Polyester.jl/"/><meta property="twitter:url" content="https://JuliaSIMD.github.io/Polyester.jl/"/><link rel="canonical" href="https://JuliaSIMD.github.io/Polyester.jl/"/><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.050/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/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"><div class="docs-package-name"><span class="docs-autofit"><a href>Polyester.jl</a></span></div><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 class="is-active"><a class="tocitem" href>Home</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 class="is-active"><a href>Home</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Home</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://github.com/JuliaSIMD/Polyester.jl/blob/master/docs/src/index.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"><h1 id="Polyester"><a class="docs-heading-anchor" href="#Polyester">Polyester</a><a id="Polyester-1"></a><a class="docs-heading-anchor-permalink" href="#Polyester" title="Permalink"></a></h1><ul><li><a href="#Polyester.reset_threads!-Tuple{}"><code>Polyester.reset_threads!</code></a></li><li><a href="#Polyester.@batch-Tuple{Any}"><code>Polyester.@batch</code></a></li></ul><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Polyester.reset_threads!-Tuple{}" href="#Polyester.reset_threads!-Tuple{}"><code>Polyester.reset_threads!</code></a> — <span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">Polyester.reset_threads!()</code></pre><p>Resets the threads used by <a href="https://github.com/JuliaSIMD/Polyester.jl">Polyester.jl</a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/JuliaSIMD/Polyester.jl/blob/0b2d48aef6ba39dfda807199de2b20ad2912542d/src/Polyester.jl#L41-L45">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="Polyester.@batch-Tuple{Any}" href="#Polyester.@batch-Tuple{Any}"><code>Polyester.@batch</code></a> — <span class="docstring-category">Macro</span></header><section><div><pre><code class="language-julia hljs">@batch for i in Iter; ...; end</code></pre><p>Evaluate the loop on multiple threads.</p><pre><code class="nohighlight hljs">@batch minbatch=N for i in Iter; ...; end</code></pre><p>Evaluate at least N iterations per thread. Will use at most <code>length(Iter) ÷ N</code> threads.</p><pre><code class="nohighlight hljs">@batch threadlocal=init() for i in Iter; ...; end</code></pre><p>Create a thread-local storage used in the loop.</p><p>The <code>init</code> function will be called at the start at each thread. <code>threadlocal</code> will refer to storage local for the thread. At the end of the loop, a <code>threadlocal</code> vector containing all the thread-local values will be available. A type can be specified with <code>threadlocal=init()::Type</code>.</p><pre><code class="nohighlight hljs">@batch reduction=((op1, var1), (op2, var2), ...) for i in Iter; ...; end</code></pre><p>Perform OpenMP-esque reduction on the <code>isbits</code> variables <code>var1</code>, <code>var2</code>, <code>...</code> using the operations <code>op1</code>, <code>op2</code>, <code>...</code> . The variables have to be initialized before the loop and cannot be a fieldname like <code>x.y</code> or <code>x[i]</code>. Supported operations are <code>+</code>, <code>*</code>, <code>min</code>, <code>max</code>, <code>&</code>, and <code>|</code>. The type does not have to be provided, since it is already inferred from the initialized variables–-<strong>caution has to be taken to ensure that the type remains consistent throughout the loop</strong>. While <code>threadlocal</code> can do the same thing, <code>reduction</code> does not incur additional allocations and is generally more efficient for its purpose. It is up to the user to ensure that there are no data dependencies between iterations, which could lead to incorrect results.</p><pre><code class="nohighlight hljs">@batch per=core for i in Iter; ...; end
0 commit comments