@@ -28,34 +28,37 @@ the number of threads per memory domain, the number of domains considered, and t
2828measured 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)
0 commit comments