| creation | isbits type | immutable type | mutable type | array | gpu array | (device) local memory |
|---|---|---|---|---|---|---|
| pass to device | yes, copy | no ptrs, copy | copy | no | by reference | no |
| on device | yes | may contain device ptr | no | no | no | yes |
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
| cd(@__DIR__) | |
| using Makie | |
| using FileIO, GeometryTypes, Colors, GDAL | |
| GDAL.allregister() | |
| istiff(x) = endswith(x, ".tif") | |
| function loadf0(x) | |
| img = GDAL.open(x, GDAL.GA_ReadOnly) | |
| band = GDAL.getrasterband(img, 1) | |
| xsize = GDAL.getrasterbandxsize(band) | |
| ysize = GDAL.getrasterbandysize(band) |
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 Makie | |
| import DiffEqPhysics: SimulationResult | |
| import AbstractPlotting: Plot, default_theme, plot!, to_value | |
| # Probably worth having a macro for this! | |
| function default_theme(scene::SceneLike, ::Type{<: Plot(SimulationResult)}) | |
| Theme( | |
| simulation_index = 1 |
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
| unroll(f, ::Val{1}) = f() | |
| function unroll(f, ::Val{N}) where N | |
| f(); unroll(f, Val(N-1)) | |
| end | |
| function test() | |
| box = Ref(1.0) # explicitely box to make escape analysis easier | |
| unroll(()-> box[] += sin(box[]), Val(3)) | |
| box[] | |
| 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
| using GLVisualize, GeometryTypes, Colors | |
| using GLAbstraction | |
| using Reactive | |
| window = glscreen() | |
| timesignal = bounce(linspace(0f0,1f0,360)) | |
| description = """ | |
| Animated 2D particles in 3D space with glow. | |
| """ |
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 |