Skip to content

Commit

Permalink
upd for multithreading
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrKryslUCSD committed Mar 14, 2024
1 parent 536b20e commit 701ebed
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
18 changes: 9 additions & 9 deletions examples/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.2"
manifest_format = "2.0"
project_hash = "692de4f9982b002df11b52d4a2fedf7d577cea41"
project_hash = "8236851a195829bb0e45588a8093aeeb780be081"

[[deps.AbstractTrees]]
git-tree-sha1 = "2d9c9a55f9c93e8887ad391fbae72f8ef55e1177"
Expand Down Expand Up @@ -281,6 +281,14 @@ git-tree-sha1 = "2d19911310cab0a3fade7987a194a1cae8ccd8c7"
uuid = "972d1c22-8bdd-11e9-11cf-cdcb7577b041"
version = "3.0.5"

[[deps.FinEtoolsMultithreading]]
deps = ["ChunkSplitters", "FinEtools", "LinearAlgebra", "SparseArrays", "SparseMatricesCSR", "Test"]
git-tree-sha1 = "0651710dcb8582120fe75551bd8ca7e9e33b9930"
repo-rev = "main"
repo-url = "https://github.com/PetrKryslUCSD/FinEtoolsMultithreading.jl.git"
uuid = "6d2818ca-ed81-4c53-b1fa-1f68c2fd5913"
version = "0.1.6"

[[deps.FixedPointNumbers]]
deps = ["Statistics"]
git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc"
Expand Down Expand Up @@ -659,14 +667,6 @@ git-tree-sha1 = "526f5a03792669e4187e584e8ec9d534248ca765"
uuid = "36c8627f-9965-5494-a995-c6b170f724f3"
version = "1.52.1+0"

[[deps.ParFEM]]
deps = ["ChunkSplitters", "FinEtools", "LinearAlgebra", "SparseArrays", "SparseMatricesCSR", "Test"]
git-tree-sha1 = "c9cbce958f8f5fd01072869d1cf4ac74535221fc"
repo-rev = "main"
repo-url = "https://github.com/PetrKryslUCSD/ParFEM.jl.git"
uuid = "6d2818ca-ed81-4c53-b1fa-1f68c2fd5913"
version = "0.1.5"

[[deps.Parsers]]
deps = ["Dates", "PrecompileTools", "UUIDs"]
git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821"
Expand Down
2 changes: 1 addition & 1 deletion examples/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Cthulhu = "f68482b8-f384-11e8-15f7-abe071a5a75f"
DataDrop = "aa547a04-dd37-49ab-8e73-656744f8a8fc"
FinEtools = "91bb5406-6c9a-523d-811d-0644c4229550"
FinEtoolsHeatDiff = "972d1c22-8bdd-11e9-11cf-cdcb7577b041"
FinEtoolsMultithreading = "6d2818ca-ed81-4c53-b1fa-1f68c2fd5913"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
PProf = "e4faabce-9ead-11e9-39d9-4379958e3056"
ParFEM = "6d2818ca-ed81-4c53-b1fa-1f68c2fd5913"
PlotlyLight = "ca7969ec-10b3-423e-8d99-40f33abb42bf"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
Sparspak = "e56a9233-b9d6-4f03-8d0f-1825330902ac"
Expand Down
34 changes: 26 additions & 8 deletions examples/steady_state/2-d/Poisson_examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ using FinEtools.AlgoBaseModule: solve_blocked!, matrix_blocked, vector_blocked
using FinEtoolsHeatDiff
using FinEtoolsHeatDiff.AlgoHeatDiffModule
import LinearAlgebra: cholesky
using ParFEM.Exports
using FinEtoolsMultithreading.Exports
using FinEtoolsMultithreading: csc_matrix

function Poisson_FE_example()
println("""
Expand Down Expand Up @@ -282,7 +283,7 @@ function Poisson_FE_Q4_example()
true
end # Poisson_FE_Q4_example

function Poisson_FE_Q4_parallel_example(N = 2000, ntasks = Threads.nthreads())
function Poisson_FE_Q4_parallel_example(N = 100, ntasks = Threads.nthreads(), assembly_only = false)
println("""
Heat conduction example described by Amuthan A. Ramabathiran
Expand All @@ -293,7 +294,6 @@ function Poisson_FE_Q4_parallel_example(N = 2000, ntasks = Threads.nthreads())
Version: 03/13/2024
""")


A = 1.0
thermal_conductivity = [i == j ? one(Float64) : zero(Float64) for i = 1:2, j = 1:2] # conductivity matrix
function getsource!(forceout, XYZ, tangents, feid, qpid)
Expand Down Expand Up @@ -331,18 +331,36 @@ function Poisson_FE_Q4_parallel_example(N = 2000, ntasks = Threads.nthreads())
conductivity(femm, assembler, geom, Temp)
end

n2e = FENodeToFEMap(fes.conn, nnodes(Temp))

println("Conductivity")
t0 = time();

t1 = time()
assembler = fill_assembler(fes, Temp, createsubdomain, matrixcomputation!, ntasks)
println("Fill assembler = $(time() - t1) [s]")
println(" Fill assembler = $(time() - t1) [s]")

t1 = time()
n2n = FENodeToNeighborsMap(n2e, fes.conn)
println(" Make node to neighbor map = $(time() - t1) [s]")

t1 = time()
K = make_pattern(fes, Temp, :CSC)
println("Makes sparsity pattern = $(time() - t1) [s]")
start, dofs = sparsity_pattern_symmetric(fes, Temp, n2n)
println(" Make sparsity pattern = $(time() - t1) [s]")

t1 = time()
K = csc_matrix(start, dofs, nalldofs(Temp), zero(eltype(Temp.values)))
println(" Make zero matrix = $(time() - t1) [s]")

t1 = time()
add_to_matrix!(K, assembler)
println("Add to matrix = $(time() - t1) [s]")
println("Total = $(time() - t0) [s]")
println(" Add to matrix = $(time() - t1) [s]")

println("Assembly total = $(time() - t0) [s]")

if assembly_only
return
end

println("Internal heat generation")
fi = ForceIntensity(Float64, 1, getsource!)
Expand Down

0 comments on commit 701ebed

Please sign in to comment.