Skip to content

Instantly share code, notes, and snippets.

@jrevels
Last active May 3, 2018 14:35
Show Gist options
  • Save jrevels/20f5e1d7ac64c0b51099960ded3e4687 to your computer and use it in GitHub Desktop.
Save jrevels/20f5e1d7ac64c0b51099960ded3e4687 to your computer and use it in GitHub Desktop.
using Test, SparseArrays, LinearAlgebra, Random
N, M, p = 10, 12, 0.3;
Q, X, Y, Z = sprand(N, M, p), sprand(Float32, N, M, p), sprand(N, M, p), sprand(N, M, p);
f(x, y, z) = x + y + z + 1;
broadcast!(+, Q, X, Y, Z); # warmup for @allocated
broadcast!(*, Q, X, Y, Z); # warmup for @allocated
broadcast!(f, Q, X, Y, Z); # warmup for @allocated
@test (@allocated broadcast!(+, Q, X, Y, Z)) == 0
@test (@allocated broadcast!(*, Q, X, Y, Z)) == 0
@test (@allocated broadcast!(f, Q, X, Y, Z)) == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment