From 60976175165a2202842c3019b7156345b1315161 Mon Sep 17 00:00:00 2001 From: xzgao Date: Wed, 3 Apr 2024 16:41:29 +0800 Subject: [PATCH] add distributed for long direct --- Project.toml | 1 + src/FastSpecSoG.jl | 1 + src/energy/energy_long_naive.jl | 12 ++++-------- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index b6606ce..c298fe3 100644 --- a/Project.toml +++ b/Project.toml @@ -5,6 +5,7 @@ version = "1.0.0-DEV" [deps] ChebParticleMesh = "1983ef0c-217d-4026-99b0-9163e7750d85" +Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" ExTinyMD = "fec76197-d59f-46dd-a0ed-76a83c21f7aa" FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" FastChebInterp = "cf66c380-9a80-432c-aff8-4f9c79c0bdde" diff --git a/src/FastSpecSoG.jl b/src/FastSpecSoG.jl index 6f047c9..b4bf3b0 100644 --- a/src/FastSpecSoG.jl +++ b/src/FastSpecSoG.jl @@ -1,5 +1,6 @@ module FastSpecSoG +using Distributed using ExTinyMD, LinearAlgebra, SpecialFunctions, ChebParticleMesh, SumOfExpVPMR, LoopVectorization, OMEinsum, FastChebInterp, Polynomials, FFTW import FastChebInterp: ChebPoly diff --git a/src/energy/energy_long_naive.jl b/src/energy/energy_long_naive.jl index 02470af..74d9115 100644 --- a/src/energy/energy_long_naive.jl +++ b/src/energy/energy_long_naive.jl @@ -102,15 +102,13 @@ function long_energy_us_k(qs::Vector{T}, poses::Vector{NTuple{3, T}}, accuracy:: @assert M_min ≥ 1 @assert M_max ≤ length(uspara.sw) - Ek = zero(T) - - for l in M_min:M_max + Ek = @distributed (+) for l in M_min:M_max s, w = uspara.sw[l] # accuracy = exp(-k^2 * s^2 / 4) km = sqrt(-4 * log(accuracy) / s^2) # km = π * n / max{L_x, L_y, L_z} cutoff = ceil(Int, km * maximum(L) / 2π) + 1 - Ek += long_energy_sw_k(qs, poses, cutoff, L, s, w) + long_energy_sw_k(qs, poses, cutoff, L, s, w) end @debug "long range energy, direct su, k" Ek @@ -121,11 +119,9 @@ function long_energy_us_0(qs::Vector{T}, poses::Vector{NTuple{3, T}}, L::NTuple{ @assert M_min ≥ 1 @assert M_max ≤ length(uspara.sw) - E0 = zero(T) - - for l in M_min:M_max + E0 = @distributed (+) for l in M_min:M_max s, w = uspara.sw[l] - E0 += long_energy_sw_0(qs, poses, L, s, w) + long_energy_sw_0(qs, poses, L, s, w) end @debug "long range energy, direct sum, zeroth mode" E0