Processor Review: Intel i7 2600k

The Summary:

This processor is insanely fast, and will only set you back about $300.

The Specs:

  • 8 logical cores (4 physical, each hyper-threaded)
  • 3.4 GHz (stock)
  • 32nm
  • 8mb cache
  • Intel HD 3000 Integrated Graphics

This processor has 8 logical cores (4 physical cores, each hyperthreaded) so you’ll have a good experience with any multitasking you might have to do. Cache is pretty big as well.

The Setup:

CPU in actionIntel i7-2600k
Stock Cooler (with Arctic Silver)
2GB DDR3 PC2100
ASrock P67 Extreme4 Gen3 Motherboard
850W Corsair Professional PSU

The Stock Benchmarks:

Passmark has become the go-to standard for processor benchmark s. That being said, this processor ranks pretty highly, and is the first processor under $599 listed.
It is ranked #7 at the time of writing for “high end CPU’s” on passmark.

The Overclocking:

This processor also does pretty well on the overclocked benchmarks over at Passmark, coming in at #8. They say that most people are able to overclock at an average of 31% above stock clock speed, or 4.45Ghz.

There are claims on the internet that you can get this CPU up to 5.1Ghz or higher (+50%) using overclocking and modifying the voltage levels in the CPU. I was unwilling to shorten the lifespan and risk burning out the chip by messing with the voltages on the CPU, but I did get the CPU up to 4.3 GHz stable clock without modifying the default voltage levels, and with the stock cooler. Under load, the processor seems to stay at moderately cool. With this, I reran some compiles I did on the stock install (like the linux kernel), and saw some slight improvement.

This is a great processor, and I’m glad I went with it! I’ll keep mine overclocked at 4.3GHz.

 

Posted in Uncategorized | Leave a comment

The Art of

“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil”

–Donald Knuth

 

If you’ve heard of Big-O analysis, or linked lists, or sorting, or searching, or recursion, or pretty much any other thing you as a programmer would know, chances are Donald Knuth was writing about it first in his 1968 book The Art of Computer Programming. The quote above is one of my favorites, and there’s a lot of insight in it.

Put another way, Knuth is reminding us that “over-optimization” from the start leads to unnecessary headaches further down the road, and can even cause projects to end up unfinished and late. Here’s just a few of the dangers that extensive optimization early in a project can lead to down the road:

  • Danger in Completing the Program
    Say you’re creating a physics engine for your game, and need to do a matrix calculation. You could do this the straightforward way, but you decide that CPU operations are too slow. So you write a GPU accelerated matrix library because normal CPU based matrix calculations are slower. After a few weeks muddling around with OpenCL in your side library, your physics engine will be late, or you could have lost the motivation to even finish it.The icing on the cake here is that you don’t even know that your matrix calculations would be a bottleneck in your engine! It could be that the derivatives calculation is really what slows you down to an unacceptable level. By optimizing too early, you optimized something didn’t really need it, and wasted a bunch of time doing so.But hey, at least you’ll have a decent GPU accelerated matrix calculator!
  • Danger in Legibility/Understandability
    It could be faster to unroll loops and make full use of the SSE extension through x86 assembly for some areas of your code. This doesn’t make it easier to understand, and surely obfuscates the meaning of what you’re trying to do! In some circumstances this can’t be avoided, but if you optimize later in the development, you’ll only have your assembly code in limited areas where you really do need it.
  • Danger in Maintenance
    If you have some highly optimized chunks of code, they can be more difficult to adapt to any new changing circumstances, simply because there might only be 1 or 2 people who understand what is going on! If you don’t get what’s going on, changing a nonintuitive optimized chunk of code might introduce corner cases that show up later on as bugs, crashes, or worse. Like with legibility, you want these chunks of code only where you absolutely need them. Optimizing later in the development process will ensure that your complex, hard-to-grasp code is just where you need it to be, and will help out anyone who might have to maintain things later down the road.

Being able to know what to optimize is just as important as deciding what features your project should support. Both are also learned over time; they’re a wisdom that comes with experience (or good project management!)

Posted in Coding, Open Source | Leave a comment

Simple OpenGL Application for Beginners

A friend of mine recently complained that starting OpenGL on Linux is too confusing. In helping him out, I figured out that like most beginners, he couldn’t figure out how to display anything on the screen without 200 lines of confusing code from some tutorial site he found. Furthermore, probably 3/4 these tutorial sites are targeted towards Windows users, so getting it running on Linux is even more confusing!

Learning how to draw an OpenGL triangle on Linux shouldn’t be hard. Most beginners just want a basic scratchpad they can tinker with, not an expansive explanation of what’s going on, and what window manager is doing what, etc. They just want a function that they can plug the beginning OpenGL concepts into.

All you want to see if just starting out is something like this:
So, I whipped up some simple code to do so! Here it is! simple_gl20_triangle.tar.gz

gl.c:

#include "stdio.h"
#include "GL/glut.h"
 
void render()
{
	glBegin(GL_TRIANGLES);
		glColor3f(  1.0, 0.0, 0.0);
		glVertex3f(-0.5, 0.0, 0.0);
 
		glColor3f(  0.0, 0.0, 1.0);
		glVertex3f( 0.0, 0.5, 0.0);
 
		glColor3f(  0.0, 1.0, 0.0);
		glVertex3f( 0.5, 0.0, 0.0);
	glEnd();
 
	glutSwapBuffers();
 
	return;
}
 
int main(int argc, char **argv)
{
        glutInit(&argc, argv);
        glutInitWindowPosition(100,100);
        glutInitWindowSize(500,500);
        glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
        glutCreateWindow("testwin");
 
        glutDisplayFunc(render);
	glutMainLoop();
 
	return 0;
}

Use the makefile included in the tar package, or compile and run like this:

gcc -o gl gl.c -lglut -lGL -lGLU -lX11 -lXmu -lXi -lm
./gl

Just put whatever commands you want to tinker with in the render() function. I included a makefile to compile. Make sure you have the libglut3-dev and libgl1-mesa-dev packages installed.

Now, there are no animations, and no responses to keyboard or mouse input. (This is possible with glut, but not implemented here). But, this chunk of code should be very useful for trying out just the basics of OpenGL with a linux client for beginners on Linux!

Posted in Uncategorized | Leave a comment

Whirlwind Tour of the Graphics Stack

Graphics drivers have often been a sticking point in the Linux ecosystem. Getting them to work the way you want can be (and historically was) tricky.

Ever wonder why?

The simple answer is that the software stack needed to support graphics cards are complicated. Very complicated.  There are many layers and features the graphics stack needs to run in the way you want it to.

The simple idea is a graphics card is a specialized co-processor. Its really good, and designed for hugely parallelized mathematical computations needed to process 3d images.

A GPU is a distinct processor, so it needs to be programmed by the CPU in order to compute anything. The CPU has to manage all the memory the GPU needs to work with, and it needs to tell the GPU exactly what to do. The CPU needs to assemble all the byte-level instructions for the GPU. And it needs to do all of this on the fly, at least 60 times per second! Quite impressive that it works.

In linux, the chunk of code that makes the commands for the GPU is usually libGL.so. This creates a bunch of memory, and fills commands for the GPU to process. It is, essentially, a real-time assembler that uses OpenGL calls as input. It takes a lot of dynamic, clever coding to get this chunk of code to create the assembly-level instructions for the GPU. Once the commands for the GPU are assembled, and all the graphics buffers have been allocated, managed, and collected, libGL.so is done with its work (for this one frame). Again, this is not a trivial matter. A modern desktop GPU has hundreds of registers to program for each frame. Compare that to the 32 registers an ARM CPU has!

At this point, all the things the GPU needs to do its work are in memory. Commands are assembled, and buffers are allocated. However, all this information was created in userspace! It still has to get through to the kernel (and later, the hardware) somehow. Here’s where the kernel driver kicks in. libGL.so submits all the information to the kernel driver. The kernel driver then takes care of submitting to the hardware to work on. It has to keep track of when and what it submitted, and keep track of when the GPU finishes its work. The kernel driver is an important intermediary between the program that wants to use the GPU and the actual hardware.

When the GPU is done, the kernel driver is told, and eventually, this information gets propogated back to the user of the OpenGL spec. Now we’re ready to do this all over again for the next frame!

If you’ve followed my explanation so far, thats great! :) There’s a lot of other layers of complication like…

  1. We have to deal with virtual memory! The CPU’s virtual addresses are not necessarily the same as the GPU’s virtual address. You have to program various MMU’s to make sure the CPU and the GPU are referencing the same physical address. You have to ensure all the MMU’s are coherent with each other as well…
  2. What about many programs using the OpenGL stack at once? Its possible that there are 2 programs that want to use the hardware concurrently. This adds all sorts of locking and threading.
  3. Say you’re rendering a 1080p (1920×1080) scene, using 32 bit color at 60 frames per second. This is:
    1920 x 1080 x 32 x 60 = 3.9 * 10^9 bits of information per second!
    You have to move 500 megabytes per second onto the framebuffer (screen). By the time you’ve finished watching Hot Tub Time Machine, you’ve consumed more bits of data than the digitalization of the entire Library of Congress. Moving this much data takes special ways and special hardware paths.
  4. GPU’s need initializition and special care to get going….
  5. The graphics stack on the CPU side isn’t simple either… Ever hear of X11?

Its really amazing what goes on every second in a computer. Its also why I like working in graphics!

 

Posted in Uncategorized | Leave a comment

Motherboard Review: ASRock P67 EXTREME4 GEN3

Review Summary:

Great motherboard good price point ($155). Buy it if you need a 1155 socket and like to overclock. No real drawbacks, but a few manageable quirks.

What's in the P67 box (along with some other desk clutter)

I like to prefix a review  with what I was looking for in a motherboard.

From rooting about the internet, the P67 or the Z68 are the motherboard types best suited to my processor (intel i7 2600k). That being said, the Z68 is a slight upgrade to the P67, supporting using a SSD as a cache for a hard-disk, along with other minor improvements that I wasn’t particularly dying to get. The core components are essentially the same, so I decided to save the $30 and go with the respected P67 variety of Intel motherboards. I’ve also heard good things about the overclocking capability of this motherboard, so it seemed like a good fit.

P67 Board


I decided to stick with ASRock as the brand. My old ASRock motherboard endured nearly 6 years of 24/7 use. It endured probably 30 moves, 2 years in a fraternity house with 200 year old shoddy wiring, a house with a chronically broken heater during Michigan winters, and stifling heat in no-AC rooms during the summer, as well as a long UPS journey from Detroit to San Diego. I figured with this track record, I’d give ASRock mobo’s another shot for a job well done on the board I was replacing.

Ports on P67

Let’s get into the pro’s and con’s…

Pros:

The things that stood out to me the most are:

  • Works out-of the box with Ubuntu. Every feature I’ve tested seems to work well.
  • The Dr Debug LED. There’s a 2 digit hex LED on the motherboard that displays various codes that can assist you in debugging the board if you need to. Very handy feature, I doubt I’d ever buy another motherboard with one.
  • The graphical BIOS has pretty much every overclocking feature you can think of. Very configurable CPU configurations.
  • Lots of CPU chasis fan hookup headers
  • Support for DDR3 2100 RAM, USB 3.0, PCI Ex 3.0, all the latest bells and whistles
  • Ton of USB 3.0 and 2.0 ports. The included a front panel usb header that fits in most 3.5′ floppy bays and gives you 2 additional USB 3.0 ports.

Quirks:

