Skip to content

Commit

Permalink
Update unified_memory.jl (#37)
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
pitmonticone authored Jun 29, 2022
1 parent 7e8bb53 commit ef72706
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/unified_memory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ using LinearAlgebra
# these transfers are unnecessary and allow for a more seamless
# use of the available heterogeneous compute architecture.

# This document is meant to showcase potential usecases allowed by unified memory.
# This document is meant to showcase potential use cases allowed by unified memory.

function simple_kernel(arr)
idx = thread_position_in_grid_1d()
arr[idx] = cos(arr[idx])
return
end

### Unsafe wrapping a GPU array by a CPU array and altering eachother's (same) data
### Unsafe wrapping a GPU array by a CPU array and altering each other's (same) data
# Note that since the GPU array allocation requires more assumptions about the
# underlying data, in a unified memory architecture, the GPU array should first
# be allocated, then wrapped by a CPU array...not the other way around.
Expand Down Expand Up @@ -48,7 +48,7 @@ Metal.@sync @metal threads=1024 grid=1024 simple_kernel(arr_mtl)
# This would otherwise require a set of copies back and forth.

round.(rand!(arr_cpu)*100)
# Example 1: Calculate the deteminant using CPU implementation
# Example 1: Calculate the determinant using CPU implementation
det(arr_cpu)
# Example 2: Singular Value Decomposition
svd(arr_cpu)
Expand Down

0 comments on commit ef72706

Please sign in to comment.