From 01a8e675157bb8229b795ad0ec528255fbee158c Mon Sep 17 00:00:00 2001 From: MRIDUL JAIN <105979087+Spinachboul@users.noreply.github.com> Date: Thu, 28 Mar 2024 15:55:40 +0530 Subject: [PATCH] Update Radials.jl --- src/Radials.jl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Radials.jl b/src/Radials.jl index 1139d80a..a1f6bc3f 100644 --- a/src/Radials.jl +++ b/src/Radials.jl @@ -209,12 +209,20 @@ function _approx_rbf(val, rad::RadialBasis) n = length(rad.x) approx = _make_approx(val, rad) - Threads.@threads for i in 1:n + # Define a function to compute tmp for a single index i + function compute_tmp(i) tmp = zero(eltype(val)) @inbounds @simd ivdep for j in eachindex(val) tmp += ((val[j] - rad.x[i][j]) / rad.scale_factor)^2 end - tmp = sqrt(tmp) + return sqrt(tmp) + end + + # Use pmap to parallelize the computation of tmp + tmp_values = pmap(compute_tmp, 1:n) + + # Update the approx using the computed tmp values + for (i, tmp) in enumerate(tmp_values) _add_tmp_to_approx!(approx, i, tmp, rad) end