Tag Archives: GPU

SIGGRAPH 2012: Mobile, OpenGL 4.3 and Python

I recently had the opportunity to attend SIGGRAPH in LA. For those of you who don’t know, SIGGRAPH is an annual conference for Graphics and Visualization that does a great job of attracting people from both the scientific and artistic halves of the visualization community. For broader coverage, you can read some of the usual blog coverage here. I was particularly interested, however, in the OpenGL developments.

Increased focus on performance/watt for mobile applications

SIGGRAPH 2012 was important for many reasons, but particularly for those of us that use OpenGL (this year was the 20th anniversary of the OpenGL API). OpenGL 4.3 and OpenGL ES 3.0 were announced and there were many interesting sessions on the new OpenGL release (more about this later) and graphics on mobile devices.

The rapid ascent of mobile and its dominance as the primary computer that people interact with on a daily basis has opened up an interesting challenge for people designing games and visualization — the difference in the power envelope between mobile devices and their desktop brethren. The power envelope of high-end desktop devices is ~300 watt while the power envelope of mobile gpu’s is < 1 watt. This power disparity implies a massive gulf in performance across the full spectrum of devices, assuming similar architectures are in use.

Multiple speakers stressed that power consumption should be a first class design metric when designing graphics algorithms along with the traditional metric of performance. Currently, the tools for profiling and measuring power consumption of algorithms are almost non-existent and nowhere near the sophistication of tools for measuring performance. Nevertheless, data transfers over a bus were recognized as an expensive power activity and a place where power savings can be realized.

To this end, OpenGL (finally) announced new texture compression formats that are royalty free, work on both OpenGL and OpenGL ES and are guaranteed on all compliant OpenGL implementations. This is great for developers since we can finally assume that this functionality will be available across all devices. More information about the new texture compression formats lives here.

Using OpenGL 4.3 from Python: Rabbit of Caerbannog

The OpenGL ARB committee started an effort to modernise OpenGL around OpenGL 3.x and large parts of the old fixed pipeline functionality was deprecated. These changes were great from a driver implementors point of view and should allow developers to write code that runs faster on modern GPU’s. However the deprecations have obsoleted much of the OpenGL tutorials that exist on the internet. I have listed two examples here which do not use deprecated functionality and can be used as a starting point to write modern OpenGL graphics examples in Python.

So, how do you use the brand spanking new 4.3 api’s from Python? I’ve written a code sample that uses modern opengl (no deprecated functionality used) to draw a triangle from Python.

Opengl display output showing a colored triangle

Triangle drawn using modern opengl and Python

For the code please refer to https://gist.github.com/3494203

For fun, here’s a screenshot of Stanford bunny drawn using modern OpenGL –

Stanford bunny drawn using modern OpenGL and python

Stanford bunny drawn using modern OpenGL and python

For the code please refer to  https://gist.github.com/3494560


  1. Right now only Nvidia has Opengl 4.3 drivers available
  2. OSX only supports Opengl versions upto 3.2 as of today
  3. You will require a trunk release of PyOpenGL to create a OpenGL 4.3 context
  4. Code for the examples can be obtained from https://github.com/enthought/glfwpy.git
  5. I have conservatively marked the OpenGL version as 3.2 here since many readers will not have 4.3 working on their machines. To enable OpenGL 4.3 change the OpenWindowHint call for OPENGL_VERSION_MAJOR to 4 and the OpenWindowHint call for OPENGL_VERSION_MINOR to 3.

Clyther Pygotham Talk

Here is a screencast of the Clyther talk at Pygotham. Clyther is an open source project, along the lines of Cython, that allows users to program a GPU with Python via a JIT OpenCL engine. Unfortunately, the multiple monitor setup resulted in some odd aspect ratio’s. Nevertheless, the content has been captured for posterity. You can find the github page here. Enjoy!

GPU-palooza: May 21, NYC

Enthought is proud to sponsor the NYC HPC-GPU Supercomputing meetup on May 21st, 2012. This meeting will focus on the GPU and Python (what else?).

A happy coincidence brings together three GPU wise men at this meetup. Andreas Klockner is the author of PyCUDA and PyOpenCL. Nicolas Pinto comes to us via MIT with an extensive background in machine learning/GPU-related research. Last but not least, Enthought’s own Sean Ross Ross will share the latest on OpenCL and CLyther.

It promises to be a GPU-accelerated night! The room is filled to capacity I believe, but it’s not uncommon for people to get off the waiting list.

Please come by and say hello!

PyGotham Sneak Peek: GPU Computing

