Last active
November 3, 2017 12:10
-
-
Save SimonDanisch/87409265ea5788e7fbf0f7ba74b211a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using GPUArrays | |
| # Overloading the Julia Base map! function for GPUArrays | |
| function Base.map!(f::Function, A::GPUArray, B::GPUArray) | |
| # the below is the Julia syntax to create a closure and pass it | |
| # as the first argument to gpu_call | |
| gpu_call(A, (f, A, B)) do state, f, A, B | |
| # If launch parameters arent specified, linear_index gets the index | |
| # into the Array passed as second argument to gpu_call (`A`) | |
| i = linear_index(state) | |
| A[i] = f(B[i]) | |
| return | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment