This file contains 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
# 2D linear diffusion solver - GPU MPI | |
using Printf | |
using JLD2 | |
using CUDA | |
# include(joinpath(@__DIR__, "../../shared.jl")) | |
include(joinpath(@__DIR__, "shared.jl")) | |
if !isinteger(sqrt(Threads.nthreads())) | |
error("Number of threads must be square, e.g. 4, 9, or 16.") | |
end |
This file contains 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
# 2D linear diffusion solver - MPI | |
using Printf | |
using JLD2 | |
using Base.Threads: @threads | |
using ThreadPinning | |
pinthreads(:cores) | |
# include(joinpath(@__DIR__, "../../shared.jl")) | |
include(joinpath(@__DIR__, "shared.jl")) |
This file contains 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 Test: @test | |
using Base.Threads: nthreads | |
using BenchmarkTools: @btime | |
using OhMyThreads: @tasks, tmap!, tmapreduce, chunks | |
using ThreadPinning | |
pinthreads(:cores) | |
# naive, math implementation | |
function matvec_row!(y, A, x) | |
fill!(y, zero(length(y))) |
This file contains 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
# Equations: | |
# ∂P/∂t = -k(∂Vx/∂x + ∂Vy/∂y) | |
# ∂Vx/∂t = -1/ρ ∂P/∂x | |
# ∂Vy/∂t = -1/ρ ∂P/∂y | |
# => Update rules: | |
# Vx = Vx - Δt/ρ ΔP/Δx | |
# Vy = Vy - Δt/ρ ΔP/Δy | |
# P = P - Δt*k (Δ(Vx)/Δx + Δ(Vy)/Δy) |
This file contains 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
function run_experiment(N; saverate=1) | |
hits = 0 | |
dist = Uniform(-1,1) | |
is = Int64[] | |
pis = Float64[] | |
for i in 1:N | |
x, y = rand(dist), rand(dist) | |
# speed-up computation by omiting sqrt | |
if (x^2 + y^2) <= 1 |
This file contains 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
function pi_animation() | |
N = 1000 | |
Random.seed!(123) | |
# setup figure | |
f = Figure(resolution = (1000,400)) | |
dart_fig = f[1,1] | |
dart_ax = Axis(dart_fig, aspect=1, title="Monte-Carlo-Simulation") | |
approx_fig = f[1,2] | |
approx_ax = Axis(approx_fig, title="Quality of Approximation") |
This file contains 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
julia> function vector_dot(B, C) | |
a = zero(eltype(B)) | |
for i in eachindex(B,C) | |
@inbounds a += B[i] * C[i] | |
end | |
return a | |
end | |
vector_dot (generic function with 1 method) | |
julia> function vector_dot_macro(B, C) |
This file contains 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 DelimitedFiles | |
using LinearAlgebra | |
using Test | |
function readqcd(fname::AbstractString; verify=true) | |
open(fname, "r") do f | |
header_str = readuntil(f, "END_HEADER\n") | |
header_mat = readdlm(IOBuffer(header_str), '=') | |
header = Dict(strip(header_mat[i, 1]) => header_mat[i, 2] for i in 2:size(header_mat, 1)) |
This file contains 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 CUDA | |
using BenchmarkTools | |
using Statistics | |
using UnicodePlots | |
# bandwidth test | |
abstract type BytesSIPrefixed end | |
struct B <: BytesSIPrefixed | |
value::Int64 | |
end |
This file contains 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
# This file is machine-generated - editing it directly is not advised | |
julia_version = "1.7.1" | |
manifest_format = "2.0" | |
[[deps.ArgTools]] | |
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" | |
[[deps.Artifacts]] | |
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" |
NewerOlder