# How to generate Coverage for CUDA functions

Hey there I have a hard time getting the correct coverage for my small project.
So I am trying to do simple CFD and run most of the computation on the GPU with CUDA.jl.

Everything works as I would expect it and the tests pass and show the correct results.
Now when I try to get coverage from the tests all CUDA functions say they are not covered.
Here is one of my functions:

``````function kernel_laplacianperiodic!(res, arg)
len = size(res,1)
wid = size(res,2)
@inbounds for j = 1:wid
for i = 1:len
# NN
ip = mod1(i+1+len,len)
im = mod1(i-1-len,len)
jp = mod1(j+1+wid,wid)
jm = mod1(j-1-wid,wid)

# Computation
res[i,j] = 1.0f0/6.0f0 * (4.0f0 * (arg[ip, j] + arg[im, j] + arg[i, jp] + arg[i, jm])
+ (arg[ip, jp] + arg[im, jp] + arg[im, jm] + arg[ip, jm])
- 20.0f0 * arg[i, j])
end
end
return nothing
end
``````

And I test this with:

``````@testset "kernel_laplacianperiodic" begin
x = reshape(collect(1.0f0:25.0f0),5,5)
xcu = cu(x)
y = CUDA.zeros(5,5)
@test isa(y, CuArray{Float32,2,Nothing})
result = zeros(5,5)
result[1,1] = 30.0; result[1,2] = 5.0; result[1,3] = 5.0; result[1,4] = 5.0; result[1,5] = -20.0;
result[2,1] = 25.0; result[2,5] = -25.0;
result[3,1] = 25.0; result[3,5] = -25.0;
result[4,1] = 25.0; result[4,5] = -25.0;
result[5,1] = 20.0; result[5,2] = -5.0; result[5,3] = -5.0; result[5,4] = -5.0; result[5,5] = -30.0;
yy = Array(y)
@test yy == result
end
``````

The test passes and in my .cov file I can see that the lines are executed, but somehow in the coverages output it says that the functions has no coverage at all.
Is there a simple way to fix it? Yes I ran the tests on an machine with GPUs. I use Coverage.jl v1.1.1 and julia v1.4.2 on linux

Code coverage is not supported GPU-side. As a workaround, you can use `COV_EXCL_START` and `COV_EXCL_STOP` markers around kernel code.

I see, thanks for the quick response 