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

CUDA #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

CUDA #6

wants to merge 2 commits into from

Conversation

fgerick
Copy link
Owner

@fgerick fgerick commented Nov 17, 2024

Following #5 this implements the CUDA transforms. Here is a preliminary example, using a cuda compiled SHTns library:

import Pkg; Pkg.activate(@__DIR__)
using Revise

ENV["SHTNS_PATH"] = "/home/eh/gerickf/programs/shtns/libshtns_cuda.so"
using CUDA
using SHTns

function spat_func_test(theta, phi)
    return 1.0 + 0.01*cos(theta)  + 0.1*(3cos(theta)*cos(theta) - 1.0) +	#// Y00, Y10, Y20
    (cos(phi) + 0.3*sin(phi)) * sin(theta)	+ #// Y11
    (cos(2phi) + 0.1*sin(2phi)) * sin(theta)*sin(theta) * (7.0* cos(theta)*cos(theta) - 1.0) * 3/8 	#// Y42
end

nlat, nphi, lmax = 512,1024,7

cfg_gpu = SHTnsCfg(lmax, 3, 1, nlat, nphi; shtype=SHTns.QuickInit(; gpu=true, contiguous_lat = true, contiguous_phi=false, padding=false, float32=false) )
cfg_cpu = SHTnsCfg(lmax, 3, 1, nlat, nphi; shtype=SHTns.QuickInit(; gpu=false, contiguous_lat = true, contiguous_phi=false, padding=false) )

θ,ϕ = SHTns.grid(cfg_cpu)

d = spat_func_test.(θ,ϕ')
q = SHTns.analys(cfg_cpu, d)

dg = CuArray(zero(d))
qg = CuArray(q)

SHTns.synth!(cfg_gpu, qg, dg)

Array(dg)  d #true

SHTns.analys!(cfg_gpu, dg, qg)

Array(qg)  q #true

SHTns.synth!(cfg_cpu, qg, dg) #throws assertion error, need to define SHTnsCfg with shtype with gpu=true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant