Showing posts with label experiment. Show all posts
Showing posts with label experiment. Show all posts

Wednesday, 3 April 2013

Spring updates, RU invades the GPU

Spring has come! (for most at least, Sweden is actually a bit behind). So here's some spring news:

Firstly, I've updated the stochastic optimization framework. The plugin system is now fully functional - yes, you can pack your favourite algorithm into a .jar, drop it in the plug-ins folder and see how it performs. The usual bug fixes here and there also come with this update.

Secondly, I've updated and shared Particle48 on github. It's a particle systems library (for JS & the HTML5 canvas) I made a while ago for use at LD events (and I've actually used it in Homo Vermes). I expect to update it before every LD compo and add new types of particles. If I get fellow ludumers to contribute, things will really start rolling.

And last but not least, OCLEx got 2 new additions: 1. a simple demo to the bundle to show how to set things up to start doing some image manipulation on the GPU and 2. RU on the GPU - this basically means that every Executor is a separate "process" running on the GPU and doing its duty. It started as an experiment to see how one would simulate a MIMD architecture in a SIMD environment and then got disguised in a nice RU uniform. Early OpenCL capable video cards have terrible performance penalties if the kernels are not executing the same instruction. This is a big bummer if you have any sorts of branches in the kernels. With this simulation you don't get any performance penalties (everything runs slower, but it's independent of the instructions the kernels are executing). I'll come back with more details after I do some more work and prettify it. In the mean time you can find it here.

The screenshot looks like that not because it's a work in progress but because it uses the GL_UGLY texture filter.

Sunday, 7 October 2012

OpenCL Experiments

While there are many applications (not necessarily scientific ones) for OpenCL and the technology has been available for some years, I have yet to see any piece of software that took advantage of this. There aren't even many tutorials and books on OpenCL. Now, I'm no expert but I thought I could make some OpenCL demos and share them on Github. Here's what I have so far:

  • Simulation of repulsive particles - similar to the n-body problem, except here all particles want to stay apart and all particles are attracted to just one. This makes them chase each other which results in some neat patterns and dynamics.
  • Hillclimbing! - the hillclimbing algorithm is a very simple stochastic optimization algorithm. The algorithm can be described as follows: a dwarf is placed in the search space (the hills). The dwarf chooses a random direction and goes that way as long as he keeps climbing, after which he chooses another direction and does that until he's on top of the hill. Obviously the hillclimbing algorithm is prone to getting stuck in local maxima, but that's where OpenCL comes in to save us: initialize N parallel hill climbers (dwarves) from random positions in the search space. Thus, we get N local maxima, one of which is the global maxima (hopefully).
  • Particle Swarm Optimization (actually Parallel Asynchronous PSO) - I've already covered PSO in this online demo and extensively in my Bachelor's graduation thesis and Gloptat. PAPSO is more suitable for the GPU since synchronizing "threads" is costly. There is also no clear disadvantage in using asynchronous PSO and there are even scientific studies that show how reliable PAPSO is. PAPSO is even closer to what it simulates, to the natural model.
  • Shadow demo - it's just a little demo showing a simple way to compute shadows using rays. It also shows how you can have more than one kernel on the same context/queue and that they can use the same allocated global memory without issues.

Saturday, 22 October 2011

Update: Bezier curves

I have just updated the Bezier curves demo.
--> http://madflame991.blogspot.com/p/bezier-curves.html

It's now prettier and the control points are easier to adjust.

Wednesday, 12 October 2011

Penrose polygons


Number of sides:

Sunday, 25 September 2011

Saturday, 17 September 2011

Graph.addPhysics()


I've been wanting for a long long time to make this but never got the chance
It is supposed to draw a graph, but fails to settle down sometimes and starts acting like an ameoba

Edge list



Write one edge per line

Ex:
0 1 (edge between nodes 0 and 1)
1 2 (edge between nodes 1 and 2)
2 0 (edge between nodes 2 and 0)

Friday, 29 July 2011

Update: Tree.dance()

Your browser does not support the canvas element.

Split sequence
Colors
Split angle attenuator [0.7..1.5]
Split angle mul [0.2..0.9] Split angle bias [0.2..0.9]
Length attenuator [0.4..1.2]
Length mul [0..80] Length bias [90..180]

Tuesday, 21 June 2011

3D.engage()

Your browser does not support the canvas element.

Wednesday, 23 February 2011

Text.grow()


Your browser does not support the canvas element.


Tuesday, 22 February 2011

The new cube


Your browser does not support the canvas element.



Sunday, 6 February 2011

Bezier curves

See the newer and updated version here --> http://madflame991.blogspot.com/p/bezier-curves.html


Your browser does not support the canvas element.



Bezier 0.6

+ click on an empty zone to spawn a point
+ click on a point to select it and click again to designate its new location
+ doubleclick on a point to delete it

For more information on Bezier curves check:
http://en.wikipedia.org/wiki/B%C3%A9zier_curve
http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/Bezier/bezier-elev.html

Sunday, 10 October 2010

The Cube!

That spinning cube in the sidebar was made in only 3 hours by a total beginner in JavaScript/HTML5. I made it just to see how powerful the canvas element is and it surely convinced me.