ewyser / ep2DeJu

Small Julia project of an explicit finite strain implementation of elasto-plastic problems within a material point framework
MIT License
3 stars 0 forks source link

reduce allocation in ``deform!()`` and ``elast!()`` #3

Open ewyser opened 11 months ago

ewyser commented 11 months ago

deform!() 0.001077 seconds (11.83 k allocations: 18.056 MiB) elast!() 0.001239 seconds (19.39 k allocations: 1.892 MiB) elastoplast!() 0.002832 seconds (31.28 k allocations: 19.954 MiB)

ewyser commented 10 months ago
julia> include("./scripts/unit_testing/allocTest.jl")
┌ Warning: unit testing
└ @ Main C:\Users\Terranum\Dropbox\Jobs\git\ep2DeJu\scripts\unit_testing\allocTest.jl:2
[ Info: ϵp23De() init by-default mode
[ Info: ** ϵp2-3De v0.3.0: time & allocation evaluation **
┌ Info: mesh & mp feature(s):
│   ϕ∂ϕType = :bsmpm
│   fwrkDeform = :finite
│   trsfrAp = :mUSL
│   isΔFbar = true
│   nel = 40
└   nthreads() = 1
[ Info: Evaluate core functions:
launch ϕ∂ϕ!()
  171.900 μs (12 allocations: 2.27 KiB)
launch mapsto!(p->n)
  396.500 μs (4735 allocations: 389.03 KiB)
launch solve!()
  6.780 μs (12 allocations: 1.72 KiB)
launch mapsto!(p<-n)
  61.600 μs (43 allocations: 7.31 KiB)
launch elastoplast!()
  1.116 ms (27624 allocations: 18.60 MiB)
┌ Warning: Digging deeper in elastoplast!(),
└ @ Main C:\Users\Terranum\Dropbox\Jobs\git\ep2DeJu\scripts\unit_testing\allocTest.jl:39
-> launch deform!()
  763.900 μs (8883 allocations: 17.84 MiB)
-> launch ΔFbar!()
  325.400 μs (4740 allocations: 5.62 MiB)
-> launch elast!()
  189.400 μs (7689 allocations: 601.16 KiB)
│
└ (✓) Done! exiting...
julia>
ewyser commented 10 months ago

reduced mem. alloc, see commit bc1ad8a97b6202de28d11d551866872d1de2682a and see results below:

launch elastoplast!() 424.011 μs (23731 allocations: 13.00 MiB) ┌ Warning: Digging deeper in elastoplast!(), └ @ Main ~/Dropbox/Jobs/git/ep2DeJu/scripts/unit_testing/allocTest.jl:39 -> launch deform!() 210.205 μs (5456 allocations: 12.28 MiB) -> launch ΔFbar!() 56.385 μs (1272 allocations: 58.80 KiB) -> launch elast!() 112.291 μs (7137 allocations: 550.77 KiB)

ewyser commented 10 months ago
julia> include("./scripts/unit_testing/allocTest.jl")
┌ Warning: unit testing
└ @ Main C:\Users\Terranum\Dropbox\Jobs\git\ep2DeJu\scripts\unit_testing\allocTest.jl:2
[ Info: ϵp23De() init performance mode on
[ Info: ** ϵp3De v0.3.0: infinitesimal strain formulation **
[ Info: init...
┌ Info: mesh & mp feature(s):
│   ϕ∂ϕType = :bsmpm
│   fwrkDeform = :infinitesimal
│   trsfrAp = :mUSL
│   isΔFbar = true
│   nel = 80
└   nthreads() = 8
[ Info: Evaluate core functions:
launch ϕ∂ϕ!()
  13.867 ms (98 allocations: 17.84 KiB)
launch mapsto!(p->n)
  29.006 ms (50 allocations: 8.81 KiB)
launch solve!()
  204.700 μs (147 allocations: 20.20 KiB)
launch mapsto!(p<-n)
  13.657 ms (500 allocations: 81.33 KiB)
launch elastoplast!()
  508.084 ms (3195483 allocations: 3.29 GiB)
┌ Warning: Digging deeper in elastoplast!(),
└ @ Main C:\Users\Terranum\Dropbox\Jobs\git\ep2DeJu\scripts\unit_testing\allocTest.jl:41
-> launch deform!()
  478.349 ms (1002549 allocations: 3.14 GiB)
-> launch ΔFbar!()
  8.384 ms (200578 allocations: 7.66 MiB)
-> launch elast!()
  16.073 ms (1904610 allocations: 126.96 MiB)
ewyser commented 10 months ago

see comit 08d3728389510b254542f4400b22317409849f7e

ewyser commented 10 months ago
julia> include("./scripts/unit_testing/allocTest.jl")
┌ Warning: unit testing
└ @ Main ~/Dropbox/Jobs/git/ep2DeJu/scripts/unit_testing/allocTest.jl:2
[ Info: ϵp23De() init performance mode on
[ Info: ** ϵp3De v0.3.0: finite strain formulation **
[ Info: init...
┌ Info: mesh & mp feature(s):
│   ϕ∂ϕType = :bsmpm
│   fwrkDeform = :finite
│   trsfrAp = :mUSL
│   isΔFbar = true
│   nel = 80
└   nthreads() = 8
[ Info: Evaluate core functions:
launch ϕ∂ϕ!()
  44.134 ms (95 allocations: 15.03 KiB)
launch mapsto!(p->n)
  43.491 ms (46 allocations: 7.52 KiB)
launch solve!()
  436.109 μs (143 allocations: 16.19 KiB)
launch mapsto!(p<-n)
  23.377 ms (462 allocations: 67.67 KiB)
launch elastoplast!()
  59.321 ms (1604080 allocations: 148.40 MiB)
┌ Warning: Digging deeper in elastoplast!(), 
└ @ Main ~/Dropbox/Jobs/git/ep2DeJu/scripts/unit_testing/allocTest.jl:41
-> launch deform!()
  24.377 ms (200615 allocations: 15.32 MiB)
-> launch ΔFbar!()
  9.076 ms (90 allocations: 12.62 KiB)
-> launch elast!()
  21.500 ms (1202929 allocations: 111.66 MiB)
│
└ (✓) Done! exiting...

see commit 0941b48392d0e00f85ffa6268bff452f6042a848

ewyser commented 10 months ago

discrepancies are observed between the standard and performance mode for finite strain, need to investigate

ewyser commented 10 months ago

it is fine for infinitesimal formulation

ewyser commented 10 months ago

it is fine for finite strain

ewyser commented 10 months ago

odd behaviour in elastoplast!( ) when perf = true, should investigate

ewyser commented 10 months ago

now it works