Dual Hetero Quadro on Heaven

Literally the punchiest title I could come up with. I’ve been told that heterogeneous GPU setups are ridiculously slower than a single-GPU. This is largely an anecdotal shrug of “hey - a second GPU doesn’t really slow my computer down in any meaningful manner at all!” I’m sure that I did this all wrong and that the GPU is capable of being tweaked into a setting where this all becomes conclusively - the legwork for that isn’t interesting to me so I haven’t done it.

TL:DR; A second GPU which doesn’t match up or SLI won’t give you cooties.

Background

My workstation came with an NVidia PNY Quadro K600 GPU, which was replaced with a K620. I decided to put the K600 back into my computer as a secondary card and run UniGine Heaven benchmark to see just how slow a third wheel makes it. All tests were carried out at full-screen-exclusive resolution but were otherwise using the Heaven Benchmark’s default settings for their namesake. Stereoscopy was disabled for the non-stereo setting, and I used 3d Vision as UniGine’s the stereo method. For stereo settings the 3D OpenGL Stereo profile was used with Stereo= Enabled and Display Mode= Generic Active Stereo.

Statistics

I really can’t see any reason that a consumer would use this setup - it just amused me.

Configuration Detail Setting Stereo Score Frames Per Second Minimum FPS Maximum FPS
K620 Extreme Yes 131 5.2 3.5 24.4
K620 Basic Yes 269 10.7 5.2 21.6
K620 Extreme No 281 11.2 7.3 22.5
K620 Basic No 592 23.5 15.0 42.2
K620 + K600 Extreme Yes 131 5.2 3.7 10.0
K620 + K600 Basic Yes 270 10.7 8.2 18.4
K620 + K600 Extreme No 280 11.1 7.2 22.0
K620 + K600 Basic No 591 23.5 14.8 40.5

Analysis

The relation between the numbers suggests that;

  • the second GPU does kind of slow it down measurably
  • the second GPU doesn’t slow it down noticeably
  • the Dual-GPU is a teensy bit helpful with Stereo rendering, but not quite worth the cost
  • in a real-game, I could tell the second GPU to do PhysX work and maybe see some improvement?

I may have left some junk running on the desktop during the single-GPU tests, so the difference could be skewed a bit. Regardless; I’m confident that adding the second GPU to this desktop hasn’t sucked-up all my PCIe lanes or something silly.

Questions;

  • how would this work in an AMD/NVidia mix? (Red/Green)
  • would a x86 OS work any good/evil with with x86 benchmark?
  • would something with PhysX really be that different good/evil?

Canadian Racing Geese

I have had several geese charge me - this is a poor approximation.

I was quite young and the geese were acclimated to humans, more importantly they knew how tasty the french fries and clam strips we carried were. I never had a chance, nor will I ever forget. Honking with an bestial hunger, the savage geese charged! Pursing me across the fried clam shop’s parking lot, my mother could only cackle as she scrambled for the camera.

To this day - I have not returned to that shop.

Bin Plugins / Python 3.5.1

I was playing with Python’s binary extension system and was impressed with the simplicity. I think that the usage of setup.py encourages a consistent ecosystem … as opposed to the more open conventions used by Java and CLR.

(I followed the generic instructions and they worked fine on Windows 8.1 - disregard the hype/hate!)

Example on GitHub

Samon 2

I wrote a whole post/blurb in one sitting!

Read it here

Also; Haoyi made a neat post about Build Tools (I mentioned his work at least once and wanted to be sure I had his deets and URL correct)

Switched Themes

I switched themes … because.

New theme seems to be better on mobile devices and easier to tweak

I wish it did previews of posts

Hungarian Notation

In which I pontificate on the subject of Hungarian Notation


Hungarian Notation is a contentious topic.

It boils down to an ambiguity for the word “type” within English / C++. MicroSfot’s modern style-guide says not to use “Abbreviations and Acronyms” or “Hungarian Notation” - originally Hungarian Notation was a style of abbreviation. I’m going to paraphrase a long blog post by Joel on Software and summarize my thoughts at the end.

Story-Time!

C-family languages (C/C++, Java. C# JavaScript, Python, etc) have rather “weak” types, things like Haskell and Ada95 have strong types. If you define an integer in Ada95 (for example) you can give it a range of values (1 to 7) or even names (days of the week) to prevent confusion. So you’ll never be able to assign a day-of-the-month (1 to 31) value to a day-of-the-week (1 to 7) variable without a compiler error from Ada95.

I’m going to illustrate this with an example of storing the day number as an integer.

Charles Simonyi’s idea was that when you created an int day; to store the weekday variable you would use the name int wDay; to denote that the semantic type of this day integer was “week.” They were using “Abbreviations and Acronyms” as a sematic-type on their variables The IT managers who set policy didn’t understand the difference between semantic type (the meaning of the data) and storage type (the mechanical storage of the data) but knew Simonyi’s team was working better and the “type” as a prefix to their variables. So the convention became “thou musteth prefixth thine variable names with their types” for a long time.

I think that this was before IntelliSense and CodeCompletion was practical - error checking took a long time and this misinterpreted version of Hungarian Notation did help. My guess would be that IntelliSense and CodeCompletion came along and the practice became a redundant chore so it was abandoned mostly.

Peter’s Advice

To get the best of both worlds (and still look clever) name your int day; as dayOfWeek / dayOfMonth so that things like …

1
2
3
4
5
6
7
8
9
10
11
12
...

// day of month will be between 0 and 30 (or 1 and 31)
result->dayOfMonth = weekDay;

...

// "day of week" will be between 0 and 7
// "day of year" will be between 0 and 365 (or 1 and 366)
int dayOfWeek = (dayOfYear + 1) % 7;

...

… will look more-wrong and stick out when you’re debugging.

Certainly better than;

1
2
// What is this?
result->iDayWhichMightBeSomething = iDayWhichIsSomething;

Space Ships

Awhile ago I undertook a goofy little “game-play study” with space ships.

It has space ships

I’m calling it Space-Ships.


I wanted to see if 2D game-play (like S.P.A.Z.) could “feel” like traditional 3D. (like Freelancer) To study this I built a game-play prototype with a 2.5D chase-cam in (Unity) a 3D game engine. I used engine’s existing rigid body simulator (PhysX) to provide a limited version of physics. After constraining everything to a 2D plane and fiddling with the interia values in various ways I was happy with the flight mechanics. I made a doo-dad generator to setup and teardown an infinite (not-quite) random set of space junk - amusingly this reduced disorientation with the slight tradeoff of vague motion sickness. I created some guns and a dumb AI ship that flew in circles until e saw something and started shooting at it.

Even when constrained to a 2D plane, the “accurate” dynamics simulation annoyed me. Momentum became an obstacle when I wanted to rapidly change directions to pursue another ship. My I changed the ships to get a lot of “inertia” when the controls weren’t being used - take your foot off the gas and you start to slow down. (It wasn’t actually inertia - it was “drag” … I think the manuals call it inertia … which is going to bug me now) Hunting down other ships was amusing, but the core of the game-play literally felt shallow I think that it would work for PvP style game-play, or as a sugary layer over any game with a meta-strategy system - but I’d worry about trying to make a game out of just shooting other ships. The lack of height variation limits the size of ships a bit so doesn’t lend itself to sweeping space-opera drama without big triangular ships looming over the audience’s view.

I don’t consider the technical aspects especially interesting - however I’ll outline them for the purpose of self-promotion. The project allowed me to go nuts with extending the UnityEditor - an experience that I’m happy to repeat. Unity’s Editor is the real star of Unity - adding extra shiny-bits in the SceneView is relatively easy, and extending or replacing the inspectors to give each script its own special arrangement of buttons doesn’t take much thought. The most delightful of this was using a drop-down menu to assign string values (parsed from ProjectSettings/Inputmanager.asset) to controls that had to read from Input.Get??(...) - a trick that I’m surprised I haven’t seen this sort of thing in Unity proper. (It’s too cool to be a new discovery though … also it relies on using forced text asset serialization)

At a higher level - I experimented with a sort of “detached manipulator pattern” to decouple functionality without relying on inheritance. The spaceship’s engines and guns were MonoBehaviour classes with public variables to control whether they were firing or pushing or whatever. The player’s ship and the AI ships both had an additional MonoBehaviour class that grabbed these scripts and set the values as their logic needed to. The player (of course) set the openFire field to the value of UnityEngine.Input.GetButton(...) on Update(). The AI ship used a trigger volume pointing forwards and “fired” whenever something which could be destroyed moved into that volume. While the pilot scripts were coupled to the flight system, the flight systems weren’t coupled to the pilots. This had the unexpected benefit of making it possible to “fly by inspector” and debug things that weren’t quite right.

For the moment I’m happy with this as a sort of “game-play study.” I’m not especially interested in carrying out more work on it at this point, but I’m not nearly as put off the idea as I would expect. I was able to try out various technical approaches and feel that while it’s not “done” it’s a decent RoI for the weeknights and weekend I spent on it.

Maybe someday I’ll add multi-player …. or maybe I’ll tryout a 2D isometric adventure.

… did I mention that there are SPACESHIPs!

Automated Unity WebGL Deployment

I have an old Unity project that I haven’t looked at in awhile - this one. If memory serves; assembling a WebGL version is slow and boring - so I’m making my eager little Jenkins server do it.

Really I’m a bit bored with sbt-launch malarkey and I wanted to see if I could get this rolling. Broadly the steps that I followed went like this;

  1. Install Unity (5.3.3) with WebGL modules
    • 5.3.3’s WebGL stuff has improved since I last checked
  2. Build the whole tootin thing by hand (on your workstation)
    • This never works on the first try - better to do it locally
    • A custom build script was involved but many snags later it lives!
  3. Validate WebGL player
    • file:// isn’t enough boyo; you need http:// to play your game
    • … actually ; NW.js can open the local page as if it’s a real-boy
      • … y’know, this suggests some interesting options with desktop applications and Unity
  4. Build by hand (again) on the CI server
    • I needed to reinstall Unity5.3.3 to get the trimmings I wanted
    • I also needed to make a build script BB8ild (script is below)
    • my CI server is slow so I wanted to iron out slow problems before I started picking at it here
    • still need to set it up for CI stuff
  5. Configure Jenkins to assemble and post the project
    • This was more complex than I had anticipated
    • I needed to cd around and run a variety of tasks (script is below)
    • In the end - I cloned and pushed the whole site
    • … and hoped for the best

Jenkins Task

Some paths were changed for security-via-obscurity; this won’t literally work but if run line-by-line and changed as you go you’ll get there.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
cd mySpaceShips
/Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -nographics -quit -executeMethod BB8ild.PerformBuild
cd build/
rm -dfr peter-lavalle.github.io/
hg clone git+ssh://git@github.com:peter-lavalle/peter-lavalle.github.io.git
rm -dfr peter-lavalle.github.io/assets/mySpaceShips/
mkdir -p peter-lavalle.github.io/assets/mySpaceShips/
mv ./web-gl/* ./peter-lavalle.github.io/assets/mySpaceShips
cd peter-lavalle.github.io/
hg add .
hg commit -m "$BUILD_TAG"
hg push
cd ..
rm -dfr peter-lavalle.github.io/
rm -dfr web-gl/
cd ..
rm -dfr build/
rm -dfr Library/

Unity BB8ild build script

This’ll work as-is

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using UnityEditor;

class BB8ild
{
[MenuItem("Build/Build WebGL")]
static void PerformBuild()
{

var sceneSettings = EditorBuildSettings.scenes;
string[] scenePaths = new string[sceneSettings.Length];

for (int i = 0; i < scenePaths.Length; ++i)
{
scenePaths[i] = sceneSettings[i].path;
}
BuildPipeline.BuildPlayer(scenePaths, "build/web-gl", BuildTarget.WebGL, BuildOptions.None);
}
}

Hexo and Jenkins atop Os X

In which I ramble a bit about setting up CI for this very blog.

I have a Jenkins server running on my OsX computer. (… or … I’m setting one up anyway) I also have (am establishing?) a blog built by Hexo … because that seems the right way to do this sort of thing. My constraints of “MarkDown“ and “no really - let me use MarkDown because I’m going to have a lot of code fragments” seem alien to most blogging software - “Hexo delivers” as the kids say.

I knew that this would all work from a command line on the computer and a command line on my Windows 7 PC. After a bunch of chewing - I’ve scrawled this post in victory as a sort of test.

NPM setup

Hexo is built in Node.JS. I installed it and played about with it as I was instructed.

1
2
npm install hexo
npm install hexo-generator-sitemap --save

After installing Node.JS I encountered various errors and I switching to a stable version of NPM. (… which I thought I had already used but … I guess not)

1
npm -g install npm

This was discussed here but may be irrelevant.

The Build

I setup Jenkins to poll (and pull) my repository at H/15 * * * *. I had already setup a Hexo site and configured it to deploy to GitHub pages. (… which incidentally don’t seem to do anything interesting for you with Jekyll AFAIK)

The “secret” to this recipe seemed to be that the Jenkins build seems to require installing Hexo itself to work. Not just npm install in the folder but full-on npm install hexo et al. This seems odd to me but it’s what worked … but this is a CI server so longish builds are fine with me.

I used four steps, each a shell command, to perform the generation and deploy the site.

The first command installs Hexo. I tried to install it (globally?) with -g but encountered a security exception.

1
npm install hexo

The second command installs a sitemap plugin that should make my site reachable from Google-like crawlers

1
npm install hexo-generator-sitemap --save

The third command … installs … the site? This may be redundant but I’m not interested in going through a “change” > “reboot” > “check” cycle to learn that I’ve broken my configuration.

1
npm install

The fourth command actually generates the site and uploads the generated site. It seems odd to me deploy doesn’t implicitly generate the site - but I can take advantage of that, see the Addendum!

1
hexo deploy --generate

Conclusion

So … yeah … that’s that. This post was the first one that I set to push out through this system.

Addendum

So it’s been a few weeks/months and I want to stick generated HTML from somewhere else onto my site. But … Hexo tries to “fill in the blanks” which keeps a consistent CSS and <title> stuff … but breaks my Unity WebGL game. To work around this, I’ve

  • generated the WebGL to a assets/ folder and committed it to the blog’s repository
    • an explanation of this is beyond the scope of this post … I’ll write it up another time
  • split generation and deployment into two steps
  • copied the assets/ folder into the blog’s public/ folder
  • deployed everything as normal

The fourth step above is replaced with these three commands;

1
2
3
hexo generate
cp -r assets/* public/
hexo deploy

… and it works!

New Digs

I am experimenting with Hexo. I do believe it’s much nicer than my old system.

So far I’ve setup a basic site, a sitemap generator and it deploys to my existing GitHub pages configuration. Now I’m tweaking themes/ and copying over worthwhile articles from previous blogs!

Whole thing weighs in at 480K (or did before I added this sentence) so I’m fighting the Website Obesity Crisis somewhat … right?

… I pass the Taft test I think …