Q

Home » Top Secret » The Affinity Mask

The Affinity Mask

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 45 other followers

I have owned dual core and quad core processors for years.

I have also owned a 64 bit operating system for years as well.

Now as a programmer, you would think someone like me would have been versed in the advantages of multi core processors beyond the marketing hype. And as a programmer I can assure you a tiny fraction of programmers actually comprehend what both provide.

In layman’s terms.

Put specifically, as technical people we regurgitate marketing hype and might go so far to make recommendations.

But as a programmer, I can assure you that 99% of the software created does not actually leverage the advantages of the multi core.

Let’s take for example, the 3d background I just created.

With these simple lines of code (in C++):

    // Run this on the second core. 
    HANDLE process = GetCurrentProcess();
    DWORD_PTR processAffinityMask = 2;
    BOOL success = SetProcessAffinityMask(process, processAffinityMask);

This 64 bit process which was hiccuping every once in a while when I opened up too many applications now runs extremely smooth…

Even a full screen capture – which VIDEO captures of screens typically ANNIHILATE the processor… Was much smoother.

So as a programmer having spent years working in the corporate world, we worked with one primary impetus with our development: Focusing on the lowest common denominator of equipment. Usually this was single core, low end disk and hardware, and we’d certainly never have GPU r graphics acceleration available to us on the target equipment we developed for.

Conversely, the machines we as developers were provided were usually top end. And while they NEVER had graphics acceleration, this often made it difficult to develop and test for users because of the demands of our development software and machines.

Now the machine I am working on is…

I’ll be polite…

Impaired.

IT has 4 gig of ram and a slightly accelerated video care with 384 meg of ram on it.

While the thing does run Windows 7, the only tolerable development environment is Visual Studio 2005, where anything newer takes too much time to load up and compile, let alone all the baggage associated with developing in these environments.

So I have learned I HAD to, out of necessity (and to alleviate boredom) – develop OpenGL using basic APIs and WM_ Windows Messaging.

Every ‘off the shelf’ 3d engine required too much for system specs. And the end product – a game like Titan Quest – a cheesy rip off of Diablo with ineffective (boring) gameplay – consistently overheated my machine crashing it – HARD.

As a homeless guy. I can’t afford anything for equipment. This computer was donated to begin with.

And KNOWING that a great majority of Windows users ‘out there’ may have specs similar to this machine…

Microsoft with Windows and companies providing games are doing – in my opinion – a shit poor job of supporting those who may not want the latest and greatest equipment that – if you listened to the manufacturers – will be obsolete in 5 years time.

THIS is my audience. The Windows XP systems that Microsoft quit supporting. The Windows Vista and 7 users who wince in pain as a ‘fancy’ User interface like aero consumes a shit ton of resources, memory, all to provide a decent user experience at such a great cost of simple reliability of the OS and associated applications.

I am my audience I suppose.

And with this.

I have one pegged CPU core with my primary renderer as can be seen with this Task Manager graph:

TaskManager

And as can easily be seen within the process, the program I created runs isolated to that CPU core:

TMAffinity

So I learned something. That YOU as a developer HAVE to implement code through SetAffinityMask and the similar thread functions in order to take advantage of parallel processing between and across processor cores.

From what I understand, only one recent game – Far Cry 4 –  absolutely requires a Quad Core Processor. So MOST high end game programmers aren’t taking advantage of multiple cores in development, and as a result, they are depriving themselves of a WONDERFUL ability to manage and optimize their game engines.

But then again, most programmers are leveraging off the shelf pre-canned  engines they themselves didn’t work on or understand. So they are developing with a single core mindset.

Personally, I can say I am blown away by the differences in speed compiling this with 64 bit enabled AND isolating this to a single core has worked.

Why the isolation? I then depend on Windows to see that core 2 is pegged so rather than spending time swapping threads and processes between the cores, it focuses on the one I am not using. So my core rendering tasks run fast. And anything else I do OS wise, whether it’s browse the web or pop up my development environment – isn’t contending with this process for CPU time as the system tries to ‘balance out CPU usage’.

Sometimes, it’s just flat out better to program imbalance in the system to provide for a better user experience.

On a final note.

Corporations – to their defense – have a plethora of web browsers to support and a smorgasborg of systems to support as well.

But now that I have had the chance to experience life ‘on the outside’ of corporations looking in.

If I were ever offered a CIO position within a company, I’d probably get in more trouble with the EEO than anyone in history. And with that said, I might intentionally focus development for creating high end 3d GPU intensive software ….

Just because I can.

I’d probably have everyone in the company pissed off about IT’s lack of responsiveness.

So I’d outsource support for existing systems to foreigners. You know. To placate the dissenters.

And from there. I’d probably keep the lawyers busy with the constant barrage of sexual harassment lawsuits and ridiculous requirements of females such as ‘no clothes Friday’.

For the night owls. I might have a line to a government sanctioned cocaine dealer. I rather enjoyed that experience myself and might indulge on occasion if given the opportunity.

That and I’d probably take on my own pet projects and when asked to do something by others. I’d consider it.

But quite likely focus on my own stuff.

It would be fun for me and the few horny males I’d hire.

That I can guarantee.

But then again, who in their right mind would hire a homeless guy to run their IT department knowing this would be the start of what I would do?

Maybe this is why I’ not seeing job offers.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Enter your email address to follow this blog and receive notifications of new posts by email.