Skip to content

Commit e70ec27

Browse files
committed
bwscaling_memory_domains domains kwarg + version bump
1 parent 96cd0e8 commit e70ec27

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BandwidthBenchmark"
22
uuid = "68eb07c1-04fd-4e62-9736-d6127c4c03c6"
33
authors = ["Carsten Bauer <crstnbr@gmail.com>"]
4-
version = "0.1.1"
4+
version = "0.2.0"
55

66
[deps]
77
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"

src/bwscaling.jl

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,37 @@ the number of threads per memory domain, the number of domains considered, and t
2828
measured memory bandwidth (in MB/s).
2929
3030
**Keyword arguments**
31-
- `max_nnuma`: maximal number of memory domains to consider
31+
- `domains`: memory domains to consider (logical indices, i.e. starting at 1)
3232
- `max_nthreads`: maximal number of threads per memory domain to consider
3333
"""
34-
function bwscaling_memory_domains(; max_nnuma=nnuma(),
34+
function bwscaling_memory_domains(; domains=1:nnuma(),
3535
max_nthreads=maximum(ncores_per_numa()), kwargs...)
36-
if Threads.nthreads() < max_nnuma * max_nthreads
37-
throw(ErrorException("Not enough Julia threads. Please start Julia with at least " *
38-
"$(max_nnuma * max_nthreads) threads."))
39-
elseif !all(>=(max_nthreads), ncores_per_numa())
40-
throw(ErrorException("Not all memory domains have enough cores (at least " *
41-
"max_nthreads=$(max_nthreads)). You may try to set the " *
42-
"keyword argument max_nthreads to a lower value."))
36+
if !all(i->i>0 && i<=nnuma(), domains)
37+
throw(ArgumentError("Invalid argument `numas` (out of bounds)."))
4338
end
4439
# query system information
45-
numacpuids = cpuids_per_numa()
40+
numacpuids = cpuids_per_numa()[domains]
4641
filter!.(!ishyperthread, numacpuids) # drop hyperthreads
42+
if !all(x->length(x) >= max_nthreads, numacpuids)
43+
throw(ArgumentError("Some memory domains don't have enough CPU-cores. Please provide a smaller value for `max_nthreads`."))
44+
end
45+
if Threads.nthreads() < length(domains) * max_nthreads
46+
throw(ErrorException("Not enough Julia threads. Please start Julia with at least " *
47+
"$(length(domains) * max_nthreads) threads."))
48+
end
4749
results = DataFrame(;
4850
Function=String[],
4951
var"# Threads per domain"=Int64[],
5052
var"# Memory domains"=Int64[],
5153
var"Rate (MB/s)"=Float64[]
5254
)
53-
for nn in 1:max_nnuma # how many domains to use
55+
for nn in 1:length(domains) # how many domains to use
5456
for nt in 1:max_nthreads # how many threads/cores to use per domain
55-
println("nnuma=$nn, nthreads_per_numa=$nt")
57+
println("domain=$(domains[nn]), nthreads_per_numa=$nt")
5658
total_nthreads = nn * nt
5759
# select cpuids
5860
cpuids = @views reduce(vcat, numacpuids[i][1:nt] for i in 1:nn)
61+
# @show cpuids
5962
# pin threads
6063
pinthreads(cpuids)
6164
# run benchmark (all kernels)

test/bwscaling_tests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Threads.nthreads() ≥ 2 ||
1313
end
1414

1515
@testset "bwscaling_memory_domains" begin
16-
df = bwscaling_memory_domains(; max_nnuma=1, max_nthreads=2, N=1000)
16+
df = bwscaling_memory_domains(; domains=1:1, max_nthreads=2, N=1000)
1717
@test df isa DataFrame
1818
@test names(df) == ["Function", "# Threads per domain", "# Memory domains", "Rate (MB/s)"]
1919
@test size(df) == (1 * 2 * BandwidthBenchmark.NBENCH, 4)

0 commit comments

Comments
 (0)