This file contains hidden or 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
# 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 |
This file contains hidden or 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 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) |
This file contains hidden or 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 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) |
This file contains hidden or 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 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 |
This file contains hidden or 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
#= | |
# 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 |
This file contains hidden or 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 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 |
This file contains hidden or 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
#https://github.com/hughsk/moire-1/b | |
using GeometryTypes | |
using MakiE, Colors | |
struct Ring | |
movement::Float32 | |
radius::Float32 | |
speed::Float32 | |
spin::Vec2f0 |
This file contains hidden or 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 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) |
This file contains hidden or 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
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 |
This file contains hidden or 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
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" |