From cb78adb0138c28919940941373145498007fb6c5 Mon Sep 17 00:00:00 2001 From: Carsten Bauer Date: Sun, 20 Feb 2022 18:42:44 +0100 Subject: [PATCH] @threads :static for everywhere (#27) --- docs/src/examples/perfmon.jl | 10 +++++----- docs/src/examples/perfmon.md | 10 +++++----- docs/src/examples/saxpy.md | 4 ++-- docs/src/likwid-pin.md | 2 +- examples/perfctr_threads/threads.jl | 4 ++-- examples/pin/pin.jl | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/src/examples/perfmon.jl b/docs/src/examples/perfmon.jl index 6d393f7b..6c567e00 100644 --- a/docs/src/examples/perfmon.jl +++ b/docs/src/examples/perfmon.jl @@ -21,12 +21,12 @@ const NUM_THREADS = 3; # Let's pin the first `NUM_THREADS` threads to the first `NUM_THREADS` cores. using LIKWID cores = 0:NUM_THREADS-1 -@threads for tid in 1:NUM_THREADS +@threads :static for tid in 1:NUM_THREADS LIKWID.pinthread(cores[tid]) end # To check that the pinning was successfull, we call [`LIKWID.get_processor_id`](@ref) on each thread. -@threads for tid in 1:NUM_THREADS +@threads :static for tid in 1:NUM_THREADS core = LIKWID.get_processor_id() println("Thread $tid, Core $core") end @@ -64,7 +64,7 @@ PerfMon.init() # region. Typically these are done in separate parallel blocks, relying on # the implicit barrier at the end of the parallel block. Usually there is # a parallel block for initialization and a parallel block for execution. -@threads for tid in 1:NUM_THREADS +@threads :static for tid in 1:NUM_THREADS Marker.registerregion("Total") Marker.registerregion("calc_flops") @@ -93,7 +93,7 @@ function monitor_do_flops(NUM_FLOPS = 100_000_000) a = 1.8 b = 3.2 c = 1.0 - @threads for tid in 1:NUM_THREADS + @threads :static for tid in 1:NUM_THREADS ## Notice that only the first group specified, `FLOPS_DP`, will be measured. ## See further below for how to measure multiple groups. Marker.startregion("calc_flops") @@ -108,7 +108,7 @@ monitor_do_flops() # # To query basic information about the region from all threads # we use [`Marker.getregion`](@ref). -@threads for threadid in 1:NUM_THREADS +@threads :static for threadid in 1:NUM_THREADS nevents, events, time, count = Marker.getregion("calc_flops") gid = PerfMon.get_id_of_active_group() group_name = PerfMon.get_name_of_group(gid) diff --git a/docs/src/examples/perfmon.md b/docs/src/examples/perfmon.md index f9dd92cd..2af60d6f 100644 --- a/docs/src/examples/perfmon.md +++ b/docs/src/examples/perfmon.md @@ -28,7 +28,7 @@ Let's pin the first `NUM_THREADS` threads to the first `NUM_THREADS` cores. ````@example perfmon using LIKWID cores = 0:NUM_THREADS-1 -@threads for tid in 1:NUM_THREADS +@threads :static for tid in 1:NUM_THREADS LIKWID.pinthread(cores[tid]) end ```` @@ -36,7 +36,7 @@ end To check that the pinning was successfull, we call [`LIKWID.get_processor_id`](@ref) on each thread. ````@example perfmon -@threads for tid in 1:NUM_THREADS +@threads :static for tid in 1:NUM_THREADS core = LIKWID.get_processor_id() println("Thread $tid, Core $core") end @@ -84,7 +84,7 @@ the implicit barrier at the end of the parallel block. Usually there is a parallel block for initialization and a parallel block for execution. ````@example perfmon -@threads for tid in 1:NUM_THREADS +@threads :static for tid in 1:NUM_THREADS Marker.registerregion("Total") Marker.registerregion("calc_flops") @@ -120,7 +120,7 @@ function monitor_do_flops(NUM_FLOPS = 100_000_000) a = 1.8 b = 3.2 c = 1.0 - @threads for tid in 1:NUM_THREADS + @threads :static for tid in 1:NUM_THREADS # Notice that only the first group specified, `FLOPS_DP`, will be measured. # See further below for how to measure multiple groups. Marker.startregion("calc_flops") @@ -138,7 +138,7 @@ To query basic information about the region from all threads we use [`Marker.getregion`](@ref). ````@example perfmon -@threads for threadid in 1:NUM_THREADS +@threads :static for threadid in 1:NUM_THREADS nevents, events, time, count = Marker.getregion("calc_flops") gid = PerfMon.get_id_of_active_group() group_name = PerfMon.get_name_of_group(gid) diff --git a/docs/src/examples/saxpy.md b/docs/src/examples/saxpy.md index 3d568599..2a6ef47d 100644 --- a/docs/src/examples/saxpy.md +++ b/docs/src/examples/saxpy.md @@ -193,7 +193,7 @@ using Base.Threads: nthreads, @threads @assert nthreads() > 1 # multithreading # Julia threads should be pinned! -@threads for tid in 1:nthreads() +@threads :static for tid in 1:nthreads() core = LIKWID.get_processor_id() println("Thread $tid, Core $core") end @@ -209,7 +209,7 @@ function saxpy_cpu!(z, a, x, y) end function saxpy_threads(zs, a, x, y) - @threads for tid in 1:nthreads() + @threads :static for tid in 1:nthreads() @region "saxpy_cpu!" saxpy_cpu!(zs[tid], a, x, y) end end diff --git a/docs/src/likwid-pin.md b/docs/src/likwid-pin.md index 78e6285b..013b7697 100644 --- a/docs/src/likwid-pin.md +++ b/docs/src/likwid-pin.md @@ -16,7 +16,7 @@ using Base.Threads glibc_coreid() = @ccall sched_getcpu()::Cint -@threads for i in 1:nthreads() +@threads :static for i in 1:nthreads() println("Thread: $(i), CPU: $(glibc_coreid())") end ``` diff --git a/examples/perfctr_threads/threads.jl b/examples/perfctr_threads/threads.jl index a1420e58..e39686d4 100644 --- a/examples/perfctr_threads/threads.jl +++ b/examples/perfctr_threads/threads.jl @@ -6,7 +6,7 @@ using Base.Threads: nthreads, @threads @assert nthreads() > 1 # multithreading # Julia threads should be pinned! -@threads for tid in 1:nthreads() +@threads :static for tid in 1:nthreads() core = LIKWID.get_processor_id() println("Thread $tid, Core $core") end @@ -22,7 +22,7 @@ function saxpy_cpu!(z, a, x, y) end function saxpy_threads(zs, a, x, y) - @threads for tid in 1:nthreads() + @threads :static for tid in 1:nthreads() @region "saxpy_cpu!" saxpy_cpu!(zs[tid], a, x, y) end end diff --git a/examples/pin/pin.jl b/examples/pin/pin.jl index 5f7d03a1..578f3727 100644 --- a/examples/pin/pin.jl +++ b/examples/pin/pin.jl @@ -3,6 +3,6 @@ using Base.Threads glibc_coreid() = @ccall sched_getcpu()::Cint -@threads for i in 1:nthreads() +@threads :static for i in 1:nthreads() println("Thread: $(i), CPU: $(glibc_coreid())") end \ No newline at end of file