Skip to content

Commit

Permalink
@threads :static for everywhere (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenbauer committed Feb 20, 2022
1 parent 2f3210c commit cb78adb
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions docs/src/examples/perfmon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions docs/src/examples/perfmon.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ 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
````

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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/saxpy.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/src/likwid-pin.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
4 changes: 2 additions & 2 deletions examples/perfctr_threads/threads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/pin/pin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cb78adb

Please sign in to comment.