Skip to content

Instantly share code, notes, and snippets.

View SimonDanisch's full-sized avatar
🏠
Working from home

Simon SimonDanisch

🏠
Working from home
View GitHub Profile
# Modular pass manager:
context = ExecutionContext()
# adds a predefined function from Sugar as a pass.
# this one takes care of e.g.:
# * turning Expr(:invoke, args...) into Expr(:call, args...)
# * removes apply_type
# * turn all functions into GlobalRef
# * etc
using Gtk, GLWindow, GLAbstraction, Reactive, GeometryTypes, Colors, GLVisualize
using GtkReactive
using Gtk.GConstants, ModernGL
mutable struct GtkContext <: GLWindow.AbstractContext
window::Gtk.GLArea
framebuffer::GLWindow.GLFramebuffer
end
function make_context_current(screen::Screen)
function getop(op)
op == :inc && return +
op == :dec && return -
eval(Base, op)
end
function eval_instr(instr, vars)
lhs, op, rhs = split(instr, " ")
slhs = Symbol(lhs)
val1 = get!(vars, slhs, 0)
val2 = parse(Int, rhs)
using GeometryTypes, Makie
include("noise.jl") #https://gist.github.com/SimonDanisch/89779b923d77a4ecdf61246cbe24611b#file-noise4-jl
# inspired by https://github.com/rougier/alien-life
resolution = (1000, 1000)
scene = Scene(resolution = resolution)
n = 60_000
#=
# Perlin noise ported from: https://github.com/caseman/noise
# with the license:
Copyright (c) 2008 Casey Duncan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
function find_jl_files(dir, files = String[])
for file in readdir(dir)
path = joinpath(dir, file)
if endswith(path, ".jl")
push!(files, path)
elseif isdir(path)
find_jl_files(path, files)
end
end
files
#https://github.com/hughsk/moire-1/b
using GeometryTypes
using MakiE, Colors
struct Ring
movement::Float32
radius::Float32
speed::Float32
spin::Vec2f0
using CLArrays
Wx = CLArray(rand(100))
y = CLArray(rand(100))
b = CLArray(rand(100))
σ(x) = 1 / (1 + exp(-x))
# this will get fused to a single kernel call:
y .= σ.(Wx .+ b)
import CLBLAS # The low-level Julia CLBLAS C wrapper
GPUArrays.blas_module(A::CLArray) = CLBLAS
function GPUArrays.blasbuffer(A::CLArray)
cl.CLArray(clbuffer(A), global_queue(A), size(A))
end
names_gpu = CLArray(FixedString{12}[
"Egon", "Hugo", "Frederick", "Franz"
])
julia> replace_with(names_gpu, "Egon", "Lorenz")
GPU: 4-element Array{FixedString{12},1}:
"Lorenz"
"Hugo"
"Frederick"
"Franz"