1

So I'm trying to use ArrayFire in Julia, and I find that the performance bizarrely degrades over time:

using ArrayFire
srand(1)

function f()
    r = AFArray(zeros(Float32, 100, 100000))
    a = AFArray(rand(Float32, 100, 100000))
    for d in 1:100:90000
        r[:,d:d+99] = a[:,d:d+99] .* a[:,d:d+99]
    end
    nothing
end

function g()
    r = zeros(Float32, 100, 100000)
    a = ones(Float32, 100, 100000)
    for d in 1:100:90000
        r[:,d:d+99] = a[:,d:d+99] .* a[:,d:d+99]
    end
    nothing
end

for _ in 1:15
    @time f()
end

If you run this code you'll see every iteration gets slower and slower. I tried calling finalize on r and a inside f() to try to throw these arrays out of GPU memory, in case that was the problem, but it didn't do anything.

Here is the output:

  0.810842 seconds (114.91 k allocations: 80.216 MB, 0.71% gc time)
  0.283941 seconds (79.22 k allocations: 78.561 MB, 3.22% gc time)
  0.267405 seconds (79.22 k allocations: 78.561 MB, 2.31% gc time)
  0.332186 seconds (79.22 k allocations: 78.561 MB, 1.76% gc time)
  0.405174 seconds (79.22 k allocations: 78.561 MB, 1.50% gc time)
  0.433224 seconds (79.22 k allocations: 78.561 MB, 2.11% gc time)
  0.501358 seconds (79.22 k allocations: 78.561 MB, 1.18% gc time)
  0.572704 seconds (79.22 k allocations: 78.561 MB, 1.07% gc time)
  0.650663 seconds (79.22 k allocations: 78.561 MB, 1.10% gc time)
  0.794873 seconds (79.22 k allocations: 78.561 MB, 1.16% gc time)
  0.838882 seconds (79.22 k allocations: 78.561 MB, 1.04% gc time)
  1.281940 seconds (79.22 k allocations: 78.561 MB, 0.61% gc time)
  1.200713 seconds (79.22 k allocations: 78.561 MB, 0.37% gc time)
  1.268786 seconds (79.22 k allocations: 78.561 MB, 0.78% gc time)
  1.396851 seconds (79.22 k allocations: 78.561 MB, 0.66% gc time)
Michael Ohlrogge
  • 10,559
  • 5
  • 48
  • 76
Set
  • 934
  • 6
  • 25
  • I ran this loop 50 times, and don't see any degradation at all... This is on Windows x64 with a GTX 960. What are you using? – ARM Jul 09 '16 at 00:05
  • @ARM I'm using a MacBook Pro with OS X 10.11.5 with an Intel HD Graphics 4000 1536 MB. I just updated the post with my timings. – Set Jul 09 '16 at 12:48

0 Answers0