Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
roflmaostc committed Feb 10, 2024
1 parent 2a59bcf commit 1c5e4e3
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 137 deletions.
36 changes: 26 additions & 10 deletions examples/0_example_radon_backproject.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,35 @@ using RadonKA
using IndexFunArrays, ImageShow, Plots, ImageIO, PlutoUI, PlutoTest, TestImages

# ╔═╡ 03bccb92-b47f-477a-9bdb-74cc404da690
using KernelAbstractions, CUDA, CUDA.CUDAKernels
using CUDA

# ╔═╡ 6f6c8d28-5a54-440e-9b7a-52e1fce959ab
md"# Activate example environment"

# ╔═╡ f5e2024b-deaf-4344-b610-a4b956abbfaa
md"# Load CUDA
In case you have no CUDA card available, it will run on CPU :)
md"# Load packages
On the first run, Julia is going to install some packages automatically. So start this notebook and give it some minutes to install all packages.
No worries, any future runs will be much faster to start!
"

# ╔═╡ ef92457a-87c0-43bf-a046-9fe82afbbe13
begin
use_CUDA = Ref(true && CUDA.functional())
var"@mytime" = use_CUDA[] ? CUDA.var"@time" : var"@time"
"""
togoc(x)
Stands for "to GPU or CPU". In case you have a GPU, it moves the array to the GPU.
In case CUDA is runable, it will just leave it on the CPU
"""
togoc(x) = use_CUDA[] ? CuArray(x) : x
end

# ╔═╡ f5e2024b-deaf-4344-b610-a4b956abbfaa
md""" ## CUDA
Thanks to Julia multiple dispatch and [CUDA.jl](https://github.com/JuliaGPU/CUDA.jl) our code can run on CUDA GPUs.
Big reconstructions can run 5-20 times faster on a CUDA GPU!
Your CUDA is functional: **$(use_CUDA[])**
"""

# ╔═╡ 810aebe4-2c6e-4ba6-916b-9e4306df33c9
TableOfContents()

Expand Down Expand Up @@ -135,25 +147,28 @@ simshow(Array(filtered_bproj[:, :, i_z4]))
# ╔═╡ a29be556-174a-4ec5-962d-9fdf203d51aa
backproject Array(backproject_cu)

# ╔═╡ fd2bab7a-7ef6-42aa-bcb5-2a52bffc61db


# ╔═╡ Cell order:
# ╠═6f6c8d28-5a54-440e-9b7a-52e1fce959ab
# ╟─6f6c8d28-5a54-440e-9b7a-52e1fce959ab
# ╠═4eb3148e-8f8b-11ee-3cfe-854d3bd5cc80
# ╠═b336e55e-0be4-422f-b48a-0a2242cb0915
# ╠═1311e853-c4cd-42bb-8bf3-5e0d564bf9c5
# ╟─f5e2024b-deaf-4344-b610-a4b956abbfaa
# ╠═03bccb92-b47f-477a-9bdb-74cc404da690
# ╠═ef92457a-87c0-43bf-a046-9fe82afbbe13
# ╟─ef92457a-87c0-43bf-a046-9fe82afbbe13
# ╟─810aebe4-2c6e-4ba6-916b-9e4306df33c9
# ╟─d25c1381-baf1-429b-8150-622b8f731d83
# ╠═54208d78-cf55-41d7-b4bf-6d1ab4927bbb
# ╠═1393d029-66be-40aa-a2f9-f31317222575
# ╠═01b4b8f8-37d5-425f-975e-ebb3890d8624
# ╟─01b4b8f8-37d5-425f-975e-ebb3890d8624
# ╟─8be220a4-293d-411d-bbce-e39b64780814
# ╠═b8618268-0892-4abc-ae26-e25e41d07968
# ╠═135e728b-efd8-44bc-81d9-6a2244ce4c31
# ╠═d2cc6fc6-135b-4c4a-8453-9c5bf9e4a24f
# ╠═dc14103d-993c-402f-a8b5-a35843f3f4ac
# ╠═783f05e0-2640-4ecd-8c19-1c15a99ee294
# ╟─783f05e0-2640-4ecd-8c19-1c15a99ee294
# ╠═db2676fd-3305-408f-93b4-08a3d04fdd02
# ╠═1a931e03-6a29-4c3e-b66f-bc1b5936a6f4
# ╠═3d584d94-b88f-4738-a470-7db1fb3fb996
Expand All @@ -169,3 +184,4 @@ backproject ≈ Array(backproject_cu)
# ╟─bc6e2d40-fcd1-4d7b-8f96-3d4d9e4336de
# ╠═eee184e3-8d5d-42fb-81fb-a5d7e59a083a
# ╠═a29be556-174a-4ec5-962d-9fdf203d51aa
# ╠═fd2bab7a-7ef6-42aa-bcb5-2a52bffc61db

0 comments on commit 1c5e4e3

Please sign in to comment.