This week, we are highlighting GPUs. Sean Ross Ross has put together a brief sneak peek screencast (above) of his GPU computing PyGotham talk that covers some basic terminology and a short example. The example ports a python/numpy algorithm to the GPU via CLyther. CLyther offers a higher level of abstraction that allows programmers to more easily leverage OpenCL and GPUs from Python. Again, don’t worry if some of the terminology is not defined, that’s what the talk is for! And in case you missed it, go ahead and check out last week’s Portable Parallel Python sneak peek.

Although new advances out of Intel, AMD, and Nvidia promise more seamless interaction between CPUs and GPUs, for the time being CUDA and OpenCL dominate the landscape. The learning curve associated with these technologies can make it a challenge to make effective use of your GPU assets. Sean will introduce you to heterogeneous computing, particularly with OpenCL, and show you how CLyther can help simplify your GPU life.

PyGotham Sneak Peek: The Three “P’s”

As we announced last week, Enthought is sponsoring an open-source High Performance Python track at PyGotham this year. The video above is meant to give you a sneak peek at the Parallel Python class. Please remember that the class will cover a broader array of topics (as described below), so don’t worry if you aren’t familiar with MPI as discussed in the video.

The talk itself will offer advice every developer should know for writing effective parallel python. Many of the examples you find on parallel python focus on the mechanics of getting parallel infrastructure working with your code, and not on actually building good Portable Parallel Python (the 3 P’s!). This talk is intended to be a broad introduction that is well suited to both the beginner and the veteran developer.

For example:

  1. Leverage existing code wherever possible. Most likely someone has solved a subset of your problem and it was probably their primary interest. As such, their code is probably better optimized for performance within their defined scope than your code will be. Use the standards: numpy, scipy, etc. Don’t do anything fancy unless its absolutely necessary.
  2. Build efficient models. Evolve code from for-loops to list comprehensions and generator comprehensions to numpy and cython.
  3. Optimize your code for speed and memory performance using profilers.
  4. Keep the minimum set of information you need at hand at all times. Whatever you do, don’t trap a piece of necessary information in a dark corner of your code. The rediscovery of information is very expensive.
  5. Separate the consumer and producer of information from the communication mechanism. Build simple-as-possible data structures, using or deriving from basic types. Use function-based operations on a data type or to map between data types. Keep any diagnostic and monitoring tools separate from your data and functions. Good design here can increase the parallel nature of your code significantly.
  6. Learn the different parallel communication technologies (multiprocessing, MPI, zmq, GPU, cloud, …) and use parallel map and/or map-reduce.
  7. Stay name space aware. Ensure your code has self-contained key-value pairs for name=object definitions at the level of the parallel map. Use imports and definitions wisely. Know scoping rules and how they apply to parallelization.
  8. When the above fails, lean on a good serializer.

We look forward to seeing you at PyGotham! Let us know if there’s anything you’d like to see covered (within the scope of each respective talk) and stay tuned for future “sneak peeks.”

Enthought at PyGotham: June 8th & 9th

To the PyCluster!

Enthought is a proud sponsor of the second annual PyGotham conference in New York City (June 8th and 9th). As part of our commitment, we are also offering a High Performance Python track that will illustrate how to build applications and utilize parallel computing techniques with various open source projects. Stayed tuned for more details as they become available.

Here’s the lineup so far:

  • Python with Parallelism in Mind. Rarely does code just happen to be “embarrassingly parallel.” We will discuss some simple rules, structural changes, and diagnostic tools that can help optimize the parallel efficiency of your code. This session will also introduce several common parallel communication technologies that can lower the barrier to parallel computing.
  • GPU Computing with CLyther. GPU computing has come a long way over the past few years but still requires knowledge of CUDA or OpenCL. Similar to Cython, CLyther is a Python language extension that makes writing OpenCL code as easy as Python itself.
  • MapReduce with the Disco Project. MapReduce frameworks provide a powerful abstraction for distributed data storage and processing. Our friend, Chris Mueller, will talk about the Disco Project, a refreshing alternative to the Hadoop hegemony that uses Python for the front-end and Erlang for the back-end. More importantly, he will discuss when a MapReduce framework makes sense and when it doesn’t.
  • Interactive Plotting with Chaco. Most “big data” problems don’t stop with distributed computation. You have to render your results in a way that a larger audience can understand. Chaco is an open source library that helps developers generate performant, interactive data visualizations.
  • Declarative UIs with Enaml. Enaml is pythonic UI development done right. Enaml shares Python’s goals of simplicity, conciseness and elegance. Enaml implements a constraint based layout system which ensures that UI’s built with Enaml behave and appear identical on Windows, Linux and OSX. This introduction to Enaml will get you started on the path of writing non trivial UI’s in an afternoon.
  • Tie It Together: Build An App. In an updated version of his Pycon talk, Jonathan Rocher ties together time series data — from storage to analysis to visualization — in a demo application. We’ll also walk through a more computationally demanding application to illustrate concepts introduced in the previous talks.

Look forward to seeing everyone there!