Skip to content

LoopManagers is the companion package of ManagedLoops. It provides managers to execute loops with SIMD, on multiple threads or on GPUs.

License

Notifications You must be signed in to change notification settings

ClimFlows/LoopManagers.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LoopManagers

Stable Dev Build Status Coverage

LoopManagers is the companion package of MangedLoops. It provides managers to execute loops with SIMD, on multiple threads or on GPUs. There is also a meta-manager that selects among a provided set of managers the one with the shortest execution time, on a per-function basis.

Example

# Would belong to a 'provider' module, depending only on ManagedLoops

using ManagedLoops: @loops, @vec

@loops function loop!(_, a, b)
    let (irange, jrange) = axes(a)
        @vec for i in irange, j in jrange
            @inbounds a[i, j] = @fastmath exp(b[i, j])
        end
    end
end

# Belongs to a 'consumer' module/program, that requires LoopManagers to run

using LoopManagers: PlainCPU, VectorizedCPU, MultiThread
using SIMDMathFunctions # for vectorized exp
using BenchmarkTools
using InteractiveUtils

versioninfo() # check JULIA_EXCLUSIVE and JULIA_NUM_THREADS
scalar = PlainCPU()
simd = VectorizedCPU(8)
threads = MultiThread(simd)

b = randn(1024, 1024);
a = similar(b);

for mgr in (scalar, simd, threads)
    @info mgr
    display(@benchmark loop!($mgr, $a, $b))
end

About

LoopManagers is the companion package of ManagedLoops. It provides managers to execute loops with SIMD, on multiple threads or on GPUs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages