These are our stories of sailing across the Pacific, to inspire your own adventures. You may even find some useful tidbits of technical information to help you avoid our mistakes.
Monday, January 12, 2015
End of the Line
Monday, April 29, 2013
Pyopencl (GPU) vs Numpy (CPU) Performance Comparison
So numpy must be well-optimized. I tried optimizing my GPU kernel by minimizing array index lookups, etc, but nothing I came up with made a significant difference for this simple kernel. Both the CPU and GPU gave exactly the same answer, so that's nice.
Here's the output with execution times...
GPU execution time: 0.0115399 CPU execution time: 2.7895e-05 CPU/GPU speed ratio for 10^0 kernel executions: 0.241726% Difference between the 2 answers: 0.0 GPU execution time: 0.0115771 CPU execution time: 2.19345e-05 CPU/GPU speed ratio for 10^1 kernel executions: 0.189464% Difference between the 2 answers: 0.0 GPU execution time: 0.0116088 CPU execution time: 2.19345e-05 CPU/GPU speed ratio for 10^2 kernel executions: 0.188947% Difference between the 2 answers: 0.0 GPU execution time: 0.0115681 CPU execution time: 2.59876e-05 CPU/GPU speed ratio for 10^3 kernel executions: 0.22465% Difference between the 2 answers: 0.0 GPU execution time: 0.011663 CPU execution time: 7.70092e-05 CPU/GPU speed ratio for 10^4 kernel executions: 0.660289% Difference between the 2 answers: 0.0 GPU execution time: 0.023535 CPU execution time: 0.000612974 CPU/GPU speed ratio for 10^5 kernel executions: 2.60452% Difference between the 2 answers: 0.0 GPU execution time: 0.0234549 CPU execution time: 0.0182121 CPU/GPU speed ratio for 10^6 kernel executions: 77.6472% Difference between the 2 answers: 0.0 GPU execution time: 0.0668991 CPU execution time: 0.240016 CPU/GPU speed ratio for 10^7 kernel executions: 358.773% Difference between the 2 answers: 0.0 GPU execution time: 0.567215 CPU execution time: 2.24371 CPU/GPU speed ratio for 10^8 kernel executions: 395.566% Difference between the 2 answers: 0.0With cgminer running at -I 9 on all the GPUs, the speed advantage for a GPU doesn't budge, significantly. So pyopencl is pretty effective at interrupting cgminer and prioritizing its threads.GPU execution time: 0.179582 CPU execution time: 2.7895e-05 CPU/GPU speed ratio for 10^0 kernel executions: 0.0155333% Difference between the 2 answers: 0.0 GPU execution time: 0.263615 CPU execution time: 2.31266e-05 CPU/GPU speed ratio for 10^1 kernel executions: 0.00877287% Difference between the 2 answers: 0.0 GPU execution time: 0.263666 CPU execution time: 2.40803e-05 CPU/GPU speed ratio for 10^2 kernel executions: 0.00913287% Difference between the 2 answers: 0.0 GPU execution time: 0.011616 CPU execution time: 2.81334e-05 CPU/GPU speed ratio for 10^3 kernel executions: 0.242195% Difference between the 2 answers: 0.0 GPU execution time: 0.0116951 CPU execution time: 7.60555e-05 CPU/GPU speed ratio for 10^4 kernel executions: 0.650317% Difference between the 2 answers: 0.0 GPU execution time: 0.023536 CPU execution time: 0.000617981 CPU/GPU speed ratio for 10^5 kernel executions: 2.62569% Difference between the 2 answers: 0.0 GPU execution time: 0.0236619 CPU execution time: 0.0189419 CPU/GPU speed ratio for 10^6 kernel executions: 80.0524% Difference between the 2 answers: 0.0 GPU execution time: 0.0630081 CPU execution time: 0.230431 CPU/GPU speed ratio for 10^7 kernel executions: 365.717% Difference between the 2 answers: 0.0 GPU execution time: 0.82972 CPU execution time: 2.4491 CPU/GPU speed ratio for 10^8 kernel executions: 295.172% Difference between the 2 answers: 0.0Installation was a bit tricky. You have to make sure setuptools is overriden by distribute. But Ubuntu 12.04 makes this easy. Thanks to kermit666 on SO for this simple approach to getting virtualenv wrapper and numpy up and running quickly on a fresh Ubuntu install.#!/usr/bin/env sh sudo apt-get install python-pip python-dev sudo pip install virtualenv virtualenvwrapper echo 'export PROJECT_HOME="$HOME/src"' >> $HOME/.bashrc echo 'export WORKON_HOME="$HOME/.virtualenvs"' >> $HOME/.bashrc echo 'source /usr/local/bin/virtualenvwrapper.sh' >> $HOME/.bashrc sudo apt-get install -y gfortran g++ # sudo apt-get remove -y --purge python-setuptools # start a new virtalenv project mkproject parallel pip install --upgrade distribute pip install mako numpy pyopencl
Here's the python code that ran the kernel and measured execution time. It's based on the official pyopencl example ...
import pyopencl as cl import numpy import numpy.linalg as la import time for M in range(0, 8): N = 10**M * 1000 a = numpy.random.rand(N).astype(numpy.float32) b = numpy.random.rand(N).astype(numpy.float32) ctx = cl.create_some_context() queue = cl.CommandQueue(ctx) mf = cl.mem_flags a_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=a) b_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=b) dest_buf = cl.Buffer(ctx, mf.WRITE_ONLY, b.nbytes) prg = cl.Program(ctx, """ __kernel void sum(__global const float *a, __global const float *b, __global float *c) { float a2 = a[gid]; float b2 = b[gid]; c[gid] = a2 * a2 + b2 * b2; } """).build() prg.sum(queue, a.shape, None, a_buf, b_buf, dest_buf) gpu_ans = numpy.empty_like(a) gpu_t0 = time.time() cl.enqueue_copy(queue, gpu_ans, dest_buf) gpu_t = time.time() - gpu_t0 print 'GPU execution time: %g' % gpu_t cpu_ans = numpy.empty_like(a) cpu_t0 = time.time() cpu_ans = a * a + b * b cpu_t = time.time() - cpu_t0 print 'CPU execution time: %g' % cpu_t print 'CPU/GPU difference in speed for %d additions: %g%% ' % (N, 200.0 * cpu_t / (gpu_t + cpu_t)) print 'Difference between the 2 answers:' print la.norm(cpu_ans - gpu_ans)
Monday, April 1, 2013
Bitcoin's Easter Sunday
Saturday, June 9, 2012
The 2nd Great Depression is Here -- and that's Good News for the Smart
I love this FT series on the economics and politics of deflation and recession.
http://ftalphaville.ft.com/blog/2012/06/08/1030801/the-end-of-artificial-scarcity/
Near as I can tell FT is saying "don't worry, be happy." Fortunately smart people worry and we are a social animal. Pack social dynmics are ushering in an era when national governments are no longer relevant to our material happiness. Barring WWIII, smart people will continue to band together into clubs, clans, coops. Just wander around Portland for a day. They barter within a web of trust, set up insurance pools, loan each other money--even mint their own fiat currencies (bitcoin) or fund grand scientific and space adventures. These pockets of stability and hope will thrive while the rest of us decide which "Like" buttons to click.
Thursday, April 26, 2012
Gardening
Thursday, April 19, 2012
Irregularly Sampled Time-Series
But markets aren't physical systems that can be probed with pure sinusoid inputs. Instead, it seems to me, your best bet is to think in terms of volumetric spans rather than time spans. Or even better, just in terms of transaction counts. What matters is how far the price moved between trades, not between days, hours or microseconds. How many different people or groups of people or computer algorithms decided to adjust their price and by how much? That's a fair gage of the "temperature" or "pressure" of the thermodynamics of the market. Of course with electronic exchanges facilitating HFT, these independent actors are getting parsed into the tiniest little chunks. So volumetric measures may be even better. That helps get over the fractal nature of the markets. In the end, even a fractal has a volume, as least it's projection in 3-space does. Hopefully the same concept makes sense for the markets, because that's the path we're crawling down with bitcrawl.
But time is money, so eventually we'll have to do the conversion back to real time, based on some average trade frequency or volume rate for a given instrument. But my guess is we'll discover a lot of hidden dynamics lurking in volumetric and transaction-count space. I hope I can find a market to give me this level of detail.Bitfloor is all I've got right now, without succumbing to the price-gouging of Bloomberg or other financial services, or public exchanges.
Towing?
Wednesday, April 18, 2012
Pirate Skipper and His Cursed Companion
Thursday, April 5, 2012
Mosque Dome
Sunday, April 1, 2012
Malaysia Power
Wednesday, February 29, 2012
Malaysian Cutlure
The other two photos show how Malaysians and Filipinos dry fish in the sun covered with salt, to preserve them for selling at the market or eating at home. Ice doesn't last long in the tropics and most of the locals, especially in the water villages where the fishermen live, don't have a refrigerator or ice. And they tap into electrical power from street lights nearby without paying taxes or utility bills, since technically they live on the water (swamps, reefs, and ditches near the city) where you can't own the "land".
Friday, February 10, 2012
The End of Illness
Monday, January 2, 2012
Building bitcoin-qt from source on Ubuntu 11.10 Oneiric
bitcoin-qt (the "official" bitcoin GUI).
git clone https://github.com/bitcoin/bitcoin
cd bitcoin
sudo aptitude install bitcoind qt4-qmake libqt4-dev build-essential
libboost-dev libboost-system-dev libboost-filesystem-dev
libboost-program-options-dev libboost-thread-dev libssl-dev
libdb4.8++-dev libminiupnpc-dev
qmake USE_DBUS=1 USE_UPNP=0
make
# then to run the executable gui
bitcoin-qt
Saturday, December 24, 2011
Solar Panel "Breakthrough"
http://en.wikipedia.org/wiki/Quantum_dot#Photovoltaic_devices
Conventional solar panels already acheive 100% MEG, so 114% represents a minor improvement in quantum efficiency. Only when it reaches 700% MEG (the theoretical maximum, according to wikipedia) will it make any real difference for solar panels. And even then it will only bring up the total efficiency of a panel from about 30% (where we are now) to about 35%, which would have a negligible impact on the total cost per kWhr of electricity. So this "doctor" that wrote the article is just hyping it because he's got nothing else to talk about in his newsletter today. Same for me, I guess...
A Trade War May Scuttle This Huge
Solar Breakthrough
by Dr. Kent Moors
Tuesday, November 8, 2011
Great Jobs Site for Software Developers -- Stack Overflow Careers 2.0
http://bit.ly/sUxwGK
Sunday, November 6, 2011
ML-Class Insight into Neural Networks
Tuesday, November 1, 2011
FedEx Contributing to the Greater Bad
FedEx and UPS pricing seems to be based on the extortion principle--never set your ransom so high as to incite revenge or law enforcement involvment. And always set it just within the means of your "customer." By making the total cost impact 50 to 150% of the shipped item cost, they can be pretty sure that a desperate customer will pay the exorbitant fees. The worst part is, that most of that money, caused by FedEx "total bad" goes to corrupt political bureaucracies and FedEx call center employee salaries rather than the pockets of the selfish executives that put those policies in place. And FedEx guessed wrong with me. My sense of fairness has inspired me to share my displeasure at their extortion as widely as possible. If I can just make the negative publicity cost them a few customers that will be enough to right the wrong and turn this into a "total good", nudging business and cultural evolution to produce a more well-adapted global shipping business. Fortunately the solution is easy for anyone wanting to avoid FedEx and UPS extortion for packages from the US... ship through the USPS. Though packages typically take more than two weeks when shipped by USPS, they arrive without hassle or phone calls at your doorstep (or marina mailbox), and without any hidden fees or duties to be paid. I wonder if DHL offers similar "total-good" service if you are willing to jump through the hoops required to set up a business account with them. In the end, this "Priority Express" package from FedEx is going to take more than a week to come to me around the world, and it's still hung up in their bureaucracy right now. So USPS would have been faster. Now if I can just convince the major marine parts distributors to accept a "non-preferred" shipper as my preferred delivery option, then we'd be in business. But that's a corporate collusion and market manipulation topic for another post.
So whenever possible use usps.com and avoid fedex.com.
Sunday, October 30, 2011
Ubuntu 11.10 Oneiric Tweaks
Today's Ubuntu tweaks were to get my desktop background shuffling script to run at startup.
For example to get firefox to launch at startup usesudo cp /usr/share/applications/firefox.desktop /etc/xdg/autostart(thanks http://www.liberiangeek.net/2011/09/automatically-startup-applications-for-all-users-in-ubuntu-11-10/)
So I created a desktop file in /etc/xdg/autostart:
[Desktop Entry]
Name=Background Image Shuffler
Comment=Periodically change the desktop background image
#Icon=
Exec=python /home/hobs/bin/looping_shuffle_background_photo.py
#Terminal=true
#NoDisplay=true
Type=Application
Categories=
OnlyShowIn=GNOME;
X-GNOME-Autostart-Delay=90
X-Ubuntu-Gettext-Domain=looping_shuffle_background_photo
Also I liked this gnome tweaking suggestion
sudo apt-get install gnome-tweak-tool(thanks http://www.webupd8.org/2011/10/things-to-tweak-after-installing-ubuntu.html)
Thursday, October 27, 2011
Craig's List in Malaysia
http://malaysia.craigslist.org/reo/2671113694.html
Now that we're starting to get a diversity of listings at brokerages, want-ads, and cruising forums, it will be interesting to compare the response rate at each. Still not much traffic at our own site:
http://totalgood.com/australis/
Google Does Evil
We techie lemmings were a disappointment when we killed Palm OS by "upgrading" to iPhones, Windows Smartphones, and Android. Palm was the most elegant, efficient OS I've ever used (and I've passionately explored nearly every imaginable OS from the beginning--Amiga, TRS-80 "CoCo", Apple IIe, Mac, Sun, Linux, DOS, Windows CE, Windows 3.1/XP/Vista/etc.
I still look longingly at my wife's ancient Treo and admire the ease with which she retrieved the most obscure bit of information from her tiny little "brain" (the Palm, not her massively intelligent real brain). I used to be that guy too, the guy you could ask anything about anyone, and he'd tell you in an instant. I could tell you in 1 minute everything I knew about anyone I'd ever met. I'd sync up my palm daily (or more) with lots of offline text data gleaned from corporate servers and my own random thoughts.
I was sure the king of search would eventually do a bang-up job with the Android magnifying glass search button. But it seems to have opted for the short-term buck--using the search button to route users through their online services. What happened to efficiently indexing and searching private, local data, **MY** data -- not **YOUR** user profiling data. I used to be able to find people based on partial birthdays, telephone numbers, badge numbers, you name it. Now I have to remember their name--not any nicknames, or memory crutches like "bald" or "wears glasses", but their full name. Not even their first name will do, because "John" turns up 100's of people I've met in my life and recorded some detail about.
I will spend my last bit of spare coding brainpower supporting open-source alternatives to Google desktop and similar knowledge indexing. Cloud, schmloud. I just want my brain back, the part that is embedded in a Palm Pilot, buried in a landfill somewhere.