Skip to content

Instantly share code, notes, and snippets.

View MasonProtter's full-sized avatar

Mason Protter MasonProtter

View GitHub Profile
module Syms
export sym, Sym
#--------------------------------------------------------------------------------
# Set up some symbolic types
#--------------------------------------------------------------------------------
abstract type Symbolic{T} end # Symbolic{T} will act like it is <: T
struct Sym{T} <: Symbolic{T}
name::Symbol
using BenchmarkTools, StaticArrays, Transducers
function _pi_kernel_static()
xs = @SVector rand(50)
ys = @SVector rand(50)
sum(((x, y),) -> x^2 + y^2 < 1.0, zip(xs, ys))
end
function _pi_kernel(r)
xs = rand(r)
ys = rand(r)
using BenchmarkTools
function _pi(x::Vector, y::Vector)
acc = 0
@inbounds @simd for i ∈ eachindex(x)
acc += (x[i]*x[i] + y[i]*y[i]) < 1.0
end
4acc/length(x)
end
using InteractiveUtils, Pkg
for pk in ["Transducers", "LoopVectorization"]
if pk ∉ keys(Pkg.project().dependencies)
Pkg.add(pk)
end
end
using Transducers, LoopVectorization
function picalc_kernel(r, a, b)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.