Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize calcF! in examples with stochastic forcing #225

Merged
merged 11 commits into from
Apr 13, 2021

Conversation

navidcy
Copy link
Member

@navidcy navidcy commented Apr 12, 2021

Closes #223.

@navidcy navidcy requested a review from glwagner April 12, 2021 04:46
@glwagner
Copy link
Member

If that works, that's awesome!


Fh .= ArrayType(dev)(ξ) .* sqrt.(forcing_spectrum)

Fh .= sqrt.(forcing_spectrum) .* exp(2π * im * random_uniform(eltype(grid))) ./ sqrt(clock.dt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good :-D

Unfortunately you may need different functions for Fh::Array and Fh::CuArray, because you may need to use CUDA.sqrt?

Copy link
Member Author

@navidcy navidcy Apr 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, there are some still some issues which I will fix.

But on the other hand, CUDA.sqrt() wasn't required previously... why it should be now? Even before forcing_spectrum could be a CuArray...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I guess you're right:

julia> using CUDA

julia> a = CuArray(rand(3))
3-element CuArray{Float64,1}:
 0.3974296213138291
 0.46740283369767677
 0.5039702920081996

julia> b = sqrt.(a)
3-element CuArray{Float64,1}:
 0.6304201942465272
 0.6836686578289785
 0.7099086504672272

@navidcy navidcy merged commit eb2df54 into master Apr 13, 2021
@navidcy navidcy deleted the ncc/optimize-stochastic-forcing-calcF branch April 13, 2021 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use CUDA.randn(nx, ny) instead of cu(randn(nx, ny))
2 participants