Skip to content

Specifying deterministic forcing on GPUs #311

Answered by navidcy
chowland asked this question in Q&A
Discussion options

You must be logged in to vote

There are a few problems with what you do here. First

zeros(eltype(grid), size(sol))

is an array on the CPU. Also, vars.Fh is complex-valued but the array you create in setF! is real-valued.

(There is another "problem" that what you are doing up there is not that efficient since you are allocating a whole array every time you call setF!.)

This

function setF!(Fh, sol, t, clock, vars, params, grid)
  @. Fh = 0
  return nothing
end

is device-agnostic and thus will work. But perhaps just zeroing out the forcing is not what you really aiming for but you were just playing around?

If you need to create an array, there is device_array:

help?> device_array
search: device_array

  device_array(device

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@chowland
Comment options

Answer selected by chowland
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants