# L-17 MCS 572 Fri 4 Oct 2024 : gpuadd.jl # Copied from the tutorial at # https://cuda.juliagpu.org/stable/tutorials/introduction/ using CUDA using Test function gpu_add1!(y, x) for i = 1:length(y) @inbounds y[i] += x[i] end return nothing end N = 2^20 x_d = CUDA.fill(1.0f0, N) # a vector stored on the GPU filled with 1.0 (Float32) y_d = CUDA.fill(2.0f0, N) # a vector stored on the GPU filled with 2.0 fill!(y_d, 2) @cuda gpu_add1!(y_d, x_d) result = (@test all(Array(y_d) .== 3.0f0)) println(result)