There isn’t one glaringly bad thing about this motherboard. I struggled to even come up with this list, and named the section “Quirks” instead of “Cons”, because they’re all just minor things. That being said, there are a few minor things I wish were a bit quirky:

  • The 8 SATA ports are forward-facing, and stacked on top of each other. This makes them a bit difficult to access, compared to a header on the board. This seems to be a common thing on motherboards these days though.
  • I was a bit sad there was no serial port on the back, I’m still a user who uses that from time to time. Its not all bad though, the motherboard has a COM header I can hook up if I find the right parts.
  • If you have PATA/IDE drives, this board does not have support for the old ribbon cables. This could arguably be in the highlights section.
  • Still haven’t learned the ‘trick’ for getting the BIOS to boot the way i want it to every time. You only have a quick second to hit the escape keys to the boot device or the BIOS.
  • PCI Express 3.0 is not supported by Sandy Bridge processors. This is a Sandy Bridge processor limitation, but be forewarned that you won’t be able to use PCI Express x16 3.0 if you don’t use an Ivy Bridge processor (which will come out next year)
  • The eSATA port and one of the 8 onboard SATA ports conflict. (You can’t use both at once, and the eSATA takes precedence).

 

Features and Ports

Finally, I’ll lay out what the board has on board. Its quite a lot of things, and all of them seem to be linux-friendly (as far as I can tell so far….)

Unboxed P67 Mobo

  • Intel 1155 Socket Type
  • 24 Pin motherboard power port / 8 pin CPU power port
  • P67 Chipset (and the stickers on the board assure me the “SATA problem” is “fixed!”
  • Crossfire/SLI support
  • Dual-Channel DDR3 2133(OC) / 1866(OC) / 1600 / 1333 / 1066
  • 2 PCI Express x16 3.0
  • 1 PCI Express x16 2.0
  • 2 PCI Express x1
  • 2 PCI
  • 4 SATA 6GB/s and 4 SATA 3GB/s
  • Ethernet Realtek 8111E (up to 1000Mbps)
  • 2 PS2 ports
  • 2 USB 3.0
  • 6 USB 2.0
  • 8 Channel Audio Realtek ALC892
  • 6 External Audio ports, Optical and coaxial SPDIF ports.
  • 1 Firewire port
  • 1 FDD connector (not sure why these are still around)
  • 1 Dr. Debug and a Debug LED
  • 1 Serial port header
  • CPU/Chassis/Power fan connectors
  • Front panel audio connector

 

Posted in Hardware, Reviews, Uncategorized | 2 Comments

Computer Breakdown and Upgrade

Sadly, I found that my old desktop won’t boot up anymore. I’ve had this desktop since January 2006, and a lot of learning was done on it. I’d say a 5 and 1/2 year run with no failures was pretty good. On the most part, I left this computer on 24/7.

I’m not quite sure what the cause of failure was, but I suspect the motherboard just stopped working. It stopped POSTing reliably a few months back. Erasing the BIOS memory sometimes would help the problem, so I’m pointing my finger towards the motherboard for the failure. It started out with 1 failure out of 20 boot up attempts, but now won’t post probably 99/100 times. I tried swapping out ram and gpu, resetting the bios, everything I could think of to no avail.

I’m not too sad about it though, the system served me well, and now I get to upgrade to a shiny new system! I’m going to do the upgrade in two steps. The first step, I’m going to upgrade the mobo, cpu, power supply, graphics card, ram (the core of the system). Second step, I’m going to add more ram, buy a beefier graphics card, and a solid state drive for the OS.

Here’s what I’m upgrading this step:

Old Component New Component
AMD Athlon X2 3800 Dual Core 2.0 GHz Intel i7 2600K Quad Core 3.4GHz
ASRock Dual Sata 939 ASRock P67 EXTREME4 GEN3 LGA 1155
450W Came-with-the-case PSU 850W Corsair Professional 850HX
2GB DDR2 PC1600 RAM 2GB DDR3 PC2100 RAM

I’ll also use this opportunity to get rid of all my PATA drives (so long old technology!). I’ll have a 1TB RAID1 setup as storage, and a 500GB for my OS drive. (until I buy a solid state drive for the OS, that is)

I’ll be writing a review for each of the interesting new components!

Posted in Uncategorized | Leave a comment

My Switch to Dvorak, 3 1/2 years later

Somewhere around February 13th, 2008, I switched my primary keyboard layout to dvorak. This means I’ve been a dvorak* user for a little over 3 1/2 years now! I have no intention of going back to the normal qwerty layout again. Its been a minor inconvenience at times, but it has had a lot of perks to it.

Here’s my anecdotal take-away from my long-term use of dvorak:

  1. Ergonomics are better. When I was a typing with qwerty for many hours a day between school and work, my hands would tire out. After my internship and a few hours of coding for school, my hands would be achy and feel horrible. This was the primary reason I chose to try out the dvorak layout, and I can honestly say that this layout has saved my hands a lot of grief. I think this may be largely due to the more convenient  placement of the period, comma, and dash keys. (I have no scientific study to back that up though…)
  2. Useful for keeping others off your computer. Its sorta funny to see someone unaccustomed to my keyboard try to use my computer.
  3. Sharing a computer with a qwerty user is annoying. Luckily, I don’t have to share a computer with someone else while I’m working too much. I’ve found its best to set up a widget on the taskbar to switch back and forth. I’ve also found its just quicker to just not explain that you use dvorak to your lab partner or coworker.
  4. I still can type with qwerty. I was a bit afraid setting out that this skill would disappear, but it hasn’t.
  5. Speed’s about the same. I don’t see that much of a speed-up in typing rates when using dvorak versus using qwerty. Like I said above, my hands aching after 12 hours is what motivated the switch. I’ve never focused on getting my qwerty or dvorak to over 120wpm (or some other high number like that).
  6. Its impossible to buy a dvorak keyboard. This might not be strictly true, but practically it is. Most of my keyboards are still labeled in a qwerty fashion, and are “re-wired” in software to be dvorak keyboards. Converting a qwerty keyboard to dvorak is not possible with all keyboards. A lot of times, any random key won’t fit in any othe random key’s hole, making physically rearranging them impossible. Laptop keyboards are generally not rearrangeable. Putting stickers on top of the keys is a safer bet.
  7. This perfected my touch-typing skills. With none of the keys actually what they’re labeled (point 6), this has made me a good touch typer! One handed typing is still a bit tricky though…

*For those of you who haven’t heard of dvorak keyboard layouts, it is an alternative to the normal qwerty layout. It was created in 1936 as an alternative to qwerty, and the rearrangement does things like put all the vowels in the middle (“home”) row, and tries to group the common symbols into easy-to-reach places.

 

Posted in Uncategorized | 1 Comment

Programming: Its all about the attitude

CEO David Barrett wrote an excellent post a few months ago about their hiring practices.

While a lot of the article focuses on .NET programming (and has a lot of great points), there’s one excerpt that I was cheering as I read it…

See, experience is cheap.  All it takes is time.  Skill is harder, but really only requires hard work — a lot of people can get that.  But attitude.  You either have it, or you don’t.  The right sort of person is so passionate about coding, they can’t be stopped from doing it.  They typically started before high school — sometimes before middle school — and never looked back.  They write everything from assembly to jQuery, on PCs to mobile phones, doing hard core computer graphics to high level social networking.  They’ve tried everything.

You know you’ve worked with someone who just doesn’t have that go-gettem-tiger attitude about their coding. I’m sure you know some high-functioning, well-pedigreed programmers who went into the business because its consistently one of the highest paid bachelor’s degrees available. You probably know another person who started out with that attitude, but over time it was mollified by lush pay and the bureaucracy that surrounded their work.

I hope you’re the type of coder that sees a goal, and attacks it like a monkey on a cupcake. (Dog with a bone works better, but the monkey analogy made me chuckle a bit…) These are the type of coders I also hope you’re fortunate enough to surround yourself with!

This is part of what I like about open source. It keeps you sharp, keeps you learning. It has a plethora of coders with the right attitude.  The only ones who make it in open source are the ones with the unstoppable attitude, which is the attitude to accomplish your goal no matter what stands in your way.

Posted in Coding, Random, Ubuntu | 1 Comment

Hacks They Don’t Teach in School… (#1)

I thought it would be interesting to do a series on Hacks they don’t teach you in university. I’ve thought of quite a few. I like thinking about this, stirs my memories to back when I was just fledging.

Today, we’re going to talk about…

Debug #define dumps

Debuggers like gdb are great, but sometimes you need logging or debugging, and the ability to turn it on and off when you need it.

I learned this trick from my coworker Eric P. (creator of Handbrake) back when I was an intern. Obviously, this isn’t a secret, but its something you’ve got to learn at some point if you’re a C coder…

This trick is simple and versatile. Put something like this is your project header:
header

 #define DEBUG_ON 1
#if DEBUG_ON
#define PRINT(...)      printf(__VA_ARGS__)
#else
#define PRINT(...)
#endif

Then, anywhere in your program, you can do:

PRINT("this is a test message\n")

and it will work like a printf, that you can turn off and on by editing the DEBUG_ON define (or even a gcc -D DEBUG_ON will compile the debug messages into the code)

This might seem trivial, but you can edit hundreds of debug log messages out of your code very quickly, and saves a lot of time. Plus, since this is in the preprocessor, the printf’s are not compiled into the code, saving your code from having to do a conditional check at every instance of a print during run time! If you really want to get fancy, you can add different levels of debug logging for different statements, or use stderr instead of stdout. Play around!

Its faster, and cleaner, and is a good trick for someone just starting out in C/C++ to know!

Posted in Coding, Random, Ubuntu | Leave a comment

Usuability, Expressibility, and Linux

Vivek Haldar got me thinking a bit with this great post here contrasting GUI’s vs CLI’s

Short summary is that some computer environments are targeted towards expression, while others are targeted towards operation. GUI-based programs tend to be a way to operate a computer, while CLI program systems allow for recombination and expression.

Think about it. You run a GUI, and everything you do is an operation. It is targeted strictly towards a well defined set of results. While operating a GUI, you can’t take the data from the top-corner button, and pipe it to the bottom corner button to make it do something new and cool, you’re stuck with what you see in front of you.
On the other hand, if you run a CLI, with its pipes, redirects, and scripts, you’re unbounded, you can create whatever results you want. Data can flow where you direct it, but you have to learn a lot about the system before you can be a master of this. CLI’s are unbounded and require mastery, while GUI’s are bounded, and do not require mastery.

Neither approach is bad intrinsically, its just some approaches are better suited for some purposes. Just like a car needs an operation panel, many computer users just need an operation panel to accomplish whatever function they have. e.g. Its sufficient for an accountant to just push a button to compute a well-defined sum of all the spreadsheets they have. Expressive purposes, like programming or managing computing systems tend to
favor the expressive CLI approach. An admin needs to be able to recombine his system quickly on the fly, and the CLI approach better lends itself to this.

This way of thinking about the dichotomy between GUI and CLI is pretty applicable to thinking about how computers have evolved over the past 20 or 30 years.

Linux saturated the “expressive market” quite readily, from when it became usable in the early 90′s. Everyone who wanted full flexibility of their system flocked to Linux. It cornered the expressive niches (servers, scripters, programmers) quickly, but always stalled out when trying to take share from the operational market (read, Windows). If you can internalize the Linux ecosystem’s commands, then you have unbounded potential to recombine and use your computer.

Windows is heavily GUI based; that is, its heavily designed around operating a computer, and it has done very well in terms of market share because it met the need a large
majority of computer users need. I, being a programmer accustomed to the expressibility of Linux, feel like I’m fumbling on a Windows computer because I can’t express, combine, recombine, and create the way I’m used to. The big majority of users don’t particularly care about this, they want their computer to do a few fixed functions, and the GUI approach works for them.

The success of Ubuntu stems from the realization that Linux circa 2005 was ready for prime-time, but was totally geared towards expressibility. In order to gain market share, (and the advantages that come with market share and additional resources), Ubuntu started gearing more towards operational efficiency, without sacrificing its expressive roots. Its great to see how it continues to grow, and just who is picking up Linux/Ubuntu these days as the open source ecosystem continues to grow in operational efficiency! I like to see new approaches like Unity coming down the pipes; hopefully it will help Ubuntu gain more and more of the “operational” user base!

Posted in Open Source, Ubuntu | 1 Comment