You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently trying to benchmark our parallel implementation of knn at different numbers of samples and dimensions.
using BenchmarkTools:@benchmarkimport NearestNeighbors as NN
const input_samples =Int.(exp2.(9:14))
const input_dims =Int.(exp2.(7:12))
functionknn_parallel(tree, X, k, sort)
# pre-allocate the result arrays (as in NearestNeighbors.jl)
indices =eachindex(X)
dists = [Vector{NN.get_T(eltype(X))}(undef, k) for _ in indices]
idxs = [Vector{Int}(undef, k) for _ in indices]
# get number of threads
nThreads = Threads.nthreads()
# partition the input array equally
n_samples =length(X)
divides_data =mod(n_samples, nThreads) ==0
partition_size = divides_data ? n_samples ÷ nThreads : n_samples ÷ nThreads +1
partitions = Iterators.partition(indices, partition_size)
# parallel computation over the equal array splits
Threads.@threadsfor idx incollect(partitions)
@inbounds idxs[idx], dists[idx] = NN.knn(tree, X[idx], k, sort)
end
idxs, dists
endfor dims in input_dims, samples in input_samples
@info"Running benchmark with $dims dims and $samples samples"
X = [NN.SizedVector{dims}(rand(Float32, dims)) for _ in1:samples]
cpu_bench =@benchmarkknn_parallel(NN.BruteTree($X), $X, 10, true)
display(cpu_bench)
end
However, the benchmark randomly leads to memory corruptions and crashes. Could not reproduce with a sequential call to knn yet. Do you maybe have an idea how that could happen?
The text was updated successfully, but these errors were encountered:
Interestingly, there are no problems with --check-bounds=yes, i.e. there are no out-of-bounds errors. Can anyone reproduce, maybe? Edit: My first guess would be that resource utilization is so great that my slightly overclocked processor is not handling the load, which does not happen with boundchecks.
OS Name Microsoft Windows 10 Pro
Version 10.0.19044 Build 19044
Processor AMD Ryzen 9 3900X 12-Core Processor, 4200 Mhz, 12 Core(s), 24 Logical Processor(s)
Hi!
I'm currently trying to benchmark our parallel implementation of
knn
at different numbers of samples and dimensions.However, the benchmark randomly leads to memory corruptions and crashes. Could not reproduce with a sequential call to
knn
yet. Do you maybe have an idea how that could happen?The text was updated successfully, but these errors were encountered: