-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acebd14
commit 9f4abf5
Showing
5 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#= | ||
using TestEnv | ||
TestEnv.activate() | ||
using CUDA # (optional) | ||
using Revise; include(joinpath("test", "execution", "measure_parameter_memory.jl")) | ||
=# | ||
|
||
include("utils_test.jl") | ||
include("utils_setup.jl") | ||
include("utils_benchmark.jl") | ||
|
||
import MultiBroadcastFusion as MBF | ||
|
||
#! format: off | ||
function perf_kernel_shared_reads_fused!(X, Y) | ||
(; x1, x2, x3, x4) = X | ||
(; y1, y2, y3, y4) = Y | ||
# TODO: can we write this more compactly with `@fused_assemble`? | ||
|
||
# Let's make sure that every broadcasted object is different, | ||
# so that we use up a lot of parameter memory: | ||
fmb = MBF.@get_fused_direct begin | ||
@. y1 = x1 | ||
@. y2 = x1 + x2 | ||
@. y3 = x1 + x2 + x3 | ||
@. y4 = x1 * x2 + x3 + x4 | ||
@. y1 = x1 * x2 + x3 + x4 + x1 | ||
@. y2 = x1 * x2 + x3 + x4 + x1 + x2 | ||
@. y3 = x1 * x2 + x3 + x4 + x1 + x2 + x3 | ||
@. y4 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 | ||
@. y1 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 | ||
@. y2 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 + x2 | ||
@. y3 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 + x2 + x3 | ||
@. y4 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 | ||
@. y1 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 | ||
@. y2 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 + x2 | ||
@. y3 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 + x2 + x3 | ||
@. y4 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 | ||
@. y1 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 | ||
@. y2 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 + x2 | ||
@. y3 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 + x2 + x3 | ||
@. y4 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 | ||
@. y1 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 | ||
@. y2 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 + x2 | ||
@. y3 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 + x2 + x3 | ||
@. y4 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 | ||
@. y1 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 | ||
@. y2 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 + x2 | ||
@. y3 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 + x2 + x3 | ||
@. y4 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 | ||
@. y1 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 | ||
@. y2 = x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 * x2 + x3 + x4 + x1 + x2 # breaks on A100 due to too much parameter memory | ||
end | ||
MBFExt = Base.get_extension(MBF, :MultiBroadcastFusionCUDAExt) | ||
@show MBFExt.param_usage_args(fmb) | ||
end | ||
#! format: on | ||
|
||
@static get(ENV, "USE_CUDA", nothing) == "true" && using CUDA | ||
use_cuda = @isdefined(CUDA) && CUDA.has_cuda() # will be true if you first run `using CUDA` | ||
AType = use_cuda ? CUDA.CuArray : Array | ||
device_name = use_cuda ? CUDA.name(CUDA.device()) : "CPU" | ||
bm = Benchmark(; device_name, float_type = Float32) | ||
problem_size = (50, 5, 5, 6, 5400) | ||
|
||
array_size = problem_size # array | ||
X = get_arrays(:x, AType, bm.float_type, array_size) | ||
Y = get_arrays(:y, AType, bm.float_type, array_size) | ||
@testset "Test measuring parameter memory" begin | ||
use_cuda && perf_kernel_shared_reads_fused!(X, Y) | ||
end | ||
|
||
nothing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters