Skip to content

Commit a038923

Browse files
committed
Added profiling of u0 copy.
1 parent 6a9eef6 commit a038923

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

Project.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1010
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
1111
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1212
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
13+
NVTX = "5da4648a-3479-48b8-97b9-01cb529c0a1f"
1314
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1415
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1516
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
@@ -19,23 +20,24 @@ TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
1920
[weakdeps]
2021
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
2122
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
23+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
2224
ReadVTK = "dc215faf-f008-4882-a9f7-a79a826fadc3"
2325
WriteVTK = "64499a7a-5c06-52f2-abe2-ccb03c286192"
24-
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
2526

2627
[extensions]
2728
WaterLilyAMDGPUExt = "AMDGPU"
2829
WaterLilyCUDAExt = "CUDA"
30+
WaterLilyPlotsExt = "Plots"
2931
WaterLilyReadVTKExt = "ReadVTK"
3032
WaterLilyWriteVTKExt = "WriteVTK"
31-
WaterLilyPlotsExt = "Plots"
3233

3334
[compat]
3435
DocStringExtensions = "0.9"
3536
EllipsisNotation = "1.8"
3637
ForwardDiff = "^0.10.18"
3738
KernelAbstractions = "0.9.1"
3839
LoggingExtras = "1.1"
40+
NVTX = "0.3.5"
3941
Reexport = "^1.2.2"
4042
Requires = "1.3"
4143
StaticArrays = "^1.1.0"

src/Flow.jl

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,28 @@ Integrate the `Flow` one time step using the [Boundary Data Immersion Method](ht
151151
and the `AbstractPoisson` pressure solver to project the velocity onto an incompressible flow.
152152
"""
153153
@fastmath function mom_step!(a::Flow{N},b::AbstractPoisson) where N
154-
a.u⁰ .= a.u; scale_u!(a,0); U = BCTuple(a.U,a.Δt,N)
154+
NVTX.@range "copy_u0!" begin a.u⁰ .= a.u end
155+
NVTX.@range "scale_u!" begin scale_u!(a,0) end
156+
NVTX.@range "BCTuple" begin U = BCTuple(a.U,a.Δt,N) end
155157
# predictor u → u'
156158
@log "p"
157-
conv_diff!(a.f,a.u⁰,a.σ,ν=a.ν,perdir=a.perdir)
158-
accelerate!(a.f,@view(a.Δt[1:end-1]),a.g,a.U)
159-
BDIM!(a); BC!(a.u,U,a.exitBC,a.perdir)
160-
a.exitBC && exitBC!(a.u,a.u⁰,U,a.Δt[end]) # convective exit
161-
project!(a,b); BC!(a.u,U,a.exitBC,a.perdir)
159+
NVTX.@range "conv_diff!" begin conv_diff!(a.f,a.u⁰,a.σ,ν=a.ν,perdir=a.perdir) end
160+
NVTX.@range "accelerate!" begin accelerate!(a.f,@view(a.Δt[1:end-1]),a.g,a.U) end
161+
NVTX.@range "BDIM!" begin BDIM!(a) end
162+
NVTX.@range "BC!" begin BC!(a.u,U,a.exitBC,a.perdir) end
163+
NVTX.@range "exitBC!" begin a.exitBC && exitBC!(a.u,a.u⁰,U,a.Δt[end]) end # convective exit
164+
NVTX.@range "project!" begin project!(a,b) end
165+
NVTX.@range "BC!" begin BC!(a.u,U,a.exitBC,a.perdir) end
162166
# corrector u → u¹
163167
@log "c"
164-
conv_diff!(a.f,a.u,a.σ,ν=a.ν,perdir=a.perdir)
165-
accelerate!(a.f,a.Δt,a.g,a.U)
166-
BDIM!(a); scale_u!(a,0.5); BC!(a.u,U,a.exitBC,a.perdir)
167-
project!(a,b,0.5); BC!(a.u,U,a.exitBC,a.perdir)
168-
push!(a.Δt,CFL(a))
168+
NVTX.@range "conv_diff!" begin conv_diff!(a.f,a.u,a.σ,ν=a.ν,perdir=a.perdir) end
169+
NVTX.@range "accelerate!" begin accelerate!(a.f,a.Δt,a.g,a.U) end
170+
NVTX.@range "BDIM!" begin BDIM!(a) end
171+
NVTX.@range "scale_u!" begin scale_u!(a,0.5) end
172+
NVTX.@range "BC!" begin BC!(a.u,U,a.exitBC,a.perdir) end
173+
NVTX.@range "project!" begin project!(a,b,0.5) end
174+
NVTX.@range "BC!" begin BC!(a.u,U,a.exitBC,a.perdir) end
175+
NVTX.@range "CFL!" begin push!(a.Δt,CFL(a)) end
169176
end
170177
scale_u!(a,scale) = @loop a.u[Ii] *= scale over Ii inside_u(size(a.p))
171178

src/WaterLily.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $(README)
33
"""
44
module WaterLily
55

6-
using DocStringExtensions
6+
using DocStringExtensions, NVTX
77

88
include("util.jl")
99
export L₂,BC!,@inside,inside,δ,apply!,loc,@log
@@ -104,7 +104,7 @@ function sim_step!(sim::AbstractSimulation,t_end;remeasure=true,max_steps=typema
104104
end
105105
end
106106
function sim_step!(sim::AbstractSimulation;remeasure=true)
107-
remeasure && measure!(sim)
107+
NVTX.@range "measure!" begin remeasure && measure!(sim) end
108108
mom_step!(sim.flow,sim.pois)
109109
end
110110

0 commit comments

Comments
 (0)